示例#1
0
 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
 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
 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);
 }
示例#4
0
 /**
  * 婚庆列表
  */
 public function actionIndex()
 {
     $this->selectedType = zmf::filterInput($_GET['type']);
     if (!$this->selectedType || !in_array($this->selectedType, array('1', '2'))) {
         $this->selectedType = '1';
     }
     if ($this->selectedType == 1) {
         //用户
         $criteria = new CDbCriteria();
         $criteria->condition = 'classify=' . Users::USER_CLASSIFY_WEDDING;
         $criteria->select = 'id,truename,avatar,sex,tagids,content';
         //            $criteria->order = 'cTime DESC';
         $count = Users::model()->count($criteria);
         $pager = new CPagination($count);
         $pager->pageSize = 30;
         $pager->applyLimit($criteria);
         $posts = Users::model()->findAll($criteria);
         if (!empty($posts)) {
             foreach ($posts as $k => $val) {
                 $posts[$k]['avatarImg'] = Users::getAvatar($val['avatar']);
                 $posts[$k]['tagids'] = Tags::getByIds($val['tagids']);
             }
         }
     } elseif ($this->selectedType == 2) {
         //团队
         $criteria = new CDbCriteria();
         $criteria->order = 'cTime DESC';
         $count = WeddingGroup::model()->count($criteria);
         $pager = new CPagination($count);
         $pager->pageSize = 30;
         $pager->applyLimit($criteria);
         $posts = WeddingGroup::model()->findAll($criteria);
         if (!empty($posts)) {
             foreach ($posts as $k => $val) {
                 $posts[$k]['avatar'] = Users::getAvatar($val['avatar']);
             }
         }
     }
     //面包屑
     $breads[] = CHtml::link('婚庆', array('group/index'));
     $this->pageTitle = '婚礼人 - ' . zmf::config('sitename');
     $this->render('index', array('pages' => $pager, 'posts' => $posts, 'breads' => $breads));
 }
示例#5
0
 public function actionCreate($id = '')
 {
     $this->layout = 'common';
     $id = zmf::myint($id);
     if (!$this->uid) {
         $this->redirect(array('site/login'));
     }
     if ($id) {
         $model = $this->loadModel($id);
         $isNew = false;
     } else {
         $model = new Posts();
         $isNew = true;
     }
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'posts-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     if (isset($_POST['Posts'])) {
         //处理文本
         $filter = Posts::handleContent($_POST['Posts']['content']);
         $_POST['Posts']['content'] = $filter['content'];
         if (!empty($filter['attachids'])) {
             $attkeys = array_filter(array_unique($filter['attachids']));
             if (!empty($attkeys)) {
                 $_POST['Posts']['faceimg'] = $attkeys[0];
                 //默认将文章中的第一张图作为封面图
             }
         } else {
             $_POST['Posts']['faceimg'] = '';
             //否则将封面图置为空(有可能编辑后没有图片了)
         }
         if (!$_POST['Posts']['mapZoom']) {
             //没有缩放级别则认为用户只是点开看了一下
             $_POST['Posts']['lat'] = $_POST['Posts']['long'] = '';
         }
         $tagids = array_unique(array_filter($_POST['tags']));
         $model->attributes = $_POST['Posts'];
         if ($model->save()) {
             //将上传的图片置为通过
             Attachments::model()->updateAll(array('status' => Posts::STATUS_DELED), 'logid=:logid AND classify=:classify', array(':logid' => $model->id, ':classify' => 'posts'));
             if (!empty($attkeys)) {
                 $attstr = join(',', $attkeys);
                 if ($attstr != '') {
                     Attachments::model()->updateAll(array('status' => Posts::STATUS_PASSED, 'logid' => $model->id), 'id IN(' . $attstr . ')');
                 }
             }
             //处理标签
             $intoTags = array();
             if (!empty($tagids)) {
                 foreach ($tagids as $tagid) {
                     $_info = Tags::addRelation($tagid, $model->id, 'posts');
                     if ($_info) {
                         $intoTags[] = $tagid;
                     }
                 }
             }
             if (!$isNew || !empty($intoTags)) {
                 Posts::model()->updateByPk($model->id, array('tagids' => join(',', $intoTags)));
             }
             if ($model->status == Posts::STATUS_NOTPASSED) {
                 $this->redirect(array('posts/index'));
             } else {
                 $this->redirect(array('/posts/view', 'id' => $model->id));
             }
         }
     }
     $tags = Tags::getClassifyTags('posts');
     $postTags = array();
     if (!$isNew) {
         $postTags = Tags::getByIds($model->tagids);
     }
     $this->pageTitle = '与世界分享你的旅行见闻 - ' . zmf::config('sitename');
     $this->render('create', array('model' => $model, 'tags' => $tags, 'postTags' => $postTags));
 }