Example #1
0
 /**
  * 把普通内容转换为有汽车属性的内容
  *
  * @param object $contents
  */
 function convertAutoContents($contents)
 {
     $autoIDArr = array();
     if ($contents) {
         foreach ($contents as $c) {
             if (intval($c->autoid)) {
                 array_push($autoIDArr, intval($c->autoid));
             }
         }
     }
     //
     $autoclassification_db = bpBase::loadModel('autoclassification_model');
     $where = to_sqls($autoIDArr, '', 'id');
     $autos = $autoclassification_db->get_results('*', '', $where);
     $autos = objectsToArrByKey($autos, 'id');
     if ($contents) {
         $i = 0;
         foreach ($contents as $c) {
             if (intval($c->autoid)) {
                 $contents[$i]->auto = $autos[intval($c->autoid)];
             }
             $i++;
         }
     }
     return $contents;
 }
Example #2
0
 function channel()
 {
     $channelid = $this->channel['id'];
     //meta
     if (!$this->channel['metatitle']) {
         $this->assign('metaTitle', $this->channel['name'] . '_' . $this->site['name']);
     } else {
         $this->assign('metaTitle', $this->channel['metatitle']);
     }
     $this->assign('metaKeywords', $this->channel['metakeyword']);
     $this->assign('metaDescription', $this->channel['metades']);
     //子分类
     $page = intval($_GET['page']);
     $page = $page > 0 ? $page : 1;
     $pageSize = intval($this->channel['pagesize']);
     $channelIDs = array($channelid);
     $subChannels = $this->channel_db->getChannelsByParentID($channelid);
     if ($subChannels) {
         $subChannels = objectsToArrByKey($subChannels);
         $subChannels = $this->convertLinks($subChannels);
         $this->assign('subChannels', $subChannels);
         if ($subChannels) {
             foreach ($subChannels as $sc) {
                 array_push($channelIDs, $sc['id']);
             }
         }
         $contents = $this->article_db->listinfo(to_sqls($channelIDs, '', 'channel_id'), $order = 'taxis DESC', $page, $pageSize);
     } else {
         //
         $contents = $this->article_db->listinfo(array('channel_id' => $channelid), $order = 'taxis DESC', $page, $pageSize);
     }
     //如果只有一条信息就链接到该信息
     if (count($contents) == 1) {
         header('Location:?m=site&c=home&a=content&contentid=' . $contents[0]['id']);
     }
     //
     $contents = $this->convertLinks($contents);
     $this->assign('contents', $contents);
     //
     $total = $this->article_db->number;
     if ($pageSize) {
         if ($total % $pageSize == 0) {
             $totalPage = $total / $pageSize;
         } else {
             $totalPage = intval($total / $pageSize) + 1;
         }
     }
     $totalPage = $totalPage > 0 ? $totalPage : 1;
     $this->assign('totalPage', $totalPage);
     //总页数
     $currentPage = $page;
     $this->assign('currentPage', $currentPage);
     //当前页码
     if ($totalPage == 1 || $currentPage == 1) {
         $this->assign('previousPageLink', 'javascript:void(0)');
         //上页链接
     } else {
         $previousPageNum = $currentPage - 1;
         $this->assign('previousPageLink', $this->channel['link'] . '&page=' . $previousPageNum);
         //上页链接
     }
     if ($totalPage == 1 || $currentPage == $totalPage) {
         $this->assign('nextPageLink', 'javascript:void(0)');
         //下页链接
     } else {
         $nextPageNum = $currentPage + 1;
         $this->assign('nextPageLink', $this->channel['link'] . '&page=' . $nextPageNum);
         //下页链接
     }
     //template
     $template_db = M('template');
     $channelTemplate = $template_db->get_one(array('id' => $this->channel['channeltemplate']));
     $templatePaths = explode('/', $channelTemplate['path']);
     $templateFileName = $templatePaths[count($templatePaths) - 1];
     $this->display($this->smartyDir . $templateFileName, 0);
 }
Example #3
0
 function search()
 {
     $parms = array('m' => 'article', 'c' => 'm_article', 'a' => 'search');
     $siteID = $_GET['siteid'];
     if (isset($_GET['siteid']) && $_GET['siteid'] != $this->siteid) {
         exit;
     }
     $user_db = bpBase::loadModel('user_model');
     $admins = $user_db->select(array('isadmin' => 1));
     $channel = bpBase::loadAppClass('channelObj', 'channel');
     $display = $channel->channelCreatePageTree($channel->tree(0, $siteID), 0);
     //
     //$thisChannel=$channel->getChannelByID($_GET['id']);
     $pageSize = 20;
     $start = isset($_GET['start']) ? intval($_GET['start']) : 0;
     if (isset($_GET['startdate']) && $_GET['startdate'] != '') {
         $st = $_GET['startdate'];
         $stArr = explode('-', $st);
         $starttime = mktime(0, 0, 0, intval($stArr[1]), intval($stArr[2]), intval($stArr[0]));
         $parms['startdate'] = $_GET['startdate'];
     } else {
         $starttime = 0;
         $st = '';
     }
     if (isset($_GET['enddate']) && $_GET['enddate'] != '') {
         $et = $_GET['enddate'];
         $parms['enddate'] = $_GET['enddate'];
         $etArr = explode('-', $et);
         $endtime = mktime(23, 59, 59, intval($etArr[1]), intval($etArr[2]), intval($etArr[0]));
     } else {
         $endtime = 0;
         $et = '';
     }
     //
     $keyword = $_GET['keyword'];
     $parms['keyword'] = $_GET['keyword'];
     $keyword = str_replace('\'', '', $keyword);
     $keyword = str_replace('or', '', $keyword);
     $keyword = str_replace('and', '', $keyword);
     $keyword = str_replace('=', '', $keyword);
     $page = isset($_GET['page']) ? abs(intval($_GET['page'])) : 1;
     $articleObj = bpBase::loadAppClass('articleObj', 'article');
     //计算总数
     $totalSql = $articleObj->searchContentSql($_GET['channel'], $keyword, 0, 0, $starttime, $endtime, 0, $_GET['uid'], $this->siteid);
     $total = $this->article_db->get_varBySql($totalSql, 'COUNT(id)');
     //
     $contents = $articleObj->searchContents($_GET['channel'], $keyword, $page, $pageSize, $starttime, $endtime, 0, $_GET['uid'], $this->siteid);
     $contents = objectsToArrByKey($contents);
     $parmStr = http_build_query($parms);
     $pages = pages($total, $page, $pageSize, '?' . $parmStr . '&');
     //
     include $this->showManageTpl('search');
 }