*/ class admin_plugin_qc extends DokuWiki_Admin_Plugin { var $data; var $order; function getMenuSort() { return 999; } function forAdminOnly() { return false; } /** * handle the request befor html output * * @see html() */ function handle() { global $conf; // load the quality data if (is_file($conf['tmpdir'].'/qcgather')) { $this->data = file_get_contents($conf['tmpdir'].'/qcgather'); $this->data = unserialize($this->data); } else { $this->data = array(); } // order the data if (!isset($_REQUEST['pluginqc']['order'])) { $_REQUEST['pluginqc']['order'] = 'quality'; } switch ($_REQUEST['pluginqc']['order']) { case 'fixme': uasort($this->data, array($this, 'sortFixme')); $this->order = 'fixme'; break; default: uasort($this->data, array($this, 'sortQuality')); $this->order = 'quality'; } } /** * output html for the admin page */ function html() { global $ID; $max = $this->getConf('maxshowen'); if (!$max || $max <= 0) $max = 25; echo '
'; echo '

'.$this->getLang('admin_headline').'

'; echo '

'.sprintf($this->getLang('admin_desc'),$max).'

'; echo ''; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; if ($this->data) { foreach ($this->data as $id => $data) { if ($max == 0) break; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; $max--; } } echo '
'.$this->getLang('admin_page').''.$this->getOrderArrow('quality').''.$this->getLang('admin_quality').''.$this->getOrderArrow('fixme').''.$this->getLang('admin_fixme').'
'; tpl_pagelink(':' . $id, $id); echo '' . $data['score'] . ' ' . $data['err']['fixme'] . '
'; echo '
'; } function getOrderArrow($type) { if ($type == $this->order) return '↓ '; return ''; } function getImgUrl($score, $return = true) { $maxerr = 10; if ($score > $maxerr) { $ico = DOKU_BASE . 'lib/plugins/qc/pix/'.$this->getConf('theme').'/status_red.png'; } elseif($score) { $ico = DOKU_BASE . 'lib/plugins/qc/pix/'.$this->getConf('theme').'/status_yellow.png'; } else { $ico = DOKU_BASE . 'lib/plugins/qc/pix/'.$this->getConf('theme').'/status_green.png'; } if ($return) return $ico; echo $ico; } /** * order by quality */ function sortQuality($a, $b) { if ($a['score'] == $b['score']) return 0; return ($a['score'] < $b['score']) ? 1 : -1; } /** * order by fixmes */ function sortFixme($a, $b) { if ($a['err']['fixme'] == $b['err']['fixme']) return 0; return ($a['err']['fixme'] < $b['err']['fixme']) ? 1 : -1; } } ?>