<?php
// +----------------------------------------------------------------------
// | WindSNS 国内领先企业级社交开源SNS框架系统
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2020 http://windsns.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 常州微诺信息科技有限公司 http://www.weinuo.net
// +----------------------------------------------------------------------
// | E-mail: open@weinuo.net
// +----------------------------------------------------------------------
namespace app\index\controller;
use app\common\controller\Frontend;
use think\Config;
use think\Hook;
use think\Db;
use think\Request;


class Videos extends Frontend
{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';
	/**
	 * 协议
	 * @author   Devil
	 * @blog     http://www.weinuo.net
	 * @version  0.0.1
	 * @datetime 2020-03-03
	 */
    public function index()
    {
    	$this->view->assign('title', __('视频'));
    	
      
		$videosype = Db::name('admin_videostype')->order('video_typeid', 'desc')->select(); 
		$this->assign('videosype', $videosype);
		
		$videoslist = Db::name('admin_videos')->
		alias('a')->join('ws_admin_videostype w','a.videos_fenleiid = w.video_typeid') ->
		where(['videos_opentype'=>1]) -> 
		order('videosid', 'desc')->paginate(28); 
		$page = $videoslist->render();
		$this->assign('videoslist', $videoslist);
		$this->assign('page', $page);
		
		
		$videosum = Db::name('admin_videos')->
		alias('a')->join('ws_admin_videostype w','a.videos_fenleiid = w.video_typeid') ->
		where(['videos_opentype'=>1]) -> count();
		
		
		 if($videosum > 1 or $videosum == 1){
			return $this->view->fetch('windsns_videos');
		}else{
		 return $this->view->fetch('videos_inexnull');
		}





    	
        return $this->view->fetch('windsns_videos');
      
    }


			 public function videos_typelist()
			    {

					$getvideostypeid  =  input('get.videostypeid'); 
					
					$videos_typelittle = Db::name('admin_videostype')-> where(['video_typeid'=>$getvideostypeid]) -> find();
			        $type_names = $videos_typelittle['video_typenames'];
					$this->view->assign('title', __($type_names));
					$this->assign('type_names', $type_names);
					

				    $videosype = Db::name('admin_videostype')-> order('video_typeid', 'desc')->select(); 
			        $this->assign('videosype', $videosype);
					
					
					$videoslist = Db::name('admin_videos')->
			        alias('a')->join('ws_admin_videostype w','a.videos_fenleiid = w.video_typeid') ->
			        where(['videos_opentype'=>1,'videos_fenleiid'=>$getvideostypeid]) -> 
			        order('videosid', 'desc') -> paginate(28,false,['query' => request()->param()]);
			        $page = $videoslist->render();
			    	$this->assign('videoslist', $videoslist);
			        $this->assign('page', $page);
					
					
					$videosum = Db::name('admin_videos')->
		            alias('a')->join('ws_admin_videostype w','a.videos_fenleiid = w.video_typeid') ->
		            where(['videos_opentype'=>1,'videos_fenleiid'=>$getvideostypeid]) -> count();
			
			        $sqlvideostype = Db::name('admin_videostype') -> where(['video_typeid'=>$getvideostypeid]) -> find();
			
			        if(!$sqlvideostype){
			        	return $this->view->fetch('videos_typesqlno');
			        }else{

			        	   if($videosum > 1 or $videosum == 1){
				        	return $this->view->fetch('viseos_typlelist');
				            }else{
				            return $this->view->fetch('videos_typeliastnull');
				            }
			        	
			        }


			}

    	
    	
  








   

}
