当前位置: 首页>>代码示例>>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;未经允许,请勿转载。