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