private function _searchReviewRatings($word, &$qt) { global $Conf; $this->reviewAdjust = true; if (preg_match('/\\A(.+?)\\s*(|[=!<>]=?|≠|≤|≥)\\s*(\\d*)\\z/', $word, $m) && ($m[3] !== "" || $m[2] === "") && $Conf->setting("rev_ratings") != REV_RATINGS_NONE) { // adjust counts if ($m[3] === "") { $m[2] = ">"; $m[3] = "0"; } if ($m[2] === "") { $m[2] = $m[3] == 0 ? "=" : ">="; } else { $m[2] = CountMatcher::canonical_comparator($m[2]); } $nqt = count($qt); // resolve rating type if ($m[1] === "+" || $m[1] === "good") { $this->interestingRatings["good"] = ">0"; $term = "nrate_good"; } else { if ($m[1] === "-" || $m[1] === "bad" || $m[1] === "−") { $this->interestingRatings["bad"] = "<1"; $term = "nrate_bad"; } else { if ($m[1] === "any") { $this->interestingRatings["any"] = "!=100"; $term = "nrate_any"; } else { $x = Text::simple_search($m[1], ReviewForm::$rating_types); unset($x["n"]); /* don't allow "average" */ if (count($x) == 0) { $this->warn("Unknown rating type “" . htmlspecialchars($m[1]) . "”."); $qt[] = new SearchTerm("f"); } else { $type = count($this->interestingRatings); $this->interestingRatings[$type] = " in (" . join(",", array_keys($x)) . ")"; $term = "nrate_{$type}"; } } } } if (count($qt) == $nqt) { if ($m[2][0] === "<" || $m[2] === "!=" || $m[2] === "=" && $m[3] == 0 || $m[2] === ">=" && $m[3] == 0) { $term = "coalesce({$term},0)"; } $qt[] = new SearchTerm("revadj", 0, array("rate" => $term . $m[2] . $m[3])); } } else { if ($Conf->setting("rev_ratings") == REV_RATINGS_NONE) { $this->warn("Review ratings are disabled."); } else { $this->warn("Bad review rating query “" . htmlspecialchars($word) . "”."); } $qt[] = new SearchTerm("f"); } }