aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2016-11-02 16:34:10 +0100
committerArthurHoaro <arthur@hoa.ro>2016-11-05 14:29:56 +0100
commitc8f0a06d801d1e6405f5d86b45ba5967a6569c8c (patch)
tree173523374b5ac660ace025181acb817125ede482
parentcac0ea87be6326271993c958788afbd244815ef1 (diff)
downloadShaarli-c8f0a06d801d1e6405f5d86b45ba5967a6569c8c.tar.gz
Shaarli-c8f0a06d801d1e6405f5d86b45ba5967a6569c8c.tar.zst
Shaarli-c8f0a06d801d1e6405f5d86b45ba5967a6569c8c.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
-rw-r--r--plugins/addlink_toolbar/addlink_toolbar.html6
-rw-r--r--plugins/addlink_toolbar/addlink_toolbar.php20
-rw-r--r--plugins/demo_plugin/custom_demo.css4
-rw-r--r--plugins/demo_plugin/demo_plugin.php74
-rw-r--r--plugins/playvideos/playvideos.html1
-rw-r--r--plugins/playvideos/playvideos.php8
-rw-r--r--tpl/linklist.html14
-rw-r--r--tpl/linklist.paging.html11
-rw-r--r--tpl/page.header.html9
9 files changed, 124 insertions, 23 deletions
diff --git a/plugins/addlink_toolbar/addlink_toolbar.html b/plugins/addlink_toolbar/addlink_toolbar.html
deleted file mode 100644
index f38c41a0..00000000
--- a/plugins/addlink_toolbar/addlink_toolbar.html
+++ /dev/null
@@ -1,6 +0,0 @@
1<div id="addlink_toolbar">
2 <form method="GET" action="" name="addform" class="addform">
3 <input type="text" name="post" placeholder="URI">
4 <input type="submit" value="Add link" class="bigbutton">
5 </form>
6</div> \ No newline at end of file
diff --git a/plugins/addlink_toolbar/addlink_toolbar.php b/plugins/addlink_toolbar/addlink_toolbar.php
index cfd74207..c96a891e 100644
--- a/plugins/addlink_toolbar/addlink_toolbar.php
+++ b/plugins/addlink_toolbar/addlink_toolbar.php
@@ -15,7 +15,25 @@
15function hook_addlink_toolbar_render_header($data) 15function hook_addlink_toolbar_render_header($data)
16{ 16{
17 if ($data['_PAGE_'] == Router::$PAGE_LINKLIST && $data['_LOGGEDIN_'] === true) { 17 if ($data['_PAGE_'] == Router::$PAGE_LINKLIST && $data['_LOGGEDIN_'] === true) {
18 $data['fields_toolbar'][] = file_get_contents(PluginManager::$PLUGINS_PATH . '/addlink_toolbar/addlink_toolbar.html'); 18 $form = array(
19 'method' => 'GET',
20 'action' => '',
21 'name' => 'addform',
22 'class' => 'addform',
23 'inputs' => array(
24 array(
25 'type' => 'text',
26 'name' => 'post',
27 'placeholder' => 'URI',
28 ),
29 array(
30 'type' => 'submit',
31 'value' => 'Add link',
32 'class' => 'bigbutton',
33 ),
34 ),
35 );
36 $data['fields_toolbar'][] = $form;
19 } 37 }
20 38
21 return $data; 39 return $data;
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 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) {
diff --git a/plugins/playvideos/playvideos.html b/plugins/playvideos/playvideos.html
deleted file mode 100644
index fda3d54f..00000000
--- a/plugins/playvideos/playvideos.html
+++ /dev/null
@@ -1 +0,0 @@
1<a href="#" id="playvideos">► Play Videos</a> \ No newline at end of file
diff --git a/plugins/playvideos/playvideos.php b/plugins/playvideos/playvideos.php
index 7645b778..2f4b0a31 100644
--- a/plugins/playvideos/playvideos.php
+++ b/plugins/playvideos/playvideos.php
@@ -16,7 +16,13 @@
16function hook_playvideos_render_header($data) 16function hook_playvideos_render_header($data)
17{ 17{
18 if ($data['_PAGE_'] == Router::$PAGE_LINKLIST) { 18 if ($data['_PAGE_'] == Router::$PAGE_LINKLIST) {
19 $data['buttons_toolbar'][] = file_get_contents(PluginManager::$PLUGINS_PATH . '/playvideos/playvideos.html'); 19 $playvideo = array(
20 'href' => '#',
21 'title' => 'Video player',
22 'id' => 'playvideos',
23 'html' => '► Play Videos'
24 );
25 $data['buttons_toolbar'][] = $playvideo;
20 } 26 }
21 27
22 return $data; 28 return $data;
diff --git a/tpl/linklist.html b/tpl/linklist.html
index 9979f12a..8608e61e 100644
--- a/tpl/linklist.html
+++ b/tpl/linklist.html
@@ -28,7 +28,19 @@
28 <input type="submit" value="Search" class="bigbutton"> 28 <input type="submit" value="Search" class="bigbutton">
29 </form> 29 </form>
30 {loop="$plugins_header.fields_toolbar"} 30 {loop="$plugins_header.fields_toolbar"}
31 {$value} 31 <form
32 {loop="$value"}
33 {if="$key!='inputs'"}
34 {$key}="{$value}"
35 {/if}
36 {/loop}>
37 {loop="$value.inputs"}
38 <input
39 {loop="$value"}
40 {$key}="{$value}"
41 {/loop}>
42 {/loop}
43 </form>
32 {/loop} 44 {/loop}
33 </div> 45 </div>
34</div> 46</div>
diff --git a/tpl/linklist.paging.html b/tpl/linklist.paging.html
index e91c8f86..42f58d0d 100644
--- a/tpl/linklist.paging.html
+++ b/tpl/linklist.paging.html
@@ -13,7 +13,16 @@
13 </div> 13 </div>
14{/if} 14{/if}
15 {loop="$action_plugin"} 15 {loop="$action_plugin"}
16 {$value} 16 <div class="paging_privatelinks">
17 <a
18 {loop="$value"}
19 {if="$key!='html'"}
20 {$key}="{$value}"
21 {/if}
22 {/loop}>
23 {$value.html}
24 </a>
25 </div>
17 {/loop} 26 {/loop}
18 <div class="paging_linksperpage"> 27 <div class="paging_linksperpage">
19 Links per page: <a href="?linksperpage=20">20</a> <a href="?linksperpage=50">50</a> <a href="?linksperpage=100">100</a> 28 Links per page: <a href="?linksperpage=20">20</a> <a href="?linksperpage=50">50</a> <a href="?linksperpage=100">100</a>
diff --git a/tpl/page.header.html b/tpl/page.header.html
index 0012c689..b9fc5275 100644
--- a/tpl/page.header.html
+++ b/tpl/page.header.html
@@ -35,7 +35,14 @@
35 <li><a href="?do=picwall{$searchcrits}">Picture wall</a></li> 35 <li><a href="?do=picwall{$searchcrits}">Picture wall</a></li>
36 <li><a href="?do=daily">Daily</a></li> 36 <li><a href="?do=daily">Daily</a></li>
37 {loop="$plugins_header.buttons_toolbar"} 37 {loop="$plugins_header.buttons_toolbar"}
38 {$value} 38 <li><a
39 {loop="$value"}
40 {if="$key!='html'"}
41 {$key}="{$value}"
42 {/if}
43 {/loop}>
44 {$value.html}
45 </a></li>
39 {/loop} 46 {/loop}
40{/if} 47{/if}
41 </ul> 48 </ul>