$instance
$instance : object
Reference to the CI singleton
Application Controller Class
This class object is the super class that every library in CodeIgniter will be assigned to.
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Search extends CI_Controller
{
private static $data = array();
public function __construct()
{
parent::__construct();
$this->load->model('Webcommon_model','common');//公共
$this->load->model('Symptom_model','bbs');
$this->load->model('Apparticle_model','article');
$this->load->model('Appfile_model','file');
$this->load->model('Protflio_model','Protflio');
$this->load->model('Userinfo_model','userinfo');
$this->load->model('Appcate_model','cate');
}
/**
* 文章搜索页
* */
public function article()
{
$title = trim($this->input->get_post('title'));
$start = !empty($start) ? $start : 0;
$limit = 10;
//获取文章
$articleList = $this->article->getAppArticleNewList($limit,$start,$title);
$articleListArray = array();
foreach($articleList as $key=>$value)
{
if(time()>=$value['createTime']){
$userInfo = $this->userinfo->getUserInfoRow($value['userId']);
$articleListArray[$key]['articleuserId'] = $value['userId'];
$articleListArray[$key]['nickName']=empty($userInfo['nickName'])?'佚名':$userInfo['nickName'];
$userInfo['headUrl'] = empty($userInfo['headUrl'])?$userInfo['thirdheadUrl']:$this->config->item('hwclouds').$userInfo['headUrl'];
$articleListArray[$key]['headUrl'] = empty($userInfo['headUrl'])?$this->config->item('base_url').'/public/web/images/use_tx_03.jpg': $userInfo['headUrl'];
$articleListArray[$key]['articleId'] = $value['articleId'];
$cateInfo = $this->cate->getCateRow($value['cateId']);
$articleListArray[$key]['cateName'] = empty($cateInfo['cateName'])?'无分类':$cateInfo['cateName'];
$articleListArray[$key]['title'] = $value['title'];
$content = str_replace('&', '&', $value['content']);
$content = str_replace('<','<',$content);
$content = str_replace('>', '>', $content);
$content = str_replace('&nbsp;','', $content);
$content =strip_tags($content);
$pattern = '/\s/';//去除空白
$content = preg_replace($pattern,'', $content);
$articleListArray[$key]['content'] = mb_substr($content, 0, 80);
$articleListArray[$key]['viewNum'] = $value['viewNum'];
$articleListArray[$key]['zanNum'] = $value['zanNum'];
$articleListArray[$key]['commentNum'] = $value['commentNum'];
$articleListArray[$key]['relayNum'] = $value['relayNum'];
$articleListArray[$key]['createTime'] = format_time($value['createTime']);
$articleListArray[$key]['coverImage'] = empty($value['coverImage'])?'':$this->config->item('hwclouds').$value['coverImage'];
$articleListArray[$key]['imagePath'] = empty($value['coverImage'])?'':$this->config->item('hwclouds').$value['coverImage'];
}
}
echo $this->common->returnArray ( array ( 'articleList'=>$articleListArray), '读取成功', 200 );exit;
}
/**
* 搜索作品集
*/
public function protfolio(){
$title = trim($this->input->get_post('title'));
$start = !empty($start) ? $start : 0;
$limit = 10;
$protflio = $this->Protflio->searchProtfolio($title,$limit,$start);
foreach ($protflio as $key=>$value){
$protflioData[$key]['protfolioId'] = $value['id'];
$protflioData[$key]['direction'] = $value['dirction'];
$protflioData[$key]['finishstatus'] = $value['finishstatus'];
$protflioData[$key]['coverimage'] = $this->config->item('hwclouds').$value['coverimage'];
$protflioData[$key]['Name'] = $value['Name'];
}
echo $this->common->returnArray(array ('ProtflioData'=>$protflioData),'获取成功',200);exit;
}
/**
* 论坛搜索页
* */
public function bbs()
{
$title = trim($this->input->get_post('title'));
$start = !empty($start) ? $start : 0;
$limit = 10;
$bbsList = $this->bbs->getAllBbsList($limit,$start,$title);
// echo $this->db->last_query();exit;
foreach($bbsList as $key=>$value)
{
$bbsList[$key]['docName'] = '';
// echo $value['userId'];exit;
$userInfo = $this->userinfo->getUserInfoRow($value['userId'],2);
if(empty($userInfo))
{
$userInfo = $this->userinfo->getUserInfoRow($value['userId'],1);
if(empty($userInfo))
{
$userInfo = $this->userinfo->getUserInfoRow($value['userId'],0);
}
}
$nickName = empty($userInfo['nickName'])?'':$userInfo['nickName'];
$userInfo['headUrl'] = empty($userInfo['headUrl'])?$userInfo['thirdheadUrl']:$this->config->item('hwclouds').$userInfo['headUrl'];
$headUrl = empty($userInfo['headUrl'])?$this->config->item('base_url').'/public/web/images/use_tx_03.jpg': $userInfo['headUrl'];
$bbsList[$key]['createTime'] = format_time($value['createTime']);
$imagepathstr = $value['imagePath'];
$imafepatharr = explode(',',$imagepathstr);
foreach ($imafepatharr as $k=> $v){
$v = str_replace('"', '', $v);
$imafepatharr[$k] = $this->config->item('hwclouds').$v;
}
$a=array();
$bbsList[$key]['imagePath'] = empty($value['imagePath'])?$a:$imafepatharr;
//查询论坛的附件
$bbsList[$key]['typeFlag'] = 0;
$video = $this->file->getBbsDocPath($value['bbsId'],1);
$bbsList[$key]['docName'] = empty($video['docName'])?'':$video['docName'];
if(!empty($video))
{
$bbsList[$key]['typeFlag'] = 1;//视频
}
else if(empty($video))
{
$video = $this->file->getBbsDocPath($value['bbsId'],2);//音频
if(!empty($video))
{
$bbsList[$key]['typeFlag'] = 2;//音频
$bbsList[$key]['docName'] = $video['docName'];
}
else
{
$video = $this->file->getBbsDocPath($value['bbsId'],0);//图片
if(!empty($video))
{
$bbsList[$key]['typeFlag'] = 3;//图片
}
}
}
$bbsList[$key]['nickName'] = $nickName;
// $bbsList[$key]['videopath'] = $videopath;
// $bbsList[$key]['audiopath'] = $audiopath;
// $bbsList[$key]['audioTitle'] = $audioTitle;
// $bbsList[$key]['singer'] = $singer;
$bbsList[$key]['type'] = $value['type'];
$bbsList[$key]['headUrl'] = $headUrl;
$bbsList[$key]['commentNum'] = $value['commentNum'];
unset($bbsList[$key]['typeFlag']);
}
echo $this->common->returnArray(array('bbsList' => $bbsList), '读取成功', 200);exit;
}
}