public function getAllItems($lastId = 0, $searchTag = "", $userId = false, $limit = false) { $query = Video::find()->from(["v" => Video::tableName()])->joinWith(['items i'])->andWhere('i.deleted = 0')->orderBy('id DESC'); // Определяем за какой период будем показывать if (!empty($limit)) { $query = $query->limit((int) $limit); } else { $query = $query->limit(100); } if ($lastId != 0) { $query = $query->andWhere('i.id < :id', [':id' => $lastId]); } if (!empty($userId)) { $query = $query->andWhere('i.user_id = :userId', [':userId' => $userId]); } if (!empty($searchTag)) { if (is_array($searchTag)) { $tagsId = $searchTag; } else { $tags = Tags::find()->where(['name' => $searchTag])->all(); $tagsId = []; foreach ($tags as $tag) { $tagsId[] = (int) $tag->id; } } if (count($tagsId) > 0) { $query = $query->andWhere('(SELECT COUNT(*) as tagCount FROM `' . TagEntity::tableName() . '` te WHERE te.entity = "' . TagEntity::ENTITY_ITEM . '" AND te.entity_id = i.id AND te.tag_id IN (' . join(',', $tagsId) . ')) > 0'); } } return $query->all(); }
public function run() { parent::run(); // TODO: Change the autogenerated stub $nodes = Video::find()->where(['status' => 10])->limit(2)->all(); return $this->render('VideoRightWidget', ['nodes' => $nodes]); }
public static function getData() { $videoModel = new Video(); $videoData = $videoModel->find()->limit(6)->all(); $videoHot = array($videoData[0], $videoData[1]); $videoHotChild = array($videoData[2], $videoData[3], $videoData[4], $videoData[5]); return array('videoHot' => $videoHot, 'videoHotChild' => $videoHotChild); }
protected function findModel($id) { if (($model = Video::find()->where(['and', 'id=' . $id])->One()) !== null) { return $model; } else { throw new NotFoundHttpException('你所查找的网页不存在'); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Video::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'views' => $this->views, 'course' => $this->course, 'class' => $this->class, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'thumb', $this->thumb])->andFilterWhere(['like', 'keyword', $this->keyword])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'author', $this->author]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Video::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'size' => $this->size, 'duration' => $this->duration, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by, 'confirmed' => $this->confirmed]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'embed', $this->embed])->andFilterWhere(['like', 'poster', $this->poster])->andFilterWhere(['like', 'videoId', $this->videoId])->andFilterWhere(['like', 'mobileLink', $this->mobileLink])->andFilterWhere(['like', 'sdLink', $this->sdLink])->andFilterWhere(['like', 'hlsLink', $this->hlsLink]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Video::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'user_id' => $this->user_id, 'status' => $this->status, 'course_id' => $this->course_id]); $query->andFilterWhere(['like', 'type', $this->type])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'video_url', $this->video_url]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Video::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'category_id' => $this->category_id, 'status' => $this->status, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'meta_title', $this->meta_title])->andFilterWhere(['like', 'meta_keywords', $this->meta_keywords])->andFilterWhere(['like', 'meta_description', $this->meta_description]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = VideoModel::find(); // add conditions that should always apply here $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } // grid filtering conditions $query->andFilterWhere(['id' => $this->id, 'video_source_id' => $this->video_source_id, 'date_added' => $this->date_added, 'date_created' => $this->date_created, 'added_by_id' => $this->added_by_id]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'key', $this->key])->andFilterWhere(['like', 'thumbnail', $this->thumbnail]); return $dataProvider; }
public function actionIndex() { $type = Yii::$app->request->get('type'); $class = Yii::$app->request->get('class'); $course = Yii::$app->request->get('course'); $key = Yii::$app->request->get('key'); $sort = Yii::$app->request->get('sort'); //条件 $where[] = 'and'; $where[] = 'status>' . Status::STATUS_INACTIVE; if (!is_null($class)) { $where[] = ['class' => $class]; } if (!is_null($course)) { $where[] = ['course' => $course]; } if (!is_null($key)) { $where[] = ['like', 'title', $key]; } //排序 $sort = ['created_at' => SORT_DESC]; if ($sort == 'star') { $sort = ['star' => SORT_DESC]; } //课程类型 if ($type == 0) { $query = Video::find()->where($where); //查询4条推荐信息 $where[1] = 'status=' . Status::STATUS_REC; $infoRec = Video::find()->where($where)->limit(4)->all(); } else { $where[] = ['type' => $type]; $query = Resource::find()->where($where); //查询4条推荐信息 $where[1] = 'status=' . Status::STATUS_REC; $infoRec = Resource::find()->where($where)->limit(4)->all(); } $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => $sort], 'pagination' => ['pageSize' => 15]]); return $this->render('index', ['models' => $dataProvider->getModels(), 'pagination' => $dataProvider->pagination, 'type' => $type, 'class' => $class, 'course' => $course, 'key' => $key, 'infoRec' => $infoRec]); }
public function actionIndex() { //轮播图 $slider = Slider::find()->where(['place' => 0])->orderBy(['ord' => SORT_ASC])->all(); //微课 $weike = \common\models\Video::find()->where(['and', ['status' => \common\models\Status::STATUS_REC]])->limit(6)->all(); //教案 $jiaoan = \common\models\Resource::find()->where(['and', ['type' => 0], ['status' => \common\models\Status::STATUS_REC]])->limit(3)->all(); //课件 $kejian = \common\models\Resource::find()->where(['and', ['type' => 1], ['status' => \common\models\Status::STATUS_REC]])->limit(3)->all(); //试题 $shiti = \common\models\Resource::find()->where(['and', ['type' => 2], ['status' => \common\models\Status::STATUS_REC]])->limit(3)->all(); //新闻公告 $news = \common\models\News::find()->where(['and', 'status>' . \common\models\Status::STATUS_INACTIVE])->orderBy(['id' => SORT_DESC])->limit(3)->all(); //推荐下载 $recdown = \common\models\Resource::find()->where(['and', ['status' => \common\models\Status::STATUS_REC]])->orderBy(['id' => SORT_DESC])->limit(4)->all(); //最新评价 $pinglun = \common\models\Pinglun::find()->where(['and', 'status>' . \common\models\Status::STATUS_INACTIVE])->orderBy(['id' => SORT_DESC])->limit(6)->all(); //学霸必备 $xueba = \common\models\Resource::find()->where(['and', 'status>' . \common\models\Status::STATUS_REC])->orderBy(['rand()' => SORT_DESC])->limit(10)->all(); //友情链接 $friendLink = \common\models\Friendlink::find()->where(['isshow' => \common\models\YesNo::YES])->orderBy(['ord' => SORT_ASC])->all(); return $this->render('index', ['slider' => $slider, 'weike' => $weike, 'jiaoan' => $jiaoan, 'kejian' => $kejian, 'shiti' => $shiti, 'news' => $news, 'recdown' => $recdown, 'pinglun' => $pinglun, 'xueba' => $xueba, 'friendlink' => $friendLink]); }
<dt>[报考指南]</dt> <dd><a href="#">2015河南造价员资格证书领</a></dd> <dd><a href="#">取通知造价员考试合格标准</a></dd> <dt>[报考指南]</dt> <dd><a href="#">2015河南造价员资格证书领</a></dd> <dd><a href="#">取通知造价员考试合格标准</a></dd> </dl> </div> <div class="third-right f-l"> <div class="wlst-tit lm-tb"><span><a href="<?php echo Yii::$app->urlManager->createUrl(['video/index']); ?> ">更多</a></span>网络试听</div> <?php $video = \common\models\Video::find()->where(['status' => \common\models\Status::STATUS_REC])->one(); ?> <?php if ($video) { ?> <div class="wlst-sp"> <a href="<?php echo Yii::$app->urlManager->createUrl(['video/show', 'id' => $video->id]); ?> "> <img src="<?php echo $video->content . "?vframe/jpg/offset/" . $video->thumb; ?> " width="295" height="196" /> </a> </div>
<textarea class="collegecomments-nr" id="content" name="Pinglun[content]" placeholder="请输入要评论的内容"></textarea> <div class="collegecomments-btn"><input type="submit" value="发表评论"></div> </form> <div class="collegecomments-body" id ="comment"> </div> </div> <div class="recommend-class margin-top20"> <div class="recommend-class-tit">推荐内容</div> <?php $infoRec = \common\models\Video::find()->where('status=' . \common\models\Status::STATUS_REC)->limit(4)->all(); foreach ($infoRec as $k => $v) { ?> <?php $thumb = '/statics/images/default-image.png'; $url = 'video'; $thumb = $v->video . "?vframe/jpg/offset/" . $v->thumb; ?> <div class="recommend-class-body<?php if ($k != 4) { echo ' margin-right36'; } ?> "> <img src="<?php
public function actionGetVideoByTime() { $time = Yii::$app->request->post('time'); //vd($time); if ($time == 0) { $model = Video::find()->orderBy('created_at DESC')->all(); } else { $model = Video::find()->orderBy('created_at ASC')->all(); } //vd($model); Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; return $this->renderAjax('get-video-by-categoria-id', ['model' => $model]); }
/** * @return Video */ public static function getRandomVideo($exclude = []) { $find = Video::find()->orderBy(new Expression('rand()')); if (!empty($exclude)) { $find = $find->andWhere(['not in', 'entity_id', $exclude]); } return $find->one(); }
public function actionViews() { $slug = Yii::$app->request->get('slug'); $model = Video::find()->where(['slug' => $slug])->one(); $this->meta = $model; return $this->render('views', ['model' => $model]); }
public function actionMyVideo() { $where[] = 'and'; $where[] = ['created_by' => Yii::$app->user->id]; $query = \common\models\Video::find()->where($where); $dataProvider = new \yii\data\ActiveDataProvider(['query' => $query, 'pagination' => ['defaultPageSize' => 6], 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]]]); return $this->render('my-video', ['models' => $dataProvider->getModels(), 'pagination' => $dataProvider->pagination]); }