deleteFile() public méthode

public deleteFile ( $fileName )
 function manage($verb, $args, &$message)
 {
     if (!parent::manage($verb, $args, $message)) {
         return false;
     }
     $journal =& Request::getJournal();
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->register_function('plugin_url', array(&$this, 'smartyPluginUrl'));
     $this->import('XMLGalleySettingsForm');
     $form = new XMLGalleySettingsForm($this, $journal->getId());
     switch ($verb) {
         case 'test':
             // test external XSLT renderer
             $xsltRenderer = $this->getSetting($journal->getId(), 'XSLTrenderer');
             if ($xsltRenderer == "external") {
                 // get command for external XSLT tool
                 $xsltCommand = $this->getSetting($journal->getId(), 'externalXSLT');
                 // get test XML/XSL files
                 $xmlFile = dirname($_SERVER['SCRIPT_FILENAME']) . DIRECTORY_SEPARATOR . $this->getPluginPath() . '/transform/test.xml';
                 $xslFile = $this->getPluginPath() . '/transform/test.xsl';
                 // create a testing article galley object (to access the XSLT render method)
                 $this->import('ArticleXMLGalley');
                 $xmlGalley = new ArticleXMLGalley($this->getName());
                 // transform the XML using whatever XSLT processor we have available
                 $result = $xmlGalley->transformXSLT($xmlFile, $xslFile, $xsltCommand);
                 // check the result
                 if (trim(preg_replace("/\\s+/", " ", $result)) != "Open Journal Systems Success") {
                     $form->addError('content', Locale::translate('plugins.generic.xmlGalley.settings.externalXSLTFailure'));
                 } else {
                     $templateMgr->assign('testSuccess', true);
                 }
             }
         case 'settings':
             Locale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON, LOCALE_COMPONENT_PKP_MANAGER));
             // if we are updating XSLT settings or switching XSL sheets
             if (Request::getUserVar('save')) {
                 $form->readInputData();
                 $form->initData();
                 if ($form->validate()) {
                     $form->execute();
                 }
                 $form->display();
                 // if we are uploading a custom XSL sheet
             } elseif (Request::getUserVar('uploadCustomXSL')) {
                 $form->readInputData();
                 import('classes.file.JournalFileManager');
                 // if the a valid custom XSL is uploaded, process it
                 $fileManager = new JournalFileManager($journal);
                 if ($fileManager->uploadedFileExists('customXSL')) {
                     // check type and extension -- should be text/xml and xsl, respectively
                     $type = $fileManager->getUploadedFileType('customXSL');
                     $fileName = $fileManager->getUploadedFileName('customXSL');
                     $extension = strtolower($fileManager->getExtension($fileName));
                     if (($type == 'text/xml' || $type == 'text/xml' || $type == 'application/xml' || $type == 'application/xslt+xml') && $extension == 'xsl') {
                         // if there is an existing XSL file, delete it from the journal files folder
                         $existingFile = $this->getSetting($journal->getId(), 'customXSL');
                         if (!empty($existingFile) && $fileManager->fileExists($fileManager->filesDir . $existingFile)) {
                             $fileManager->deleteFile($existingFile);
                         }
                         // upload the file into the journal files folder
                         $fileManager->uploadFile('customXSL', $fileName);
                         // update the plugin and form settings
                         $this->updateSetting($journal->getId(), 'XSLstylesheet', 'custom');
                         $this->updateSetting($journal->getId(), 'customXSL', $fileName);
                     } else {
                         $form->addError('content', Locale::translate('plugins.generic.xmlGalley.settings.customXSLInvalid'));
                     }
                 } else {
                     $form->addError('content', Locale::translate('plugins.generic.xmlGalley.settings.customXSLRequired'));
                 }
                 // re-populate the form values with the new settings
                 $form->initData();
                 $form->display();
                 // if we are deleting an existing custom XSL sheet
             } elseif (Request::getUserVar('deleteCustomXSL')) {
                 import('classes.file.JournalFileManager');
                 // if the a valid custom XSL is uploaded, process it
                 $fileManager = new JournalFileManager($journal);
                 // delete the file from the journal files folder
                 $fileName = $this->getSetting($journal->getId(), 'customXSL');
                 if (!empty($fileName)) {
                     $fileManager->deleteFile($fileName);
                 }
                 // update the plugin and form settings
                 $this->updateSetting($journal->getId(), 'XSLstylesheet', 'NLM');
                 $this->updateSetting($journal->getId(), 'customXSL', '');
                 $form->initData();
                 $form->display();
             } else {
                 $form->initData();
                 $form->display();
             }
             return true;
         default:
             // Unknown management verb
             assert(false);
             return false;
     }
 }
 /**
  * Create a package containing the serialized deposit objects 
  * @return string The full path of the created zip archive
  */
 function generatePackage()
 {
     // get DAOs, plugins and settings
     $journalDao =& DAORegistry::getDAO('JournalDAO');
     $issueDao =& DAORegistry::getDAO('IssueDAO');
     $sectionDao =& DAORegistry::getDAO('SectionDAO');
     $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
     PluginRegistry::loadCategory('importexport');
     $exportPlugin =& PluginRegistry::getPlugin('importexport', 'NativeImportExportPlugin');
     $plnPlugin =& PluginRegistry::getPlugin('generic', PLN_PLUGIN_NAME);
     $fileManager = new JournalFileManager($journalDao->getById($this->_deposit->getJournalId()));
     $journal =& $journalDao->getById($this->_deposit->getJournalId());
     $depositObjects = $this->_deposit->getDepositObjects();
     // set up folder and file locations
     $bagDir = $this->getDepositDir() . DIRECTORY_SEPARATOR . 'bag';
     $packageFile = $this->getPackageFilePath();
     $exportFile = $bagDir . DIRECTORY_SEPARATOR . $this->_deposit->getObjectType() . '.xml';
     $termsFile = $bagDir . DIRECTORY_SEPARATOR . 'terms.xml';
     $bag = new BagIt($bagDir);
     switch ($this->_deposit->getObjectType()) {
         case PLN_PLUGIN_DEPOSIT_OBJECT_ARTICLE:
             $articles = array();
             // we need to add all of the relevant articles to an array to export as a batch
             while ($depositObject =& $depositObjects->next()) {
                 $article =& $publishedArticleDao->getPublishedArticleByArticleId($this->_deposit->getObjectId(), $journal->getId());
                 $issue =& $issueDao->getIssueById($article->getIssueId(), $journal->getId());
                 $section =& $sectionDao->getSection($article->getSectionId());
                 // add the article to the array we'll pass for export
                 $articles[] = array('publishedArticle' => $article, 'section' => $section, 'issue' => $issue, 'journal' => $journal);
                 unset($depositObject);
             }
             // export all of the articles together
             if ($exportPlugin->exportArticles($articles, $exportFile) !== true) {
                 return false;
             }
             break;
         case PLN_PLUGIN_DEPOSIT_OBJECT_ISSUE:
             // we only ever do one issue at a time, so get that issue
             $depositObject =& $depositObjects->next();
             $issue =& $issueDao->getIssueByBestIssueId($depositObject->getObjectId(), $journal->getId());
             // export the issue
             if ($exportPlugin->exportIssue($journal, $issue, $exportFile) !== true) {
                 return false;
             }
             break;
         default:
     }
     // add the current terms to the bag
     $termsXml = new DOMDocument('1.0', 'utf-8');
     $entry = $termsXml->createElementNS('http://www.w3.org/2005/Atom', 'entry');
     $entry->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:dcterms', 'http://purl.org/dc/terms/');
     $entry->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:pkp', PLN_PLUGIN_NAME);
     $terms = unserialize($plnPlugin->getSetting($this->_deposit->getJournalId(), 'terms_of_use'));
     $pkpTermsOfUse = $termsXml->createElementNS(PLN_PLUGIN_NAME, 'pkp:terms_of_use');
     foreach ($terms as $termName => $termData) {
         $element = $termsXml->createElementNS(PLN_PLUGIN_NAME, $termName, $termData['term']);
         $element->setAttribute('updated', $termData['updated']);
         $pkpTermsOfUse->appendChild($element);
     }
     $entry->appendChild($pkpTermsOfUse);
     $termsXml->appendChild($entry);
     $termsXml->save($termsFile);
     // add the exported content to the bag
     $bag->addFile($exportFile, $this->_deposit->getObjectType() . $this->_deposit->getUUID() . '.xml');
     // add the exported content to the bag
     $bag->addFile($termsFile, 'terms' . $this->_deposit->getUUID() . '.xml');
     $bag->update();
     // delete files
     $fileManager->deleteFile($exportFile);
     $fileManager->deleteFile($termsFile);
     // create the bag
     $bag->package($packageFile, 'zip');
     // remove the temporary bag directory
     $fileManager->rmtree($bagDir);
     return $packageFile;
 }
 /**
  * Save changes to journal settings.
  * @param $args array first parameter is the step being saved
  * @param $request Request
  */
 function saveSetup($args, &$request)
 {
     $this->validate();
     $step = isset($args[0]) ? (int) $args[0] : 0;
     if ($step >= 1 && $step <= 5) {
         $this->setupTemplate(true);
         $formClass = "JournalSetupStep{$step}Form";
         import("classes.manager.form.setup.{$formClass}");
         $setupForm = new $formClass();
         $setupForm->readInputData();
         $formLocale = $setupForm->getFormLocale();
         // Check for any special cases before trying to save
         switch ($step) {
             case 1:
                 if ($request->getUserVar('reassignDOIs')) {
                     $articleDao =& DAORegistry::getDAO('ArticleDAO');
                     $journal =& $request->getJournal();
                     $articleDao->assignDOIs(true, $journal->getId());
                     $editData = true;
                 } else {
                     if ($request->getUserVar('addSponsor')) {
                         // Add a sponsor
                         $editData = true;
                         $sponsors = $setupForm->getData('sponsors');
                         array_push($sponsors, array());
                         $setupForm->setData('sponsors', $sponsors);
                     } else {
                         if (($delSponsor = $request->getUserVar('delSponsor')) && count($delSponsor) == 1) {
                             // Delete a sponsor
                             $editData = true;
                             list($delSponsor) = array_keys($delSponsor);
                             $delSponsor = (int) $delSponsor;
                             $sponsors = $setupForm->getData('sponsors');
                             array_splice($sponsors, $delSponsor, 1);
                             $setupForm->setData('sponsors', $sponsors);
                         } else {
                             if ($request->getUserVar('addContributor')) {
                                 // Add a contributor
                                 $editData = true;
                                 $contributors = $setupForm->getData('contributors');
                                 array_push($contributors, array());
                                 $setupForm->setData('contributors', $contributors);
                             } else {
                                 if (($delContributor = $request->getUserVar('delContributor')) && count($delContributor) == 1) {
                                     // Delete a contributor
                                     $editData = true;
                                     list($delContributor) = array_keys($delContributor);
                                     $delContributor = (int) $delContributor;
                                     $contributors = $setupForm->getData('contributors');
                                     array_splice($contributors, $delContributor, 1);
                                     $setupForm->setData('contributors', $contributors);
                                 }
                             }
                         }
                     }
                 }
                 break;
             case 2:
                 if ($request->getUserVar('addCustomAboutItem')) {
                     // Add a custom about item
                     $editData = true;
                     $customAboutItems = $setupForm->getData('customAboutItems');
                     $customAboutItems[$formLocale][] = array();
                     $setupForm->setData('customAboutItems', $customAboutItems);
                 } else {
                     if (($delCustomAboutItem = $request->getUserVar('delCustomAboutItem')) && count($delCustomAboutItem) == 1) {
                         // Delete a custom about item
                         $editData = true;
                         list($delCustomAboutItem) = array_keys($delCustomAboutItem);
                         $delCustomAboutItem = (int) $delCustomAboutItem;
                         $customAboutItems = $setupForm->getData('customAboutItems');
                         if (!isset($customAboutItems[$formLocale])) {
                             $customAboutItems[$formLocale][] = array();
                         }
                         array_splice($customAboutItems[$formLocale], $delCustomAboutItem, 1);
                         $setupForm->setData('customAboutItems', $customAboutItems);
                     }
                 }
                 if ($request->getUserVar('addReviewerDatabaseLink')) {
                     // Add a reviewer database link
                     $editData = true;
                     $reviewerDatabaseLinks = $setupForm->getData('reviewerDatabaseLinks');
                     array_push($reviewerDatabaseLinks, array());
                     $setupForm->setData('reviewerDatabaseLinks', $reviewerDatabaseLinks);
                 } else {
                     if (($delReviewerDatabaseLink = $request->getUserVar('delReviewerDatabaseLink')) && count($delReviewerDatabaseLink) == 1) {
                         // Delete a custom about item
                         $editData = true;
                         list($delReviewerDatabaseLink) = array_keys($delReviewerDatabaseLink);
                         $delReviewerDatabaseLink = (int) $delReviewerDatabaseLink;
                         $reviewerDatabaseLinks = $setupForm->getData('reviewerDatabaseLinks');
                         array_splice($reviewerDatabaseLinks, $delReviewerDatabaseLink, 1);
                         $setupForm->setData('reviewerDatabaseLinks', $reviewerDatabaseLinks);
                     }
                 }
                 break;
             case 3:
                 if ($request->getUserVar('addChecklist')) {
                     // Add a checklist item
                     $editData = true;
                     $checklist = $setupForm->getData('submissionChecklist');
                     if (!isset($checklist[$formLocale]) || !is_array($checklist[$formLocale])) {
                         $checklist[$formLocale] = array();
                         $lastOrder = 0;
                     } else {
                         $lastOrder = $checklist[$formLocale][count($checklist[$formLocale]) - 1]['order'];
                     }
                     array_push($checklist[$formLocale], array('order' => $lastOrder + 1));
                     $setupForm->setData('submissionChecklist', $checklist);
                 } else {
                     if (($delChecklist = $request->getUserVar('delChecklist')) && count($delChecklist) == 1) {
                         // Delete a checklist item
                         $editData = true;
                         list($delChecklist) = array_keys($delChecklist);
                         $delChecklist = (int) $delChecklist;
                         $checklist = $setupForm->getData('submissionChecklist');
                         if (!isset($checklist[$formLocale])) {
                             $checklist[$formLocale] = array();
                         }
                         array_splice($checklist[$formLocale], $delChecklist, 1);
                         $setupForm->setData('submissionChecklist', $checklist);
                     }
                 }
                 if (!isset($editData)) {
                     // Reorder checklist items
                     $checklist = $setupForm->getData('submissionChecklist');
                     if (isset($checklist[$formLocale]) && is_array($checklist[$formLocale])) {
                         usort($checklist[$formLocale], create_function('$a,$b', 'return $a[\'order\'] == $b[\'order\'] ? 0 : ($a[\'order\'] < $b[\'order\'] ? -1 : 1);'));
                     } else {
                         if (!isset($checklist[$formLocale])) {
                             $checklist[$formLocale] = array();
                         }
                     }
                     $setupForm->setData('submissionChecklist', $checklist);
                 }
                 break;
             case 4:
                 $router =& $request->getRouter();
                 $journal =& $router->getContext($request);
                 $templates = $journal->getSetting('templates');
                 import('classes.file.JournalFileManager');
                 $journalFileManager = new JournalFileManager($journal);
                 if ($request->getUserVar('addTemplate')) {
                     // Add a layout template
                     $editData = true;
                     if (!is_array($templates)) {
                         $templates = array();
                     }
                     $templateId = count($templates);
                     $originalFilename = $_FILES['template-file']['name'];
                     $fileType = $journalFileManager->getUploadedFileType('template-file');
                     $filename = "template-{$templateId}." . $journalFileManager->parseFileExtension($originalFilename);
                     $journalFileManager->uploadFile('template-file', $filename);
                     $templates[$templateId] = array('originalFilename' => $originalFilename, 'fileType' => $fileType, 'filename' => $filename, 'title' => $request->getUserVar('template-title'));
                     $journal->updateSetting('templates', $templates);
                 } else {
                     if (($delTemplate = $request->getUserVar('delTemplate')) && count($delTemplate) == 1) {
                         // Delete a template
                         $editData = true;
                         list($delTemplate) = array_keys($delTemplate);
                         $delTemplate = (int) $delTemplate;
                         $template = $templates[$delTemplate];
                         $filename = "template-{$delTemplate}." . $journalFileManager->parseFileExtension($template['originalFilename']);
                         $journalFileManager->deleteFile($filename);
                         array_splice($templates, $delTemplate, 1);
                         $journal->updateSetting('templates', $templates);
                     }
                 }
                 $setupForm->setData('templates', $templates);
                 break;
             case 5:
                 if ($request->getUserVar('uploadHomeHeaderTitleImage')) {
                     if ($setupForm->uploadImage('homeHeaderTitleImage', $formLocale)) {
                         $editData = true;
                     } else {
                         $setupForm->addError('homeHeaderTitleImage', __('manager.setup.homeTitleImageInvalid'));
                     }
                 } else {
                     if ($request->getUserVar('deleteHomeHeaderTitleImage')) {
                         $editData = true;
                         $setupForm->deleteImage('homeHeaderTitleImage', $formLocale);
                     } else {
                         if ($request->getUserVar('uploadHomeHeaderLogoImage')) {
                             if ($setupForm->uploadImage('homeHeaderLogoImage', $formLocale)) {
                                 $editData = true;
                             } else {
                                 $setupForm->addError('homeHeaderLogoImage', __('manager.setup.homeHeaderImageInvalid'));
                             }
                         } else {
                             if ($request->getUserVar('deleteHomeHeaderLogoImage')) {
                                 $editData = true;
                                 $setupForm->deleteImage('homeHeaderLogoImage', $formLocale);
                             } else {
                                 if ($request->getUserVar('uploadJournalFavicon')) {
                                     if ($setupForm->uploadImage('journalFavicon', $formLocale)) {
                                         $editData = true;
                                     } else {
                                         $setupForm->addError('journalFavicon', __('manager.setup.journalFaviconInvalid'));
                                     }
                                 } else {
                                     if ($request->getUserVar('deleteJournalFavicon')) {
                                         $editData = true;
                                         $setupForm->deleteImage('journalFavicon', $formLocale);
                                     } else {
                                         if ($request->getUserVar('uploadPageHeaderTitleImage')) {
                                             if ($setupForm->uploadImage('pageHeaderTitleImage', $formLocale)) {
                                                 $editData = true;
                                             } else {
                                                 $setupForm->addError('pageHeaderTitleImage', __('manager.setup.pageHeaderTitleImageInvalid'));
                                             }
                                         } else {
                                             if ($request->getUserVar('deletePageHeaderTitleImage')) {
                                                 $editData = true;
                                                 $setupForm->deleteImage('pageHeaderTitleImage', $formLocale);
                                             } else {
                                                 if ($request->getUserVar('uploadPageHeaderLogoImage')) {
                                                     if ($setupForm->uploadImage('pageHeaderLogoImage', $formLocale)) {
                                                         $editData = true;
                                                     } else {
                                                         $setupForm->addError('pageHeaderLogoImage', __('manager.setup.pageHeaderLogoImageInvalid'));
                                                     }
                                                 } else {
                                                     if ($request->getUserVar('deletePageHeaderLogoImage')) {
                                                         $editData = true;
                                                         $setupForm->deleteImage('pageHeaderLogoImage', $formLocale);
                                                     } else {
                                                         if ($request->getUserVar('uploadHomepageImage')) {
                                                             if ($setupForm->uploadImage('homepageImage', $formLocale)) {
                                                                 $editData = true;
                                                             } else {
                                                                 $setupForm->addError('homepageImage', __('manager.setup.homepageImageInvalid'));
                                                             }
                                                         } else {
                                                             if ($request->getUserVar('deleteHomepageImage')) {
                                                                 $editData = true;
                                                                 $setupForm->deleteImage('homepageImage', $formLocale);
                                                             } else {
                                                                 if ($request->getUserVar('uploadJournalStyleSheet')) {
                                                                     if ($setupForm->uploadStyleSheet('journalStyleSheet')) {
                                                                         $editData = true;
                                                                     } else {
                                                                         $setupForm->addError('journalStyleSheet', __('manager.setup.journalStyleSheetInvalid'));
                                                                     }
                                                                 } else {
                                                                     if ($request->getUserVar('deleteJournalStyleSheet')) {
                                                                         $editData = true;
                                                                         $setupForm->deleteImage('journalStyleSheet');
                                                                     } else {
                                                                         if ($request->getUserVar('addNavItem')) {
                                                                             // Add a navigation bar item
                                                                             $editData = true;
                                                                             $navItems = $setupForm->getData('navItems');
                                                                             $navItems[$formLocale][] = array();
                                                                             $setupForm->setData('navItems', $navItems);
                                                                         } else {
                                                                             if (($delNavItem = $request->getUserVar('delNavItem')) && count($delNavItem) == 1) {
                                                                                 // Delete a  navigation bar item
                                                                                 $editData = true;
                                                                                 list($delNavItem) = array_keys($delNavItem);
                                                                                 $delNavItem = (int) $delNavItem;
                                                                                 $navItems = $setupForm->getData('navItems');
                                                                                 if (is_array($navItems) && is_array($navItems[$formLocale])) {
                                                                                     array_splice($navItems[$formLocale], $delNavItem, 1);
                                                                                     $setupForm->setData('navItems', $navItems);
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 break;
         }
         if (!isset($editData) && $setupForm->validate()) {
             $setupForm->execute();
             $request->redirect(null, null, 'setupSaved', $step);
         } else {
             $setupForm->display($request, $this->getDispatcher());
         }
     } else {
         $request->redirect();
     }
 }
 /**
  * Save changes to journal settings.
  * @param $args array first parameter is the step being saved
  * @param $request Request
  */
 function saveSetup($args, &$request)
 {
     $this->validate();
     $step = isset($args[0]) ? (int) $args[0] : 0;
     if ($step >= 1 && $step <= 5) {
         $this->setupTemplate(true);
         $formClass = "JournalSetupStep{$step}Form";
         import("classes.manager.form.setup.{$formClass}");
         $CBPPlatformDao =& DAORegistry::getDAO('CBPPlatformDAO');
         $setupForm = new $formClass();
         $setupForm->readInputData();
         $formLocale = $setupForm->getFormLocale();
         // Check for any special cases before trying to save
         switch ($step) {
             case 1:
                 if ($request->getUserVar('reassignDOIs')) {
                     $articleDao =& DAORegistry::getDAO('ArticleDAO');
                     $journal =& $request->getJournal();
                     $articleDao->assignDOIs(true, $journal->getId());
                     $editData = true;
                 } else {
                     if ($request->getUserVar('addSponsor')) {
                         // Add a sponsor
                         $editData = true;
                         $sponsors = $setupForm->getData('sponsors');
                         array_push($sponsors, array());
                         $setupForm->setData('sponsors', $sponsors);
                     } else {
                         if (($delSponsor = $request->getUserVar('delSponsor')) && count($delSponsor) == 1) {
                             // Delete a sponsor
                             $editData = true;
                             list($delSponsor) = array_keys($delSponsor);
                             $delSponsor = (int) $delSponsor;
                             $sponsors = $setupForm->getData('sponsors');
                             array_splice($sponsors, $delSponsor, 1);
                             $setupForm->setData('sponsors', $sponsors);
                         } else {
                             if ($request->getUserVar('addContributor')) {
                                 // Add a contributor
                                 $editData = true;
                                 $contributors = $setupForm->getData('contributors');
                                 array_push($contributors, array());
                                 $setupForm->setData('contributors', $contributors);
                             } else {
                                 if (($delContributor = $request->getUserVar('delContributor')) && count($delContributor) == 1) {
                                     // Delete a contributor
                                     $editData = true;
                                     list($delContributor) = array_keys($delContributor);
                                     $delContributor = (int) $delContributor;
                                     $contributors = $setupForm->getData('contributors');
                                     array_splice($contributors, $delContributor, 1);
                                     $setupForm->setData('contributors', $contributors);
                                 }
                             }
                         }
                     }
                 }
                 break;
             case 2:
                 $journal =& $request->getJournal();
                 //%CBP% options for manager to select hybrid or workshop review models
                 if ($request->getUserVar('workflowModel')) {
                     $CBPPlatformDao->setWorkshop($journal->getJournalId(), $request->getUserVar('workflowModel'));
                 }
                 if ($request->getUserVar('addCustomAboutItem')) {
                     // Add a custom about item
                     $editData = true;
                     $customAboutItems = $setupForm->getData('customAboutItems');
                     $customAboutItems[$formLocale][] = array();
                     $setupForm->setData('customAboutItems', $customAboutItems);
                 } else {
                     if (($delCustomAboutItem = $request->getUserVar('delCustomAboutItem')) && count($delCustomAboutItem) == 1) {
                         // Delete a custom about item
                         $editData = true;
                         list($delCustomAboutItem) = array_keys($delCustomAboutItem);
                         $delCustomAboutItem = (int) $delCustomAboutItem;
                         $customAboutItems = $setupForm->getData('customAboutItems');
                         if (!isset($customAboutItems[$formLocale])) {
                             $customAboutItems[$formLocale][] = array();
                         }
                         array_splice($customAboutItems[$formLocale], $delCustomAboutItem, 1);
                         $setupForm->setData('customAboutItems', $customAboutItems);
                     }
                 }
                 if ($request->getUserVar('addReviewerDatabaseLink')) {
                     // Add a reviewer database link
                     $editData = true;
                     $reviewerDatabaseLinks = $setupForm->getData('reviewerDatabaseLinks');
                     array_push($reviewerDatabaseLinks, array());
                     $setupForm->setData('reviewerDatabaseLinks', $reviewerDatabaseLinks);
                 } else {
                     if (($delReviewerDatabaseLink = $request->getUserVar('delReviewerDatabaseLink')) && count($delReviewerDatabaseLink) == 1) {
                         // Delete a custom about item
                         $editData = true;
                         list($delReviewerDatabaseLink) = array_keys($delReviewerDatabaseLink);
                         $delReviewerDatabaseLink = (int) $delReviewerDatabaseLink;
                         $reviewerDatabaseLinks = $setupForm->getData('reviewerDatabaseLinks');
                         array_splice($reviewerDatabaseLinks, $delReviewerDatabaseLink, 1);
                         $setupForm->setData('reviewerDatabaseLinks', $reviewerDatabaseLinks);
                     }
                 }
                 break;
             case 3:
                 // TODO: Tidy up code below!!
                 if ($request->getUserVar('collectionRequiredSections')) {
                     if ($request->getUserVar('collectionRequiredSections') == "articlesPrefaceIntroduction") {
                         $requiredSections[] = array('title' => "Preface", 'policy' => 'Please submit a preface less than 500 words.', 'delegated' => 'editor', 'compulsary' => '1');
                         $requiredSections[] = array('title' => 'Introduction', 'policy' => 'Please submit an introduction less than 2000 words.', 'delegated' => 'editor', 'compulsary' => '1');
                         $requiredSections[] = array('title' => "Author Biographies", 'policy' => 'Please submit an author biography less than 250 words. When entering a title for the biography, please use the format "Firstname Lastname Author Biography"', 'delegated' => 'author', 'compulsary' => '0');
                     } elseif ($request->getUserVar('collectionRequiredSections') == "articlesBiographies") {
                         $requiredSections[] = array('title' => "Preface", 'policy' => 'Please submit a preface less than 500 words.', 'delegated' => 'editor', 'compulsary' => '0');
                         $requiredSections[] = array('title' => 'Introduction', 'policy' => 'Please submit an introduction less than 2000 words.', 'delegated' => 'editor', 'compulsary' => '0');
                         $requiredSections[] = array('title' => "Author Biographies", 'policy' => 'Please submit an author biography less than 250 words. When entering a title for the biography, please use the format "Firstname Lastname Author Biography"', 'delegated' => 'author', 'compulsary' => '1');
                     } else {
                         $requiredSections[] = array('title' => "Preface", 'policy' => 'Please submit a preface less than 500 words.', 'delegated' => 'editor', 'compulsary' => '0');
                         $requiredSections[] = array('title' => 'Introduction', 'policy' => 'Please submit an introduction less than 2000 words.', 'delegated' => 'editor', 'compulsary' => '0');
                         $requiredSections[] = array('title' => "Author Biographies", 'policy' => 'Please submit an author biography less than 250 words. When entering a title for the biography, please use the format "Firstname Lastname Author Biography"', 'delegated' => 'author', 'compulsary' => '0');
                     }
                     $router =& $request->getRouter();
                     $journal = $router->getContext(&$request);
                     $journal = $journal->_data;
                     $CBPPlatformDao->setRequiredSections($requiredSections, $journal['id']);
                 }
                 if ($request->getUserVar('addChecklist')) {
                     // Add a checklist item
                     $editData = true;
                     $checklist = $setupForm->getData('submissionChecklist');
                     if (!isset($checklist[$formLocale]) || !is_array($checklist[$formLocale])) {
                         $checklist[$formLocale] = array();
                         $lastOrder = 0;
                     } else {
                         $lastOrder = $checklist[$formLocale][count($checklist[$formLocale]) - 1]['order'];
                     }
                     array_push($checklist[$formLocale], array('order' => $lastOrder + 1));
                 } else {
                     if (($delChecklist = $request->getUserVar('delChecklist')) && count($delChecklist) == 1) {
                         // Delete a checklist item
                         $editData = true;
                         list($delChecklist) = array_keys($delChecklist);
                         $delChecklist = (int) $delChecklist;
                         $checklist = $setupForm->getData('submissionChecklist');
                         if (!isset($checklist[$formLocale])) {
                             $checklist[$formLocale] = array();
                         }
                         array_splice($checklist[$formLocale], $delChecklist, 1);
                         $setupForm->setData('submissionChecklist', $checklist);
                     }
                 }
                 if (!isset($editData)) {
                     // Reorder checklist items
                     $checklist = $setupForm->getData('submissionChecklist');
                     if (isset($checklist[$formLocale]) && is_array($checklist[$formLocale])) {
                         usort($checklist[$formLocale], create_function('$a,$b', 'return $a[\'order\'] == $b[\'order\'] ? 0 : ($a[\'order\'] < $b[\'order\'] ? -1 : 1);'));
                     } else {
                         if (!isset($checklist[$formLocale])) {
                             $checklist[$formLocale] = array();
                         }
                     }
                     $setupForm->setData('submissionChecklist', $checklist);
                 }
                 break;
             case 4:
                 $router =& $request->getRouter();
                 $journal =& $router->getContext(&$request);
                 $templates = $journal->getSetting('templates');
                 import('classes.file.JournalFileManager');
                 $journalFileManager = new JournalFileManager($journal);
                 if ($request->getUserVar('registrationCriteria') != "") {
                     $criteria = $request->getUserVar('registrationCriteria');
                     $CBPPlatformDao->setRegistrationCriteria($journal->getJournalId(), $criteria);
                 }
                 if ($request->getUserVar('addTemplate')) {
                     // Add a layout template
                     $editData = true;
                     if (!is_array($templates)) {
                         $templates = array();
                     }
                     $templateId = count($templates);
                     $originalFilename = $_FILES['template-file']['name'];
                     $fileType = $_FILES['template-file']['type'];
                     $filename = "template-{$templateId}." . $journalFileManager->parseFileExtension($originalFilename);
                     $journalFileManager->uploadFile('template-file', $filename);
                     $templates[$templateId] = array('originalFilename' => $originalFilename, 'fileType' => $fileType, 'filename' => $filename, 'title' => $request->getUserVar('template-title'));
                     $journal->updateSetting('templates', $templates);
                 } else {
                     if (($delTemplate = $request->getUserVar('delTemplate')) && count($delTemplate) == 1) {
                         // Delete a template
                         $editData = true;
                         list($delTemplate) = array_keys($delTemplate);
                         $delTemplate = (int) $delTemplate;
                         $template = $templates[$delTemplate];
                         $filename = "template-{$delTemplate}." . $journalFileManager->parseFileExtension($template['originalFilename']);
                         $journalFileManager->deleteFile($filename);
                         array_splice($templates, $delTemplate, 1);
                         $journal->updateSetting('templates', $templates);
                     }
                 }
                 $setupForm->setData('templates', $templates);
                 break;
             case 5:
                 $CBPPlatformDao =& DAORegistry::getDAO('CBPPlatformDAO');
                 $router =& $request->getRouter();
                 $journal = $router->getContext(&$request);
                 $journal = $journal->_data;
                 //%CBP% set Imprint stylesheet
                 if ($request->getUserVar('imprintStylesheet')) {
                     $CBPPlatformDao->setImprintStylesheet($request->getUserVar('imprintStylesheet'), $journal['id']);
                 }
                 //%CBP% set Imprint type
                 if ($request->getUserVar('imprintType')) {
                     $CBPPlatformDao->setImprintType($journal['id'], $request->getUserVar('imprintType'));
                 }
                 if ($request->getUserVar('uploadHomeHeaderTitleImage')) {
                     if ($setupForm->uploadImage('homeHeaderTitleImage', $formLocale)) {
                         $editData = true;
                     } else {
                         $setupForm->addError('homeHeaderTitleImage', Locale::translate('manager.setup.homeTitleImageInvalid'));
                     }
                 } else {
                     if ($request->getUserVar('deleteHomeHeaderTitleImage')) {
                         $editData = true;
                         $setupForm->deleteImage('homeHeaderTitleImage', $formLocale);
                     } else {
                         if ($request->getUserVar('uploadHomeHeaderLogoImage')) {
                             if ($setupForm->uploadImage('homeHeaderLogoImage', $formLocale)) {
                                 $editData = true;
                             } else {
                                 $setupForm->addError('homeHeaderLogoImage', Locale::translate('manager.setup.homeHeaderImageInvalid'));
                             }
                         } else {
                             if ($request->getUserVar('deleteHomeHeaderLogoImage')) {
                                 $editData = true;
                                 $setupForm->deleteImage('homeHeaderLogoImage', $formLocale);
                             } else {
                                 if ($request->getUserVar('uploadJournalFavicon')) {
                                     if ($setupForm->uploadImage('journalFavicon', $formLocale)) {
                                         $editData = true;
                                     } else {
                                         $setupForm->addError('journalFavicon', Locale::translate('manager.setup.journalFaviconInvalid'));
                                     }
                                 } else {
                                     if ($request->getUserVar('deleteJournalFavicon')) {
                                         $editData = true;
                                         $setupForm->deleteImage('journalFavicon', $formLocale);
                                     } else {
                                         if ($request->getUserVar('uploadPageHeaderTitleImage')) {
                                             if ($setupForm->uploadImage('pageHeaderTitleImage', $formLocale)) {
                                                 $editData = true;
                                             } else {
                                                 $setupForm->addError('pageHeaderTitleImage', Locale::translate('manager.setup.pageHeaderTitleImageInvalid'));
                                             }
                                         } else {
                                             if ($request->getUserVar('deletePageHeaderTitleImage')) {
                                                 $editData = true;
                                                 $setupForm->deleteImage('pageHeaderTitleImage', $formLocale);
                                             } else {
                                                 if ($request->getUserVar('uploadPageHeaderLogoImage')) {
                                                     if ($setupForm->uploadImage('pageHeaderLogoImage', $formLocale)) {
                                                         $editData = true;
                                                     } else {
                                                         $setupForm->addError('pageHeaderLogoImage', Locale::translate('manager.setup.pageHeaderLogoImageInvalid'));
                                                     }
                                                 } else {
                                                     if ($request->getUserVar('deletePageHeaderLogoImage')) {
                                                         $editData = true;
                                                         $setupForm->deleteImage('pageHeaderLogoImage', $formLocale);
                                                     } else {
                                                         if ($request->getUserVar('uploadHomepageImage')) {
                                                             if ($setupForm->uploadImage('homepageImage', $formLocale)) {
                                                                 $editData = true;
                                                             } else {
                                                                 $setupForm->addError('homepageImage', Locale::translate('manager.setup.homepageImageInvalid'));
                                                             }
                                                         } else {
                                                             if ($request->getUserVar('deleteHomepageImage')) {
                                                                 $editData = true;
                                                                 $setupForm->deleteImage('homepageImage', $formLocale);
                                                             } else {
                                                                 if ($request->getUserVar('uploadJournalStyleSheet')) {
                                                                     if ($setupForm->uploadStyleSheet('journalStyleSheet')) {
                                                                         $editData = true;
                                                                     } else {
                                                                         $setupForm->addError('journalStyleSheet', Locale::translate('manager.setup.journalStyleSheetInvalid'));
                                                                     }
                                                                 } else {
                                                                     if ($request->getUserVar('deleteJournalStyleSheet')) {
                                                                         $editData = true;
                                                                         $setupForm->deleteImage('journalStyleSheet');
                                                                     } else {
                                                                         if ($request->getUserVar('addNavItem')) {
                                                                             // Add a navigation bar item
                                                                             $editData = true;
                                                                             $navItems = $setupForm->getData('navItems');
                                                                             $navItems[$formLocale][] = array();
                                                                             $setupForm->setData('navItems', $navItems);
                                                                         } else {
                                                                             if (($delNavItem = $request->getUserVar('delNavItem')) && count($delNavItem) == 1) {
                                                                                 // Delete a  navigation bar item
                                                                                 $editData = true;
                                                                                 list($delNavItem) = array_keys($delNavItem);
                                                                                 $delNavItem = (int) $delNavItem;
                                                                                 $navItems = $setupForm->getData('navItems');
                                                                                 if (is_array($navItems) && is_array($navItems[$formLocale])) {
                                                                                     array_splice($navItems[$formLocale], $delNavItem, 1);
                                                                                     $setupForm->setData('navItems', $navItems);
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 break;
         }
         if (!isset($editData) && $setupForm->validate()) {
             $setupForm->execute();
             $request->redirect(null, null, 'setupSaved', $step);
         } else {
             $setupForm->display($request, $this->getDispatcher());
         }
     } else {
         $request->redirect();
     }
 }