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


PHP FileManager::model方法代码示例

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


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

示例1: getCover

    /**
     * Вывод обложки для file manager
     * @param int $id идентификатор модели
     * @param string $name имя модели
     * @param string $link ссылка, если задана, то выводится ссылка, иначе галерея
     * @param string $noImage если изображение не найдено
     * @param string $type тип изображения, которое хотим получить
     * @return string
     */
    public static function getCover($id, $name, $link = '', $type = 'thumbnail', $noImage = '')
    {
        Yii::import('application.modules.file.models.FileManager');
        $data = FileManager::model()->find('model_name=:model_name AND model_id = :model_id AND cover = 1', array(':model_id' => $id, ':model_name' => $name));
        if ($data === null) {
            $noImage = '<img alt = "" class = "j-lazy" src = "/images/' . Yii::app()->getModule('file')->noImage . '"/>';
            if ($link == '') {
                $view = $noImage;
            } else {
                $view = '<a href = "' . $link . '">' . $noImage . '</a>';
            }
        } else {
            $file = Yii::getPathOfAlias('webroot') . DS . 'upload' . DS . Yii::app()->getModule('file')->uploadFolder . DS . $data->folder . DS . $type . DS . $data->file;
            if (Yii::app()->cFile->set($file)->exists) {
                $img = '<img alt = "' . strip_tags($data->description) . '" class = "j-lazy" src = "/upload/' . Yii::app()->getModule('file')->uploadFolder . '/' . $data->folder . '/' . $type . '/' . $data->file . '"/>';
            } else {
                $img = '<img alt = "' . strip_tags($data->description) . '" class = "j-lazy" src = "/images/' . Yii::app()->getModule('file')->noImage . '/>';
            }
            if ($link == '') {
                $view = '<ul id= "j-photobox_gallery_cover" class = "b-images_view b-image_cover j-photobox_gallery">
						<li class = "l-inline_block">
							<a href = "/upload/' . Yii::app()->getModule('file')->uploadFolder . '/' . $data->folder . '/original/' . $data->file . '">' . $img . '</a>
						</li>
					</ul>';
                if (!Yii::app()->request->isAjaxRequest) {
                    Yii::app()->clientScript->registerPackage('photobox');
                }
                JS::add('photobox_init', "\$('.j-photobox_gallery').photobox('a',{ 'time':0, 'loop':false, 'afterClose': function(){}});");
            } else {
                $view = '<a href = "' . $link . '">' . $img . '</a>';
            }
        }
        return $view;
    }
开发者ID:blrtromax,项目名称:seobility,代码行数:43,代码来源:Helper.php

示例2: run

 public function run()
 {
     if (!Yii::app()->request->isAjaxRequest) {
         Yii::app()->clientScript->registerPackage('photobox');
     }
     Yii::import('application.modules.file.models.FileManager');
     $dataprovider = FileManager::model()->findAll(array('order' => 'position, date DESC', 'condition' => 'model_id=:model_id AND model_name=:model_name AND file_type=:file_type', 'params' => array(':model_id' => $this->id, ':model_name' => $this->modelName, ':file_type' => 'file')));
     $this->render('file', array('dataprovider' => $dataprovider));
 }
开发者ID:blrtromax,项目名称:seobility,代码行数:9,代码来源:FileRenderWidget.php

示例3: beforeDelete

 public function beforeDelete($event)
 {
     $model = $this->getOwner();
     $files = FileManager::model()->findAllByAttributes(array('model_id' => get_class($model), 'object_id' => $model->id));
     foreach ($files as $file) {
         $file->delete();
     }
     return parent::beforeDelete($event);
 }
开发者ID:nizsheanez,项目名称:documentation,代码行数:9,代码来源:FileManagerBehavior.php

示例4: afterDelete

 public function afterDelete($event)
 {
     $modelName = get_class($this->owner);
     $model = FileManager::model()->find(array('condition' => 'model_id=:model_id AND model_name=:model_name', 'params' => array(':model_id' => $this->owner->id, ':model_name' => $modelName)));
     if ($model !== null) {
         $dir = Yii::getPathOfAlias('webroot') . DS . 'upload' . DS . Yii::app()->getModule('file')->uploadFolder . DS . $model->folder;
         Yii::app()->cFile->set($dir)->delete();
     }
     FileManager::model()->deleteAll(array('condition' => 'model_id=:model_id AND model_name=:model_name', 'params' => array(':model_id' => $this->owner->id, ':model_name' => $modelName)));
 }
开发者ID:blrtromax,项目名称:seobility,代码行数:10,代码来源:FileManagerBehavior.php

示例5: run

 public function run()
 {
     Yii::app()->getClientScript()->registerCoreScript('jquery.ui');
     JS::add('jquery-ui-sortable', "\$('#d-file_manager_items').sortable({'delay':'300','deactivate':function(event, ui ) { sendImagesPosion();}});");
     Yii::import('application.modules.file.models.FileManager');
     $criteria = FileManager::getSearchCriteria($this->id, $this->modelName);
     $criteria->order = 'position, date DESC';
     if ($this->id < 0) {
         if (Yii::app()->user->hasState('file_manager_folder_' . $this->modelName)) {
             $folderName = Yii::app()->user->getState('file_manager_folder_' . $this->modelName);
         } else {
             $folderName = Yii::app()->getModule('file')->generateName(Yii::getPathOfAlias('webroot') . DS . 'upload' . DS . Yii::app()->getModule('file')->uploadFolder);
         }
         $criteria->compare('folder', $folderName, true);
     }
     $dataprovider = FileManager::model()->findAll($criteria);
     $this->render('form', array('dataprovider' => $dataprovider));
 }
开发者ID:blrtromax,项目名称:seobility,代码行数:18,代码来源:FormWidget.php

示例6: getFolder

 /**
  * Генерация папок
  * @param int $id модели для загрузки
  * @param name $name название модели для загрузки
  * @return string
  */
 protected function getFolder($id, $name)
 {
     $criteria = FileManager::getSearchCriteria($id, $name);
     if (Yii::app()->user->getState('file_manager_folder_' . $name)) {
         $folderName = Yii::app()->user->getState('file_manager_folder_' . $name);
     } else {
         $folderName = Yii::app()->getModule('file')->generateName(Yii::getPathOfAlias('webroot') . DS . 'upload' . DS . $this->module->uploadFolder);
     }
     if ($id < 0) {
         $criteria->compare('folder', $folderName, true);
     }
     $model = FileManager::model()->find($criteria);
     if ($model !== null) {
         $folderName = $model->folder;
         $this->itemPosition = $model->position + 1;
     } else {
         $this->itemPosition = 1;
     }
     if ($id < 0 && !Yii::app()->user->hasState('file_manager_folder_' . $name)) {
         Yii::app()->user->setState('file_manager_folder_' . $name, $folderName);
     }
     $dir = Yii::getPathOfAlias('webroot') . DS . 'upload' . DS . $this->module->uploadFolder . DS . $folderName . DS;
     $cFile = Yii::app()->cFile;
     //Общая папка
     $cFile->createDir($dir);
     $cFile->set($dir, true)->setPermissions(Yii::app()->params['folderPermission']);
     //Миниатюры для админки
     $cFile->createDir($dir . 'admin');
     $cFile->set($dir . 'admin', true)->setPermissions(Yii::app()->params['folderPermission']);
     //Оригиналы
     $cFile->createDir($dir . 'original');
     $cFile->set($dir . 'original', true)->setPermissions(Yii::app()->params['folderPermission']);
     //Миниатюры
     $cFile->createDir($dir . 'thumbnail');
     $cFile->set($dir . 'thumbnail', true)->setPermissions(Yii::app()->params['folderPermission']);
     //Файлы
     $cFile->createDir($dir . 'file');
     $cFile->set($dir . 'file', true)->setPermissions(Yii::app()->params['folderPermission']);
     //Обложка или изображения среднего размера
     if (isset($_GET['medium'])) {
         $cFile->createDir($dir . 'medium');
         $cFile->set($dir . 'medium', true)->setPermissions(Yii::app()->params['folderPermission']);
     }
     return $folderName;
 }
开发者ID:blrtromax,项目名称:seobility,代码行数:51,代码来源:UploadController.php


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