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> 7*0a5d2da2SAndreas 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 13*0a5d2da2SAndreas Gohr/** 14*0a5d2da2SAndreas Gohr * Information about the farm and the current instance 15*0a5d2da2SAndreas 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 69632c5618SAndreas Gohr echo '</table>'; 70632c5618SAndreas Gohr } 71632c5618SAndreas Gohr 72c4c8e953SAndreas Gohr /** 73c4c8e953SAndreas Gohr * List or count the animals 74c4c8e953SAndreas Gohr * 75c4c8e953SAndreas Gohr * @param bool $list 76c4c8e953SAndreas Gohr * @return string 77c4c8e953SAndreas Gohr */ 78c4c8e953SAndreas Gohr protected function animals($list) { 79c4c8e953SAndreas Gohr global $ID; 80c4c8e953SAndreas Gohr 81c4c8e953SAndreas Gohr $animals = $this->helper->getAllAnimals(); 82c4c8e953SAndreas Gohr $html = ''; 83c4c8e953SAndreas Gohr if(!$list) { 84c4c8e953SAndreas Gohr $html = count($animals); 85c4c8e953SAndreas Gohr $self = wl($ID, array('do' => 'admin', 'page' => 'farmer', 'sub' => 'info', 'list' => 1)); 86c4c8e953SAndreas Gohr $html .= ' [<a href="' . $self . '">' . $this->getLang('conf_notfound_list') . '</a>]'; 87c4c8e953SAndreas Gohr return $html; 88c4c8e953SAndreas Gohr } 89c4c8e953SAndreas Gohr 90c4c8e953SAndreas Gohr $html .= '<ol>'; 91c4c8e953SAndreas Gohr foreach($animals as $animal) { 92c4c8e953SAndreas Gohr $link = $this->helper->getAnimalURL($animal); 93c4c8e953SAndreas Gohr $html .= '<li><div class="li"><a href="' . $link . '">' . $animal . '</a></div></li>'; 94c4c8e953SAndreas Gohr } 95c4c8e953SAndreas Gohr $html .= '</ol>'; 96c4c8e953SAndreas Gohr return $html; 97c4c8e953SAndreas Gohr } 98c4c8e953SAndreas Gohr 99c4c8e953SAndreas Gohr /** 100c4c8e953SAndreas Gohr * Output a table line 101c4c8e953SAndreas Gohr * 102c4c8e953SAndreas Gohr * @param string $langkey 103c4c8e953SAndreas Gohr * @param string $value 104c4c8e953SAndreas Gohr */ 105632c5618SAndreas Gohr protected function line($langkey, $value) { 106632c5618SAndreas Gohr echo '<tr>'; 107632c5618SAndreas Gohr echo '<th>' . $this->getLang($langkey) . '</th>'; 108632c5618SAndreas Gohr echo '<td>' . $value . '</td>'; 109632c5618SAndreas Gohr echo '</tr>'; 110632c5618SAndreas Gohr } 111632c5618SAndreas Gohr 112632c5618SAndreas Gohr} 113632c5618SAndreas Gohr 114632c5618SAndreas Gohr// vim:ts=4:sw=4:et: 115