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