Exemple #1
0
 public function output()
 {
     global $_G;
     //echo  json_encode($_G['group']); die(0);
     //echo  json_encode($maxratetoday); die(0);
     // 评分项列表
     $raterange = $_G['group']['raterange'];
     $maxratetoday = getratingleft($raterange);
     $creditmap = $_G['setting']['extcredits'];
     $ratelist = array();
     $isself = 0;
     foreach ($raterange as $extcredits => &$im) {
         if (!isset($creditmap[$extcredits])) {
             continue;
         }
         $im["extcredits"] = $extcredits;
         $im["title"] = $creditmap[$extcredits]["title"];
         $im["todayleft"] = $maxratetoday[$extcredits];
         $ratelist[] = $im;
         if ($im['isself'] == 1) {
             $isself = 1;
         }
     }
     // 评分理由列表
     $reasons = explode("\n", $_G['setting']["userreasons"]);
     foreach ($reasons as $k => &$v) {
         $v = trim($v);
         if ($v == "") {
             unset($reasons[$k]);
         }
     }
     $variable = array("status" => isset($_G['messageparam'][0]) ? 0 : 1, "isself" => $isself, "ratelist" => $ratelist, "reasons" => $reasons);
     bigapp_core::result(bigapp_core::variable($variable));
     die(0);
 }
function getratelist($raterange)
{
    global $_G;
    $maxratetoday = getratingleft($raterange);
    $ratelist = array();
    foreach ($raterange as $id => $rating) {
        if (isset($_G['setting']['extcredits'][$id])) {
            $ratelist[$id] = '';
            $rating['max'] = $rating['max'] < $maxratetoday[$id] ? $rating['max'] : $maxratetoday[$id];
            $rating['min'] = -$rating['min'] < $maxratetoday[$id] ? $rating['min'] : -$maxratetoday[$id];
            $offset = abs(ceil(($rating['max'] - $rating['min']) / 10));
            if ($rating['max'] > $rating['min']) {
                for ($vote = $rating['max']; $vote >= $rating['min']; $vote -= $offset) {
                    $ratelist[$id] .= $vote ? '<li>' . ($vote > 0 ? '+' . $vote : $vote) . '</li>' : '';
                }
            }
        }
    }
    return $ratelist;
}