aboutsummaryrefslogtreecommitdiffhomepage
path: root/plugins/demo_plugin
diff options
context:
space:
mode:
authorArthur <arthur@hoa.ro>2016-12-12 03:07:13 +0100
committerGitHub <noreply@github.com>2016-12-12 03:07:13 +0100
commita0d079141eb155c263ebfaa1aad2629382223e31 (patch)
treee72090d95310391fdbe155906eab050764a95c47 /plugins/demo_plugin
parentbea80e43a3714663b0c32879f7bdf4fd19161b2e (diff)
parentba0fd80732acbff0fcda57a0b31e4edfaa337001 (diff)
downloadShaarli-a0d079141eb155c263ebfaa1aad2629382223e31.tar.gz
Shaarli-a0d079141eb155c263ebfaa1aad2629382223e31.tar.zst
Shaarli-a0d079141eb155c263ebfaa1aad2629382223e31.zip
Merge pull request #679 from ArthurHoaro/plugins/header
Improve theme dependent plugin placeholders:
Diffstat (limited to 'plugins/demo_plugin')
-rw-r--r--plugins/demo_plugin/custom_demo.css4
-rw-r--r--plugins/demo_plugin/demo_plugin.php82
2 files changed, 75 insertions, 11 deletions
diff --git a/plugins/demo_plugin/custom_demo.css b/plugins/demo_plugin/custom_demo.css
index af5e8bf9..95019e28 100644
--- a/plugins/demo_plugin/custom_demo.css
+++ b/plugins/demo_plugin/custom_demo.css
@@ -2,10 +2,6 @@
2 color: red; 2 color: red;
3} 3}
4 4
5.upper_plugin_demo {
6 float: left;
7}
8
9#demo_marquee { 5#demo_marquee {
10 background: darkmagenta; 6 background: darkmagenta;
11 color: white; 7 color: white;
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) {