lang $this->setupLocale(); } function register(Doku_Event_Handler $controller) { $controller->register_hook( 'TPL_ACT_RENDER', 'BEFORE', $this, '_displayQualityMessage', array() ); } /** * Main function; dispatches the visual comment actions * @param $event Doku_Event */ function _displayQualityMessage(&$event, $param) { if ($event->data == 'show') { /** * Quality is just for the writers */ if (!Auth::isWriter()) { return; } $note = $this->getQualityNote(PluginUtility::getPageId(), $this); if ($note != null) { ptln($note->getHtml()); } } } /** * @param $pageId * @param $plugin - Plugin * @return Note|null */ static public function getQualityNote($pageId, $plugin) { $page = new Page($pageId); if ($page->isBar()) { return null; } if ($page->existInFs()) { $analytics = $page->getAnalyticsFromFs(); $rules = $analytics[Analytics::QUALITY][Analytics::RULES]; /** * If there is no info, nothing to show */ if (!array_key_exists(Analytics::INFO, $rules)) { return null; } /** * The error info */ $qualityInfoRules = $rules[Analytics::INFO]; /** * Excluding the excluded rules */ global $conf; $excludedRulesConf = $conf['plugin'][PluginUtility::PLUGIN_BASE_NAME][self::CONF_EXCLUDED_QUALITY_RULES_FROM_DYNAMIC_MONITORING]; $excludedRules = preg_split("/,/", $excludedRulesConf); foreach ($excludedRules as $excludedRule) { if (array_key_exists($excludedRule, $qualityInfoRules)) { unset($qualityInfoRules[$excludedRule]); } } if (sizeof($qualityInfoRules) > 0) { $qualityScore = $analytics[Analytics::QUALITY][renderer_plugin_combo_analytics::SCORING][renderer_plugin_combo_analytics::SCORE]; $message = new Note($plugin); $message->addContent("
Well played, you got a " . PluginUtility::getUrl("quality:score", "quality score") . " of {$qualityScore} !
"); if ($page->isLowQualityPage()) { $analytics = $page->getAnalyticsFromFs(true); $mandatoryFailedRules = $analytics[Analytics::QUALITY][Analytics::FAILED_MANDATORY_RULES]; $rulesUrl = PluginUtility::getUrl("quality:rule", "rules"); $lqPageUrl = PluginUtility::getUrl("low_quality_page", "low quality page"); $message->addContent("You can still win a couple of points.
"); $message->addContent("