00001 <?php
00002
00015
00016
00017
00018 import('form.Form');
00019
00020 class XMLGalleySettingsForm extends Form {
00022 var $journalId;
00023
00025 var $plugin;
00026
00032 function XMLGalleySettingsForm(&$plugin, $journalId) {
00033 $templateMgr = &TemplateManager::getManager();
00034
00035 parent::Form($plugin->getTemplatePath() . 'settingsForm.tpl');
00036
00037 $this->journalId = $journalId;
00038 $this->plugin = &$plugin;
00039
00040 $this->addCheck(new FormValidatorPost($this));
00041 }
00042
00046 function initData() {
00047 $journalId = $this->journalId;
00048 $plugin =& $this->plugin;
00049
00050 $templateMgr = &TemplateManager::getManager();
00051
00052
00053 $xsltPHP5 = ( version_compare(PHP_VERSION,'5','>=') && extension_loaded('xsl') && extension_loaded('dom') );
00054 $xsltPHP4 = ( version_compare(PHP_VERSION,'5','<') && extension_loaded('xslt') );
00055
00056
00057 $this->setData('xsltPHP5', $xsltPHP5);
00058 $this->setData('xsltPHP4', $xsltPHP4);
00059
00060 if ( !Request::getUserVar('save') ) {
00061 $this->setData('XSLTrenderer', $plugin->getSetting($journalId, 'XSLTrenderer'));
00062 $this->setData('externalXSLT', $plugin->getSetting($journalId, 'externalXSLT'));
00063 $this->setData('XSLstylesheet', $plugin->getSetting($journalId, 'XSLstylesheet'));
00064 $this->setData('nlmPDF', $plugin->getSetting($journalId, 'nlmPDF'));
00065 $this->setData('externalFOP', $plugin->getSetting($journalId, 'externalFOP'));
00066 }
00067 $this->setData('customXSL', $plugin->getSetting($journalId, 'customXSL'));
00068 }
00069
00073 function readInputData() {
00074 $this->readUserVars(array('XSLTrenderer', 'XSLstylesheet', 'externalXSLT', 'customXSL', 'nlmPDF', 'externalFOP'));
00075
00076
00077 if ($this->getData('XSLTrenderer') == "external") {
00078 $this->addCheck(new FormValidator($this, 'externalXSLT', 'required', 'plugins.generic.xmlGalley.settings.externalXSLTRequired'));
00079 }
00080
00081
00082 if ($this->getData('nlmPDF') == "1") {
00083 $this->addCheck(new FormValidator($this, 'externalFOP', 'required', 'plugins.generic.xmlGalley.settings.xslFOPRequired'));
00084 }
00085
00086
00087 if ($this->getData('XSLstylesheet') == "custom") {
00088 $this->addCheck(new FormValidator($this, 'customXSL', 'required', 'plugins.generic.xmlGalley.settings.customXSLRequired'));
00089 }
00090
00091 }
00092
00096 function execute() {
00097 $plugin = &$this->plugin;
00098 $journalId = $this->journalId;
00099
00100
00101 $flushCache = false;
00102 foreach ($this->_data as $setting => $value) {
00103 if ($plugin->getSetting($journalId, $setting) != $value) $flushCache = true;
00104 }
00105
00106
00107 if ($flushCache == true) {
00108 $cacheManager =& CacheManager::getManager();
00109 $cacheManager->flush('xsltGalley');
00110 }
00111
00112 $plugin->updateSetting($journalId, 'nlmPDF', $this->getData('nlmPDF'));
00113 $plugin->updateSetting($journalId, 'externalFOP', $this->getData('externalFOP'));
00114 $plugin->updateSetting($journalId, 'XSLTrenderer', $this->getData('XSLTrenderer'));
00115 $plugin->updateSetting($journalId, 'XSLstylesheet', $this->getData('XSLstylesheet'));
00116 $plugin->updateSetting($journalId, 'externalXSLT', $this->getData('externalXSLT'));
00117 $plugin->updateSetting($journalId, 'customXSL', $this->getData('customXSL'));
00118 }
00119 }
00120
00121 ?>