aboutsummaryrefslogtreecommitdiffhomepage
path: root/plugins/demo_plugin/demo_plugin.php
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/demo_plugin/demo_plugin.php')
-rw-r--r--plugins/demo_plugin/demo_plugin.php99
1 files changed, 92 insertions, 7 deletions
diff --git a/plugins/demo_plugin/demo_plugin.php b/plugins/demo_plugin/demo_plugin.php
index 18834e53..8fdbf663 100644
--- a/plugins/demo_plugin/demo_plugin.php
+++ b/plugins/demo_plugin/demo_plugin.php
@@ -15,6 +15,23 @@
15 */ 15 */
16 16
17/** 17/**
18 * Initialization function.
19 * It will be called when the plugin is loaded.
20 * This function can be used to return a list of initialization errors.
21 *
22 * @param $conf ConfigManager instance.
23 *
24 * @return array List of errors (optional).
25 */
26function demo_plugin_init($conf)
27{
28 $conf->get('toto', 'nope');
29
30 $errors[] = 'This a demo init error.';
31 return $errors;
32}
33
34/**
18 * Hook render_header. 35 * Hook render_header.
19 * Executed on every page redering. 36 * Executed on every page redering.
20 * 37 *
@@ -33,15 +50,68 @@ function hook_demo_plugin_render_header($data)
33 50
34 // If loggedin 51 // If loggedin
35 if ($data['_LOGGEDIN_'] === true) { 52 if ($data['_LOGGEDIN_'] === true) {
36 // Buttons in toolbar 53 /*
37 $data['buttons_toolbar'][] = '<li><a href="#">DEMO_buttons_toolbar</a></li>'; 54 * Links in toolbar:
55 * A link is an array of its attributes (key="value"),
56 * and a mandatory `html` key, which contains its value.
57 */
58 $button = array(
59 'attr' => array (
60 'href' => '#',
61 'class' => 'mybutton',
62 'title' => 'hover me',
63 ),
64 'html' => 'DEMO buttons toolbar',
65 );
66 $data['buttons_toolbar'][] = $button;
38 } 67 }
39 68
40 // Fields in toolbar 69 /*
41 $data['fields_toolbar'][] = 'DEMO_fields_toolbar'; 70 * Add additional input fields in the tools.
71 * A field is an array containing:
72 * [
73 * 'form-attribute-1' => 'form attribute 1 value',
74 * 'form-attribute-2' => 'form attribute 2 value',
75 * 'inputs' => [
76 * [
77 * 'input-1-attribute-1 => 'input 1 attribute 1 value',
78 * 'input-1-attribute-2 => 'input 1 attribute 2 value',
79 * ],
80 * [
81 * 'input-2-attribute-1 => 'input 2 attribute 1 value',
82 * ],
83 * ],
84 * ]
85 * This example renders as:
86 * <form form-attribute-1="form attribute 1 value" form-attribute-2="form attribute 2 value">
87 * <input input-1-attribute-1="input 1 attribute 1 value" input-1-attribute-2="input 1 attribute 2 value">
88 * <input input-2-attribute-1="input 2 attribute 1 value">
89 * </form>
90 */
91 $form = array(
92 'attr' => array(
93 'method' => 'GET',
94 'action' => '?',
95 'class' => 'addform',
96 ),
97 'inputs' => array(
98 array(
99 'type' => 'text',
100 'name' => 'demo',
101 'placeholder' => 'demo',
102 )
103 )
104 );
105 $data['fields_toolbar'][] = $form;
42 } 106 }
43 // Another button always displayed 107 // Another button always displayed
44 $data['buttons_toolbar'][] = '<li><a href="#">DEMO</a></li>'; 108 $button = array(
109 'attr' => array(
110 'href' => '#',
111 ),
112 'html' => 'Demo',
113 );
114 $data['buttons_toolbar'][] = $button;
45 115
46 return $data; 116 return $data;
47} 117}
@@ -126,8 +196,19 @@ function hook_demo_plugin_render_footer($data)
126 */ 196 */
127function hook_demo_plugin_render_linklist($data) 197function hook_demo_plugin_render_linklist($data)
128{ 198{
129 // action_plugin 199 /*
130 $data['action_plugin'][] = '<div class="upper_plugin_demo"><a href="?up" title="Uppercase!">←</a></div>'; 200 * Action links (action_plugin):
201 * A link is an array of its attributes (key="value"),
202 * and a mandatory `html` key, which contains its value.
203 * It's also recommended to add key 'on' or 'off' for theme rendering.
204 */
205 $action = array(
206 'attr' => array(
207 'href' => '?up',
208 'title' => 'Uppercase!',
209 ),
210 'html' => '←',
211 );
131 212
132 if (isset($_GET['up'])) { 213 if (isset($_GET['up'])) {
133 // Manipulate link data 214 // Manipulate link data
@@ -135,7 +216,11 @@ function hook_demo_plugin_render_linklist($data)
135 $value['description'] = strtoupper($value['description']); 216 $value['description'] = strtoupper($value['description']);
136 $value['title'] = strtoupper($value['title']); 217 $value['title'] = strtoupper($value['title']);
137 } 218 }
219 $action['on'] = true;
220 } else {
221 $action['off'] = true;
138 } 222 }
223 $data['action_plugin'][] = $action;
139 224
140 // link_plugin (for each link) 225 // link_plugin (for each link)
141 foreach ($data['links'] as &$value) { 226 foreach ($data['links'] as &$value) {