當前位置: 首頁>>代碼示例>>PHP>>正文


PHP rating::inited方法代碼示例

本文整理匯總了PHP中rating::inited方法的典型用法代碼示例。如果您正苦於以下問題:PHP rating::inited方法的具體用法?PHP rating::inited怎麽用?PHP rating::inited使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rating的用法示例。


在下文中一共展示了rating::inited方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: display

 /**
  * Инициализация рейтинга звёздами
  * @param int $toid ID ресурса
  * @param int $owner владелец ресурса(ч/с создатель торрента)
  * @param array $res массив ресурса
  * @param int $stoid доп. ID ресурса(только для проверки на то, голосовал ли)
  * @return null
  */
 public function display($toid, $owner = null, $res = null, $stoid = 0)
 {
     if (!$this->state) {
         return;
     }
     if (is_array($toid)) {
         if ($toid["type"]) {
             $this->change_type($toid["type"]);
         }
         $owner = $toid["owner"];
         $res = $toid["res"];
         $stoid = $toid["stoid"];
         if ($toid["stype"]) {
             $this->change_stype($toid["stype"]);
         }
         $toid = $toid["toid"];
     }
     $type = $this->type;
     $stype = $this->stype;
     lang::o()->get('rating');
     $owner = (int) $owner;
     $toid = (int) $toid;
     $stoid = (int) $stoid;
     $count = 0;
     if (is_numeric($res["rate_count"]) && is_numeric($res["rnum_count"])) {
         $count = $res["rnum_count"];
         $cur_votes = $res["rnum_count"] ? $res["rate_count"] / $res["rnum_count"] : 0;
     } else {
         $where = 'toid = ? AND type = ?';
         $count = db::o()->p($toid, $type)->count_rows("ratings", $where);
         $cur_votes = db::o()->p($toid, $type)->act_rows("ratings", "value", "avg", $where);
     }
     $this->min[$type] = (double) $this->min[$type];
     $this->max[$type] = (double) $this->max[$type];
     $this->part[$type] = (double) $this->part[$type];
     $disabled = $this->check_voted($owner, $toid, $stoid);
     $this->value_to_part($cur_votes);
     self::$count++;
     tpl::o()->assign('subratingid', 'cb' . self::$count . 'ce');
     tpl::o()->assign("rtoid", $toid);
     tpl::o()->assign("rtype", $type);
     tpl::o()->assign("total", $cur_votes);
     tpl::o()->assign("disabled", $disabled);
     tpl::o()->assign("count", $count);
     tpl::o()->assign("min", $this->min[$type]);
     tpl::o()->assign("loop", $this->part[$type] ? ($this->max[$type] - $this->min[$type]) / $this->part[$type] + 1 : 1);
     // section почему-то не хочет обрабатывать последнее значение
     tpl::o()->assign("per", $this->part[$type]);
     tpl::o()->assign("split", $this->part[$type] ? $this->part[$type] > 0 && $this->part[$type] <= 1 ? 1 / $this->part[$type] : 1 : 0);
     tpl::o()->assign("rating_inited", self::$inited);
     if (!self::$inited) {
         self::$inited = true;
     }
     tpl::o()->display("content/rating.tpl");
 }
開發者ID:SjayLiFe,項目名稱:CTRev,代碼行數:63,代碼來源:class.rating.php


注:本文中的rating::inited方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。