*/ class admin_plugin_qc extends AdminPlugin { protected $data; protected $order; /** @inheritdoc */ public function forAdminOnly() { return false; } /** @inheritDoc */ public function getMenuIcon() { return __DIR__ . '/svg/good.svg'; } /** @inheritdoc */ public 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 = []; } // order the data if (!isset($_REQUEST['pluginqc']['order'])) { $_REQUEST['pluginqc']['order'] = 'quality'; } switch ($_REQUEST['pluginqc']['order']) { case 'fixme': uasort($this->data, [$this, 'sortFixme']); $this->order = 'fixme'; break; default: uasort($this->data, [$this, 'sortQuality']); $this->order = 'quality'; } } /** @inheritdoc */ public 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 '' . Output::scoreIcon($data['score']) . '' . $data['err']['fixme'] . '
'; echo '
'; } /** * return an arrow if currently sorted by this type * * @ return string */ protected function getOrderArrow($type) { if ($type == $this->order) return '↓ '; return ''; } /** * order by quality */ protected function sortQuality($a, $b) { return $b['score'] <=> $a['score']; } /** * order by fixmes */ protected function sortFixme($a, $b) { return $b['err']['fixme'] <=> $a['err']['fixme']; } }