otcommend'] = $this->get_content_img($info['hotcommend']); return $info; } /*获取文章正文图片*/ public function get_content_img($info){ foreach($info as $k=>$v){ $sql = "select `content` from `es_news_data` WHERE `id`={$v['id']} limit 1"; $data = $this->query($sql,'select'); $soImages = '~]* />~'; preg_match_all( $soImages, $data[0]['content'], $thePics ); $allPics = count($thePics[0]); if($allPics > 2){ $imgs = array(); foreach($thePics[0] as $kk=>$vv){ preg_match('//i',$vv,$match); $imgs[] = $match[1]; } /*最多取其中的前三张图*/ if(!empty($imgs[0])) $imgss[0] = $imgs[0]; if(!empty($imgs[1])) $imgss[1] = $imgs[1]; if(!empty($imgs[2])) $imgss[2] = $imgs[2]; $info[$k]['imgs'] = $imgss; array_splice($imgs,0,3); array_splice($thePics[0],0); array_splice($match,0); }else{ $info[$k]['imgs'] = ''; } } return $info; } //列表页加分页 public function list_page(){ $catid=intval(I('id')); if($catid){ $total = $this->where(array('catid'=>$catid,'status'=>99))->total(); import('wpage'); $page=new Wpage($total); $info['list']=$this->field('id,title,inputtime,thumb')->where(array('catid'=>$catid,'status'=>99))->limit($page->limit)->order('inputtime desc')->select(); $info['page']=$page->show(); $model=D('category'); $arr=$model->get_news_title($catid); $farr=$model->get_news_ftitle($catid); $info['ftitle']=$farr['catname']; $info['fid']=$farr['fcatid']; $info['title']=$arr['catname']; $info['keywords']=''; $info['description']=''; return $info; }else{ return false; } } //新闻频道页 public function channel(){ $info['focpic']=$this->get_channel_focpic(); $info['yaowen']=$this->get_newest(10); $info['jianzao']=$this->get_channel_jianzao(12); $info['yingyun']=$this->get_channel_yingyun(12); $info['zonghe']=$this->get_channel_zonghe(12); $info['jiaoyi']=$this->get_channel_jiaoyi(12); $info['title']='新闻频道 - 船舶建造,船舶营运,船舶交易,海事展览'; $info['keywords']='船舶建造,船舶营运,船舶交易,造船修船,买船租船,船厂船东,设备配套,海事展览,船舶信息,船厂动态,新签订单,撤单改单,在建新船,船舶设计,新船市场,配套商动态,船板市场,船机动态,船配市场,国外造船,地方造船,二手船市场,二手船动态,租船市场,租船动态,废钢船动态,废钢船市场,船东动态,新船营运,船舶运力,在航船动态港口船讯,航线变化,散运市场,油运市场,集运市场,海工市场,船级社,地方海事,船舶金融,舰船风云,海事展,船市,新型船舶,地方船检,船界人物,船股评论,船舷内外,维修改装,拆船动态,新船报到'; $info['description']='国际船舶网新闻频道提供船舶建造,船舶交易,造船修船,买船租船方面的相关信息,致力于帮助行业内客户及时了解船厂,船东,配套商的相关动态,及时发布造船,新船,二手船,废钢船等的相关最新信息,为客户提供一个最好的船舶行业门户网站,为船舶行业发展奋斗'; return $info; } //频道页焦点图 private function get_channel_focpic(){ $key=__FUNCTION__; $data=mcache_get($key); if($data) return $data; $sql="select `es_news`.`title`,`es_news`.`id`,`es_news`.`thumb` from `es_position_data`,`es_news` where `es_position_data`.`posid`='13' and `es_position_data`.`siteid`='1' and `es_position_data`.`id`=`es_news`.`id` order by `es_position_data`.`listorder` desc limit 5"; $data=$this->query($sql,'select'); mcache_set($key,$data,60*15); return $data; } //频道页船舶建造 private function get_channel_jianzao($n){ $key=__FUNCTION__.$n; $data=mcache_get($key); if(!$data){ $data=$this->field('id,title,thumb,inputtime')->where(array('catid'=>array(780,781,785,786,787,788,789,790,791,792,793,847),'status'=>99))->order('inputtime desc')->limit($n)->select(); mcache_set($key,$data,60*15); } return $data; } //频道页船舶营运 private function get_channel_yingyun($n){ $key=__FUNCTION__.$n; $data=mcache_get($key); if(!$data){ $data=$this->field('id,title,thumb,inputtime')->where(array('catid'=>array(800,801,803,804,805,806,807,808,809,810),'status'=>99))->order('inputtime desc')->limit($n)->select(); mcache_set($key,$data,60*15); } return $data; } //频道页综合 private function get_channel_zonghe($n){ $key=__FUNCTION__.$n; $data=mcache_get($key); if(!$data){ $data=$this->field('id,title,thumb,inputtime')->where(array('catid'=>array(812,813,814,815,816,817,818,819,820,821,822,823,802,845),'status'=>99))->order('inputtime desc')->limit($n)->select(); mcache_set($key,$data,60*15); } return $data; } //频道页交易 private function get_channel_jiaoyi($n){ $key=__FUNCTION__.$n; $data=mcache_get($key); if(!$data){ $data=$this->field('id,title,thumb,inputtime')->where(array('catid'=>array(794,795,796,797,798,799),'status'=>99))->order('inputtime desc')->limit($n)->select(); mcache_set($key,$data,60*15); } return $data; } //新闻二级频道--新船建造 public function pindao_jianzao(){ $info['ccdt']=$this->get_type_news(780); $info['xqdd']=$this->get_type_news(781); $info['cdgd']=$this->get_type_news(785); $info['zjxc']=$this->get_type_news(786); $info['cbsj']=$this->get_type_news(787); $info['xcsc']=$this->get_type_news(788); $info['ptsdt']=$this->get_type_news(789); $info['cbsc']=$this->get_type_news(790); $info['cjdt']=$this->get_type_news(791); $info['cpsc']=$this->get_type_news(847); $info['gwzc']=$this->get_type_news(792); $info['dfzc']=$this->get_type_news(793); $info['ddtj']=$this->get_type_news(2547); $info['title']='船舶建造频道'; $info['keywords']=''; $info['description']=''; return $info; } //新闻二级频道--船市交易 public function pindao_jiaoyi(){ $info['escsc']=$this->get_type_news(794); $info['escdt']=$this->get_type_news(795); $info['zcsc']=$this->get_type_news(796); $info['zcdt']=$this->get_type_news(797); $info['fgcsc']=$this->get_type_news(798); $info['fgcdt']=$this->get_type_news(799); $info['title']='船舶交易频道'; $info['keywords']=''; $info['description']=''; return $info; } //新闻二级频道--船舶营运 public function pindao_yingyun(){ $info['cddt']=$this->get_type_news(800); $info['xcyy']=$this->get_type_news(801); $info['cbyl']=$this->get_type_news(803); $info['zhcdt']=$this->get_type_news(804); $info['gkcx']=$this->get_type_news(805); $info['hxbh']=$this->get_type_news(806); $info['sysc']=$this->get_type_news(807); $info['yysc']=$this->get_type_news(808); $info['jysc']=$this->get_type_news(809); $info['hgsc']=$this->get_type_news(810); $info['title']='船舶营运频道'; $info['keywords']=''; $info['description']=''; return $info; } //新闻二级频道--综合 public function pindao_zonghe(){ $info['zhxw']=$this->get_type_news(812); $info['cjs']=$this->get_type_news(813); $info['dfhs']=$this->get_type_news(814); $info['cbjr']=$this->get_type_news(815); $info['jcfy']=$this->get_type_news(816); $info['zhxx']=$this->get_type_news(817); $info['csgc']=$this->get_type_news(818); $info['xxcb']=$this->get_type_news(819); $info['dfcj']=$this->get_type_news(820); $info['cjrw']=$this->get_type_news(821); $info['cgpl']=$this->get_type_news(822); $info['cxnw']=$this->get_type_news(823); $info['wxgz']=$this->get_type_news(802); $info['ccdt']=$this->get_type_news(845); $info['title']='综合频道'; $info['keywords']=''; $info['description']=''; return $info; } //新闻内容页 public function article_show(){ $newsid=intval(I('id')); $info['show']=$this->field('id,catid,title,keywords,thumb,description,inputtime')->where(array('status'=>99,'id'=>$newsid))->find(); $u=D('news_data')->field('content,copyfrom')->where(array('id'=>$newsid))->find(); $info['show']['content']=str_replace('[page]','',$u['content']); $str=str_replace('|0','',$u['copyfrom']); $info['show']['copyfrom']=str_replace('|1','国际船舶网',$str); $relation=$this->tags( explode(',',$info['show']['keywords'])); $info['xgyd']=$relation['data']; $info['newsjianzao']=$this->get_channel_jianzao(5); $info['newsyingyun']=$this->get_channel_yingyun(5); $info['newsjiaoyi']=$this->get_channel_jiaoyi(5); $info['newszonghe']=$this->get_channel_zonghe(5); $info['show']['catname']=catname($info['show']['catid']); unset($u); return $info; } /*小程序新闻内容页*/ public function xcx_article_show(){ $newsid=intval(I('id')); $info['show']=$this->field('id,catid,title,keywords,thumb,description,inputtime')->where(array('status'=>99,'id'=>$newsid))->find(); $u=D('news_data')->field('content,copyfrom')->where(array('id'=>$newsid))->find(); $info['show']['content']=str_replace('[page]','',$u['content']); $str=str_replace('|0','',$u['copyfrom']); $info['show']['copyfrom']=str_replace('|1','国际船舶网',$str); $info['xgyd']= $this->xcx_getxgyd($info['show']['catid']); $info['show']['catname']=catname($info['show']['catid']); unset($u); return $info; } /*小程序相关阅读,同栏目下内容*/ private function xcx_getxgyd($catid){ $sql="select * from es_news WHERE `catid`={$catid} AND `status` = 99 ORDER BY `updatetime` DESC limit 10"; $data = $this->query($sql,'select'); return $data; } private function tags($keywords,$limit=5,$page=1){ $keywords=is_array ($keywords)? array_map("strtolower",$keywords):$keywords; $get_tag_list=tpinterface('search_tags',array('data'=>$keywords,'limit'=>$limit=5,'page'=>$page )); $result=json_decode($get_tag_list,true); return $result; } public function search_news(){ $page = intval($_GET['page']); $page = $page <1? 1:$page ; $search_kind=htmlspecialchars(I('search_kind')); $search_keyword=I('search_keyword'); $search_keyword=htmlspecialchars(trim($search_keyword)); $get_tag_list=tpinterface('search_news',array('query'=>strtolower($search_keyword),'limit'=>20,'page'=>$page )); $result=json_decode($get_tag_list,true); import('wpage'); $page=new Wpage($result['total'],true); $info['list']=$result['data']; $info['page']=$page->show(); $info['total']=$result['total']; $info['key']=$search_keyword; return $info; } /*查询文章标题和 url gjq2019-03-26*/ public function get_pinglun_api($catid,$contentid){ $sql = "select `title`,`url` from `es_news` WHERE `catid`={$catid} AND `id`={$contentid}"; $res = $this->query($sql,'select'); $r = $res[0]; $res2 = $sql = "select * from `es_news_data` WHERE `id`={$contentid}"; $data_info = $res2[0]; if ($r) { return array('title'=>$r['title'], 'url'=>$r['url'],'allow_comment'=>(isset($data_info['allow_comment']) ? $data_info['allow_comment'] : 1)); } else { return false; } } }