00001 <?php
00002
00015 import('controllers.tab.settings.form.SettingsFileUploadForm');
00016
00017 class NewPressCssFileForm extends SettingsFileUploadForm {
00018
00023 function NewPressCssFileForm($cssSettingName) {
00024 parent::SettingsFileUploadForm();
00025 $this->setFileSettingName($cssSettingName);
00026 }
00027
00028
00029
00030
00031
00035 function fetch(&$request) {
00036 $params = array('fileType' => 'css');
00037 return parent::fetch($request, $params);
00038 }
00039
00040
00041
00042
00043
00048 function execute(&$request) {
00049 $temporaryFile = $this->fetchTemporaryFile($request);
00050
00051 import('classes.file.PublicFileManager');
00052 $publicFileManager = new PublicFileManager();
00053
00054 if (is_a($temporaryFile, 'TemporaryFile')) {
00055 $type = $temporaryFile->getFileType();
00056 if ($type != 'text/plain' && $type != 'text/css') {
00057 return false;
00058 }
00059
00060 $settingName = $this->getFileSettingName();
00061 $uploadName = $settingName . '.css';
00062 $press = $request->getPress();
00063 if($publicFileManager->copyPressFile($press->getId(), $temporaryFile->getFilePath(), $uploadName)) {
00064 $value = array(
00065 'name' => $temporaryFile->getOriginalFileName(),
00066 'uploadName' => $uploadName,
00067 'dateUploaded' => Core::getCurrentDate()
00068 );
00069
00070 $settingsDao =& DAORegistry::getDAO('PressSettingsDAO');
00071 $settingsDao->updateSetting($press->getId(), $settingName, $value, 'object');
00072
00073
00074 $this->removeTemporaryFile($request);
00075
00076 return true;
00077 }
00078 }
00079 return false;
00080 }
00081 }
00082
00083 ?>