<?php
namespace Video\Lib;

use Dever;

class Core
{
	public function vod_api()
    {
    	$data['name'] = '视频';
        $where = array();
        $name = Dever::input('search_name');
        $cate = Dever::input('search_cate');
        if ($name) {
            $where['name'] = $name;
        }
        if ($cate > 0) {
            $where['cate_id'] = $cate;
        }
        $data['file'] = Dever::db('video/vod')->list($where);
        $data['cate'] = Dever::db('content/cate')->getAll();


        if ($data['file']) {
        	foreach ($data['file'] as $k => $v) {
                $data['file'][$k]['source_name'] = $v['name'];
                $data['file'][$k]['file'] = $v['pic_cover'];
                $data['file'][$k]['pic'] = $v['pic_cover'];
        	}
        }

        return $data;
    }

    public function live_api()
    {
    	$data['name'] = '直播';
        $where = array();
        $name = Dever::input('search_name');
        $cate = Dever::input('search_cate');
        if ($name) {
            $where['name'] = $name;
        }
        if ($cate > 0) {
            $where['cate_id'] = $cate;
        }
        $data['file'] = Dever::db('video/live')->list($where);
        $data['cate'] = Dever::db('content/cate')->getAll();

        if ($data['file']) {
            foreach ($data['file'] as $k => $v) {
                $data['file'][$k]['source_name'] = $v['name'];
                $data['file'][$k]['file'] = $v['pic_cover'];
                $data['file'][$k]['pic'] = $v['pic_cover'];
            }
        }

        return $data;
    }
}
