示例#1
0
 /**
  * Action Detail
  * @param int $id 演讲集id
  */
 public function actionDetial($id)
 {
     $model = new Speech();
     $result = $model->getById(intval($id));
     if ($result) {
         return $this->render('detial', ['model' => $result]);
     } else {
         echo '<script>alert("此产品不存在"),window.location.href="' . Url::toRoute('speech/list') . '";</script>';
         exit;
     }
 }
示例#2
0
 /**
  * 获取分页数据
  *
  * @param int $pager 当前页
  * @param boolean $isExecute 是否执行查询
  * @return ActiveRecord
  */
 public function getByPage($pager = 1, $isExecute = true)
 {
     $result;
     $data = $query = Speech::find()->where(['is_del' => self::STATUS_NORMAL]);
     $maxpager = intval($data->count() / self::PAGE_SIZE + 1);
     if ($pager > $maxpager) {
         $pager = $maxpager;
     }
     $startnum = ($pager - 1) * self::PAGE_SIZE;
     $result = $query->offset($startnum)->limit(self::PAGE_SIZE);
     $result = $result->orderBy(['create_time' => SORT_DESC]);
     if ($isExecute == true) {
         $result = $rows->all();
     }
     return $result;
 }
示例#3
0
 /**
  * 解析首页演讲集数据
  *
  * @param string $data 演讲集数据
  *  - DataFormat: JSON-String
  *  - Description: 具有演讲集ID集合的JSON格式的字符串
  *  - Example: '[1,2,3,4,6]'
  * @return mixed
  *  - null 数据不符合JSON格式
  *  - array
  *  [
  *      {
  *          'id' => '演讲集ID',
  *          'title' => '演讲集标题',
  *          'img' => '演讲集封面图片URL',
  *      },
  *      .........
  *  ]
  */
 protected function _parseMainPageSpeeches($data)
 {
     $result = [];
     $data = json_decode($data, true);
     if ($data) {
         $result = Speech::getByIds($data);
     }
     return $result;
 }