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