public function actionIndex() { $tagid = zmf::val('tagid', 2); $tagInfo = array(); $default = true; if ($tagid) { $tagInfo = Tags::getByIds($tagid); if ($tagInfo) { $default = false; $tagInfo = $tagInfo[0]; $sql = "SELECT p.id,p.uid,p.title,p.faceimg,p.content,p.tagids,p.comments,p.favorite FROM {{posts}} p,{{tag_relation}} tr WHERE tr.tagid='{$tagid}' AND tr.classify='posts' AND tr.logid=p.id AND p.`status`=" . Posts::STATUS_PASSED . " ORDER BY p.cTime DESC"; } } if ($default) { $sql = 'SELECT id,uid,title,faceimg,content,tagids,comments,favorite FROM {{posts}} WHERE `status`=1 ORDER BY cTime DESC'; } Posts::getAll(array('sql' => $sql), $pages, $posts); $size = '640'; if ($this->isMobile) { $size = '240'; } foreach ($posts as $k => $val) { if ($val['tagids'] != '') { $_tags = Tags::getByIds($val['tagids']); $posts[$k]['tagids'] = $_tags; } $posts[$k]['faceimg'] = Attachments::faceImg($val, $size); } $this->pageTitle = '文章 - ' . zmf::config('sitename'); $this->selectNav = 'posts'; $data = array('posts' => $posts, 'tagInfo' => $tagInfo, 'pages' => $pages); $this->render('/index/index', $data); }
$_secondTitle = $data['title_en'] ? $data['title_en'] : $data['title_local']; } elseif ($data['title_en'] != '') { $_title = $data['title_en']; $_secondTitle = $data['title_local']; } else { $_title = $data['title_local']; } $_address = ''; if ($data['address_cn'] != '') { $_address = $data['address_cn']; } elseif ($data['address_en'] != '') { $_address = $data['address_en']; } else { $_address = $data['address_local']; } $faceimg = Attachments::faceImg($data, 170); $url = array('position/view', 'id' => $data['id']); ?> <div class="media poi-list"><?php $this->renderPartial('/common/_faceimg', array('img' => $faceimg, 'title' => $_title, 'id' => $data['id'], 'acss' => 'media-object lazy', 'lcss' => 'media-left', 'classify' => $data['classify'], 'width' => 170, 'url' => $url)); ?> <div class="media-body"><h4 class="media-heading"><?php echo CHtml::link(CHtml::encode($_title), array('position/view', 'id' => $data['id'])); ?> </h4><p class="color-grey"><?php echo $_secondTitle; ?> </p><p class="color-grey"><?php echo CHtml::encode($_address); if ($data['lat'] && $data['long']) { echo CHtml::link('(地图)', array('position/map', 'id' => $data['id']), array('title' => $_title . '的地图'));
public function actionView($id) { $id = zmf::filterInput($id); $info = $this->loadModel($id); if ($info['redirect'] > 0) { $this->redirect(array('position/view', 'id' => $info['redirect'])); } $_title = ''; if ($info['title_cn'] != '') { $_title = $info['title_cn']; } if ($info['title_en'] != '' && $_title != '') { $_title .= '(' . $info['title_en'] . ')'; } elseif ($info['title_local'] && $_title != '') { $_title .= '(' . $info['title_local'] . ')'; } elseif ($info['title_en'] != '') { $_title .= $info['title_en']; } else { $_title .= $info['title_local']; } $_address = ''; if ($info['address_cn'] != '') { $_address = $info['address_cn']; } elseif ($info['address_en'] != '') { $_address = $info['address_en']; } else { $_address = $info['address_local']; } if (!Yii::app()->user->isGuest) { if (Favorites::checkFavored($id, 'poi')) { $this->favorited = true; } $tipinfo = PoiPost::model()->findByAttributes(array('logid' => $id, 'uid' => Yii::app()->user->id), 'status=' . Posts::STATUS_PASSED); if ($tipinfo) { $this->tiped = $tipinfo; } } $info->faceimg = Attachments::faceImg($info, 600); //获取图片 $images = Attachments::model()->findAll(array('condition' => "logid=:id AND " . ($info['faceimg'] > 0 ? "id!=" . $info['faceimg'] . ' AND ' : '') . " classify='poi' AND status=" . Posts::STATUS_PASSED, 'select' => 'id,filePath,classify,cTime', 'limit' => 6, 'order' => 'favor DESC', 'params' => array(':id' => $id))); $breads = array(); $breads[] = CHtml::link('目的地', array('position/index')); if ($info['areaid']) { $areaInfo = Area::model()->findByPk($info['areaid']); if ($areaInfo) { $breads[] = CHtml::link($areaInfo['title'], array('position/index', 'areaid' => $areaInfo['id'])); } } //获取购买地址 $buylinks = array(); if ($info['classify'] == Position::HOTEL) { $buylinks = Buylink::getAll('poi', $info->id); } //更新访问统计 Posts::updateCount($id, 'Position'); $breads[] = $_title; $this->pageTitle = $_title . ' - ' . zmf::config('sitename'); $this->pageDescription = '【' . $_title . '】位于' . $_address . ',' . zmf::subStr($info['content'], 200); $this->render('view', array('info' => $info, 'type' => $type, 'breads' => $breads, 'buylinks' => $buylinks, 'images' => $images)); }