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 $this->line('plugins', join(', ', $this->helper->getAllPlugins(false))); 70 71 echo '</table>'; 72 } 73 74 /** 75 * List or count the animals 76 * 77 * @param bool $list 78 * @return string 79 */ 80 protected function animals($list) { 81 global $ID; 82 83 $animals = $this->helper->getAllAnimals(); 84 $html = ''; 85 if(!$list) { 86 $html = count($animals); 87 $self = wl($ID, array('do' => 'admin', 'page' => 'farmer', 'sub' => 'info', 'list' => 1)); 88 $html .= ' [<a href="' . $self . '">' . $this->getLang('conf_notfound_list') . '</a>]'; 89 return $html; 90 } 91 92 $html .= '<ol>'; 93 foreach($animals as $animal) { 94 $link = $this->helper->getAnimalURL($animal); 95 $html .= '<li><div class="li"><a href="' . $link . '">' . $animal . '</a></div></li>'; 96 } 97 $html .= '</ol>'; 98 return $html; 99 } 100 101 /** 102 * Output a table line 103 * 104 * @param string $langkey 105 * @param string $value 106 */ 107 protected function line($langkey, $value) { 108 echo '<tr>'; 109 echo '<th>' . $this->getLang($langkey) . '</th>'; 110 echo '<td>' . $value . '</td>'; 111 echo '</tr>'; 112 } 113 114} 115 116// vim:ts=4:sw=4:et: 117