lang $this->setupLocale(); } function register(Doku_Event_Handler $controller) { if(!$this->getConf(self::CONF_DISABLE_QUALITY_MONITORING)) { $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->createQualityNote(PluginUtility::getPageId(), $this); if ($note != null) { ptln($note->getHtml()); } } } /** * @param $pageId * @param $plugin - Plugin * @return Message|null */ static public function createQualityNote($pageId, $plugin) { $page = new Page($pageId); if ($page->isBar()) { return null; } if (!$page->isQualityMonitored()) { return null; } if ($page->existInFs()) { $analytics = $page->getAnalyticsFromFs(); $rules = $analytics[Analytics::QUALITY][Analytics::RULES]; /** * We may got null * array_key_exists() expects parameter 2 to be array, * null given in /opt/www/datacadamia.com/lib/plugins/combo/action/qualitymessage.php on line 113 */ if ($rules==null){ return null; } /** * 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 Message($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("
This is a {$lqPageUrl} because it has failed the following mandatory {$rulesUrl}:"); $message->addContent(""); $message->addContent("
"); } $message->addContent("

You can still win a couple of points.

"); $message->addContent(""); $message->setSignatureCanonical("quality:dynamic_monitoring"); $message->setSignatureName("Quality Dynamic Monitoring Feature"); $message->setType(Message::TYPE_CLASSIC); $message->setClass(self::QUALITY_BOX_CLASS); return $message; } } return null; } }