1 | <?php |
||
20 | abstract class AbstractItem { |
||
21 | |||
22 | /** menu item is to be shown on desktop screens only */ |
||
23 | const CTX_DESKTOP = 1; |
||
24 | /** menu item is to be shown on mobile screens only */ |
||
25 | const CTX_MOBILE = 2; |
||
26 | /** menu item is to be shown in all contexts */ |
||
27 | const CTX_ALL = 3; |
||
28 | |||
29 | protected $type = ''; |
||
30 | protected $accesskey = ''; |
||
31 | protected $id = ''; |
||
32 | protected $method = 'get'; |
||
33 | protected $params = array(); |
||
34 | protected $nofollow = true; |
||
35 | protected $replacement = ''; |
||
36 | protected $category = 'page'; |
||
37 | protected $svg = DOKU_INC . 'lib/images/menu/00-default_checkbox-blank-circle-outline.svg'; |
||
38 | protected $label = ''; |
||
39 | protected $context = self::CTX_ALL; |
||
40 | |||
41 | public function __construct() { |
||
49 | |||
50 | /** |
||
51 | * Return this item's label |
||
52 | * |
||
53 | * When the label property was set, it is simply returned. Otherwise, the action's type |
||
54 | * is used to look up the translation in the main language file and, if used, the replacement |
||
55 | * is applied. |
||
56 | * |
||
57 | * @return string |
||
58 | */ |
||
59 | public function getLabel() { |
||
71 | |||
72 | /** |
||
73 | * Return the link this item links to |
||
74 | * |
||
75 | * Basically runs wl() on $id and $params. However if the ID is a hash it is used directly |
||
76 | * as the link |
||
77 | * |
||
78 | * @see wl() |
||
79 | * @return string |
||
80 | */ |
||
81 | public function getLink() { |
||
88 | |||
89 | /** |
||
90 | * Convenience method to get the attributes for constructing an <a> element |
||
91 | * |
||
92 | * @see buildAttributes() |
||
93 | * @param string|false $classprefix create a class from type with this prefix, false for no class |
||
94 | * @return array |
||
95 | */ |
||
96 | public function getLinkAttributes($classprefix = 'menuitem ') { |
||
110 | |||
111 | /** |
||
112 | * Convenience method to create a full <a> element |
||
113 | * |
||
114 | * Wraps around the label and SVG image |
||
115 | * |
||
116 | * @param string|false $classprefix create a class from type with this prefix, false for no class |
||
117 | * @return string |
||
118 | */ |
||
119 | public function asHtmlLink($classprefix = 'menuitem ') { |
||
128 | |||
129 | /** |
||
130 | * Should this item be shown in the given context |
||
131 | * |
||
132 | * @param int $ctx the current context |
||
133 | * @return bool |
||
134 | */ |
||
135 | public function visibleInContext($ctx) { |
||
138 | |||
139 | /** |
||
140 | * @return string the name of this item |
||
141 | */ |
||
142 | public function getType() { |
||
145 | |||
146 | /** |
||
147 | * @return string |
||
148 | */ |
||
149 | public function getAccesskey() { |
||
152 | |||
153 | /** |
||
154 | * @return array |
||
155 | */ |
||
156 | public function getParams() { |
||
159 | |||
160 | /** |
||
161 | * @return bool |
||
162 | */ |
||
163 | public function isNofollow() { |
||
166 | |||
167 | /** |
||
168 | * @return string |
||
169 | */ |
||
170 | public function getSvg() { |
||
173 | |||
174 | } |
||
175 |