Authored by whb

修改手机视频相关

... ... @@ -121,12 +121,10 @@ class Controller_News extends Controller_Abstract
}
if($this->_platform == 'android' || $this->_platform == 'iphone')
{
$sameID = Facade_Brand::getSameNewsByNewsID($id);
if(!empty($sameID))
{
$news[] = Facade_News::getOneById($sameID);
}
$news = array_slice(array_merge($news, Facade_News::getList(array(), 0, 3, array('视频'))), 0, 3);
$exceptTags = array('视频');
$news[] = Facade_News::getSameNewsById($id, $exceptTags);
$news = array_merge($news, Facade_News::getList(array(), 0, 3, $exceptTags));
$news = array_slice(array_filter($news), 0, 3);
}
$info['title'] = strip_tags($info['title']);
$info['pics'] = array_filter(explode('|', $info['pics']));
... ... @@ -147,15 +145,12 @@ class Controller_News extends Controller_Abstract
{
$id = intval($this->_request->id);
$list = array('recom'=> array(), 'hotVideo'=> array(), 'lastVideo' => array());
$sameID = Facade_Brand::getSameNewsByNewsID($id);
$tag = '视频';
$exceptTags = array('手机视频');
$recom = array();
if(!empty($sameID))
{
$recom[] = Facade_News::getOneById($sameID);
}
$recom = array_slice(array_merge($recom, Facade_News::getList(array(), 0, 3, $exceptTags)), 0, 3);
$recom[] = Facade_News::getSameNewsById($id, $exceptTags);
$recom = array_merge($recom, Facade_News::getList(array(), 0, 3, $exceptTags));
$recom = array_slice(array_filter($recom), 0, 3);
$hotVideo = array_values(Facade_News::getListByHits($tag, 0, 5, $exceptTags));
$lastVideo = array_values(Facade_News::getList($tag, 0, 5, $exceptTags));
$list['recom'] = $recom;
... ...
... ... @@ -334,14 +334,4 @@ class Facade_Brand
return self::service()->getBrandByName($name, $state);
}
/**
* 根据news_id获取相同的新闻
*
* @param int $news_id
* @return int
*/
public static function getSameNewsByNewsID($news_id)
{
return self::service()->getSameNewsByNewsID($news_id);
}
}
... ...
... ... @@ -245,4 +245,16 @@ class Facade_News
{
return self::service()->getListByHits($tag, $offset, $limit, $exceptTags);
}
/**
* 根据id获取相同的新闻
*
* @param int $id
* @param array $exceptTags
* @return int
*/
public static function getSameNewsById($id, $exceptTags = array())
{
return self::service()->getSameNewsById($id, $exceptTags);
}
}
\ No newline at end of file
... ...
... ... @@ -294,16 +294,5 @@ class Service_Brand extends Lib_Service
$name = '%'.addslashes($name).'%';
return self::service(self::ROUTER)->tag(self::$_tag)->fetchAssoc('getBrandByName',
array('state'=> $state,'name'=> $name));
}
/**
* 根据news_id获取相同的新闻
*
* @param int $news_id
* @return int
*/
public function getSameNewsByNewsID($news_id)
{
return self::service(self::ROUTER)->tag(self::$_tag)->fetchOne('getSameNewsByNewsID', array('news_id' => $news_id));
}
}
}
... ...
... ... @@ -248,5 +248,24 @@ class Service_News extends Lib_Service
return self::service(self::ROUTER)->tag(self::$_tag)->fetchAssoc('getListByHits',array('tag'=> $tag,
'offset'=> intval($offset), 'limit'=> intval($limit)), array('where'=> $exceptWhere));
}
/**
* 根据news_id获取相同的新闻
*
* @param int $news_id
* @param array $exceptTags
* @return int
*/
public function getSameNewsById($news_id, $exceptTags)
{
$exceptWhere = "1";
if(is_array($exceptTags) && !empty($exceptTags))
{
$exceptTags = implode("','", $exceptTags);
$exceptWhere = " `tag` NOT IN ('$exceptTags') ";
}
return self::service(self::ROUTER)->tag(self::$_tag)->fetchRow('getSameNewsById', array('news_id' => $news_id), array('where'=> $exceptWhere));
}
}
... ...
... ... @@ -30,7 +30,6 @@
<insert id="createTag">
INSERT INTO `tbl_tag` VALUES (:tag, :num, 0)
</insert>
<select id="getTags">
SELECT * FROM `tbl_tag` ORDER BY `sort` DESC
</select>
... ... @@ -46,4 +45,8 @@
<select id="getListByHits">
SELECT * FROM tbl_news WHERE `tag` = :tag AND #where# ORDER BY hits DESC LIMIT :offset, :limit
</select>
<select id="getSameNewsById">
SELECT * FROM tbl_news WHERE id &lt;&gt; :news_id AND #where# AND id IN (
SELECT news_id FROM tbl_news_brand_rela WHERE brand_id IN (SELECT brand_id FROM tbl_news_brand_rela WHERE news_id = :news_id) )
</select>
</sqlMap>
\ No newline at end of file
... ...