xref: /dokuwiki/lib/plugins/extension/GuiAdmin.php (revision 176901c266ebe449733667e837c06293c2f8322a)
1981e70caSAndreas Gohr<?php
2981e70caSAndreas Gohr
3981e70caSAndreas Gohrnamespace dokuwiki\plugin\extension;
4981e70caSAndreas Gohr
5981e70caSAndreas Gohrclass GuiAdmin extends Gui
6981e70caSAndreas Gohr{
7981e70caSAndreas Gohr    public function render()
8981e70caSAndreas Gohr    {
9981e70caSAndreas Gohr        $html = '<div id="extension__manager">';
10981e70caSAndreas Gohr
11981e70caSAndreas Gohr        $html .= $this->tabNavigation();
12981e70caSAndreas Gohr
13981e70caSAndreas Gohr        switch ($this->currentTab()) {
14981e70caSAndreas Gohr            case 'search':
15981e70caSAndreas Gohr                $html .= $this->tabSearch();
16981e70caSAndreas Gohr                break;
17981e70caSAndreas Gohr            case 'templates':
18981e70caSAndreas Gohr                $html .= $this->tabTemplates();
19981e70caSAndreas Gohr                break;
20981e70caSAndreas Gohr            case 'install':
21981e70caSAndreas Gohr                $html .= $this->tabInstall();
22981e70caSAndreas Gohr                break;
23981e70caSAndreas Gohr            case 'plugins':
24981e70caSAndreas Gohr            default:
25981e70caSAndreas Gohr                $html .= $this->tabPlugins();
26981e70caSAndreas Gohr        }
27981e70caSAndreas Gohr
28981e70caSAndreas Gohr        $html .= '</div>';
29981e70caSAndreas Gohr        return $html;
30981e70caSAndreas Gohr    }
31981e70caSAndreas Gohr
32981e70caSAndreas Gohr    /**
33981e70caSAndreas Gohr     * Print the tab navigation
34981e70caSAndreas Gohr     *
35981e70caSAndreas Gohr     */
36981e70caSAndreas Gohr    public function tabNavigation()
37981e70caSAndreas Gohr    {
38981e70caSAndreas Gohr        $html = '<ul class="tabs">';
39981e70caSAndreas Gohr        foreach ($this->tabs as $tab) {
40981e70caSAndreas Gohr            $url = $this->tabURL($tab);
41981e70caSAndreas Gohr            if ($this->currentTab() == $tab) {
42981e70caSAndreas Gohr                $class = ' active';
43981e70caSAndreas Gohr            } else {
44981e70caSAndreas Gohr                $class = '';
45981e70caSAndreas Gohr            }
46981e70caSAndreas Gohr            $html .= '<li class="' . $tab . $class . '"><a href="' . $url . '">' .
47981e70caSAndreas Gohr                $this->getLang('tab_' . $tab) . '</a></li>';
48981e70caSAndreas Gohr        }
49981e70caSAndreas Gohr        $html .= '</ul>';
50981e70caSAndreas Gohr        return $html;
51981e70caSAndreas Gohr    }
52981e70caSAndreas Gohr
53*176901c2SAndreas Gohr    /**
54*176901c2SAndreas Gohr     * Return the HTML for the list of installed plugins
55*176901c2SAndreas Gohr     *
56*176901c2SAndreas Gohr     * @return string
57*176901c2SAndreas Gohr     */
58981e70caSAndreas Gohr    public function tabPlugins()
59981e70caSAndreas Gohr    {
60981e70caSAndreas Gohr        $html = '<div class="panelHeader">';
61981e70caSAndreas Gohr        $html .= $this->helper->locale_xhtml('intro_plugins');
62981e70caSAndreas Gohr        $html .= '</div>';
63981e70caSAndreas Gohr
64*176901c2SAndreas Gohr        $plugins = (new Local())->getTemplates();
65981e70caSAndreas Gohr
66981e70caSAndreas Gohr        $html .= '<div id="extension__list">';
6780bc92fbSAndreas Gohr        $html .= '<form action="' . $this->tabURL('plugins') . '" method="post">';
6880bc92fbSAndreas Gohr        $html .= '<input type="hidden" name="overwrite" value="1">';
6980bc92fbSAndreas Gohr        $html .= formSecurityToken(false);
70*176901c2SAndreas Gohr        foreach ($plugins as $ext) {
71981e70caSAndreas Gohr            $gui = new GuiExtension($ext);
72981e70caSAndreas Gohr            $html .= $gui->render();
73981e70caSAndreas Gohr        }
7480bc92fbSAndreas Gohr        $html .= '</form>';
75981e70caSAndreas Gohr        $html .= '</div>';
76981e70caSAndreas Gohr
77981e70caSAndreas Gohr        return $html;
78981e70caSAndreas Gohr    }
79*176901c2SAndreas Gohr
80*176901c2SAndreas Gohr    /**
81*176901c2SAndreas Gohr     * Return the HTML for the list of installed templates
82*176901c2SAndreas Gohr     *
83*176901c2SAndreas Gohr     * @return string
84*176901c2SAndreas Gohr     */
85*176901c2SAndreas Gohr    public function tabTemplates() {
86*176901c2SAndreas Gohr        $html = '<div class="panelHeader">';
87*176901c2SAndreas Gohr        $html .= $this->helper->locale_xhtml('intro_templates');
88*176901c2SAndreas Gohr        $html .= '</div>';
89*176901c2SAndreas Gohr
90*176901c2SAndreas Gohr        $templates = (new Local())->getTemplates();
91*176901c2SAndreas Gohr
92*176901c2SAndreas Gohr        $html .= '<div id="extension__list">';
93*176901c2SAndreas Gohr        $html .= '<form action="' . $this->tabURL('templates') . '" method="post">';
94*176901c2SAndreas Gohr        $html .= '<input type="hidden" name="overwrite" value="1">';
95*176901c2SAndreas Gohr        $html .= formSecurityToken(false);
96*176901c2SAndreas Gohr        foreach ($templates as $ext) {
97*176901c2SAndreas Gohr            $gui = new GuiExtension($ext);
98*176901c2SAndreas Gohr            $html .= $gui->render();
99*176901c2SAndreas Gohr        }
100*176901c2SAndreas Gohr        $html .= '</form>';
101*176901c2SAndreas Gohr        $html .= '</div>';
102*176901c2SAndreas Gohr
103*176901c2SAndreas Gohr        return $html;
104*176901c2SAndreas Gohr    }
105*176901c2SAndreas Gohr
106981e70caSAndreas Gohr}
107