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.php74
1 files changed, 67 insertions, 7 deletions
diff --git a/plugins/demo_plugin/demo_plugin.php b/plugins/demo_plugin/demo_plugin.php
index 18834e53..8f675cc4 100644
--- a/plugins/demo_plugin/demo_plugin.php
+++ b/plugins/demo_plugin/demo_plugin.php
@@ -33,15 +33,62 @@ function hook_demo_plugin_render_header($data)
33 33
34 // If loggedin 34 // If loggedin
35 if ($data['_LOGGEDIN_'] === true) { 35 if ($data['_LOGGEDIN_'] === true) {
36 // Buttons in toolbar 36 /*
37 $data['buttons_toolbar'][] = '<li><a href="#">DEMO_buttons_toolbar</a></li>'; 37 * Links in toolbar:
38 * A link is an array of its attributes (key="value"),
39 * and a mandatory `html` key, which contains its value.
40 */
41 $button = array(
42 'href' => '#',
43 'class' => 'mybutton',
44 'title' => 'hover me',
45 'html' => 'DEMO buttons toolbar',
46 );
47 $data['buttons_toolbar'][] = $button;
38 } 48 }
39 49
40 // Fields in toolbar 50 /*
41 $data['fields_toolbar'][] = 'DEMO_fields_toolbar'; 51 * Add additional input fields in the tools.
52 * A field is an array containing:
53 * [
54 * 'form-attribute-1' => 'form attribute 1 value',
55 * 'form-attribute-2' => 'form attribute 2 value',
56 * 'inputs' => [
57 * [
58 * 'input-1-attribute-1 => 'input 1 attribute 1 value',
59 * 'input-1-attribute-2 => 'input 1 attribute 2 value',
60 * ],
61 * [
62 * 'input-2-attribute-1 => 'input 2 attribute 1 value',
63 * ],
64 * ],
65 * ]
66 * This example renders as:
67 * <form form-attribute-1="form attribute 1 value" form-attribute-2="form attribute 2 value">
68 * <input input-1-attribute-1="input 1 attribute 1 value" input-1-attribute-2="input 1 attribute 2 value">
69 * <input input-2-attribute-1="input 2 attribute 1 value">
70 * </form>
71 */
72 $form = array(
73 'method' => 'GET',
74 'action' => '?',
75 'class' => 'addform',
76 'inputs' => array(
77 array(
78 'type' => 'text',
79 'name' => 'demo',
80 'placeholder' => 'demo',
81 )
82 )
83 );
84 $data['fields_toolbar'][] = $form;
42 } 85 }
43 // Another button always displayed 86 // Another button always displayed
44 $data['buttons_toolbar'][] = '<li><a href="#">DEMO</a></li>'; 87 $button = array(
88 'href' => '#',
89 'html' => 'Demo',
90 );
91 $data['buttons_toolbar'][] = $button;
45 92
46 return $data; 93 return $data;
47} 94}
@@ -126,8 +173,17 @@ function hook_demo_plugin_render_footer($data)
126 */ 173 */
127function hook_demo_plugin_render_linklist($data) 174function hook_demo_plugin_render_linklist($data)
128{ 175{
129 // action_plugin 176 /*
130 $data['action_plugin'][] = '<div class="upper_plugin_demo"><a href="?up" title="Uppercase!">←</a></div>'; 177 * Action links (action_plugin):
178 * A link is an array of its attributes (key="value"),
179 * and a mandatory `html` key, which contains its value.
180 * It's also recommended to add key 'on' or 'off' for theme rendering.
181 */
182 $action = array(
183 'href' => '?up',
184 'title' => 'Uppercase!',
185 'html' => '←',
186 );
131 187
132 if (isset($_GET['up'])) { 188 if (isset($_GET['up'])) {
133 // Manipulate link data 189 // Manipulate link data
@@ -135,7 +191,11 @@ function hook_demo_plugin_render_linklist($data)
135 $value['description'] = strtoupper($value['description']); 191 $value['description'] = strtoupper($value['description']);
136 $value['title'] = strtoupper($value['title']); 192 $value['title'] = strtoupper($value['title']);
137 } 193 }
194 $action['on'] = true;
195 } else {
196 $action['off'] = true;
138 } 197 }
198 $data['action_plugin'][] = $action;
139 199
140 // link_plugin (for each link) 200 // link_plugin (for each link)
141 foreach ($data['links'] as &$value) { 201 foreach ($data['links'] as &$value) {