<?php
/**
 * 友情链接管理
 * @Copyright (C) 2016 汉潮 All rights reserved.
 * @License http://www.hanchao9999.com
 * @Author xiaogg <xiaogg@sina.cn>
 */
 
namespace Admin\Controller;
class FriendlinkController extends BaseController{ 
	public function index(){        
		$postdata=I('param.');$this->assign($postdata);
		$map=array();
		if(isset($postdata['keyword'])){
			$whereor['id']=array('like','%'.$postdata['keyword'].'%');
            $whereor['title']=array('like','%'.$postdata['keyword'].'%');
            $whereor['content']=array('like','%'.$postdata['keyword'].'%');
            $whereor['_logic'] = 'or';
            $map['_complex'] = $whereor;
		}
		$list=$this->lists('Friendlink',$map);
		$this->assign('list',$list);
		$this->display();
    }
    public function _before_add(){        
       $this->getCate();
    }
    public function _before_edit(){
        $this->getCate();
    }
    /* 得到节点树 */
	private function getCate() {
           $allCate = M('FriendlinkCat')->field('id,name')->cache(true)->select();
	       foreach($allCate as $k =>$v){
	           $linkcat[$v['id']]=$v['name'];
	       }
		  $this->assign('linkcat',$linkcat);
	}
}