コード例 #1
0
ファイル: UsersController.php プロジェクト: ph7pal/wedding
 function init()
 {
     parent::init();
     $this->layout = '/layouts/user';
     $this->currentModule = 'user';
     if ($this->isMobile == 'yes') {
         $this->message(0, '感谢你的支持!本页面暂还在拼命制作中...');
     }
     $this->uid = zmf::filterInput($_GET['id']);
     if (!$this->uid) {
         $this->uid = zmf::uid();
     }
     if (!$this->uid) {
         $this->redirect(array('site/login'));
     }
     if ($this->uid == zmf::uid()) {
         $this->mySelf = 'yes';
     }
     if ($this->mySelf != 'yes') {
         if (zmf::uid()) {
             $_favorinfo = Favorites::checkFavored($this->uid, 'user');
             if ($_favorinfo) {
                 $this->favored = true;
             }
         }
     }
     $this->userInfo = Users::getUserInfo($this->uid);
     if ($this->userInfo['tagids'] != '') {
         $this->userTags = Tags::getByIds($this->userInfo['tagids']);
     }
     $this->pageTitle = $this->userInfo['truename'] . ' - ' . zmf::config('sitename');
     $this->pageDescription = $this->userInfo['truename'] . '的【' . zmf::config('sitename') . '】的个人主页,包括TA的原创文章、精美图片及各类悉心收藏,快来看看吧!';
 }
コード例 #2
0
ファイル: PostsController.php プロジェクト: ph7pal/momo
 public function actionView()
 {
     $id = zmf::val('id', 2);
     if (!$id) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $info = $this->loadModel($id);
     $pageSize = 30;
     $comments = Comments::getCommentsByPage($id, 'posts', 1, $pageSize);
     $tags = Tags::getByIds($info['tagids']);
     $relatePosts = Posts::getRelations($id, 5);
     if (!zmf::actionLimit('visit-Posts', $id, 5, 60)) {
         Posts::updateCount($id, 'Posts', 1, 'hits');
     }
     $size = '600';
     if ($this->isMobile) {
         $size = '640';
     }
     $info['content'] = zmf::text(array(), $info['content'], true, $size);
     $data = array('info' => $info, 'comments' => $comments, 'tags' => $tags, 'relatePosts' => $relatePosts, 'loadMore' => count($comments) == $pageSize ? 1 : 0);
     $this->favorited = Favorites::checkFavored($id, 'post');
     $this->pageTitle = $info['title'];
     $this->selectNav = 'posts';
     $this->render('view', $data);
 }
コード例 #3
0
ファイル: favorite.php プロジェクト: ph7pal/wedding
<?php

$favorited = false;
if (Favorites::checkFavored($keyid, $type)) {
    $css = "favorited";
    $title = zmf::t('cancelFavorite');
    $favorited = true;
} else {
    $css = "";
    $title = zmf::t('favorite');
}
echo CHtml::link('<span class="icon-thumbs-up"></span> 赞', 'javascript:;', array('class' => 'btn btn-xs btn-' . ($_favored ? 'success' : 'default'), 'action' => 'favor', 'action-data' => $keyid, 'action-type' => 'posts', 'id' => 'favor-posts-' . $keyid));
echo CHtml::link('<span class="icon-heart"></span> 收藏', 'javascript:;', array('class' => 'btn btn-xs btn-' . ($favorited ? 'danger' : 'default'), 'action' => 'favorite', 'action-data' => $keyid, 'action-type' => 'posts'));
コード例 #4
0
ファイル: PostsController.php プロジェクト: ph7pal/wedding
 public function actionView($id)
 {
     $keyid = zmf::filterInput($id);
     $checkInfo = Posts::checkInfo($info, $keyid, 'posts');
     if (!$checkInfo['status']) {
         $this->message(0, $checkInfo['msg']);
     }
     if ($info['redirect'] != '') {
         $this->redirect(zmf::config('domain') . $info['redirect'], true, 301);
     }
     if ($info['classify'] == Posts::CLASSIFY_BLOG) {
         $this->redirect(zmf::config('blog_domain') . '/post/' . $keyid . '.html', true, 301);
     }
     $groupInfo = array();
     if ($info['groupid'] > 0) {
         $groupInfo = WeddingGroup::getOne($info['groupid']);
         if ($groupInfo['status'] != Posts::STATUS_PASSED) {
             $this->message(0, '该团队已不存在');
         }
         $groupInfo['avatar'] = Users::getAvatar($groupInfo['avatar']);
     }
     $keyid = $info['id'];
     $this->currentColid = $info['colid'];
     $colinfo = Column::getSimpleInfo($info['colid']);
     $breads[] = CHtml::link('作品', array('posts/index'));
     if ($colinfo) {
         $breads[] = CHtml::link($colinfo['title'], array('posts/index', 'colid' => $colinfo['id']));
     }
     //更新统计
     Posts::updateCount($keyid, 'Posts');
     //获取用户推荐文章
     $sqlUser = "******" . Posts::CLASSIFY_WEDDING . " ORDER BY hits DESC LIMIT 5";
     $userPosts = Yii::app()->db->createCommand($sqlUser)->queryAll();
     //获取标签
     $info['tagids'] = join(',', explode(',', $info['tagids']));
     $relPosts = array();
     if ($info['tagids'] != '') {
         //获取与本文类似文章
         //计算方法为与本文提到的标签相关文章出现次数最多的
         $relPosts = Posts::getTopPostsByTags($id, $info['tagids']);
         $_sql = "SELECT id,title FROM {{tags}} WHERE classify='posts' AND id IN({$info['tagids']})";
         $info['tagids'] = Yii::app()->db->createCommand($_sql)->queryAll();
     }
     if (!empty($userPosts)) {
         foreach ($userPosts as $k => $p) {
             if ($p['faceimg'] > 0) {
                 $_attach = Attachments::getOne($p['faceimg']);
                 $_url = Attachments::getUrl($_attach);
                 $userPosts[$k]['faceimg'] = $_url;
             } else {
                 $userPosts[$k]['faceimg'] = '';
             }
         }
     }
     if (!empty($relPosts)) {
         foreach ($relPosts as $k => $p) {
             if ($p['faceimg'] > 0) {
                 $_attach = Attachments::getOne($p['faceimg']);
                 $_url = Attachments::getUrl($_attach);
                 $relPosts[$k]['faceimg'] = $_url;
             } else {
                 $relPosts[$k]['faceimg'] = '';
             }
         }
     }
     //判断是否已收藏和赞过
     if (!Yii::app()->user->isGuest) {
         if (Favorites::checkFavored($keyid, 'posts')) {
             $this->favorited = true;
         }
         if (UserAction::checkAction($keyid, 'favorPost')) {
             $this->favored = true;
         }
     }
     $breads[] = $info['title'];
     $data = array('colinfo' => $colinfo, 'data' => $info, 'breads' => $breads, 'userPosts' => $userPosts, 'relPosts' => $relPosts, 'groupInfo' => $groupInfo);
     $this->pageTitle = (!empty($colinfo) ? "【{$colinfo['title']}】" : '') . $info['title'] . ' - ' . zmf::config('sitename');
     $this->render('view', $data);
 }
コード例 #5
0
ファイル: PositionController.php プロジェクト: ph7pal/wedding
 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));
 }
コード例 #6
0
ファイル: AjaxController.php プロジェクト: ph7pal/wedding
 /**
  * 卡片,包括用户及提到的坐标
  */
 public function actionCard()
 {
     $type = zmf::filterInput($_GET['type'], 't', 1);
     $id = zmf::filterInput($_POST['id']);
     if (!$type || !$id) {
         $this->jsonOutPut(0, '缺少参数');
     }
     if ($type == 'user') {
         $info = Users::getUserInfo($id);
         if (!$info) {
             $this->jsonOutPut(0, '用户不存在');
         }
         if ($id == zmf::uid()) {
             $itself = 1;
         } else {
             $itself = 0;
         }
         $favored = 0;
         if (zmf::uid() && $id != zmf::uid()) {
             $_info = Favorites::checkFavored($id, 'user');
             if ($_info) {
                 $favored = 1;
             }
         }
         $count = Users::getCounts($id, $info);
         $data = array('avatar' => zmf::avatar($id, 'small', true), 'userurl' => Yii::app()->createUrl('users/index', array('id' => $id)), 'username' => $info['truename'], 'posts' => $count['posts'], 'answers' => $count['answers'], 'tips' => $count['tips'], 'reputation' => $info['reputation'], 'badge' => $info['badge'], 'itself' => $itself, 'favored' => $favored, 'uid' => $id, 'desc' => $info['desc'], 'p_url' => Yii::app()->createUrl('users/index', array('id' => $id, 'type' => 'posts')), 'a_url' => Yii::app()->createUrl('users/index', array('id' => $id, 'type' => 'answer')), 't_url' => Yii::app()->createUrl('users/index', array('id' => $id, 'type' => 'tips')));
     }
     $this->jsonOutPut(1, $data);
 }