aboutsummaryrefslogtreecommitdiffhomepage
path: root/plugins/demo_plugin/demo_plugin.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2016-12-01 11:38:21 +0100
committerArthurHoaro <arthur@hoa.ro>2016-12-01 11:38:21 +0100
commitba0fd80732acbff0fcda57a0b31e4edfaa337001 (patch)
tree34eab231241e1c7b72f5b069fa132bdcedc830e0 /plugins/demo_plugin/demo_plugin.php
parent849d1650c1af853162b749af896c20bb25d4a4e8 (diff)
downloadShaarli-ba0fd80732acbff0fcda57a0b31e4edfaa337001.tar.gz
Shaarli-ba0fd80732acbff0fcda57a0b31e4edfaa337001.tar.zst
Shaarli-ba0fd80732acbff0fcda57a0b31e4edfaa337001.zip
Improve theme dependent plugin placeholders:
- buttons_toolbar: now expect links represented by an array instead of HTML content - fields_toolbar: now expect a form represented by an array instead of HTML content - action_plugin: now expect links represented by an array instead of HTML content Default templates updated accordingly mprove theme dependent plugin placeholders:
Diffstat (limited to 'plugins/demo_plugin/demo_plugin.php')
-rw-r--r--plugins/demo_plugin/demo_plugin.php82
1 files changed, 75 insertions, 7 deletions
diff --git a/plugins/demo_plugin/demo_plugin.php b/plugins/demo_plugin/demo_plugin.php
index 7335c9d4..8fdbf663 100644
--- a/plugins/demo_plugin/demo_plugin.php
+++ b/plugins/demo_plugin/demo_plugin.php
@@ -50,15 +50,68 @@ function hook_demo_plugin_render_header($data)
50 50
51 // If loggedin 51 // If loggedin
52 if ($data['_LOGGEDIN_'] === true) { 52 if ($data['_LOGGEDIN_'] === true) {
53 // Buttons in toolbar 53 /*
54 $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;
55 } 67 }
56 68
57 // Fields in toolbar 69 /*
58 $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;
59 } 106 }
60 // Another button always displayed 107 // Another button always displayed
61 $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;
62 115
63 return $data; 116 return $data;
64} 117}
@@ -143,8 +196,19 @@ function hook_demo_plugin_render_footer($data)
143 */ 196 */
144function hook_demo_plugin_render_linklist($data) 197function hook_demo_plugin_render_linklist($data)
145{ 198{
146 // action_plugin 199 /*
147 $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 );
148 212
149 if (isset($_GET['up'])) { 213 if (isset($_GET['up'])) {
150 // Manipulate link data 214 // Manipulate link data
@@ -152,7 +216,11 @@ function hook_demo_plugin_render_linklist($data)
152 $value['description'] = strtoupper($value['description']); 216 $value['description'] = strtoupper($value['description']);
153 $value['title'] = strtoupper($value['title']); 217 $value['title'] = strtoupper($value['title']);
154 } 218 }
219 $action['on'] = true;
220 } else {
221 $action['off'] = true;
155 } 222 }
223 $data['action_plugin'][] = $action;
156 224
157 // link_plugin (for each link) 225 // link_plugin (for each link)
158 foreach ($data['links'] as &$value) { 226 foreach ($data['links'] as &$value) {