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