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