helper = plugin_load('helper', 'qc'); $this->data = $this->helper->getQCData($page); } /** * Get the score as icon * * @param $score * @return string */ public static function scoreIcon($score) { $html = ''; // rate the score if ($score > self::MAXERR) { $rating = 'bad'; } elseif ($score) { $rating = 'meh'; } else { $rating = 'good'; } // output icon and score $html .= ''; $html .= inlineSVG(__DIR__ . '/svg/' . $rating . '.svg'); if ($score) $html .= '' . $score . ''; $html .= ''; return $html; } /** * Print the short summary * * @return string */ public function short() { return self::scoreIcon($this->data['score']); } /** * Print full analysis * * @return string */ public function long() { $html = ''; $html .= '

' . $this->helper->getLang('intro_h') . '

'; $html .= '
'; $html .= '
'; $html .= '
' . $this->helper->getLang('g_created') . '
'; $html .= '
' . dformat($this->data['created']) . '
'; $html .= '
' . $this->helper->getLang('g_modified') . '
'; $html .= '
' . dformat($this->data['modified']) . '
'; // print top 5 authors if (!is_array($this->data['authors'])) $this->data['authors'] = []; arsort($this->data['authors']); $top5 = array_slice($this->data['authors'], 0, 5); $cnt = count($top5); $i = 1; $html .= '
' . $this->helper->getLang('g_authors') . '
'; $html .= '
'; foreach ($top5 as $a => $e) { if ($a == '*') { $html .= $this->helper->getLang('anonymous'); } else { $html .= editorinfo($a); } $html .= ' (' . $e . ')'; if ($i++ < $cnt) $html .= ', '; } $html .= '
'; $html .= '
' . $this->helper->getLang('g_changes') . '
'; $html .= '
' . $this->data['changes'] . '
'; $html .= '
' . $this->helper->getLang('g_chars') . '
'; $html .= '
' . $this->data['chars'] . '
'; $html .= '
' . $this->helper->getLang('g_words') . '
'; $html .= '
' . $this->data['words'] . '
'; $html .= '
'; $html .= '
'; // output all the problems if ($this->data['score']) { $html .= '

' . $this->helper->getLang('errorsfound_h') . '

'; $html .= '

' . $this->helper->getLang('errorsfound') . '

'; $html .= '
'; arsort($this->data['err']); #sort by score foreach ($this->data['err'] as $err => $val) { if ($val) { $html .= '

'; $html .= sprintf($this->helper->getLang($err . '_h'), $val); $html .= ''; $html .= inlineSVG(__DIR__ . '/svg/bad.svg'); $html .= '' . $val . ''; $html .= ''; $html .= '

'; $html .= '

' . sprintf($this->helper->getLang($err), $val) . '

'; } } $html .= '
'; } return $html; } }