protected static function load() { global $wgFlaggedRevsTags, $wgFlaggedRevTags; if (self::$loaded) { return true; } if (!FlaggedRevsSetup::isReady()) { // sanity throw new MWException('FlaggedRevs config loaded too soon! Possibly before LocalSettings.php!'); } self::$loaded = true; $flaggedRevsTags = null; if (isset($wgFlaggedRevTags)) { $flaggedRevsTags = $wgFlaggedRevTags; // b/c wfWarn('Please use $wgFlaggedRevsTags instead of $wgFlaggedRevTags in config.'); } elseif (isset($wgFlaggedRevsTags)) { $flaggedRevsTags = $wgFlaggedRevsTags; } # Assume true, then set to false if needed if (!empty($flaggedRevsTags)) { self::$qualityVersions = true; self::$pristineVersions = true; self::$binaryFlagging = count($flaggedRevsTags) <= 1; } foreach ($flaggedRevsTags as $tag => $levels) { # Sanity checks $safeTag = htmlspecialchars($tag); if (!preg_match('/^[a-zA-Z]{1,20}$/', $tag) || $safeTag !== $tag) { throw new MWException('FlaggedRevs given invalid tag name!'); } # Define "quality" and "pristine" reqs if (is_array($levels)) { $minQL = $levels['quality']; $minPL = $levels['pristine']; $ratingLevels = $levels['levels']; # B/C, $levels is just an integer (minQL) } else { global $wgFlaggedRevPristine, $wgFlaggedRevValues; $ratingLevels = isset($wgFlaggedRevValues) ? $wgFlaggedRevValues : 1; $minQL = $levels; // an integer $minPL = isset($wgFlaggedRevPristine) ? $wgFlaggedRevPristine : $ratingLevels + 1; wfWarn('Please update the format of $wgFlaggedRevsTags in config.'); } # Set FlaggedRevs tags self::$dimensions[$tag] = array(); for ($i = 0; $i <= $ratingLevels; $i++) { self::$dimensions[$tag][$i] = "{$tag}-{$i}"; } if ($ratingLevels > 1) { self::$binaryFlagging = false; // more than one level } # Sanity checks if (!is_integer($minQL) || !is_integer($minPL)) { throw new MWException('FlaggedRevs given invalid tag value!'); } if ($minQL > $ratingLevels) { self::$qualityVersions = false; self::$pristineVersions = false; } if ($minPL > $ratingLevels) { self::$pristineVersions = false; } self::$minQL[$tag] = max($minQL, 1); self::$minPL[$tag] = max($minPL, 1); self::$minSL[$tag] = 1; } global $wgFlaggedRevsTagsRestrictions, $wgFlagRestrictions; if (isset($wgFlagRestrictions)) { self::$tagRestrictions = $wgFlagRestrictions; // b/c wfWarn('Please use $wgFlaggedRevsTagsRestrictions instead of $wgFlagRestrictions in config.'); } else { self::$tagRestrictions = $wgFlaggedRevsTagsRestrictions; } # Make sure that the restriction levels are unique global $wgFlaggedRevsRestrictionLevels; self::$restrictionLevels = array_unique($wgFlaggedRevsRestrictionLevels); self::$restrictionLevels = array_filter(self::$restrictionLevels, 'strlen'); # Make sure no talk namespaces are in review namespace global $wgFlaggedRevsNamespaces; foreach ($wgFlaggedRevsNamespaces as $ns) { if (MWNamespace::isTalk($ns)) { throw new MWException('FlaggedRevs given talk namespace in $wgFlaggedRevsNamespaces!'); } elseif ($ns == NS_MEDIAWIKI) { throw new MWException('FlaggedRevs given NS_MEDIAWIKI in $wgFlaggedRevsNamespaces!'); } } self::$reviewNamespaces = $wgFlaggedRevsNamespaces; # Handle $wgFlaggedRevsAutoReview settings global $wgFlaggedRevsAutoReview, $wgFlaggedRevsAutoReviewNew; if (is_int($wgFlaggedRevsAutoReview)) { self::$autoReviewConfig = $wgFlaggedRevsAutoReview; } else { // b/c if ($wgFlaggedRevsAutoReview) { self::$autoReviewConfig = FR_AUTOREVIEW_CHANGES; } wfWarn('$wgFlaggedRevsAutoReview is now a bitfield instead of a boolean.'); } if (isset($wgFlaggedRevsAutoReviewNew)) { // b/c self::$autoReviewConfig = $wgFlaggedRevsAutoReviewNew ? self::$autoReviewConfig |= FR_AUTOREVIEW_CREATION : self::$autoReviewConfig & ~FR_AUTOREVIEW_CREATION; wfWarn('$wgFlaggedRevsAutoReviewNew is deprecated; use $wgFlaggedRevsAutoReview.'); } return true; }