Esempio n. 1
0
function unparse_preference_span($preference, $always = false)
{
    if (is_object($preference)) {
        $preference = array(get($preference, "reviewerPreference"), get($preference, "reviewerExpertise"), get($preference, "topicInterestScore"));
    } else {
        if (!is_array($preference)) {
            $preference = array($preference, null, null);
        }
    }
    $pv = (int) get($preference, 0);
    $ev = get($preference, 1);
    $tv = (int) get($preference, 2);
    $type = 1;
    if ($pv < 0 || !$pv && $tv < 0) {
        $type = -1;
    }
    $t = "";
    if ($pv || $ev !== null || $always) {
        $t .= "P" . decorateNumber($pv) . unparse_expertise($ev);
    }
    if ($tv && !$pv) {
        $t .= ($t ? " " : "") . "T" . decorateNumber($tv);
    }
    if ($t !== "") {
        $t = " <span class=\"asspref{$type}\">{$t}</span>";
    }
    return $t;
}
Esempio n. 2
0
function preferenceSpan($preference, $topicInterestScore = 0)
{
    if (is_array($preference)) {
        list($preference, $topicInterestScore) = $preference;
    }
    if ($preference != 0) {
        $type = $preference > 0 ? 1 : -1;
    } else {
        $type = $topicInterestScore > 0 ? 1 : -1;
    }
    $t = " <span class='asspref{$type}'>";
    if ($preference) {
        $t .= "P" . decorateNumber($preference);
    }
    if ($preference && $topicInterestScore) {
        $t .= " ";
    }
    if ($topicInterestScore) {
        $t .= "T" . decorateNumber($topicInterestScore);
    }
    return $t . "</span>";
}