xref: /plugin/farmer/admin/info.php (revision 341a2d3514259f15502840e8abd56a11b4085405)
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    /**
28*341a2d35SAndreas Gohr     * This part is visible to managers also
29*341a2d35SAndreas Gohr      @inheritdoc
30632c5618SAndreas Gohr     */
311da41c8bSAndreas Gohr    public function forAdminOnly()
321da41c8bSAndreas Gohr    {
33632c5618SAndreas Gohr        return false;
34632c5618SAndreas Gohr    }
35632c5618SAndreas Gohr
36*341a2d35SAndreas Gohr    /** @inheritdoc */
37*341a2d35SAndreas Gohr    public function showInMenu()
381da41c8bSAndreas Gohr    {
39*341a2d35SAndreas Gohr        return false;
40632c5618SAndreas Gohr    }
41632c5618SAndreas Gohr
42*341a2d35SAndreas 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
63c4c8e953SAndreas Gohr        $this->line('animals', $this->animals($INPUT->bool('list')));
64d8c083b7SAndreas Gohr
659ea97f82SAndreas Gohr        foreach ($config['inherit'] as $key => $value) {
669ea97f82SAndreas Gohr            $this->line('conf_inherit_' . $key, $this->getLang($value ? 'conf_inherit_yes' : 'conf_inherit_no'));
679ea97f82SAndreas Gohr        }
689ea97f82SAndreas Gohr
691da41c8bSAndreas Gohr        $this->line('plugins', implode(', ', $this->helper->getAllPlugins(false)));
70af1c6dd8SAndreas Gohr
71632c5618SAndreas Gohr        echo '</table>';
72632c5618SAndreas Gohr    }
73632c5618SAndreas Gohr
74c4c8e953SAndreas Gohr    /**
75c4c8e953SAndreas Gohr     * List or count the animals
76c4c8e953SAndreas Gohr     *
77c4c8e953SAndreas Gohr     * @param bool $list
78c4c8e953SAndreas Gohr     * @return string
79c4c8e953SAndreas Gohr     */
801da41c8bSAndreas Gohr    protected function animals($list)
811da41c8bSAndreas Gohr    {
82c4c8e953SAndreas Gohr        global $ID;
83c4c8e953SAndreas Gohr
84c4c8e953SAndreas Gohr        $animals = $this->helper->getAllAnimals();
85c4c8e953SAndreas Gohr        $html = '';
86c4c8e953SAndreas Gohr        if (!$list) {
87c4c8e953SAndreas Gohr            $html = count($animals);
881da41c8bSAndreas Gohr            $self = wl($ID, ['do' => 'admin', 'page' => 'farmer', 'sub' => 'info', 'list' => 1]);
89c4c8e953SAndreas Gohr            $html .= ' [<a href="' . $self . '">' . $this->getLang('conf_notfound_list') . '</a>]';
90c4c8e953SAndreas Gohr            return $html;
91c4c8e953SAndreas Gohr        }
92c4c8e953SAndreas Gohr
93c4c8e953SAndreas Gohr        $html .= '<ol>';
94c4c8e953SAndreas Gohr        foreach ($animals as $animal) {
95c4c8e953SAndreas Gohr            $link = $this->helper->getAnimalURL($animal);
96c4c8e953SAndreas Gohr            $html .= '<li><div class="li"><a href="' . $link . '">' . $animal . '</a></div></li>';
97c4c8e953SAndreas Gohr        }
98c4c8e953SAndreas Gohr        $html .= '</ol>';
99c4c8e953SAndreas Gohr        return $html;
100c4c8e953SAndreas Gohr    }
101c4c8e953SAndreas Gohr
102c4c8e953SAndreas Gohr    /**
103c4c8e953SAndreas Gohr     * Output a table line
104c4c8e953SAndreas Gohr     *
105c4c8e953SAndreas Gohr     * @param string $langkey
106c4c8e953SAndreas Gohr     * @param string $value
107c4c8e953SAndreas Gohr     */
1081da41c8bSAndreas Gohr    protected function line($langkey, $value)
1091da41c8bSAndreas Gohr    {
110632c5618SAndreas Gohr        echo '<tr>';
111632c5618SAndreas Gohr        echo '<th>' . $this->getLang($langkey) . '</th>';
112632c5618SAndreas Gohr        echo '<td>' . $value . '</td>';
113632c5618SAndreas Gohr        echo '</tr>';
114632c5618SAndreas Gohr    }
115632c5618SAndreas Gohr}
116