1<?php 2 3namespace dokuwiki\plugin\extension; 4 5class Gui 6{ 7 protected $tabs = ['plugins', 'templates', 'search', 'install']; 8 9 protected $helper; 10 11 12 public function __construct() 13 { 14 $this->helper = plugin_load('helper', 'extension'); 15 } 16 17 18 public function getLang($msg) 19 { 20 return $this->helper->getLang($msg); 21 } 22 23 /** 24 * Return the currently selected tab 25 * 26 * @return string 27 */ 28 public function currentTab() 29 { 30 global $INPUT; 31 32 $tab = $INPUT->str('tab', 'plugins', true); 33 if (!in_array($tab, $this->tabs)) $tab = 'plugins'; 34 return $tab; 35 } 36 37 /** 38 * Create an URL inside the extension manager 39 * 40 * @param string $tab tab to load, empty for current tab 41 * @param array $params associative array of parameter to set 42 * @param string $sep seperator to build the URL 43 * @param bool $absolute create absolute URLs? 44 * @return string 45 */ 46 public function tabURL($tab = '', $params = [], $sep = '&', $absolute = false) 47 { 48 global $ID; 49 global $INPUT; 50 51 if (!$tab) $tab = $this->currentTab(); 52 $defaults = [ 53 'do' => 'admin', 54 'page' => 'extension', 55 'tab' => $tab 56 ]; 57 if ($tab == 'search') $defaults['q'] = $INPUT->str('q'); 58 59 return wl($ID, array_merge($defaults, $params), $absolute, $sep); 60 } 61} 62