xref: /plugin/farmer/admin/info.php (revision 1e6816d22c8d3a4b4d4251e4c4739ea6f6e8308a)
1632c5618SAndreas Gohr<?php
21da41c8bSAndreas Gohr
31da41c8bSAndreas Gohruse dokuwiki\Extension\AdminPlugin;
41da41c8bSAndreas Gohr
5632c5618SAndreas Gohr/**
6632c5618SAndreas Gohr * DokuWiki Plugin farmer (Admin Component)
7632c5618SAndreas Gohr *
81da41c8bSAndreas Gohr * Information about the farm and the current instance
91da41c8bSAndreas Gohr *
10632c5618SAndreas Gohr * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
11632c5618SAndreas Gohr * @author  Michael Große <grosse@cosmocode.de>
120a5d2da2SAndreas Gohr * @author  Andreas Gohr <gohr@cosmocode.de>
13632c5618SAndreas Gohr */
141da41c8bSAndreas Gohrclass admin_plugin_farmer_info extends AdminPlugin
151da41c8bSAndreas Gohr{
16c4c8e953SAndreas Gohr    /** @var helper_plugin_farmer */
17c4c8e953SAndreas Gohr    protected $helper;
18632c5618SAndreas Gohr
19c4c8e953SAndreas Gohr    /**
20c4c8e953SAndreas Gohr     * admin_plugin_farmer_info constructor.
21c4c8e953SAndreas Gohr     */
221da41c8bSAndreas Gohr    public function __construct()
231da41c8bSAndreas Gohr    {
24c4c8e953SAndreas Gohr        $this->helper = plugin_load('helper', 'farmer');
25c4c8e953SAndreas Gohr    }
26632c5618SAndreas Gohr
27632c5618SAndreas Gohr    /**
28341a2d35SAndreas Gohr     * This part is visible to managers also
29341a2d35SAndreas Gohr      @inheritdoc
30632c5618SAndreas Gohr     */
311da41c8bSAndreas Gohr    public function forAdminOnly()
321da41c8bSAndreas Gohr    {
33632c5618SAndreas Gohr        return false;
34632c5618SAndreas Gohr    }
35632c5618SAndreas Gohr
36341a2d35SAndreas Gohr    /** @inheritdoc */
37341a2d35SAndreas Gohr    public function showInMenu()
381da41c8bSAndreas Gohr    {
39341a2d35SAndreas Gohr        return false;
40632c5618SAndreas Gohr    }
41632c5618SAndreas Gohr
42341a2d35SAndreas Gohr    /** @inheritdoc */
431da41c8bSAndreas Gohr    public function html()
441da41c8bSAndreas Gohr    {
45d8c083b7SAndreas Gohr        global $conf;
46c4c8e953SAndreas Gohr        global $INPUT;
47d8c083b7SAndreas Gohr
48c4c8e953SAndreas Gohr        $animal = $this->helper->getAnimal();
49c4c8e953SAndreas Gohr        $config = $this->helper->getConfig();
50632c5618SAndreas Gohr
51632c5618SAndreas Gohr        echo '<table class="inline">';
529ea97f82SAndreas Gohr
53632c5618SAndreas Gohr        $this->line('thisis', $animal ? $this->getLang('thisis.animal') : $this->getLang('thisis.farmer'));
54a646d519SAndreas Gohr        if ($animal) {
55a646d519SAndreas Gohr            $this->line('animal', $animal);
56a646d519SAndreas Gohr        }
573ec10871SAndreas Gohr        $this->line('confdir', fullpath(DOKU_CONF) . '/');
583ec10871SAndreas Gohr        $this->line('savedir', fullpath($conf['savedir']) . '/');
59632c5618SAndreas Gohr        $this->line('baseinstall', DOKU_INC);
609ea97f82SAndreas Gohr        $this->line('farm host', $config['base']['farmhost']);
61632c5618SAndreas Gohr        $this->line('farm dir', DOKU_FARMDIR);
629ea97f82SAndreas Gohr
63*1e6816d2SAndreas Gohr        if (!$animal || $config['notfound']['show'] == 'list') {
64c4c8e953SAndreas Gohr            $this->line('animals', $this->animals($INPUT->bool('list')));
65*1e6816d2SAndreas Gohr        }
66d8c083b7SAndreas Gohr
679ea97f82SAndreas Gohr        foreach ($config['inherit'] as $key => $value) {
689ea97f82SAndreas Gohr            $this->line('conf_inherit_' . $key, $this->getLang($value ? 'conf_inherit_yes' : 'conf_inherit_no'));
699ea97f82SAndreas Gohr        }
709ea97f82SAndreas Gohr
711da41c8bSAndreas Gohr        $this->line('plugins', implode(', ', $this->helper->getAllPlugins(false)));
72af1c6dd8SAndreas Gohr
73632c5618SAndreas Gohr        echo '</table>';
74632c5618SAndreas Gohr    }
75632c5618SAndreas Gohr
76c4c8e953SAndreas Gohr    /**
77c4c8e953SAndreas Gohr     * List or count the animals
78c4c8e953SAndreas Gohr     *
79c4c8e953SAndreas Gohr     * @param bool $list
80c4c8e953SAndreas Gohr     * @return string
81c4c8e953SAndreas Gohr     */
821da41c8bSAndreas Gohr    protected function animals($list)
831da41c8bSAndreas Gohr    {
84c4c8e953SAndreas Gohr        global $ID;
85c4c8e953SAndreas Gohr
86c4c8e953SAndreas Gohr        $animals = $this->helper->getAllAnimals();
87c4c8e953SAndreas Gohr        $html = '';
88c4c8e953SAndreas Gohr        if (!$list) {
89c4c8e953SAndreas Gohr            $html = count($animals);
901da41c8bSAndreas Gohr            $self = wl($ID, ['do' => 'admin', 'page' => 'farmer', 'sub' => 'info', 'list' => 1]);
91c4c8e953SAndreas Gohr            $html .= ' [<a href="' . $self . '">' . $this->getLang('conf_notfound_list') . '</a>]';
92c4c8e953SAndreas Gohr            return $html;
93c4c8e953SAndreas Gohr        }
94c4c8e953SAndreas Gohr
95c4c8e953SAndreas Gohr        $html .= '<ol>';
96c4c8e953SAndreas Gohr        foreach ($animals as $animal) {
97c4c8e953SAndreas Gohr            $link = $this->helper->getAnimalURL($animal);
98c4c8e953SAndreas Gohr            $html .= '<li><div class="li"><a href="' . $link . '">' . $animal . '</a></div></li>';
99c4c8e953SAndreas Gohr        }
100c4c8e953SAndreas Gohr        $html .= '</ol>';
101c4c8e953SAndreas Gohr        return $html;
102c4c8e953SAndreas Gohr    }
103c4c8e953SAndreas Gohr
104c4c8e953SAndreas Gohr    /**
105c4c8e953SAndreas Gohr     * Output a table line
106c4c8e953SAndreas Gohr     *
107c4c8e953SAndreas Gohr     * @param string $langkey
108c4c8e953SAndreas Gohr     * @param string $value
109c4c8e953SAndreas Gohr     */
1101da41c8bSAndreas Gohr    protected function line($langkey, $value)
1111da41c8bSAndreas Gohr    {
112632c5618SAndreas Gohr        echo '<tr>';
113632c5618SAndreas Gohr        echo '<th>' . $this->getLang($langkey) . '</th>';
114632c5618SAndreas Gohr        echo '<td>' . $value . '</td>';
115632c5618SAndreas Gohr        echo '</tr>';
116632c5618SAndreas Gohr    }
117632c5618SAndreas Gohr}
118