xref: /dokuwiki/lib/plugins/extension/GuiAdmin.php (revision 79ff0cd0c6f2643b1208755842379c8042176441)
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
53176901c2SAndreas Gohr    /**
54176901c2SAndreas Gohr     * Return the HTML for the list of installed plugins
55176901c2SAndreas Gohr     *
56176901c2SAndreas Gohr     * @return string
57176901c2SAndreas 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*79ff0cd0SAndreas Gohr        $plugins = (new Local())->getPlugins();
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);
70176901c2SAndreas 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    }
79176901c2SAndreas Gohr
80176901c2SAndreas Gohr    /**
81176901c2SAndreas Gohr     * Return the HTML for the list of installed templates
82176901c2SAndreas Gohr     *
83176901c2SAndreas Gohr     * @return string
84176901c2SAndreas Gohr     */
85176901c2SAndreas Gohr    public function tabTemplates() {
86176901c2SAndreas Gohr        $html = '<div class="panelHeader">';
87176901c2SAndreas Gohr        $html .= $this->helper->locale_xhtml('intro_templates');
88176901c2SAndreas Gohr        $html .= '</div>';
89176901c2SAndreas Gohr
90176901c2SAndreas Gohr        $templates = (new Local())->getTemplates();
91176901c2SAndreas Gohr
92176901c2SAndreas Gohr        $html .= '<div id="extension__list">';
93176901c2SAndreas Gohr        $html .= '<form action="' . $this->tabURL('templates') . '" method="post">';
94176901c2SAndreas Gohr        $html .= '<input type="hidden" name="overwrite" value="1">';
95176901c2SAndreas Gohr        $html .= formSecurityToken(false);
96176901c2SAndreas Gohr        foreach ($templates as $ext) {
97176901c2SAndreas Gohr            $gui = new GuiExtension($ext);
98176901c2SAndreas Gohr            $html .= $gui->render();
99176901c2SAndreas Gohr        }
100176901c2SAndreas Gohr        $html .= '</form>';
101176901c2SAndreas Gohr        $html .= '</div>';
102176901c2SAndreas Gohr
103176901c2SAndreas Gohr        return $html;
104176901c2SAndreas Gohr    }
105176901c2SAndreas Gohr
106981e70caSAndreas Gohr}
107