Skip to content
Snippets Groups Projects
Commit 2f7a5efd authored by Andreas Gohr's avatar Andreas Gohr
Browse files

use menu for site tools

this adds an option to print the menu without icons (as we do in the
dokuwiki template) but icons were added nontheless
parent b85a7f3b
No related branches found
No related tags found
No related merge requests found
......@@ -66,9 +66,10 @@ abstract class AbstractMenu {
* output, use getItems() and build the HTML yourself
*
* @param string|false $classprefix create a class from type with this prefix, false for no class
* @param bool $svg add the SVG link
* @return string
*/
public function getListItems($classprefix = '') {
public function getListItems($classprefix = '', $svg = true) {
$html = '';
foreach($this->getItems() as $item) {
if($classprefix !== false) {
......@@ -78,7 +79,7 @@ abstract class AbstractMenu {
}
$html .= "<li$class>";
$html .= $item->asHtmlLink(false);
$html .= $item->asHtmlLink(false, $svg);
$html .= '</li>';
}
return $html;
......
......@@ -114,13 +114,18 @@ abstract class AbstractItem {
* Wraps around the label and SVG image
*
* @param string|false $classprefix create a class from type with this prefix, false for no class
* @param bool $svg add SVG icon to the link
* @return string
*/
public function asHtmlLink($classprefix = 'menuitem ') {
public function asHtmlLink($classprefix = 'menuitem ', $svg = true) {
$attr = buildAttributes($this->getLinkAttributes($classprefix));
$html = "<a $attr>";
$html .= '<span>' . hsc($this->getLabel()) . '</span>';
$html .= inlineSVG($this->getSvg());
if($svg) {
$html .= '<span>' . hsc($this->getLabel()) . '</span>';
$html .= inlineSVG($this->getSvg());
} else {
$html .= hsc($this->getLabel());
}
$html .= "</a>";
return $html;
......
......@@ -4,6 +4,8 @@ namespace dokuwiki\Menu\Item;
class Index extends AbstractItem {
protected $svg = DOKU_INC . 'lib/images/menu/file-tree.svg';
/** @inheritdoc */
public function __construct() {
parent::__construct();
......
......@@ -4,6 +4,8 @@ namespace dokuwiki\Menu\Item;
class Media extends AbstractItem {
protected $svg = DOKU_INC . 'lib/images/menu/folder-multiple-image.svg';
/** @inheritdoc */
public function __construct() {
global $ID;
......
......@@ -10,6 +10,7 @@ class Recent extends AbstractItem {
$this->category = 'site';
$this->accesskey = 'r';
$this->svg = DOKU_INC . 'lib/images/menu/calendar-clock.svg';
}
}
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M15 13h1.5v2.82l2.44 1.41-.75 1.3L15 16.69V13m4-5H5v11h4.67c-.43-.91-.67-1.93-.67-3a7 7 0 0 1 7-7c1.07 0 2.09.24 3 .67V8M5 21a2 2 0 0 1-2-2V5c0-1.11.89-2 2-2h1V1h2v2h8V1h2v2h1a2 2 0 0 1 2 2v6.1c1.24 1.26 2 2.99 2 4.9a7 7 0 0 1-7 7c-1.91 0-3.64-.76-4.9-2H5m11-9.85A4.85 4.85 0 0 0 11.15 16c0 2.68 2.17 4.85 4.85 4.85A4.85 4.85 0 0 0 20.85 16c0-2.68-2.17-4.85-4.85-4.85z"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M3 3h6v4H3V3m12 7h6v4h-6v-4m0 7h6v4h-6v-4m-2-4H7v5h6v2H5V9h2v2h6v2z"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M7 15l4.5-6 3.5 4.5 2.5-3L21 15m1-11h-8l-2-2H6a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2M2 6H0v14a2 2 0 0 0 2 2h18v-2H2V6z"/></svg>
\ No newline at end of file
......@@ -63,11 +63,9 @@ if (!defined('DOKU_INC')) die();
</div>
<ul>
<?php
tpl_toolsevent('sitetools', array(
tpl_action('recent', true, 'li', true),
tpl_action('media', true, 'li', true),
tpl_action('index', true, 'li', true)
));
$menu = new \dokuwiki\Menu\SiteMenu();
echo $menu->getListItems('action ', false);
unset($menu);
?>
</ul>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment