Beispiel #1
0
 public function actionView($id)
 {
     $id = zmf::filterInput($id);
     if (!$id || !is_numeric($id)) {
         throw new CHttpException(404, '你所查看的页面不存在.');
     }
     $info = Naodong::model()->findByPk($id);
     if ($info == NULL) {
         throw new CHttpException(404, '你所查看的页面不存在.');
     }
     //更新访问次数
     Posts::updateCount($id, 'Naodong');
     //获取评论列表
     $sql = "SELECT * FROM {{comments}} WHERE logid='{$id}' AND classify='naodong' AND status=" . Posts::STATUS_PASSED . " ORDER BY cTime ASC";
     Posts::getAll(array('sql' => $sql, 'pageSize' => 2), $pages, $comLists);
     //获取上下篇
     $preInfo = Naodong::model()->find(array('condition' => 'id>:id AND status=' . Posts::STATUS_PASSED, 'select' => 'id,title', 'params' => array(':id' => $id)));
     $nextInfo = Naodong::model()->find(array('condition' => 'id<:id AND status=' . Posts::STATUS_PASSED, 'select' => 'id,title', 'params' => array(':id' => $id)));
     $authorInfo = $recommends = array();
     if ($info['uid']) {
         //获取作者信息
         $authorInfo = Users::getUserInfo($info['uid']);
         //获取作者相关推荐
         $recommends = Naodong::getRecommends($info['uid'], $id);
     }
     //获取是否赞过
     if ($this->uid) {
         if (UserAction::checkAction($id, 'favorNaodong')) {
             $this->favored = true;
         }
     }
     $data = array('info' => $info, 'posts' => $comLists, 'pages' => $pages, 'userInfo' => $authorInfo, 'recommends' => $recommends, 'preInfo' => $preInfo, 'nextInfo' => $nextInfo);
     $this->pageTitle = $info['title'] . ' - ' . zmf::config('sitename');
     $this->pageDescription = zmf::subStr($info['content'], 140);
     $this->mobileTitle = $authorInfo['truename'];
     $this->render('/index/view', $data);
 }
Beispiel #2
0
 /**
  * 问题的赞成反对及其他点赞
  */
 public function actionFavor()
 {
     //        Users::checkPower('favor');
     $type = zmf::filterInput($_POST['type'], 't', 1);
     $keyid = zmf::filterInput($_POST['keyid']);
     if (!$keyid) {
         $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
     }
     if (!isset($type) or empty($type) or !in_array($type, array('naodong'))) {
         //Forbidden::updateTimes();
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     if (zmf::actionLimit('favor-' . $type, $keyid)) {
         $this->jsonOutPut(0, '操作太频繁,请稍后再试');
     }
     if ($type == 'naodong') {
         $classify = 'favorNaodong';
         $model = new Naodong();
         $field = 'favors';
     }
     if (!$model) {
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     $info = $model->findByPk($keyid);
     if (!$info) {
         $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
     } elseif ($info['status'] != Posts::STATUS_PASSED) {
         $this->jsonOutPut(0, '您操作的内容正在审核或已删除');
     }
     //        elseif ($info['uid'] == zmf::uid()) {
     //            $this->jsonOutPut(0, '不能操作自己的哦~');
     //        }
     if (UserAction::checkAction($keyid, $classify)) {
         if (UserAction::delAction($keyid, $classify)) {
             if ($field) {
                 $model->updateCounters(array($field => -1), 'id=:id', array(':id' => $keyid));
             }
             $this->jsonOutPut(3, '取消赞成功');
         } else {
             $this->jsonOutPut(0, '取消赞失败');
         }
     } else {
         if (UserAction::recordAction($keyid, $classify, $info['uid'])) {
             if ($field) {
                 if ($model->updateCounters(array($field => 1), 'id=:id', array(':id' => $keyid))) {
                     if ($type == 'naodong') {
                         $_url = CHtml::link('查看详情', array('index/view', 'id' => $keyid));
                         $_content = '您的作品有了新的赞,' . $_url;
                         $toNotice = true;
                     }
                     if ($toNotice) {
                         $_noticedata = array('uid' => $info['uid'], 'authorid' => $this->uid, 'content' => $_content, 'new' => 1, 'type' => 'favor', 'cTime' => zmf::now(), 'from_id' => $keyid, 'from_num' => 1);
                         Notification::add($_noticedata);
                     }
                 }
             }
             $this->jsonOutPut(1, '添加赞成功');
         } else {
             $this->jsonOutPut(0, '添加赞失败');
         }
     }
 }
Beispiel #3
0
<?php

$_uname = Users::getUserInfo($data['uid'], 'truename');
$_favored = false;
if (!Yii::app()->user->isGuest) {
    if (UserAction::checkAction($data['id'], 'favor' . $type)) {
        $_favored = true;
    }
}
$_imgsize = isset($imgsize) ? $imgsize : 170;
$formatTime = '';
if ($data['lastupdate'] > $data['cTime']) {
    $formatTime = '更新于' . tools::formatTime($data['lastupdate']);
} else {
    $formatTime = tools::formatTime($data['cTime']);
}
?>
<div class="media <?php 
echo $noborder == 'yes' ? '' : 'zmf-border-bottom';
?>
">
    <div class="media-left">
        <?php 
$this->renderPartial('/common/_user', array('uid' => $data['uid'], 'uname' => $_uname, 'type' => 'a'));
?>
        <br/>
        <?php 
echo CHtml::link($data['favor'], 'javascript:;', array('title' => '此点评对我有帮助', 'class' => 'btn btn-xs btn-' . ($_favored ? 'success' : 'default') . ' btn-block', 'action' => 'favor', 'action-data' => $data['id'], 'action-type' => $type, 'id' => 'favor-' . $type . '-' . $data['id']));
?>
    </div>
    <div class="media-body poi-tips-body">
Beispiel #4
0
<?php

$_userInfo = Users::getUserInfo($data['uid']);
$_favored = false;
if (!Yii::app()->user->isGuest) {
    if (UserAction::checkAction($data['id'], 'favorPost')) {
        $_favored = true;
    }
}
$formatTime = '';
if ($data['updateTime'] > $data['cTime']) {
    $formatTime = '编辑于' . tools::formatTime($data['updateTime']);
} else {
    $formatTime = tools::formatTime($data['cTime']);
}
$title = '';
if ($data['coltitle']) {
    $title = '【' . $data['coltitle'] . '】' . $data['title'];
} else {
    $title = $data['title'];
}
?>
<div class="media zmf-border-bottom">
    <div class="media-left">
        <?php 
$this->renderPartial('/common/_user', array('uid' => $data['uid'], 'userInfo' => $_userInfo, 'type' => 'a'));
?>
<br/>
        <?php 
echo CHtml::link($data['favors'], 'javascript:;', array('title' => '赞', 'class' => 'btn btn-xs btn-' . ($_favored ? 'success' : 'default') . ' btn-block', 'action' => 'favor', 'action-data' => $data['id'], 'action-type' => 'post', 'id' => 'favor-post-' . $data['id']));
?>
Beispiel #5
0
<?php

$_uname = Users::getUserInfo($data['uid'], 'truename');
$_favored = $_dislike = false;
if (!Yii::app()->user->isGuest) {
    if (UserAction::checkAction($data['id'], 'favorAnswer')) {
        $_favored = true;
    } elseif (UserAction::checkAction($data['id'], 'dislikeAnswer')) {
        $_dislike = true;
    }
}
$formatTime = '';
if ($data['lastupdate'] > $data['cTime']) {
    $formatTime = '编辑于' . tools::formatTime($data['lastupdate']);
} else {
    $formatTime = tools::formatTime($data['cTime']);
}
?>
<div class="media <?php 
if ($border != 'no') {
    echo 'zmf-border-bottom';
}
?>
">
    <div class="media-left" id="answer-feedback-<?php 
echo $data['id'];
?>
">
        <?php 
echo CHtml::link('<span class="icon-sort-up answer-feedback-btn"></span>' . $data['favor'], 'javascript:;', array('title' => '此回答对我有帮助', 'class' => 'btn btn-xs btn-' . ($_favored ? 'success' : 'default') . ' btn-block btn-answer answer-useful', 'action' => 'favor', 'action-data' => $data['id'], 'action-type' => 'answer', 'id' => 'favor-answer-' . $data['id']));
?>
Beispiel #6
0
 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);
 }
Beispiel #7
0
 /**
  * 问题的赞成反对及其他点赞
  */
 public function actionFavor()
 {
     Users::checkPower('favor');
     $type = zmf::filterInput($_POST['type'], 't', 1);
     $keyid = zmf::filterInput($_POST['keyid']);
     if (!$keyid) {
         $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
     }
     if (!isset($type) or empty($type) or !in_array($type, array('post', 'image', 'poipost', 'poitips', 'answer', 'dislike-answer', 'goods'))) {
         //Forbidden::updateTimes();
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     if (zmf::actionLimit('favor-' . $type, $keyid)) {
         $this->jsonOutPut(0, '操作太频繁,请稍后再试');
     }
     if ($type == 'image') {
         $classify = 'favorImg';
         $model = new Attachments();
         $field = 'favor';
     } elseif ($type == 'post') {
         $classify = 'favorPost';
         $model = new Posts();
         $field = 'favors';
     } elseif ($type == 'poipost') {
         $classify = 'favorPoiPost';
         $model = new PoiPost();
         $field = 'favor';
     } elseif ($type == 'poitips') {
         $classify = 'favorPoiTips';
         $model = new PoiTips();
         $field = 'favor';
     } elseif ($type == 'answer') {
         $classify = 'favorAnswer';
         $model = new Answer();
         $field = 'favor';
     } elseif ($type == 'dislike-answer') {
         $classify = 'dislikeAnswer';
         $model = new Answer();
         $field = 'nouse';
     } elseif ($type == 'goods') {
         $classify = 'goods';
         $model = new Goods();
         $field = 'favors';
     }
     if (!$model) {
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     $info = $model->findByPk($keyid);
     if (!$info) {
         $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
     } elseif ($info['status'] != Posts::STATUS_PASSED) {
         $this->jsonOutPut(0, '您操作的内容正在审核或已删除');
     } elseif ($info['uid'] == zmf::uid()) {
         $this->jsonOutPut(0, '不能操作自己的哦~');
     }
     if ($type == 'answer' || $type == 'dislike-answer') {
         if ($type == 'answer') {
             if (UserAction::checkAction($keyid, 'dislikeAnswer')) {
                 UserAction::delAction($keyid, 'dislikeAnswer');
                 $model->updateCounters(array('nouse' => -1), 'id=:id', array(':id' => $keyid));
             }
         } else {
             if (UserAction::checkAction($keyid, 'favorAnswer')) {
                 UserAction::delAction($keyid, 'favorAnswer');
                 $model->updateCounters(array('favor' => -1), 'id=:id', array(':id' => $keyid));
             }
         }
     }
     if (UserAction::checkAction($keyid, $classify)) {
         if (UserAction::delAction($keyid, $classify)) {
             if ($field) {
                 $model->updateCounters(array($field => -1), 'id=:id', array(':id' => $keyid));
             }
             $this->jsonOutPut(3, '取消赞成功');
         } else {
             $this->jsonOutPut(0, '取消赞失败');
         }
     } else {
         if (UserAction::recordAction($keyid, $classify, $info['uid'])) {
             if ($field) {
                 $model->updateCounters(array($field => 1), 'id=:id', array(':id' => $keyid));
             }
             $this->jsonOutPut(1, '添加赞成功');
         } else {
             $this->jsonOutPut(0, '添加赞失败');
         }
     }
 }