Lines Matching refs:self
59 self::RULE_CANONICAL_PRESENT,
60 self::RULE_DESCRIPTION_PRESENT,
61 self::RULE_FIXME,
62 self::RULE_INTERNAL_BACKLINKS_MIN,
63 self::RULE_INTERNAL_BROKEN_LINKS_MAX,
64 self::RULE_INTERNAL_LINKS_MIN,
65 self::RULE_OUTLINE_STRUCTURE,
66 self::RULE_TITLE_PRESENT,
67 self::RULE_WORDS_MINIMAL,
68 self::RULE_WORDS_MAXIMAL,
69 self::RULE_AVERAGE_WORDS_BY_SECTION_MIN,
70 self::RULE_AVERAGE_WORDS_BY_SECTION_MAX
77 self::RULE_WORDS_MINIMAL,
78 self::RULE_INTERNAL_BACKLINKS_MIN,
79 self::RULE_INTERNAL_LINKS_MIN
176 ->setRequestedRenderer(self::RENDERER_NAME_MODE)
183 return Mime::create(self::RENDERER_NAME_MODE . "/json");
237 $statExport[self::EDITS_COUNT] = count($revs);
270 $statExport[self::CHAR_COUNT] = strlen($text);
271 $statExport[self::WORD_COUNT] = StringUtility::getWordCount($text);
277 if (array_key_exists(self::INTERNAL_LINK_DISTANCE, $statExport)) {
278 $linkLengths = $statExport[self::INTERNAL_LINK_DISTANCE];
279 unset($statExport[self::INTERNAL_LINK_DISTANCE]);
281 $statExport[self::INTERNAL_LINK_DISTANCE]['avg'] = null;
282 $statExport[self::INTERNAL_LINK_DISTANCE]['max'] = null;
283 $statExport[self::INTERNAL_LINK_DISTANCE]['min'] = null;
285 $statExport[self::INTERNAL_LINK_DISTANCE]['avg'] = array_sum($linkLengths) / $countBacklinks;
286 $statExport[self::INTERNAL_LINK_DISTANCE]['max'] = max($linkLengths);
287 $statExport[self::INTERNAL_LINK_DISTANCE]['min'] = min($linkLengths);
303 if (array_key_exists(self::FIXME, $this->stats)) {
304 $fixmeCount = $this->stats[self::FIXME];
305 $statExport[self::FIXME] = $fixmeCount == null ? 0 : $fixmeCount;
307 $ruleResults[self::RULE_FIXME] = self::FAILED;
308 $qualityScores['no_' . self::FIXME] = 0;
310 $ruleResults[self::RULE_FIXME] = self::PASSED;
311 $qualityScores['no_' . self::FIXME] = $this->getConf(self::CONF_QUALITY_SCORE_NO_FIXME, 1);
318 $titleScore = $this->getConf(self::CONF_QUALITY_SCORE_TITLE_PRESENT, 10);
320 $ruleResults[self::RULE_TITLE_PRESENT] = self::FAILED;
321 $ruleInfo[self::RULE_TITLE_PRESENT] = "Add a title for {$titleScore} points";
323 $qualityScores[self::RULE_TITLE_PRESENT] = 0;
325 $qualityScores[self::RULE_TITLE_PRESENT] = $titleScore;
326 $ruleResults[self::RULE_TITLE_PRESENT] = self::PASSED;
332 $descScore = $this->getConf(self::CONF_QUALITY_SCORE_DESCRIPTION_PRESENT, 8);
333 if (empty($this->metadata[self::DESCRIPTION])) {
334 $ruleResults[self::RULE_DESCRIPTION_PRESENT] = self::FAILED;
335 $ruleInfo[self::RULE_DESCRIPTION_PRESENT] = "Add a description for {$descScore} points";
336 $this->metadata[self::DESCRIPTION] = $dokuWikiMetadata[self::DESCRIPTION]["abstract"];
337 $qualityScores[self::RULE_DESCRIPTION_PRESENT] = 0;
339 $qualityScores[self::RULE_DESCRIPTION_PRESENT] = $descScore;
340 $ruleResults[self::RULE_DESCRIPTION_PRESENT] = self::PASSED;
346 $canonicalScore = $this->getConf(self::CONF_QUALITY_SCORE_CANONICAL_PRESENT, 5);
351 $qualityScores[self::RULE_CANONICAL_PRESENT] = 0;
352 $ruleResults[self::RULE_CANONICAL_PRESENT] = self::FAILED;
354 $ruleInfo[self::RULE_CANONICAL_PRESENT] = "Add a canonical for {$canonicalScore} points";
357 $qualityScores[self::RULE_CANONICAL_PRESENT] = $canonicalScore;
358 $ruleResults[self::RULE_CANONICAL_PRESENT] = self::PASSED;
366 if (array_key_exists(self::HEADER_POSITION, $this->stats)) {
367 $headersCount = count($this->stats[self::HEADER_POSITION]);
368 unset($statExport[self::HEADER_POSITION]);
370 $currentHeaderLevel = $this->stats[self::HEADER_STRUCT][$i];
371 $previousHeaderLevel = $this->stats[self::HEADER_STRUCT][$i - 1];
374 $ruleInfo[self::RULE_OUTLINE_STRUCTURE] = "The " . $i . " header (h" . $currentHeaderLevel . ") has a level bigger than its precedent (" . $previousHeaderLevel . ")";
377 unset($statExport[self::HEADER_STRUCT]);
379 $outlinePoints = $this->getConf(self::CONF_QUALITY_SCORE_CORRECT_HEADER_STRUCTURE, 3);
382 $ruleResults[self::RULE_OUTLINE_STRUCTURE] = self::FAILED;
384 $ruleInfo[self::RULE_OUTLINE_STRUCTURE] = "Add headings to create a document outline for {$outlinePoints} points";
388 $ruleResults[self::RULE_OUTLINE_STRUCTURE] = self::PASSED;
398 $correctLengthScore = $this->getConf(self::CONF_QUALITY_SCORE_CORRECT_CONTENT, 10);
399 $missingWords = $minimalWordCount - $statExport[self::WORD_COUNT];
401 $ruleResults[self::RULE_WORDS_MINIMAL] = self::FAILED;
403 $ruleInfo[self::RULE_WORDS_MINIMAL] = "Add {$missingWords} words to get {$correctLengthScore} points";
405 $ruleResults[self::RULE_WORDS_MINIMAL] = self::PASSED;
407 $tooMuchWords = $statExport[self::WORD_COUNT] - $maximalWordCount;
409 $ruleResults[self::RULE_WORDS_MAXIMAL] = self::FAILED;
410 $ruleInfo[self::RULE_WORDS_MAXIMAL] = "Delete {$tooMuchWords} words to get {$correctLengthScore} points";
413 $ruleResults[self::RULE_WORDS_MAXIMAL] = self::PASSED;
425 $headers = $this->stats[self::HEADING_COUNT] ?? null;
431 $wordCount = $this->stats[self::WORD_COUNT] ?? 0;
445 $ruleResults[self::RULE_AVERAGE_WORDS_BY_SECTION_MIN] = self::FAILED;
447 $ruleInfo[self::RULE_AVERAGE_WORDS_BY_SECTION_MIN] = "The number of words by section is less than {$wordsByHeaderMin}";
449 $ruleResults[self::RULE_AVERAGE_WORDS_BY_SECTION_MIN] = self::PASSED;
452 $ruleResults[self::RULE_AVERAGE_WORDS_BY_SECTION_MAX] = self::FAILED;
454 $ruleInfo[self::RULE_AVERAGE_WORDS_BY_SECTION_MAX] = "The number of words by section is more than {$wordsByHeaderMax}";
456 $ruleResults[self::RULE_AVERAGE_WORDS_BY_SECTION_MAX] = self::PASSED;
459 $qualityScores['correct_word_avg_by_section'] = $this->getConf(self::CONF_QUALITY_SCORE_CORRECT_WORD_SECTION_AVERAGE, 10);
483 $backlinkScore = $this->getConf(self::CONF_QUALITY_SCORE_INTERNAL_BACKLINK_FACTOR, 1);
487 $ruleResults[self::RULE_INTERNAL_BACKLINKS_MIN] = self::FAILED;
488 $ruleInfo[self::RULE_INTERNAL_BACKLINKS_MIN] = "Add backlinks for {$backlinkScore} point each";
493 $ruleResults[self::RULE_INTERNAL_BACKLINKS_MIN] = self::PASSED;
499 $internalLinksCount = $this->stats[self::INTERNAL_LINK_COUNT] ?? null;
500 $internalLinkScore = $this->getConf(self::CONF_QUALITY_SCORE_INTERNAL_LINK_FACTOR, 1);
502 $qualityScores[self::INTERNAL_LINK_COUNT] = 0;
503 $ruleResults[self::RULE_INTERNAL_LINKS_MIN] = self::FAILED;
504 $ruleInfo[self::RULE_INTERNAL_LINKS_MIN] = "Add internal links for {$internalLinkScore} point each";
506 $ruleResults[self::RULE_INTERNAL_LINKS_MIN] = self::PASSED;
507 $qualityScores[self::INTERNAL_LINK_COUNT] = $countBacklinks * $internalLinkScore;
513 $brokenLinkScore = $this->getConf(self::CONF_QUALITY_SCORE_INTERNAL_LINK_BROKEN_FACTOR, 2);
515 if (array_key_exists(self::INTERNAL_LINK_BROKEN_COUNT, $this->stats)) {
516 $brokenLinksCount = $this->stats[self::INTERNAL_LINK_BROKEN_COUNT];
519 $qualityScores['no_' . self::INTERNAL_LINK_BROKEN_COUNT] = 0;
520 $ruleResults[self::RULE_INTERNAL_BROKEN_LINKS_MAX] = self::FAILED;
521 $ruleInfo[self::RULE_INTERNAL_BROKEN_LINKS_MAX] = "Delete the {$brokenLinksCount} broken links and add {$brokenLinkScore} points";
523 $qualityScores['no_' . self::INTERNAL_LINK_BROKEN_COUNT] = $brokenLinkScore;
524 $ruleResults[self::RULE_INTERNAL_BROKEN_LINKS_MAX] = self::PASSED;
531 "total_count" => self::getAndUnset($statExport, self::MEDIA_COUNT, 0),
532 "internal_count" => self::getAndUnset($statExport, self::INTERNAL_MEDIA_COUNT, 0),
533 "internal_broken_count" => self::getAndUnset($statExport, self::INTERNAL_BROKEN_MEDIA_COUNT, 0),
534 "external_count" => self::getAndUnset($statExport, self::EXTERNAL_MEDIA_COUNT, 0)
541 $qualityScores[self::EDITS_COUNT] = $statExport[self::EDITS_COUNT] * $this->getConf(self::CONF_QUALITY_SCORE_CHANGES_FACTOR, 0.25);
549 $qualityScoring[self::SCORE] = array_sum($qualityScores);
558 if ($ruleResult == self::FAILED) {
572 $mandatoryRules = preg_split("/,/", $this->getConf(self::CONF_MANDATORY_QUALITY_RULES));
602 $quality[self::LOW] = $lowLevel;
605 $quality[self::FAILED_MANDATORY_RULES] = $mandatoryRulesBroken;
607 $quality[self::SCORING] = $qualityScoring;
608 $quality[self::RULES][self::RESULT] = $qualityResult;
610 $quality[self::RULES]["info"] = $ruleInfo;
614 $quality[self::RULES][self::DETAILS] = $ruleResults;
646 $finalStats[self::METADATA] = $this->metadata;
648 $finalStats[self::STATISTICS] = $statExport;
649 $finalStats[self::QUALITY] = $quality; // Quality after the sort to get them at the end
677 return self::RENDERER_FORMAT;
683 if (!array_key_exists(self::HEADING_COUNT, $this->stats)) {
684 $this->stats[self::HEADING_COUNT] = [];
689 $this->stats[self::HEADING_COUNT])) {
690 $this->stats[self::HEADING_COUNT][$heading] = 0;
692 $this->stats[self::HEADING_COUNT][$heading]++;
695 $this->stats[self::HEADER_POSITION][$this->headerId] = $heading;
702 if (!array_key_exists(self::HEADING_COUNT, $this->stats)) {
703 $this->stats[self::HEADER_STRUCT] = [];
705 $this->stats[self::HEADER_STRUCT][] = $level;
712 $totalFixme = $this->stats[self::FIXME] ?? 0;
713 $this->stats[self::FIXME] = $totalFixme + 1;
806 $this->stats[self::PLAINTEXT][$this->plainTextId]['len'] = $len;
814 $this->stats[self::PLAINTEXT][$this->plainTextId]['multiformat'] += $numberOfFormats;
820 $totalLen = $this->stats[self::PLAINTEXT][0] ?? 0;
821 $this->stats[self::PLAINTEXT][0] = $totalLen + $len;
827 $this->stats[self::INTERNAL_MEDIA_COUNT]++;
832 $this->stats[self::EXTERNAL_MEDIA_COUNT]++;