xref: /plugin/farmer/admin/info.php (revision af1c6dd8b9c1e35385ddfb7549af221f4070c191)
1632c5618SAndreas Gohr<?php
2632c5618SAndreas Gohr/**
3632c5618SAndreas Gohr * DokuWiki Plugin farmer (Admin Component)
4632c5618SAndreas Gohr *
5632c5618SAndreas Gohr * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6632c5618SAndreas Gohr * @author  Michael Große <grosse@cosmocode.de>
70a5d2da2SAndreas Gohr * @author  Andreas Gohr <gohr@cosmocode.de>
8632c5618SAndreas Gohr */
9632c5618SAndreas Gohr
10632c5618SAndreas Gohr// must be run within Dokuwiki
11632c5618SAndreas Gohrif(!defined('DOKU_INC')) die();
12632c5618SAndreas Gohr
130a5d2da2SAndreas Gohr/**
140a5d2da2SAndreas Gohr * Information about the farm and the current instance
150a5d2da2SAndreas Gohr */
16632c5618SAndreas Gohrclass admin_plugin_farmer_info extends DokuWiki_Admin_Plugin {
17632c5618SAndreas Gohr
18c4c8e953SAndreas Gohr    /** @var helper_plugin_farmer */
19c4c8e953SAndreas Gohr    protected $helper;
20632c5618SAndreas Gohr
21c4c8e953SAndreas Gohr    /**
22c4c8e953SAndreas Gohr     * admin_plugin_farmer_info constructor.
23c4c8e953SAndreas Gohr     */
24c4c8e953SAndreas Gohr    public function __construct() {
25c4c8e953SAndreas Gohr        $this->helper = plugin_load('helper', 'farmer');
26c4c8e953SAndreas Gohr    }
27632c5618SAndreas Gohr
28632c5618SAndreas Gohr    /**
29632c5618SAndreas Gohr     * @return bool admin only!
30632c5618SAndreas Gohr     */
31632c5618SAndreas Gohr    public function forAdminOnly() {
32632c5618SAndreas Gohr        return false;
33632c5618SAndreas Gohr    }
34632c5618SAndreas Gohr
35632c5618SAndreas Gohr    /**
36632c5618SAndreas Gohr     * Should carry out any processing required by the plugin.
37632c5618SAndreas Gohr     */
38632c5618SAndreas Gohr    public function handle() {
39632c5618SAndreas Gohr    }
40632c5618SAndreas Gohr
41632c5618SAndreas Gohr    /**
42632c5618SAndreas Gohr     * Render HTML output, e.g. helpful text and a form
43632c5618SAndreas Gohr     */
44632c5618SAndreas Gohr    public function html() {
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        }
57c4c8e953SAndreas Gohr        $this->line('confdir', fullpath(DOKU_CONF));
58c4c8e953SAndreas 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
69*af1c6dd8SAndreas Gohr        $this->line('plugins', join(', ', $this->helper->getAllPlugins(false)));
70*af1c6dd8SAndreas 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     */
80c4c8e953SAndreas Gohr    protected function animals($list) {
81c4c8e953SAndreas Gohr        global $ID;
82c4c8e953SAndreas Gohr
83c4c8e953SAndreas Gohr        $animals = $this->helper->getAllAnimals();
84c4c8e953SAndreas Gohr        $html = '';
85c4c8e953SAndreas Gohr        if(!$list) {
86c4c8e953SAndreas Gohr            $html = count($animals);
87c4c8e953SAndreas Gohr            $self = wl($ID, array('do' => 'admin', 'page' => 'farmer', 'sub' => 'info', 'list' => 1));
88c4c8e953SAndreas Gohr            $html .= ' [<a href="' . $self . '">' . $this->getLang('conf_notfound_list') . '</a>]';
89c4c8e953SAndreas Gohr            return $html;
90c4c8e953SAndreas Gohr        }
91c4c8e953SAndreas Gohr
92c4c8e953SAndreas Gohr        $html .= '<ol>';
93c4c8e953SAndreas Gohr        foreach($animals as $animal) {
94c4c8e953SAndreas Gohr            $link = $this->helper->getAnimalURL($animal);
95c4c8e953SAndreas Gohr            $html .= '<li><div class="li"><a href="' . $link . '">' . $animal . '</a></div></li>';
96c4c8e953SAndreas Gohr        }
97c4c8e953SAndreas Gohr        $html .= '</ol>';
98c4c8e953SAndreas Gohr        return $html;
99c4c8e953SAndreas Gohr    }
100c4c8e953SAndreas Gohr
101c4c8e953SAndreas Gohr    /**
102c4c8e953SAndreas Gohr     * Output a table line
103c4c8e953SAndreas Gohr     *
104c4c8e953SAndreas Gohr     * @param string $langkey
105c4c8e953SAndreas Gohr     * @param string $value
106c4c8e953SAndreas Gohr     */
107632c5618SAndreas Gohr    protected function line($langkey, $value) {
108632c5618SAndreas Gohr        echo '<tr>';
109632c5618SAndreas Gohr        echo '<th>' . $this->getLang($langkey) . '</th>';
110632c5618SAndreas Gohr        echo '<td>' . $value . '</td>';
111632c5618SAndreas Gohr        echo '</tr>';
112632c5618SAndreas Gohr    }
113632c5618SAndreas Gohr
114632c5618SAndreas Gohr}
115632c5618SAndreas Gohr
116632c5618SAndreas Gohr// vim:ts=4:sw=4:et:
117