本文整理汇总了PHP中Cabinet::listFolders方法的典型用法代码示例。如果您正苦于以下问题:PHP Cabinet::listFolders方法的具体用法?PHP Cabinet::listFolders怎么用?PHP Cabinet::listFolders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cabinet
的用法示例。
在下文中一共展示了Cabinet::listFolders方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: classifyFile
public function classifyFile($files)
{
$tpl = null;
$this->cabinet->title = dgettext('filecabinet', 'Classify Files');
$classify_dir = $this->cabinet->getClassifyDir();
if (empty($classify_dir) || !is_dir($classify_dir)) {
$this->cabinet->content = dgettext('filecabinet', 'Unable to locate the classify directory. Please check your File Cabinet settings, configuration file and directory permissions.');
return;
}
if (!is_array($files)) {
$files = array($files);
}
// image folders
$image_folders = Cabinet::listFolders(IMAGE_FOLDER, true);
// document folders
$document_folders = Cabinet::listFolders(DOCUMENT_FOLDER, true);
// multimedia folders
$multimedia_folders = Cabinet::listFolders(MULTIMEDIA_FOLDER, true);
$count = 0;
$image_types = $this->cabinet->getAllowedTypes('image');
$document_types = $this->cabinet->getAllowedTypes('document');
$media_types = $this->cabinet->getAllowedTypes('media');
foreach ($files as $file) {
if (!is_file($classify_dir . $file) || !PHPWS_File::checkMimeType($classify_dir . $file) || !$this->cabinet->fileTypeAllowed($file)) {
continue;
}
$form = new PHPWS_Form('file_form_' . $count);
$ext = PHPWS_File::getFileExtension($file);
if (in_array($ext, $image_types)) {
$folders =& $image_folders;
} elseif (in_array($ext, $media_types)) {
$folders =& $multimedia_folders;
} elseif (in_array($ext, $document_types)) {
$folders =& $document_folders;
} else {
continue;
}
$form->addSelect("folder[{$count}]", $folders);
$form->setTag("folder[{$count}]", 'folder');
$form->setLabel("folder[{$count}]", dgettext('filecabinet', 'Folder'));
$form->addText("file_title[{$count}]", $file);
$form->setLabel("file_title[{$count}]", dgettext('filecabinet', 'Title'));
$form->setTag("file_title[{$count}]", 'file_title');
$form->setSize("file_title[{$count}]", 40);
$form->addTextarea("file_description[{$count}]");
$form->setLabel("file_description[{$count}]", dgettext('filecabinet', 'Description'));
$form->setTag("file_description[{$count}]", 'file_description');
$form->addSubmit('submit', dgettext('filecabinet', 'Classify files'));
$subtpl = $form->getTemplate();
$subtpl['HIDDEN'] = sprintf('<input type="hidden" name="file_count[%s]" value="%s" />', $count, $file);
$subtpl['FILE_NAME'] = $file;
$subtpl['FILE_NAME_LABEL'] = dgettext('filecabinet', 'File name');
unset($subtpl['START_FORM']);
unset($subtpl['END_FORM']);
$tpl['files'][] = $subtpl;
$count++;
}
$form = new PHPWS_Form('classify_files');
$form->addHidden('module', 'filecabinet');
$form->addHidden('aop', 'post_classifications');
if (!empty($tpl)) {
$form_template = $form->getTemplate(true, true, $tpl);
$this->cabinet->content = PHPWS_Template::process($form_template, 'filecabinet', 'Forms/classify_file.tpl');
} else {
$this->cabinet->content = dgettext('filecabinet', 'Unable to classify files.');
}
}