getList(['siteid' => $this->siteid, 'isshow' => 1, 'stat' => 0, 'country_code' => $this->country_code], ['sort', 'id'], ['id', 'pid', 'haschild', 'name', 'shortname', 'description', 'sort', 'isshow', 'recommend', 'picture', 'image1', 'image2', 'classtype', 'url']); $value = [ 'videoCategory' => $videoCategory, ]; $value['seo_title'] = config('video_seo_title')? : config('website_seo_title_us'); $value['seo_keyword'] = config('video_seo_keyword')? : config('website_seo_keyword'); $value['seo_description'] = config('video_seo_description')? : config('website_seo_description'); $this->assign($value); return $this->fetch(); } public function catelists($id = 0) { $arg_where = ['a.siteid' => $this->siteid]; $id = intval($id); if ($id > 0) { $category = Loader::model('video_category')->getRow($id); if ($category['haschild']) { $ids = Loader::model('video_category')->getChildIDArray($id); $arg_where['cid'] = ['in', $ids]; } else { $arg_where['cid'] = $id; } } if (empty($category)) { return exception('数据有误,请检查后再操作'); } unset($category['siteid']); $value['category'] = $category; switch ($category['classtype']) { case 2: $template = $category['templist']; $arg_order = ['a.id' => 'desc']; $arg_field = ['a.id', 'a.cid', 'a.name', 'a.sort', 'a.headline', 'a.ishot', 'a.recommend', 'a.viewcount', 'a.videopath', 'a.videourl', 'a.description', 'a.picture', 'a.createtime', 'c.id' => 'categoryid', 'c.name' => 'categoryname']; $dataObject = Loader::model('video')->getCateVideoLists($arg_where, $arg_order, $arg_field, 10); $value['list'] = $dataObject->isEmpty() ? null : $dataObject->items(); $value['page'] = $dataObject->render(); if ($this->request->isAjax()) { return $this->result($value, true, '视频列表'); } $videoCategory = Loader::model('video_category')->getList(['siteid' => $this->siteid, 'isshow' => 1, 'stat' => 0, 'country_code' => $this->country_code], ['sort', 'id'], ['id', 'pid', 'haschild', 'name', 'shortname', 'description', 'sort', 'isshow', 'recommend', 'picture', 'image1', 'image2', 'classtype', 'url']); $value['videoCategory'] = $videoCategory; break; case 3: header('location:' . $category['url']); exit; break; default: $template = $category['tempindex']; break; } $value['seo_title'] = $category['seo_title']? : config('website_seo_title_us'); $value['seo_keyword'] = $category['seo_keyword']? : config('website_seo_keyword'); $value['seo_description'] = $category['seo_description']? : config('website_seo_description'); $this->assign($value); return $this->fetch($template); } public function detail($id = 0) { if ($id > 0) { $detail = Loader::model('video')->getRow($id); if (empty($detail)) { return exception('数据有误,请检查后再操作'); } //$addvideo = Loader::model('VideoAddition')->getRowAddition(['aid' => $detail['id']]); $category = Loader::model('video_category')->getRow($detail['cid']); if (empty($category)) { return exception('数据有误,请检查后再操作'); } //$prev_detail = Loader::model('Video')->getRow(['id' => ['gt', $id], 'cid' => $category['id'], 'stat' => 0], ['id', 'name'], ['id' => 'asc']); //$next_detail = Loader::model('Video')->getRow(['id' => ['lt', $id], 'cid' => $category['id'], 'stat' => 0], ['id', 'name'], ['id' => 'desc']); $value = [ 'detail' => $detail, //'addvideo' => $addvideo, 'category' => $category, //'prev_detail' => $prev_detail, //'next_detail' => $next_detail, ]; $value['seo_title'] = $detail['seo_title']? : $detail['name'] . '-' . config('website_seo_title_us'); $value['seo_keyword'] = $detail['seo_keyword']? : config('website_seo_keyword'); $value['seo_description'] = $detail['seo_description']? : config('website_seo_description'); $this->assign($value); $this->viewcount($id); return $this->fetch(); } else { return exception('数据有误,请检查后再操作'); } } protected function viewcount($id) { $view = Cookie::get('videoview', 'history'); //print_r($history);exit; if (empty($view) || $view != $id) { Loader::model('video')->where(['id' => $id])->setInc('viewcount'); Cookie::set('videoview', $id, ['prefix' => 'history', 'expire' => 3600]); } } protected function historyvideo($id) { $video = Cookie::get('video', 'history'); //print_r($history);exit; if (isset($video) && !empty($video)) { $video_ids = explode(',', $video); if ($video_ids[0] != $id) { array_unshift($video_ids, $id); $video_ids = array_unique($video_ids); $num = Config::get('history_number') > 0 ? Config::get('history_number') : 10; //$video_ids = array_slice($video_ids, 0, $num); while (count($video_ids) > $num) { array_pop($video_ids); } Cookie::set('video', implode(',', $video_ids), ['prefix' => 'history', 'setcookie' => true, 'expire' => 3600 * 24 * 30]); } } else { Cookie::set('video', $id, ['prefix' => 'history', 'setcookie' => true, 'expire' => 3600 * 24 * 30]); } } }