1b3680c4fSAndreas Gohr<?php 2b3680c4fSAndreas Gohr 3b3680c4fSAndreas Gohrnamespace dokuwiki\Menu; 4b3680c4fSAndreas Gohr 5b3680c4fSAndreas Gohruse dokuwiki\Menu\Item\AbstractItem; 6b3680c4fSAndreas Gohr 7*368ce258SAndreas Gohr/** 8*368ce258SAndreas Gohr * Class MobileMenu 9*368ce258SAndreas Gohr * 10*368ce258SAndreas Gohr * Note: this does not inherit from AbstractMenu because it is not working like the other 11*368ce258SAndreas Gohr * menus. This is a meta menu, aggregating the items from the other menus and offering a combined 12*368ce258SAndreas Gohr * view. The idea is to use this on mobile devices, thus the context is fixed to CTX_MOBILE 13*368ce258SAndreas Gohr */ 14b3680c4fSAndreas Gohrclass MobileMenu { 15b3680c4fSAndreas Gohr 16b3680c4fSAndreas Gohr /** 17b3680c4fSAndreas Gohr * Returns all items grouped 18b3680c4fSAndreas Gohr * 19b3680c4fSAndreas Gohr * @return AbstractItem[][] 20b3680c4fSAndreas Gohr */ 21b3680c4fSAndreas Gohr public function getItems() { 22b3680c4fSAndreas Gohr $pagemenu = new PageMenu(AbstractItem::CTX_MOBILE); 23b3680c4fSAndreas Gohr $sitemenu = new SiteMenu(AbstractItem::CTX_MOBILE); 24b3680c4fSAndreas Gohr $usermenu = new UserMenu(AbstractItem::CTX_MOBILE); 25b3680c4fSAndreas Gohr 26b3680c4fSAndreas Gohr return array( 27b3680c4fSAndreas Gohr 'page' => $pagemenu->getItems(), 28b3680c4fSAndreas Gohr 'site' => $sitemenu->getItems(), 29b3680c4fSAndreas Gohr 'user' => $usermenu->getItems() 30b3680c4fSAndreas Gohr ); 31b3680c4fSAndreas Gohr } 32b3680c4fSAndreas Gohr 33b3680c4fSAndreas Gohr /** 34b3680c4fSAndreas Gohr * Print a dropdown menu with all DokuWiki actions 35b3680c4fSAndreas Gohr * 36b3680c4fSAndreas Gohr * Note: this will not use any pretty URLs 37b3680c4fSAndreas Gohr * 38b3680c4fSAndreas Gohr * @param string $empty empty option label 39b3680c4fSAndreas Gohr * @param string $button submit button label 40b3680c4fSAndreas Gohr * @return string 41b3680c4fSAndreas Gohr */ 42b3680c4fSAndreas Gohr public function getDropdown($empty = '', $button = '>') { 43b3680c4fSAndreas Gohr global $ID; 44b3680c4fSAndreas Gohr global $REV; 45b3680c4fSAndreas Gohr /** @var string[] $lang */ 46b3680c4fSAndreas Gohr global $lang; 47b3680c4fSAndreas Gohr global $INPUT; 48b3680c4fSAndreas Gohr 49b3680c4fSAndreas Gohr $html = '<form action="' . script() . '" method="get" accept-charset="utf-8">'; 50b3680c4fSAndreas Gohr $html .= '<div class="no">'; 51b3680c4fSAndreas Gohr $html .= '<input type="hidden" name="id" value="' . $ID . '" />'; 52b3680c4fSAndreas Gohr if($REV) $html .= '<input type="hidden" name="rev" value="' . $REV . '" />'; 53b3680c4fSAndreas Gohr if($INPUT->server->str('REMOTE_USER')) { 54b3680c4fSAndreas Gohr $html .= '<input type="hidden" name="sectok" value="' . getSecurityToken() . '" />'; 55b3680c4fSAndreas Gohr } 56b3680c4fSAndreas Gohr 57b3680c4fSAndreas Gohr $html .= '<select name="do" class="edit quickselect" title="' . $lang['tools'] . '">'; 58b3680c4fSAndreas Gohr $html .= '<option value="">' . $empty . '</option>'; 59b3680c4fSAndreas Gohr 60b3680c4fSAndreas Gohr foreach($this->getItems() as $tools => $items) { 61b3680c4fSAndreas Gohr $html .= '<optgroup label="' . $lang[$tools . '_tools'] . '">'; 62b3680c4fSAndreas Gohr foreach($items as $item) { 63b3680c4fSAndreas Gohr $params = $item->getParams(); 64b3680c4fSAndreas Gohr $html .= '<option value="' . $params['do'] . '">'; 65b3680c4fSAndreas Gohr $html .= hsc($item->getLabel()); 66b3680c4fSAndreas Gohr $html .= '</option>'; 67b3680c4fSAndreas Gohr } 68b3680c4fSAndreas Gohr $html .= '</optgroup>'; 69b3680c4fSAndreas Gohr } 70b3680c4fSAndreas Gohr 71b3680c4fSAndreas Gohr $html .= '</select>'; 72b3680c4fSAndreas Gohr $html .= '<button type="submit">' . $button . '</button>'; 73b3680c4fSAndreas Gohr $html .= '</div>'; 74b3680c4fSAndreas Gohr $html .= '</form>'; 75b3680c4fSAndreas Gohr 76b3680c4fSAndreas Gohr return $html; 77b3680c4fSAndreas Gohr } 78b3680c4fSAndreas Gohr 79b3680c4fSAndreas Gohr} 80