aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib/plugins/extension/Gui.php
blob: 4038cdfef5de30b2009bef92102553eb7d3ae719 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php

namespace dokuwiki\plugin\extension;

class Gui
{
    protected $tabs = ['plugins', 'templates', 'search', 'install'];

    protected $helper;


    public function __construct()
    {
        $this->helper = plugin_load('helper', 'extension');
    }


    public function getLang($msg)
    {
        return $this->helper->getLang($msg);
    }

    /**
     * Return the currently selected tab
     *
     * @return string
     */
    public function currentTab()
    {
        global $INPUT;

        $tab = $INPUT->str('tab', 'plugins', true);
        if (!in_array($tab, $this->tabs)) $tab = 'plugins';
        return $tab;
    }

    /**
     * Create an URL inside the extension manager
     *
     * @param string $tab tab to load, empty for current tab
     * @param array $params associative array of parameter to set
     * @param string $sep seperator to build the URL
     * @param bool $absolute create absolute URLs?
     * @return string
     */
    public function tabURL($tab = '', $params = [], $sep = '&', $absolute = false)
    {
        global $ID;
        global $INPUT;

        if (!$tab) $tab = $this->currentTab();
        $defaults = [
            'do' => 'admin',
            'page' => 'extension',
            'tab' => $tab
        ];
        if ($tab == 'search') $defaults['q'] = $INPUT->str('q');

        return wl($ID, array_merge($defaults, $params), $absolute, $sep);
    }
}