本文整理汇总了PHP中PublicFileManager::uploadSchedConfFile方法的典型用法代码示例。如果您正苦于以下问题:PHP PublicFileManager::uploadSchedConfFile方法的具体用法?PHP PublicFileManager::uploadSchedConfFile怎么用?PHP PublicFileManager::uploadSchedConfFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PublicFileManager
的用法示例。
在下文中一共展示了PublicFileManager::uploadSchedConfFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveLocationSettings
/**
* Save changes to location settings.
*/
function saveLocationSettings()
{
$this->validate();
$this->setupTemplate(true);
$schedConf =& Request::getSchedConf();
if (!$schedConf) {
Request::redirect(null, null, 'index');
}
import('manager.form.LocationSettingsForm');
$settingsForm = new LocationSettingsForm();
$settingsForm->readInputData();
$editData = false;
$locationFiles =& $schedConf->getSetting('locationFiles');
if (Request::getUserVar('uploadLocationFile')) {
// Get a numeric key for this file.
$thisFileKey = 0;
if (isset($locationFiles[$settingsForm->getFormLocale()])) {
foreach ($locationFiles[$settingsForm->getFormLocale()] as $key => $junk) {
$thisFileKey = $key + 1;
}
}
import('file.PublicFileManager');
$fileManager = new PublicFileManager();
$success = !$fileManager->uploadError('locationFile');
if ($success && ($success = $fileManager->uploadedFileExists('locationFile'))) {
$oldName = $fileManager->getUploadedFileName('locationFile');
$extension = $fileManager->getExtension($oldName);
if (!$extension) {
break;
}
$uploadName = 'location-' . $thisFileKey . '.' . $extension;
if ($success && ($success = $fileManager->uploadSchedConfFile($schedConf->getId(), 'locationFile', $uploadName))) {
$value = array('name' => $oldName, 'uploadName' => $uploadName, 'dateUploaded' => Core::getCurrentDate(), 'title' => Request::getUserVar('locationFileTitle'));
$locationFiles[$settingsForm->getFormLocale()][$thisFileKey] =& $value;
$settingsForm->setData('locationFiles', $locationFiles);
$settingsForm->setData('locationFileTitle', '');
$schedConf->updateSetting('locationFiles', $locationFiles, 'object', true);
}
}
if (!$success) {
$settingsForm->addError('locationFiles', __('common.uploadFailed'));
}
$editData = true;
} else {
$formLocale = $settingsForm->getFormLocale();
$deleteKey = null;
if (isset($locationFiles[$formLocale])) {
foreach ($locationFiles[$formLocale] as $key => $junk) {
if (Request::getUserVar("deleteLocationFile-{$formLocale}-{$key}")) {
$deleteKey = $key;
}
}
}
if ($deleteKey !== null) {
import('file.PublicFileManager');
$fileManager = new PublicFileManager();
if ($fileManager->removeSchedConfFile($schedConf->getId(), $locationFiles[$formLocale][$deleteKey]['uploadName'])) {
unset($locationFiles[$formLocale][$deleteKey]);
$schedConf->updateSetting('locationFiles', $locationFiles, 'object', true);
}
$editData = true;
}
}
if (!$editData && $settingsForm->validate()) {
$settingsForm->execute();
$templateMgr =& TemplateManager::getManager();
$templateMgr->assign(array('currentUrl' => Request::url(null, null, null, 'location'), 'pageTitle' => 'schedConf.location', 'message' => 'common.changesSaved', 'backLink' => Request::url(null, null, Request::getRequestedPage()), 'backLinkLabel' => 'manager.conferenceSiteManagement'));
$templateMgr->display('common/message.tpl');
} else {
$settingsForm->display();
}
}
示例2: uploadProgram
/**
* Uploads a program file.
* @param $settingName string setting key associated with the file
* @param $locale string
*/
function uploadProgram($settingName, $locale)
{
$schedConf =& Request::getSchedConf();
import('file.PublicFileManager');
$fileManager = new PublicFileManager();
if ($fileManager->uploadError($settingName)) {
return false;
}
if ($fileManager->uploadedFileExists($settingName)) {
$oldName = $fileManager->getUploadedFileName('programFile');
$extension = $fileManager->getExtension($oldName);
if (!$extension) {
return false;
}
$uploadName = 'program-' . $locale . '.' . $extension;
if ($fileManager->uploadSchedConfFile($schedConf->getId(), $settingName, $uploadName)) {
$value = $schedConf->getSetting($settingName);
$value[$locale] = array('name' => $oldName, 'uploadName' => $uploadName, 'dateUploaded' => Core::getCurrentDate());
$schedConf->updateSetting($settingName, $value, 'object', true);
return true;
}
}
return false;
}