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> 7632c5618SAndreas Gohr */ 8632c5618SAndreas Gohr 9632c5618SAndreas Gohr// must be run within Dokuwiki 10632c5618SAndreas Gohrif(!defined('DOKU_INC')) die(); 11632c5618SAndreas Gohr 12632c5618SAndreas Gohrclass admin_plugin_farmer_info extends DokuWiki_Admin_Plugin { 13632c5618SAndreas Gohr 14*c4c8e953SAndreas Gohr /** @var helper_plugin_farmer */ 15*c4c8e953SAndreas Gohr protected $helper; 16632c5618SAndreas Gohr 17*c4c8e953SAndreas Gohr /** 18*c4c8e953SAndreas Gohr * admin_plugin_farmer_info constructor. 19*c4c8e953SAndreas Gohr */ 20*c4c8e953SAndreas Gohr public function __construct() { 21*c4c8e953SAndreas Gohr $this->helper = plugin_load('helper', 'farmer'); 22*c4c8e953SAndreas Gohr } 23632c5618SAndreas Gohr 24632c5618SAndreas Gohr /** 25632c5618SAndreas Gohr * @return bool admin only! 26632c5618SAndreas Gohr */ 27632c5618SAndreas Gohr public function forAdminOnly() { 28632c5618SAndreas Gohr return false; 29632c5618SAndreas Gohr } 30632c5618SAndreas Gohr 31632c5618SAndreas Gohr /** 32632c5618SAndreas Gohr * Should carry out any processing required by the plugin. 33632c5618SAndreas Gohr */ 34632c5618SAndreas Gohr public function handle() { 35632c5618SAndreas Gohr } 36632c5618SAndreas Gohr 37632c5618SAndreas Gohr /** 38632c5618SAndreas Gohr * Render HTML output, e.g. helpful text and a form 39632c5618SAndreas Gohr */ 40632c5618SAndreas Gohr public function html() { 41d8c083b7SAndreas Gohr global $conf; 42*c4c8e953SAndreas Gohr global $INPUT; 43d8c083b7SAndreas Gohr 44*c4c8e953SAndreas Gohr $animal = $this->helper->getAnimal(); 45*c4c8e953SAndreas Gohr $config = $this->helper->getConfig(); 46632c5618SAndreas Gohr 47632c5618SAndreas Gohr echo '<table class="inline">'; 489ea97f82SAndreas Gohr 49632c5618SAndreas Gohr $this->line('thisis', $animal ? $this->getLang('thisis.animal') : $this->getLang('thisis.farmer')); 50a646d519SAndreas Gohr if($animal) { 51a646d519SAndreas Gohr $this->line('animal', $animal); 52a646d519SAndreas Gohr } 53*c4c8e953SAndreas Gohr $this->line('confdir', fullpath(DOKU_CONF)); 54*c4c8e953SAndreas Gohr $this->line('savedir', fullpath($conf['savedir'])); 55632c5618SAndreas Gohr $this->line('baseinstall', DOKU_INC); 569ea97f82SAndreas Gohr $this->line('farm host', $config['base']['farmhost']); 57632c5618SAndreas Gohr $this->line('farm dir', DOKU_FARMDIR); 589ea97f82SAndreas Gohr 59*c4c8e953SAndreas Gohr $this->line('animals', $this->animals($INPUT->bool('list'))); 60d8c083b7SAndreas Gohr 619ea97f82SAndreas Gohr foreach($config['inherit'] as $key => $value) { 629ea97f82SAndreas Gohr $this->line('conf_inherit_' . $key, $this->getLang($value ? 'conf_inherit_yes' : 'conf_inherit_no')); 639ea97f82SAndreas Gohr } 649ea97f82SAndreas Gohr 65632c5618SAndreas Gohr echo '</table>'; 66632c5618SAndreas Gohr } 67632c5618SAndreas Gohr 68*c4c8e953SAndreas Gohr /** 69*c4c8e953SAndreas Gohr * List or count the animals 70*c4c8e953SAndreas Gohr * 71*c4c8e953SAndreas Gohr * @param bool $list 72*c4c8e953SAndreas Gohr * @return string 73*c4c8e953SAndreas Gohr */ 74*c4c8e953SAndreas Gohr protected function animals($list) { 75*c4c8e953SAndreas Gohr global $ID; 76*c4c8e953SAndreas Gohr 77*c4c8e953SAndreas Gohr $animals = $this->helper->getAllAnimals(); 78*c4c8e953SAndreas Gohr $html = ''; 79*c4c8e953SAndreas Gohr if(!$list) { 80*c4c8e953SAndreas Gohr $html = count($animals); 81*c4c8e953SAndreas Gohr $self = wl($ID, array('do' => 'admin', 'page' => 'farmer', 'sub' => 'info', 'list' => 1)); 82*c4c8e953SAndreas Gohr $html .= ' [<a href="' . $self . '">' . $this->getLang('conf_notfound_list') . '</a>]'; 83*c4c8e953SAndreas Gohr return $html; 84*c4c8e953SAndreas Gohr } 85*c4c8e953SAndreas Gohr 86*c4c8e953SAndreas Gohr $html .= '<ol>'; 87*c4c8e953SAndreas Gohr foreach($animals as $animal) { 88*c4c8e953SAndreas Gohr $link = $this->helper->getAnimalURL($animal); 89*c4c8e953SAndreas Gohr $html .= '<li><div class="li"><a href="' . $link . '">' . $animal . '</a></div></li>'; 90*c4c8e953SAndreas Gohr } 91*c4c8e953SAndreas Gohr $html .= '</ol>'; 92*c4c8e953SAndreas Gohr return $html; 93*c4c8e953SAndreas Gohr } 94*c4c8e953SAndreas Gohr 95*c4c8e953SAndreas Gohr /** 96*c4c8e953SAndreas Gohr * Output a table line 97*c4c8e953SAndreas Gohr * 98*c4c8e953SAndreas Gohr * @param string $langkey 99*c4c8e953SAndreas Gohr * @param string $value 100*c4c8e953SAndreas Gohr */ 101632c5618SAndreas Gohr protected function line($langkey, $value) { 102632c5618SAndreas Gohr echo '<tr>'; 103632c5618SAndreas Gohr echo '<th>' . $this->getLang($langkey) . '</th>'; 104632c5618SAndreas Gohr echo '<td>' . $value . '</td>'; 105632c5618SAndreas Gohr echo '</tr>'; 106632c5618SAndreas Gohr } 107632c5618SAndreas Gohr 108632c5618SAndreas Gohr} 109632c5618SAndreas Gohr 110632c5618SAndreas Gohr// vim:ts=4:sw=4:et: 111