1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
<?php
/**
* DokuWiki Plugin farmer (Admin Component)
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
* @author Michael Große <grosse@cosmocode.de>
* @author Andreas Gohr <gohr@cosmocode.de>
*/
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();
/**
* Information about the farm and the current instance
*/
class admin_plugin_farmer_info extends DokuWiki_Admin_Plugin {
/** @var helper_plugin_farmer */
protected $helper;
/**
* admin_plugin_farmer_info constructor.
*/
public function __construct() {
$this->helper = plugin_load('helper', 'farmer');
}
/**
* @return bool admin only!
*/
public function forAdminOnly() {
return false;
}
/**
* Should carry out any processing required by the plugin.
*/
public function handle() {
}
/**
* Render HTML output, e.g. helpful text and a form
*/
public function html() {
global $conf;
global $INPUT;
$animal = $this->helper->getAnimal();
$config = $this->helper->getConfig();
echo '<table class="inline">';
$this->line('thisis', $animal ? $this->getLang('thisis.animal') : $this->getLang('thisis.farmer'));
if($animal) {
$this->line('animal', $animal);
}
$this->line('confdir', fullpath(DOKU_CONF) . '/');
$this->line('savedir', fullpath($conf['savedir']) . '/');
$this->line('baseinstall', DOKU_INC);
$this->line('farm host', $config['base']['farmhost']);
$this->line('farm dir', DOKU_FARMDIR);
$this->line('animals', $this->animals($INPUT->bool('list')));
foreach($config['inherit'] as $key => $value) {
$this->line('conf_inherit_' . $key, $this->getLang($value ? 'conf_inherit_yes' : 'conf_inherit_no'));
}
$this->line('plugins', join(', ', $this->helper->getAllPlugins(false)));
echo '</table>';
}
/**
* List or count the animals
*
* @param bool $list
* @return string
*/
protected function animals($list) {
global $ID;
$animals = $this->helper->getAllAnimals();
$html = '';
if(!$list) {
$html = count($animals);
$self = wl($ID, array('do' => 'admin', 'page' => 'farmer', 'sub' => 'info', 'list' => 1));
$html .= ' [<a href="' . $self . '">' . $this->getLang('conf_notfound_list') . '</a>]';
return $html;
}
$html .= '<ol>';
foreach($animals as $animal) {
$link = $this->helper->getAnimalURL($animal);
$html .= '<li><div class="li"><a href="' . $link . '">' . $animal . '</a></div></li>';
}
$html .= '</ol>';
return $html;
}
/**
* Output a table line
*
* @param string $langkey
* @param string $value
*/
protected function line($langkey, $value) {
echo '<tr>';
echo '<th>' . $this->getLang($langkey) . '</th>';
echo '<td>' . $value . '</td>';
echo '</tr>';
}
}
// vim:ts=4:sw=4:et:
|