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


PHP Upload::model方法代码示例

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


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

示例1: actionBatch

 /**
  * 批量操作
  * @throws CHttpException
  */
 public function actionBatch()
 {
     if ($this->method() == 'GET') {
         $command = trim($this->_request->getParam('command'));
         $ids = intval($this->_request->getParam('id'));
     } elseif ($this->method() == 'POST') {
         $command = $this->_request->getPost('command');
         $ids = $this->_request->getPost('id');
     } else {
         throw new CHttpException(404, Yii::t('admin', 'Only POST Or GET'));
     }
     empty($ids) && $this->message('error', Yii::t('admin', 'No Select'));
     switch ($command) {
         case 'attachDelete':
             foreach ((array) $ids as $id) {
                 $uploadModel = Upload::model()->findByPk($id);
                 if ($uploadModel) {
                     Uploader::deleteFile($uploadModel->file_name);
                     $uploadModel->delete();
                 }
             }
             break;
         default:
             throw new CHttpException(404, Yii::t('admin', 'Error Operation'));
             break;
     }
     $this->message('success', Yii::t('admin', 'Batch Operate Success'), $this->createUrl('index'));
 }
开发者ID:github-zjh,项目名称:task,代码行数:32,代码来源:AttachController.php

示例2: testDelete

 public function testDelete()
 {
     $file = $this->uploads('upload1');
     $upload_id = $file->id;
     $this->assertTrue($file->delete());
     $deleted_file = Upload::model()->findByPk($upload_id);
     $this->assertEquals(NULL, $deleted_file);
 }
开发者ID:sklww,项目名称:Cinch,代码行数:8,代码来源:UploadTest.php

示例3: loadModel

 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Upload::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
开发者ID:sklww,项目名称:Cinch,代码行数:13,代码来源:UploadController.php

示例4: afterSave

 public function afterSave(Post $post)
 {
     $key = param('sess_post_create_token');
     if (app()->session->contains($key) && ($token = app()->session[$key])) {
         if (!$post->hasErrors()) {
             $attributes = array('post_id' => $post->id, 'token' => '');
             Upload::model()->updateAll($attributes, 'token = :token', array(':token' => $token));
             app()->session->remove($key);
         }
     }
 }
开发者ID:rainsongsky,项目名称:24beta,代码行数:11,代码来源:PostForm.php

示例5: actionInsertUserGoddess

 /**
  * 插入用户女神相片
  *
  * @param string $user_id
  * @param string $token
  *
  */
 public function actionInsertUserGoddess()
 {
     $qq = trim(Yii::app()->request->getParam('qq'));
     $name = trim(Yii::app()->request->getParam('name'));
     $nick_name = trim(Yii::app()->request->getParam('nickname'));
     $img = trim(Yii::app()->request->getParam('img'));
     // 参数检查
     if (!isset($_REQUEST['qq']) || !isset($_REQUEST['name']) || !isset($_REQUEST['nickname']) || !isset($_REQUEST['img'])) {
         $this->_return('MSG_ERR_LESS_PARAM');
     }
     $param = array('qq' => $qq, 'name' => $name, 'nick_name' => $nick_name);
     $user_goddess_id = Upload::model()->insertUserGoddess($param);
     $param = array('url' => $img, 'user_goddess_id' => $user_goddess_id);
     $res = Upload::model()->insertUpload($param);
     if ($res == false) {
         $this->_return('MSG_ERR_UNKOWN');
     }
     $this->_return('MSG_SUCCESS');
 }
开发者ID:hucongyang,项目名称:goddess,代码行数:26,代码来源:UploadController.php

示例6: actionRemove

 /**
  * 删除附件
  * @return [type] [description]
  */
 public function actionRemove()
 {
     $imageId = intval($this->_gets->getParam('imageId'));
     try {
         $imageModel = Upload::model()->findByPk($imageId);
         if ($imageModel == false) {
             throw new Exception("附件已经被删除");
         }
         @unlink($imageModel->file_name);
         @unlink($imageModel->thumb_name);
         if (!$imageModel->delete()) {
             throw new Exception("数据删除失败");
         }
         $var['state'] = 'success';
         $var['message'] = '删除完成';
     } catch (Exception $e) {
         $var['state'] = 'errro';
         $var['message'] = '失败:' . $e->getMessage();
     }
     exit(CJSON::encode($var));
 }
开发者ID:zywh,项目名称:maplecity,代码行数:25,代码来源:UploadifyController.php

示例7: actionCreate

 public function actionCreate($id = 0)
 {
     $id = (int) $id;
     if ($id === 0) {
         $model = new AdminPost();
         $model->homeshow = user()->checkAccess('create_post_in_home') ? BETA_YES : BETA_NO;
         $model->state = user()->checkAccess('editor') ? POST_STATE_ENABLED : POST_STATE_NOT_VERIFY;
         $this->adminTitle = t('create_post');
     } elseif ($id > 0) {
         $model = AdminPost::model()->findByPk($id);
         $this->adminTitle = t('edit_post');
     } else {
         throw new CHttpException(500);
     }
     if (request()->getIsPostRequest() && isset($_POST['AdminPost'])) {
         $model->attributes = $_POST['AdminPost'];
         // 此处如果以后有多种文章模型了,这一句可以去掉。
         if ($model->getIsNewRecord()) {
             $model->user_id = user()->id;
             $model->user_name = user()->name;
             $model->post_type = POST_TYPE_POST;
         }
         if ($model->save()) {
             $this->afterPostSave($model);
             user()->setFlash('save_post_result', t('save_post_success', 'admin', array('{title}' => $model->title, '{url}' => $model->url)));
             $this->redirect(request()->getUrl());
         }
     } else {
         $key = param('sess_post_create_token');
         if (!app()->session->contains($key) || empty(app()->session[$key])) {
             $token = $model->getIsNewRecord() ? uniqid('beta', true) : $model->id;
             app()->session->add($key, $token);
         } else {
             $token = app()->session[$key];
             $tempPictures = Upload::model()->findAllByAttributes(array('token' => $token));
         }
     }
     $this->render('create', array('model' => $model, 'tempPictures' => $tempPictures));
 }
开发者ID:rainsongsky,项目名称:24beta,代码行数:39,代码来源:PostController.php

示例8: actionBatch

 /**
  * 批量操作
  *
  */
 public function actionBatch()
 {
     if ($this->method() == 'GET') {
         $command = trim($_GET['command']);
         $ids = intval($_GET['id']);
     } elseif ($this->method() == 'POST') {
         $command = trim($_POST['command']);
         $ids = $_POST['id'];
     } else {
         $this->message('errorBack', Yii::t('admin', 'Only POST Or GET'));
     }
     empty($ids) && $this->message('error', Yii::t('admin', 'No Select'));
     switch ($command) {
         case 'delete':
             //删除文章
             foreach ((array) $ids as $id) {
                 $postModel = Post::model()->findByPk($id);
                 if ($postModel) {
                     $image_list = $postModel->image_list;
                     $image_list && ($image_list = unserialize($image_list));
                     if ($image_list) {
                         foreach ($image_list as $image) {
                             Uploader::deleteFile($image['file']);
                             $file = Upload::model()->findByPk($image['fileId']);
                             if ($file) {
                                 $file->delete();
                             }
                         }
                     }
                     Uploader::deleteFile($postModel->attach_file);
                     Uploader::deleteFile($postModel->attach_thumb);
                     $postModel->delete();
                     //删除关联的标签
                     TagData::model()->deleteAll('content_id =:id AND type =:type', array(':id' => $id, ':type' => $this->_type_ids['post']));
                 }
             }
             break;
         case 'show':
             //文章显示
             foreach ((array) $ids as $id) {
                 $postModel = Post::model()->findByPk($id);
                 if ($postModel) {
                     $postModel->status = 'Y';
                     $postModel->save();
                     //更新关联的标签
                     $tagData = TagData::model()->updateAll(array('status' => 'Y'), 'content_id =:id AND type =:type', array(':id' => $id, ':type' => $this->_type_ids['post']));
                 }
             }
             break;
         case 'hidden':
             //文章隐藏
             foreach ((array) $ids as $id) {
                 $postModel = Post::model()->findByPk($id);
                 if ($postModel) {
                     $postModel->status = 'N';
                     $postModel->save();
                     //更新关联的标签
                     $tagData = TagData::model()->updateAll(array('status' => 'N'), 'content_id =:id AND type =:type', array(':id' => $id, ':type' => $this->_type_ids['post']));
                 }
             }
             break;
         case 'commend':
             //文章推荐
             foreach ((array) $ids as $id) {
                 $recom_id = intval($_POST['recom_id']);
                 if ($recom_id) {
                     $postModel = Post::model()->findByPk($id);
                     if ($postModel) {
                         $postModel->commend = 'Y';
                         $postModel->save();
                         $recom_post = new RecommendPost();
                         $recom_post->id = $recom_id;
                         $recom_post->post_id = $id;
                         $recom_post->save();
                     }
                 } else {
                     $this->message('error', Yii::t('admin', 'RecommendPosition is Required'));
                 }
             }
             break;
         case 'stick':
             //文章置顶
             foreach ((array) $ids as $id) {
                 $postModel = Post::model()->findByPk($id);
                 if ($postModel) {
                     $postModel->top_line = 'Y';
                     $postModel->save();
                 }
             }
             break;
         case 'cancelStick':
             //文章取消置顶
             foreach ((array) $ids as $id) {
                 $postModel = Post::model()->findByPk($id);
                 if ($postModel) {
                     $postModel->top_line = 'N';
//.........这里部分代码省略.........
开发者ID:redtreelchao,项目名称:wander-moon,代码行数:101,代码来源:PostController.php

示例9: explode

    <td colspan="2" >    	
      	<form>
		  <input id="uploadFile" name="uploadFile" type="file" multiple="true">
		  <ul id="fileList">
		  		<?php 
if ($model->fileid) {
    ?>
		  		<?php 
    $arr = explode(',', $model->fileid);
    ?>
		  		<?php 
    foreach ((array) $arr as $value) {
        ?>
		  		
		  		<?php 
        $file = Upload::model()->findByPk($value);
        ?>
		  		<?php 
        if ($file) {
            ?>
		  		<li id="file_<?php 
            echo $file->id;
            ?>
">
		  			<a href="/<?php 
            echo $file->file_name;
            ?>
"><?php 
            echo $file->real_name;
            ?>
</a><br/>
开发者ID:redtreelchao,项目名称:wander-moon,代码行数:31,代码来源:_form.php

示例10: afterDelete

 protected function afterDelete()
 {
     $counters = array('post_nums' => -1);
     Category::model()->updateCounters($counters, 'id = :cid', array(':cid' => $this->category_id));
     Topic::model()->updateCounters($counters, 'id = :tid', array(':tid' => $this->topic_id));
     $comments = Comment::model()->findAllByAttributes(array('post_id' => $this->id));
     foreach ($comments as $c) {
         $c->delete();
     }
     app()->db->createCommand()->delete(TABLE_POST_TAG, 'post_id = :pid', array(':pid' => $this->id));
     app()->db->createCommand()->delete(TABLE_SPECIAL_POST, 'post_id = :pid', array(':pid' => $this->id));
     $files = Upload::model()->findAllByAttributes(array('post_id' => $this->id));
     foreach ($files as $file) {
         $file->delete();
     }
 }
开发者ID:rainsongsky,项目名称:24beta,代码行数:16,代码来源:Post.php

示例11: actionDownload

 /**
  *
  * 视频下载
  * 
  */
 public function actionDownload($id)
 {
     $video = Video::model()->findByPk($id);
     if ($video) {
         $file = Upload::model()->findByPk($video->fileid);
         if ($file && file_exists($file->file_name)) {
             //更新下载次数
             $video->updateCounters(array('down_count' => 1), 'id=:id', array('id' => $id));
             //开始下载
             Yii::app()->request->sendFile($soft->title . '.' . $file->file_ext, file_get_contents($file->file_name));
             exit;
         } else {
             $this->message('error', Yii::t('common', 'Source Is Not Found'), $this->createUrl('video/view', array('id' => $id)));
         }
     } else {
         $this->message('error', Yii::t('common', 'Source Is Not Found'), $this->createUrl('video/view', array('id' => $id)));
     }
 }
开发者ID:redtreelchao,项目名称:wander-moon,代码行数:23,代码来源:VideoController.php

示例12: model

 /**
  * Returns the static model of the specified AR class.
  * @return AdminUpload the static model class
  */
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
开发者ID:rainsongsky,项目名称:24beta,代码行数:8,代码来源:AdminUpload.php

示例13: actionDownload

 /**
  * 
  * 软件下载
  */
 public function actionDownload($id)
 {
     //限制下载频率
     $cookie = Yii::app()->request->getCookies();
     $cookie_key = 'DL' . $id . 'TIMES';
     $down_cookie = $cookie[$cookie_key]->value;
     if ($down_cookie) {
         throw new CHttpException(404, Yii::t('common', 'Access frequency too fast'));
     }
     $soft = Soft::model()->findByPk($id);
     if ($soft) {
         $file = Upload::model()->findByPk($soft->fileid);
         if ($file && file_exists($file->file_name)) {
             //更新下载次数
             $soft->updateCounters(array('down_count' => 1), 'id=:id', array('id' => $id));
             //存储下载cookie次数
             unset($cookie[$cookie_key]);
             $down = 1;
             $cookie = new CHttpCookie($cookie_key, $down);
             $cookie->expire = time() + 20;
             //20秒之后可以再次下载
             Yii::app()->request->cookies[$cookie_key] = $cookie;
             //开始下载
             Yii::app()->request->sendFile($soft->title . '.' . $file->file_ext, file_get_contents($file->file_name), $file->file_mime);
             exit;
         } else {
             throw new CHttpException(404, Yii::t('common', 'Source Is Not Found'));
         }
     } else {
         throw new CHttpException(404, Yii::t('common', 'Source Is Not Found'));
     }
 }
开发者ID:redtreelchao,项目名称:wander-moon,代码行数:36,代码来源:SoftController.php

示例14: actionGetImageListXML

    public function actionGetImageListXML()
    {
        if (Yii::app()->user->isGuest) {
            return;
        }
        $pageNo = 1;
        if (isset($_REQUEST['pageNo']) && $_REQUEST['pageNo'] > 0) {
            $pageNo = (int) $_REQUEST['pageNo'];
        }
        $offset = ($pageNo - 1) * Yii::app()->params->itemCountInDataListPage;
        $out = '';
        $dataFetchedTimeKey = "ImageController.dataFetchedTime";
        if (isset($_REQUEST['list'])) {
            if ($_REQUEST['list'] == "onlyUpdated") {
                $time = Yii::app()->session[$dataFetchedTimeKey];
                if ($time !== false && $time != "") {
                    $friendList = AuxiliaryFriendsOperator::getFriendIdList();
                    $sqlCount = 'SELECT ceil(count(*)/' . Yii::app()->params->itemCountInDataListPage . ')
								 FROM ' . Upload::model()->tableName() . ' u 
								 WHERE (userId in (' . $friendList . ') 
								        OR userId = ' . Yii::app()->user->id . '
								        OR publicData = 1)
								        AND unix_timestamp(u.uploadTime) >= ' . $time;
                    $pageCount = Yii::app()->db->createCommand($sqlCount)->queryScalar();
                    $sql = 'SELECT u.Id as id, u.description, s.realname, s.Id as userId, date_format(u.uploadTime,"%d %b %Y %T") as uploadTime, u.altitude, u.latitude, u.longitude
								 FROM ' . Upload::model()->tableName() . ' u 
								 LEFT JOIN  ' . Users::model()->tableName() . ' s ON s.Id = u.userId
								 WHERE (userId in (' . $friendList . ') 
								 		OR userId = ' . Yii::app()->user->id . '
								 		OR publicData = 1)
								 		AND unix_timestamp(u.uploadTime) >= ' . $time . '
								 ORDER BY u.Id DESC
								 LIMIT ' . $offset . ' , ' . Yii::app()->params->itemCountInDataListPage;
                    $out = $this->prepareXML($sql, $pageNo, $pageCount, "userList");
                }
            }
        } else {
            $friendList = AuxiliaryFriendsOperator::getFriendIdList();
            $sqlCount = 'SELECT ceil(count(*)/' . Yii::app()->params->itemCountInDataListPage . ')
					 FROM ' . Upload::model()->tableName() . ' u 
					 WHERE userId in (' . $friendList . ') OR 
					 	   userId = ' . Yii::app()->user->id . ' OR
					 	   publicData = 1';
            $pageCount = Yii::app()->db->createCommand($sqlCount)->queryScalar();
            $sql = 'SELECT u.Id as id, u.description, s.realname, s.Id as userId, date_format(u.uploadTime,"%d %b %Y %T") as uploadTime, u.altitude, u.latitude, u.longitude
					 FROM ' . Upload::model()->tableName() . ' u 
					 LEFT JOIN  ' . Users::model()->tableName() . ' s ON s.Id = u.userId
					 WHERE userId in (' . $friendList . ') OR 
					 	   userId = ' . Yii::app()->user->id . ' OR
					 	   publicData = 1
					 ORDER BY u.Id DESC
					 LIMIT ' . $offset . ' , ' . Yii::app()->params->itemCountInDataListPage;
            $out = $this->prepareXML($sql, $pageNo, $pageCount, "imageList");
        }
        echo $out;
        Yii::app()->session[$dataFetchedTimeKey] = time();
        Yii::app()->end();
    }
开发者ID:Avinash1000,项目名称:traceper,代码行数:58,代码来源:ImageController.php

示例15: actionCreate

 public function actionCreate()
 {
     $this->channel = 'contribute';
     $form = new PostForm();
     if (request()->getIsPostRequest() && isset($_POST['PostForm'])) {
         $form->attributes = $_POST['PostForm'];
         if ($form->validate()) {
             $post = $form->save();
             if (!$post->hasErrors()) {
                 user()->setFlash('success_post_id', $post->id);
                 $this->redirect(url('post/success'));
                 exit(0);
             }
         }
     } else {
         $key = param('sess_post_create_token');
         if (!app()->session->contains($key) || empty(app()->session[$key])) {
             app()->session->add($key, uniqid('beta', true));
         } else {
             $token = app()->session[$key];
             $tempPictures = Upload::model()->findAllByAttributes(array('token' => $token));
         }
     }
     $captchaWidget = $form->hasErrors('captcha') ? $this->widget('BetaCaptcha', array(), true) : $this->widget('BetaCaptcha', array('skin' => 'defaultLazy'), true);
     $captchaClass = $form->hasErrors('captcha') ? 'error' : 'hide';
     $this->setSiteTitle(t('contribute_post'));
     cs()->registerMetaTag('noindex, follow', 'robots');
     $this->render('create', array('form' => $form, 'captchaClass' => $captchaClass, 'captchaWidget' => $captchaWidget, 'tempPictures' => $tempPictures));
 }
开发者ID:rainsongsky,项目名称:24beta,代码行数:29,代码来源:PostController.php


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