当前位置: 首页>>代码示例>>PHP>>正文


PHP Attachments::getOne方法代码示例

本文整理汇总了PHP中Attachments::getOne方法的典型用法代码示例。如果您正苦于以下问题:PHP Attachments::getOne方法的具体用法?PHP Attachments::getOne怎么用?PHP Attachments::getOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Attachments的用法示例。


在下文中一共展示了Attachments::getOne方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionIndex

 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);
 }
开发者ID:ph7pal,项目名称:wedding,代码行数:26,代码来源:UsersController.php

示例2: getAvatar

 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;
 }
开发者ID:ph7pal,项目名称:wedding,代码行数:9,代码来源:WeddingGroup.php

示例3: faceImg

 /**
  * 返回坐标的封面图
  * @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;
 }
开发者ID:ph7pal,项目名称:momo,代码行数:25,代码来源:Attachments.php

示例4: isset

<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;
?>
开发者ID:ph7pal,项目名称:wedding,代码行数:31,代码来源:singleUpload.php

示例5: faceImg

 /**
  * 返回坐标的封面图
  * @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;
 }
开发者ID:ph7pal,项目名称:wedding,代码行数:17,代码来源:Attachments.php

示例6: actionView

 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);
 }
开发者ID:ph7pal,项目名称:wedding,代码行数:36,代码来源:GroupController.php

示例7: actionDelUploadImg

 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, '操作失败');
     }
 }
开发者ID:ph7pal,项目名称:wedding,代码行数:51,代码来源:AttachmentsController.php

示例8: actionView

 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 = "SELECT id,title,faceimg,uid,colid,cTime,updateTime FROM {{posts}} WHERE id!='{$id}' AND uid='{$info['uid']}' AND classify=" . 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);
 }
开发者ID:ph7pal,项目名称:wedding,代码行数:79,代码来源:PostsController.php

示例9: text

 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;
 }
开发者ID:ph7pal,项目名称:wedding,代码行数:48,代码来源:zmf.php


注:本文中的Attachments::getOne方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。