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


PHP File::model方法代码示例

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


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

示例1: actionDelete

 public function actionDelete($id)
 {
     if (File::model()->deleteByPk($id)) {
         echo "Ajax Success";
         Yii::app()->end();
     }
 }
开发者ID:ZK413,项目名称:yiimine,代码行数:7,代码来源:FileController.php

示例2: loadModel

 public function loadModel($id)
 {
     if (($model = File::model()->findByPk($id)) === null) {
         throw new CHttpException(404, 'Страница не найдена');
     }
     return $model;
 }
开发者ID:kuzmina-mariya,项目名称:happy-end,代码行数:7,代码来源:FileBackendController.php

示例3: run

 public function run()
 {
     //if (Yii::app()->request->isAjaxRequest) {
     if (isset($_REQUEST['fid'])) {
         // Delete from database
         $file = File::model()->findByPk($_REQUEST['fid']);
         if (isset($file)) {
             if ($file->delete()) {
                 // Delete file
                 UploadUtils::deleteFile($file, SimpleUploadWidget::$fileDir);
                 $result["result"] = 0;
             } else {
                 $result["result"] = -1;
                 $result["message"] = Yii::t('upload', 'Could not delete file from db');
             }
         } else {
             $result["result"] = -1;
             $result["message"] = Yii::t('upload', 'No file with that fid');
         }
     } else {
         $result["result"] = -1;
         $result["message"] = Yii::t('upload', 'There is no file id (nor db and no session)');
     }
     echo CJSON::encode($result);
     exit(0);
     // To avoid loggers append things to request
     //}
 }
开发者ID:CHILMEX,项目名称:amocasion,代码行数:28,代码来源:DeleteAction.php

示例4: deleteFiles

 public static function deleteFiles($model, $fileDir)
 {
     $files = File::model()->findAll(array('condition' => 'entity=:entity AND EXid=:EXid', 'params' => array(':entity' => get_class($model), ':EXid' => $model->getPrimaryKey())));
     foreach ($files as $file) {
         self::deleteFile($file, $fileDir);
     }
 }
开发者ID:CHILMEX,项目名称:amocasion,代码行数:7,代码来源:UploadUtils.php

示例5: run

 public function run()
 {
     if (isset($_REQUEST['fid']) && is_numeric($_REQUEST['fid'])) {
         // Delete from database
         $file = File::model()->findByPk($_REQUEST['fid']);
         if (isset($file)) {
             if ($file->delete()) {
                 // Delete file
                 UploadUtils::deleteFile($file, PlUploadWidget::$fileDir);
                 $result["result"] = 0;
             } else {
                 $result["result"] = -1;
                 $result["message"] = Yii::t('upload', 'Could not delete file from db');
             }
         } else {
             $result["result"] = -1;
             $result["message"] = Yii::t('upload', 'No file with that fid');
         }
     } elseif (isset($_REQUEST['sid']) && is_numeric($_REQUEST['sid'])) {
         // Delete from session
         $sessionFiles = Yii::app()->session['temp_files'];
         $file = File::buildFromArray($sessionFiles[$_REQUEST['sid']]);
         unset($sessionFiles[$_REQUEST['sid']]);
         Yii::app()->session['temp_files'] = $sessionFiles;
         // Delete file
         UploadUtils::deleteFile($file, PlUploadWidget::$tempDir);
         $result["result"] = 0;
     } else {
         $result["result"] = -1;
         $result["message"] = Yii::t('upload', 'There is no file id (nor db and no session)');
     }
     echo CJSON::encode($result);
     exit(0);
     // To avoid loggers append things to request
 }
开发者ID:CHILMEX,项目名称:amocasion,代码行数:35,代码来源:DeleteAction.php

示例6: getFilesInIds

 public function getFilesInIds($ids)
 {
     $crit = new CDbCriteria();
     $crit->condition = "dataset_id = :id";
     $crit->params = array(':id' => $this->id);
     $crit->addInCondition("id", $ids);
     return File::model()->findAll($crit);
 }
开发者ID:jessesiu,项目名称:GigaDBV3,代码行数:8,代码来源:Dataset.php

示例7: beforeValidate

 /**
  * Prepares attributes before performing validation.
  */
 protected function beforeValidate($on)
 {
     if (!$this->isNewRecord && File::model()->findbyPk($this->id)->name != $this->name && $this->name != '' && file_exists(Yii::app()->params['filePath'] . $this->name)) {
         $this->addError('name', Yii::t('lan', 'File exists.'));
         return false;
     }
     return true;
 }
开发者ID:Greka163,项目名称:Yii-blog-new,代码行数:11,代码来源:File.php

示例8: getFiles

 public function getFiles()
 {
     $attributes = array('id_object' => $this->model->objectId, 'id_parameter' => $this->model->parameterId, 'id_parent_file' => null);
     if ($this->model->instanceId) {
         $attributes['id_instance'] = $this->model->instanceId;
     } else {
         $attributes['id_tmp'] = $this->model->tmpId;
     }
     return File::model()->findAllByAttributes($attributes);
 }
开发者ID:Cranky4,项目名称:npfs,代码行数:10,代码来源:FileUploadWidget.php

示例9: handleInternalUrls

 protected function handleInternalUrls($url)
 {
     // Handle urls to file
     if (substr($url, 0, 10) === "file-guid-") {
         $guid = str_replace('file-guid-', '', $url);
         $file = File::model()->findByAttributes(array('guid' => $guid));
         if ($file !== null) {
             return $file->getUrl();
         }
     }
     return $url;
 }
开发者ID:skapl,项目名称:design,代码行数:12,代码来源:HMarkdown.php

示例10: onCronDailyRun

 /**
  * On cron daily run do some cleanup stuff.
  * We delete all files which are not assigned to object_model/object_id
  * within 1 day.
  *
  * @param type $event
  */
 public static function onCronDailyRun($event)
 {
     $cron = $event->sender;
     /**
      * Delete unused files
      */
     $deleteTime = time() - 60 * 60 * 24 * 1;
     // Older than 1 day
     foreach (File::model()->findAllByAttributes(array(), 'created_at < :date AND (object_model IS NULL or object_model = "")', array(':date' => date('Y-m-d', $deleteTime))) as $file) {
         $file->delete();
     }
 }
开发者ID:ahdail,项目名称:humhub,代码行数:19,代码来源:FileModule.php

示例11: actionRotateImage

 public function actionRotateImage($gitem_id, $direction)
 {
     $model = File::model()->findByPk($gitem_id);
     if (!$model) {
         throw new CHttpException(404);
     }
     if (!Yii::app()->user->checkAccess('album_editGItem', array('item' => $model))) {
         throw new CHttpException(403);
     }
     $this->getModule()->getComponent('image')->rotate($file_path = $model->getAbsolutePath(), $direction);
     $this->getModule()->createThumbnails($file_path, true);
     echo CJSON::encode(array('success' => true));
 }
开发者ID:vasiliy-pdk,项目名称:aes,代码行数:13,代码来源:ImageController.php

示例12: setPhoto

 public function setPhoto($photos)
 {
     $curModel = get_class($this);
     $curPrimaryKeyValue = $this->{$this->tableSchema->primaryKey};
     $contition = new CDbCriteria();
     $contition->addCondition('record_id=:record_id');
     $contition->addNotInCondition('id', $photos);
     $contition->addCondition('model=:model');
     $contition->params[':record_id'] = $curPrimaryKeyValue;
     $contition->params[':model'] = $curModel;
     File::model()->updateAll(['record_id' => '0'], $contition);
     $condition = new CDbCriteria();
     $condition->addCondition('model=:model');
     $condition->params[':model'] = $curModel;
     File::model()->updateByPk($photos, ['record_id' => $curPrimaryKeyValue], $condition);
 }
开发者ID:alexanderkuz,项目名称:test-yii2,代码行数:16,代码来源:C2goActiveRecord.php

示例13: renderDataCell

 public function renderDataCell($row)
 {
     if ($this->objectParameter == null) {
         throw new Exception("Не указан ид параметр у колонки с типом Файл");
     }
     $field = $this->name;
     $data = $this->grid->dataProvider->data[$row];
     $value = $data->{$field};
     if ($value != null) {
         $this->htmlOptions = array('class' => 'col-img');
         $f = File::model()->findByPk($value);
         if ($f == null) {
             $value = "";
         } else {
             $link = $f->getUrlPath();
             $fileType = $f->getFileType();
             if ($fileType == null) {
                 $fileType = $f->definitionFileType();
             }
             if ($fileType == File::FILE_IMAGE) {
                 //Если свойством являетеся картинка, то пробуем сделать для неё превью.
                 if ($f->getStatusProcess() == 1) {
                     $memory = @ini_get("memory_limit");
                     if ($memory != null) {
                         $memory = "(" . $memory . ") ";
                     }
                     $value = "<div style='text-align:center'><img src=\"/engine/admin/gfx/msg.png\" title=\"Для данного изображения не может быть сгенирована превью-картинка. Как правило, это связано с ограничением оперативной памяти " . $memory . "на хостинг-площадке.\" alt=\"\"></div>";
                 } else {
                     $idInstance = $data->getIdInstance();
                     $filePreview = $f->getPreview(0, 50, '_da');
                     if ($filePreview == null) {
                         $value = '<b>Открыть текущий файл для просмотра</b>';
                     } else {
                         $value = '<img src="' . $filePreview->getUrlPath() . '" alt="" />';
                     }
                 }
                 $value = '<a rel="daG" target="_blank" href="' . $link . '">' . $value . '</a>';
             } else {
                 $value = '<a target="_blank" href="' . $link . '" title="Открыть текущий файл для просмотра"><i></i></a>';
                 $this->htmlOptions = array('class' => 'col-action-view');
             }
         }
     }
     echo CHtml::openTag('td', $this->htmlOptions);
     echo $value;
     echo '</td>';
 }
开发者ID:Cranky4,项目名称:npfs,代码行数:47,代码来源:FileColumn.php

示例14: actionDownload

 /**
  * 文件下载
  */
 public function actionDownload()
 {
     $id = Yii::app()->request->getQuery('id');
     $file = File::model()->findByPk($id);
     $name = '';
     $path = '';
     if (!empty($file)) {
         $name = $file->name;
         $path = $file->path;
     }
     //将网页变为下载框,原本是:header("content-type:text/html;charset=utf-8");
     header("content-type:application/x-msdownload");
     //设置下载框上的文件信息
     header("content-disposition:attachment;filename={$name}");
     //readfile("文件路径");从服务器读取文件,该函数才真正实现下载功能,其它的是固定死的
     readfile('./' . $path);
 }
开发者ID:zywh,项目名称:maplecity,代码行数:20,代码来源:FileController.php

示例15: actionDownload

 /**
  * Скачать файл по его ID
  * 
  * @param string $id - ID файла
  * 
  * @return void
  */
 public function actionDownload($alias)
 {
     $file = File::model()->find('t.alias = :alias', array(':alias' => $alias));
     if (empty($file)) {
         throw new CHttpException('404', 'Файл не найден');
     }
     //отключить профайлеры
     $this->disableProfilers();
     if (file_exists($file->path)) {
         // Увеличиваем счетчик
         $file->increaseCounter();
         // Отдаем файл на скачку
         $ext = pathinfo($file->file, PATHINFO_EXTENSION);
         Yii::app()->getRequest()->sendFile($file->title . '.' . $ext, @file_get_contents($file->path), 'application/octet-stream');
     } else {
         throw new CHttpException('404', 'Файл не найден');
     }
 }
开发者ID:kuzmina-mariya,项目名称:happy-end,代码行数:25,代码来源:FileController.php


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