本文整理汇总了PHP中FileManager::getSearchCriteria方法的典型用法代码示例。如果您正苦于以下问题:PHP FileManager::getSearchCriteria方法的具体用法?PHP FileManager::getSearchCriteria怎么用?PHP FileManager::getSearchCriteria使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileManager
的用法示例。
在下文中一共展示了FileManager::getSearchCriteria方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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));
}
示例2: 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;
}