private function account_votes($pid, $vtag, $state) { $res = $state->query(array("type" => "tag", "pid" => $pid)); $tag_re = '{\\A\\d+~' . preg_quote($vtag) . '\\z}i'; $is_vote = TagInfo::is_vote($vtag); $total = 0; foreach ($res as $x) { if (preg_match($tag_re, $x["ltag"])) { $total += $is_vote ? (double) $x["_index"] : 1; } } $state->add(array("type" => "tag", "pid" => $pid, "ltag" => strtolower($vtag), "_tag" => $vtag, "_index" => $total, "_vote" => true)); }
public function link($tag) { if (ctype_digit($tag[0])) { $x = strlen($this->_contactId); if (substr($tag, 0, $x) != $this->_contactId || $tag[$x] !== "~") { return false; } $tag = substr($tag, $x); } $base = TagInfo::base($tag); if (TagInfo::has_votish() && (TagInfo::is_votish($base) || $base[0] === "~" && TagInfo::is_vote(substr($base, 1)))) { $q = "#{$base} showsort:-#{$base}"; } else { if ($base === $tag) { $q = "#{$base}"; } else { $q = "order:#{$base}"; } } return hoturl("search", ["q" => $q]); }