Beispiel #1
0
 public function actionIndex()
 {
     if ($this->mySelf == 'yes') {
         $sql = "SELECT id,title,faceimg,uid,colid,cTime,updateTime FROM {{posts}} WHERE (uid='{$this->uid}' OR uid IN(SELECT logid FROM {{favorites}} WHERE uid='{$this->uid}' AND classify='user')) AND classify='" . Posts::CLASSIFY_WEDDING . "' ORDER BY cTime DESC";
     } else {
         $sql = "SELECT id,title,faceimg,uid,colid,cTime,updateTime FROM {{posts}} WHERE uid='{$this->uid}' AND classify='" . Posts::CLASSIFY_WEDDING . "' ORDER BY cTime DESC";
     }
     Posts::getAll(array('sql' => $sql), $pages, $lists);
     if (!empty($lists)) {
         foreach ($lists as $k => $p) {
             if ($p['faceimg'] > 0) {
                 $_attach = Attachments::getOne($p['faceimg']);
                 $_url = Attachments::getUrl($_attach);
                 $lists[$k]['faceimg'] = $_url;
             } else {
                 $lists[$k]['faceimg'] = '';
             }
         }
     }
     if ($this->mySelf != 'yes') {
         Posts::updateCount($this->uid, 'Users');
     }
     $data = array('posts' => $lists, 'pages' => $pages);
     $this->pageTitle = $this->userInfo['truename'] . '的主页 - ' . zmf::config('sitename');
     $this->render('index', $data);
 }
Beispiel #2
0
 public static function getAvatar($aid, $size = 170)
 {
     $info = Attachments::getOne($aid);
     $url = '';
     if ($info) {
         $url = zmf::uploadDirs($info['cTime'], 'site', $info['classify'], $size) . $info['filePath'];
     }
     return $url;
 }
Beispiel #3
0
 /**
  * 返回坐标的封面图
  * @param type $poiInfo
  * @param type $size
  * @return string
  */
 public static function faceImg($poiInfo, $size = '170', $type = 'posts')
 {
     $url = '';
     if ($poiInfo['faceimg']) {
         $info = Attachments::getOne($poiInfo['faceimg']);
         if ($info) {
             if ($info['remote'] != '') {
                 $url = $info['remote'];
             } else {
                 $url = zmf::uploadDirs($info['cTime'], 'site', $info['classify']) . $info['filePath'];
             }
         }
     }
     if (!$url) {
         return '';
     }
     $reurl = zmf::getThumbnailUrl($url, $size, $type);
     return $reurl;
 }
Beispiel #4
0
<div id="<?php 
echo CHtml::activeId($model, $fieldName);
?>
_upload"></div>
<div id="singleFileQueue" style="clear:both;"></div>
<div id="fileSuccess" style="clear:both;"></div>
<input type="hidden" id="file_upload_input"/>   
<?php 
if ($attachid > 0) {
    $attachinfo = Attachments::getOne($attachid);
    if ($attachinfo) {
        echo '<div id="uploadAttach' . $attachid . '"><img src="' . zmf::imgurl($attachinfo['logid'], $attachinfo['filePath'], 124, $attachinfo['classify']) . '"/>' . CHtml::link('删除', 'javascript:;', array('onclick' => "delUploadImg({$attachid},'" . CHtml::activeId($model, $fieldName) . "')", 'confirm' => '不可恢复,确认删除?')) . '</div>';
    }
}
?>
<script>
    var imgUploadUrl="<?php 
echo Yii::app()->createUrl('attachments/upload', array('id' => $keyid, 'type' => $type));
?>
";  	
    $(document).ready(
    function(){    	
        singleUploadify('<?php 
echo CHtml::activeId($model, $fieldName);
?>
_upload','<?php 
echo CHtml::activeId($model, $fieldName);
?>
',<?php 
echo isset($num) ? $num : 1;
?>
Beispiel #5
0
 /**
  * 返回坐标的封面图
  * @param type $poiInfo
  * @param type $size
  * @return string
  */
 public static function faceImg($poiInfo, $size = '170')
 {
     $url = '';
     if ($poiInfo['faceimg']) {
         $info = Attachments::getOne($poiInfo['faceimg']);
         if ($info) {
             $url = zmf::uploadDirs($info['cTime'], 'site', $info['classify'], $size) . $info['filePath'];
         }
     }
     return $url;
 }
Beispiel #6
0
 public function actionView($id)
 {
     $this->layout = '/layouts/group';
     $this->currentModule = 'group';
     $info = WeddingGroup::model()->findByPk($id);
     if (!$info) {
         throw new CHttpException(404, '你所查看的页面不存在');
     }
     $info->avatar = $info->getAvatar($info->avatar);
     if (zmf::uid()) {
         $reInfo = GroupLink::findRelation($this->uid, $id);
         if ($reInfo) {
             $this->joined = true;
         }
     }
     //获取团队成员
     $criteria = new CDbCriteria(array('condition' => 'gl.groupid=' . $id, 'join' => 'LEFT JOIN {{group_link}} gl ON t.id=gl.uid', 'select' => 't.id,t.truename,t.avatar'));
     $members = new CActiveDataProvider('Users', array('pagination' => array('pageSize' => 10), 'criteria' => $criteria));
     //获取团队案例列表
     $sql = "SELECT p.id,p.title,p.faceimg,p.uid,p.colid,p.cTime,p.updateTime FROM {{posts}} p WHERE p.groupid='{$id}' AND p.classify=" . Posts::CLASSIFY_WEDDING . " AND p.status=" . Posts::STATUS_PASSED . " ORDER BY p.cTime DESC";
     Posts::getAll(array('sql' => $sql), $pages, $posts);
     if (!empty($posts)) {
         foreach ($posts as $k => $p) {
             if ($p['faceimg'] > 0) {
                 $_attach = Attachments::getOne($p['faceimg']);
                 $_url = Attachments::getUrl($_attach);
                 $posts[$k]['faceimg'] = $_url;
             } else {
                 $posts[$k]['faceimg'] = '';
             }
         }
     }
     $data = array('info' => $info, 'posts' => $posts, 'pages' => $pages);
     $this->pageTitle = $info['title'] . ' - ' . zmf::config('sitename');
     $this->render('view', $data);
 }
 public function actionDelUploadImg($_attachid = '')
 {
     if (!empty($_attachid)) {
         $attachid = $_attachid;
     } else {
         $attachid = zmf::filterInput($_POST['attachid'], 't', 1);
     }
     //$attachid=tools::jieMi($attachid);
     if (!Yii::app()->request->isAjaxRequest) {
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     if (Yii::app()->user->isGuest) {
         $this->jsonOutPut(0, Yii::t('default', 'loginfirst'));
     }
     $info = Attachments::getOne($attachid);
     if (!$info) {
         $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
     }
     if ($info['uid'] != Yii::app()->user->id and !$admin) {
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     if ($info['classify'] == 'coverimg') {
         $model = new Posts();
     } elseif ($info['classify'] == 'columns') {
         $model = new Columns();
     } elseif ($info['classify'] == 'ads') {
         $model = new Ads();
     }
     $dirs = zmf::uploadDirs($info['logid'], 'app', $info['classify']);
     if (empty($dirs)) {
         $this->jsonOutPut(0, Yii::t('default', 'unkownerror'));
     }
     foreach ($dirs as $dir) {
         $filePath = $dir . '/' . $info['filePath'];
         //$this->delItem($attchid, $filePath);
         @unlink($filePath);
     }
     if (Attachments::model()->deleteByPk($attachid)) {
         zmf::delFCache("attach{$attachid}");
         if (isset($model)) {
             $model->updateAll(array('attachid' => 0), 'id=:id', array(':id' => $info['logid']));
         }
         if ($admin) {
             $this->jsonOutPut(1, '操作成功!');
         } else {
             $this->jsonOutPut(1, '操作成功!');
         }
     } else {
         $this->jsonOutPut(0, '操作失败');
     }
 }
Beispiel #8
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 #9
0
 public static function text($params, $content, $lazyload = true, $size = 600)
 {
     if (is_array($params)) {
         $width = $params['imgwidth'];
         $action = $params['action'];
         $encode = $params['encode'];
     }
     if (!$width) {
         $width = $size;
     }
     if ($action != 'edit') {
         $content = tools::addcontentlink($content);
     } else {
         $lazyload = false;
     }
     if (strpos($content, '[attach]') !== false) {
         preg_match_all("/\\[attach\\](\\d+)\\[\\/attach\\]/i", $content, $match);
         if (!empty($match[1])) {
             foreach ($match[1] as $key => $val) {
                 $thekey = $match[0][$key];
                 $src = Attachments::getOne($val);
                 if ($src) {
                     $_imgurl = self::uploadDirs($src['cTime'], 'site', $src['classify'], $size) . $src['filePath'];
                     $imgurl = self::uploadDirs($src['cTime'], 'app', $src['classify'], $size) . $src['filePath'];
                     $originImgurl = self::uploadDirs($src['cTime'], 'site', $src['classify'], 'origin') . $src['filePath'];
                     if ($lazyload) {
                         $filesize = getimagesize($imgurl);
                         if (empty($filesize)) {
                             $content = str_ireplace("{$thekey}", '', $content);
                             continue;
                         }
                         $imgurl = "<img src='" . self::lazyImg() . "' width='" . $filesize[0] . "' height='" . $filesize[1] . "' class='lazy img-responsive' data-original='{$_imgurl}' " . ($action == 'edit' ? 'data="' . $src['id'] . '"' : '') . "/>";
                     } else {
                         $imgurl = "<img src='{$_imgurl}' class='img-responsive' " . ($action == 'edit' ? 'data="' . $src['id'] . '"' : '') . "/>";
                     }
                     if ($action != 'edit' && $encode != 'yes') {
                         $imgurl = '<a href="' . $originImgurl . '" target="_blank">' . $imgurl . '</a>';
                     }
                     $content = str_ireplace("{$thekey}", $imgurl, $content);
                 } else {
                     $content = str_ireplace("{$thekey}", '', $content);
                 }
             }
         }
     }
     $content = self::handleContent($content);
     return $content;
 }