-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinclude.php
More file actions
executable file
·128 lines (113 loc) · 4.2 KB
/
include.php
File metadata and controls
executable file
·128 lines (113 loc) · 4.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
/**
* @copyright ..........................
* @author ........ .......... <someone [at] somewhere [dot] com>
*/
// make sure we are not being called directly
defined('APP_DIR') or exit();
/**
* meta
*/
function jrHelloWorld_meta()
{
$_tmp = array(
'name' => 'Hello World',
'url' => 'hello',
'version' => '1.0.0',
'developer' => 'Sombody Somwhere, ©' . strftime('%Y'),
'description' => 'print Hello World to the screen at: THIS-SITE.com/hello/world',
'category' => 'site',
'activate' => true
);
return $_tmp;
}
/**
* init
*/
function jrHelloWorld_init()
{
// magic view - seen at YOUR-SITE.com/blog/modulehello, YOUR-SITE.com/audio/modulehello, etc
// provides view_jrHelloWorld_modulehello for each module
// view_jrHelloWorld_modulehello is a function in index.php
jrCore_register_module_feature('jrCore','magic_view','jrHelloWorld','modulehello','view_jrHelloWorld_modulehello');
jrCore_register_event_listener('jrCore','form_display','jrHelloWorld_form_display_listener');
//add a tab to the tinymce popup
jrCore_register_event_listener('jrEmbed','tinymce_popup','jrHelloWorld_tinymce_popup_listener');
jrCore_register_event_listener('jrEmbed','output_html','jrHelloWorld_output_html_listener');
return true;
}
/**
* form_display listener displays "hello world" as an alert when viewing the integrity check form
* @param $_data array Array of information from trigger
* @param $_user array Current user
* @param $_conf array Global Config
* @param $_args array additional parameters passed in by trigger caller
* @param $event string Triggered Event name
* @return array
*/
function jrHelloWorld_form_display_listener($_data,$_user,$_conf,$_args,$event)
{
// filter out everything except the integrity check form
// and check the module config setting to see if we want the alert.
if ($_data['form_view'] == 'jrCore/integrity_check' && $_conf['jrHelloWorld_hello_world'] == 'on') {
$_js = array('alert("Hello World");');
jrCore_create_page_element('javascript_ready_function',$_js);
}
return $_data;
}
/**
* Smarty function to show an embedded hello world
* @param $params array parameters for function
* @param $smarty object Smarty object
* @return string
*/
// use in any template like this: {jrHelloWorld_hi}
// only one optional parameter - spelling="wrong"
// which would need to look exactly like this: {jrHelloWorld_hi spelling="wrong"}
// returns 'Hello World' or 'Hellow Worlg' if spelling="wrong"
function smarty_function_jrHelloWorld_hi($params,$smarty)
{
if ($params['spelling'] == 'wrong') {
return 'Hellow Worlg (which is definitely more than valid as first words written, spoken or coded).';
}
return 'Hello World';
}
/**
* Adds hello world to the popup tinymce editor for insertion into pages
*/
function jrHelloWorld_tinymce_popup_listener($_data,$_user,$_conf,$_args,$event)
{
$flag_found = FALSE;
//over-ride any existing jrSoundCloud setting.
foreach ($_data as $k => $tab) {
if ($tab['module'] == 'jrHelloWorld') {
$_data[$k]['tab_location'] = 'jrHelloWorld';
$_data[$k]['tab_tpl'] = 'tab_jrHelloWorld.tpl';
$_data[$k]['onclick'] = 'loadHelloWorld()';
$flag_found = TRUE;
}
}
//this modules tab was not set, so set it.
if (!$flag_found) {
$_data[] = array(
'module' => 'jrHelloWorld',
'name' => 'helloworld',
'tab_location' => 'jrHelloWorld',
'tab_tpl' => 'tab_jrHelloWorld.tpl',
'onclick' => 'loadHelloWorld();'
);
}
return $_data;
}
/**
* for the jrEmbed module to replace the tag [jrEmbed module="ujIpsumJam"] with 'Hello World!'.
* ujIpsumJam_output_html_listener
*/
function jrHelloWorld_output_html_listener($_data,$_user,$_conf,$_args,$event) {
//search $_data for [jrEmbed module="ujIpsumJam"] that tab_ajax_audio.tpl put into the editor's html
if ($_data['module'] == 'jrHelloWorld') {
//replace with the text
$_data['html'] = 'Hello World!';
}
return $_data;
}