<?php
namespace Home\Controller;

/**
 * @abstract 新闻模型控制器
 * @author Zxf
 */
class NewsController extends HomeController {
	public function lists($p = 1, $type = null) {
		// 获得分类信息
		$tree = D ( 'Category' )->getTree ( 41 );
		$this->assign ( "newscate", $tree ['_'] );
		$_GET ['category'] = isset ( $_GET ['category'] ) ? $_GET ['category'] : "IndustryNews";
		A ( "Article" )->lists ( $p, $type );
	}
	
	public function detail($id = 0, $p = 1){
		$tree = D ( 'Category' )->getTree ( 41 );
		$this->assign ( "newscate", $tree ['_'] );
		A ( "Article" )->detail ( $id, $p );
	}
	
	public function search(){
		$keyword = I ( 'keyword');
		$document = D("document");
		
		$ids = $document->where("model_id = 2 and title like '%{$keyword}%'")->select();
		foreach ( $ids as $id ) {
			$news [] = $document->detail ( $id ["id"] );
		}
		$this->assign ( "list", array_filter ( $news ) );
		
		$this->assign("subtitle",$keyword."_相关搜索_");
		$this->assign("subkey",$keyword."_相关搜索_");
		$this->assign("subdes",$keyword."_相关搜索_");
		$this->display();
	}
	
}