本文整理汇总了PHP中FilePermissions::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP FilePermissions::getAll方法的具体用法?PHP FilePermissions::getAll怎么用?PHP FilePermissions::getAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FilePermissions
的用法示例。
在下文中一共展示了FilePermissions::getAll方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: permissions
public function permissions()
{
try {
$file = File::find('alias', $this->getParam('alias', ''));
} catch (FileNotFoundException $e) {
System::displayError(System::getLanguage()->_('ErrorFileNotFound'), '404 Not Found');
}
$form = new Form('form-permissions', '');
$fieldset = new Fieldset(System::getLanguage()->_('PermissionSetting'));
$permission = new Select('permission', System::getLanguage()->_('Permission'), FilePermissions::getAll());
$permission->selected_value = $file->permission;
$password = new Password('password', System::getLanguage()->_('Password'));
$fieldset->addElements($permission, $password);
$form->addElements($fieldset);
if (Utils::getPOST('submit', false) !== false) {
if ($form->validate()) {
if ($permission->selected_value == 2 && empty($password->value)) {
$password->error = System::getLanguage()->_('InvalidPassword');
} else {
$file->permission->setPermission($permission->selected_value, $password->value);
System::forwardToRoute(Router::getInstance()->build('DownloadController', 'download', $file));
exit;
}
}
}
$form->addButton(new Button(System::getLanguage()->_('Cancel'), 'icon icon-cancel', Router::getInstance()->build('DownloadController', 'download', $file)));
$smarty = new Template();
$smarty->assign('title', System::getLanguage()->_('PermissionSetting'));
$smarty->assign('form', $form->__toString());
$smarty->display('form.tpl');
}
示例2: prepareSmarty
/**
* Display this class
*/
private function prepareSmarty()
{
$this->smarty = new Template();
$this->smarty->assign('heading', $this->file->filename);
$this->smarty->assign('title', $this->file->filename);
$this->smarty->assign('file', $this->file);
$this->smarty->requireResource('file');
$select = new Select('permission', '', FilePermissions::getAll());
$select->selected_value = $this->file->permission;
$this->smarty->assign('permission', $select->render());
}
示例3: upload
public function upload()
{
$form = new Form('form-upload', Router::getInstance()->build('UploadController', 'upload'));
$form->setAttribute('data-noajax', 'true');
$form->setEnctype();
$fieldset = new Fieldset(System::getLanguage()->_('General'));
$folderInput = new Select('folder', System::getLanguage()->_('ChooseFolder'), Folder::getAll());
$folderInput->selected_value = Utils::getGET('parent', NULL);
$fieldset->addElements($folderInput);
$form->addElements($fieldset);
$fieldset = new Fieldset(System::getLanguage()->_('FileUpload'));
$fileInput = new FileUpload('file', System::getLanguage()->_('ChooseFile'), false);
$fieldset->addElements($fileInput);
$form->addElements($fieldset);
if (DOWNLOAD_VIA_SERVER) {
$fieldset = new Fieldset(System::getLanguage()->_('UploadFromURL'));
$url = new Text('url', System::getLanguage()->_('EnterURL'), false);
$name = new Text('name', System::getLanguage()->_('Name'), false);
$name->setValue(System::getLanguage()->_('DownloadedFile'));
$fieldset->addElements($url, $name);
$form->addElements($fieldset);
}
$fieldset = new Fieldset(System::getLanguage()->_('PermissionSetting'));
$permissionInput = new Select('permissions', System::getLanguage()->_('Permission'), FilePermissions::getAll());
$permissionInput->selected_value = DEFAULT_FILE_PERMISSION;
$password = new Password('password', System::getLanguage()->_('Password'), false);
$fieldset->addElements($permissionInput, $password);
$form->addElements($fieldset);
if (Utils::getPOST('submit', false) != false) {
if ($permissionInput->selected_value == 2 && empty($password->value)) {
$password->error = System::getLanguage()->_('ErrorEmptyTextfield');
} else {
if ($form->validate() && (!empty($url->value) || !empty($fileInput->uploaded_file))) {
// Specify input control for error display
$err = empty($url->value) ? $fileInput : $url;
try {
$folder = Folder::find('_id', $folderInput->selected_value);
$file = new File();
$file->folder = $folder;
$file->permission = $permissionInput->selected_value;
$file->password = $password->value;
if (empty($url->value)) {
$file->filename = $fileInput->filename;
$file->upload($fileInput->uploaded_file);
} else {
$file->filename = $name->value;
$file->remote($url->value);
}
$file->save();
System::forwardToRoute(Router::getInstance()->build('BrowserController', 'show', $folder));
exit;
} catch (UploadException $e) {
$fileInput->filename = '';
$fileInput->uploaded_file = '';
$err->error = $e->getMessage();
if ($e->getCode() != 0) {
$err->error .= ' Code: ' . $e->getCode();
}
} catch (QuotaExceededException $e) {
$err->error = System::getLanguage()->_('ErrorQuotaExceeded');
} catch (Exception $e) {
$fileInput->filename = '';
$fileInput->uploaded_file = '';
$err->error = System::getLanguage()->_('ErrorWhileUpload') . ' ' . $e->getMessage();
}
}
}
}
$form->setSubmit(new Button(System::getLanguage()->_('Upload'), 'open'));
if ($folderInput->selected_value == 0) {
$form->addButton(new Button(System::getLanguage()->_('Cancel'), '', Router::getInstance()->build('BrowserController', 'index')));
} else {
$form->addButton(new Button(System::getLanguage()->_('Cancel'), '', Router::getInstance()->build('BrowserController', 'show', new Folder($folderInput->selected_value))));
}
$smarty = new Template();
$smarty->assign('title', System::getLanguage()->_('Upload'));
$smarty->assign('heading', System::getLanguage()->_('FileUpload'));
$smarty->assign('form', $form->__toString());
$smarty->assign('BODY_CLASS', 'preventreload');
$smarty->requireResource('upload');
$smarty->display('form.tpl');
}