1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace dokuwiki\template\dokuwiki; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class tpl |
7
|
|
|
* |
8
|
|
|
* Provides additional template functions for the dokuwiki template |
9
|
|
|
* @package dokuwiki\tpl\dokuwiki |
10
|
|
|
*/ |
11
|
|
|
class tpl { |
12
|
|
|
|
13
|
|
|
static $icons = array( |
14
|
|
|
'default' => '00-default_checkbox-blank-circle-outline.svg', |
15
|
|
|
'edit' => '01-edit_pencil.svg', |
16
|
|
|
'create' => '02-create_pencil.svg', |
17
|
|
|
'draft' => '03-draft_android-studio.svg', |
18
|
|
|
'show' => '04-show_file-document.svg', |
19
|
|
|
'source' => '05-source_file-xml.svg', |
20
|
|
|
'revert' => '06-revert_replay.svg', |
21
|
|
|
'revs' => '07-revisions_history.svg', |
22
|
|
|
'backlink' => '08-backlink_link-variant.svg', |
23
|
|
|
'subscribe' => '09-subscribe_email-outline.svg', |
24
|
|
|
'top' => '10-top_arrow-up.svg', |
25
|
|
|
'mediaManager' => '11-mediamanager_folder-image.svg', |
26
|
|
|
'img_backto' => '12-back_arrow-left.svg', |
27
|
|
|
|
28
|
|
|
); |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Return the HTML for one of the default actions |
32
|
|
|
* |
33
|
|
|
* Reimplements parts of tpl_actionlink |
34
|
|
|
* |
35
|
|
|
* @param string $action |
36
|
|
|
* @return string |
37
|
|
|
*/ |
38
|
|
|
static public function pageToolAction($action) { |
39
|
|
|
$data = tpl_get_action($action); |
40
|
|
|
if(!is_array($data)) return ''; |
41
|
|
|
global $lang; |
42
|
|
|
|
43
|
|
|
if($data['id'][0] == '#') { |
44
|
|
|
$linktarget = $data['id']; |
45
|
|
|
} else { |
46
|
|
|
$linktarget = wl($data['id'], $data['params']); |
47
|
|
|
} |
48
|
|
|
$caption = $lang['btn_' . $data['type']]; |
49
|
|
|
if(strpos($caption, '%s')) { |
50
|
|
|
$caption = sprintf($caption, $data['replacement']); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
$svg = __DIR__ . '/images/tools/' . self::$icons[$data['type']]; |
54
|
|
|
|
55
|
|
|
return self::pageToolItem( |
56
|
|
|
$linktarget, |
57
|
|
|
$caption, |
58
|
|
|
$svg, |
59
|
|
|
$data['accesskey'] |
60
|
|
|
); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Return the HTML for a page action |
65
|
|
|
* |
66
|
|
|
* Plugins could use this |
67
|
|
|
* |
68
|
|
|
* @param string $link The link |
69
|
|
|
* @param string $caption The label of the action |
70
|
|
|
* @param string $svg The icon to show |
71
|
|
|
* @param string $key Accesskey |
72
|
|
|
* @return string |
73
|
|
|
*/ |
74
|
|
|
static public function pageToolItem($link, $caption, $svg, $key = '') { |
75
|
|
|
$title = $caption; |
76
|
|
|
if($key) { |
77
|
|
|
$title .= ' [' . strtoupper($key) . ']'; |
78
|
|
|
$key = 'accesskey="' . $key . '"'; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
$svg = inlinSVG($svg); |
82
|
|
|
if(!$svg) $svg = inlinSVG(__DIR__ . '/images/tools/' . self::$icons['default']); |
|
|
|
|
83
|
|
|
|
84
|
|
|
$out = '<li>'; |
85
|
|
|
$out .= '<a href="' . $link . '" title="' . hsc($title) . '" rel="nofollow" ' . $key . '>'; |
86
|
|
|
$out .= '<span>' . hsc($caption) . '</span>'; |
87
|
|
|
$out .= $svg; |
88
|
|
|
$out .= '</li>'; |
89
|
|
|
return $out; |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: