00001 <?php
00002
00015
00016
00017
00018 import('form.Form');
00019
00020 class CustomThemeSettingsForm extends Form {
00021
00023 var $journalId;
00024
00026 var $plugin;
00027
00033 function CustomThemeSettingsForm(&$plugin, $journalId) {
00034 $this->journalId = $journalId;
00035 $this->plugin = &$plugin;
00036
00037 parent::Form($plugin->getTemplatePath() . 'settingsForm.tpl');
00038 }
00039
00040 function display() {
00041 $templateMgr =& TemplateManager::getManager();
00042 $additionalHeadData = $templateMgr->get_template_vars('additionalHeadData');
00043 $additionalHeadData .= '<script type="text/javascript" src="' . Request::getBaseUrl() . '/plugins/themes/custom/picker.js"></script>' . "\n";
00044 $templateMgr->addStyleSheet(Request::getBaseUrl() . '/plugins/themes/custom/picker.css');
00045 $templateMgr->assign('additionalHeadData', $additionalHeadData);
00046 $stylesheetFileLocation = $this->plugin->getPluginPath() . '/' . $this->plugin->getStylesheetFilename();
00047 $templateMgr->assign('canSave', is_writable($stylesheetFileLocation));
00048 $templateMgr->assign('stylesheetFileLocation', $stylesheetFileLocation);
00049
00050 return parent::display();
00051 }
00052
00056 function initData() {
00057 $journalId = $this->journalId;
00058 $plugin = &$this->plugin;
00059
00060 $this->_data = array(
00061 'customThemeHeaderColour' => $plugin->getSetting($journalId, 'customThemeHeaderColour'),
00062 'customThemeLinkColour' => $plugin->getSetting($journalId, 'customThemeLinkColour'),
00063 'customThemeBackgroundColour' => $plugin->getSetting($journalId, 'customThemeBackgroundColour'),
00064 'customThemeForegroundColour' => $plugin->getSetting($journalId, 'customThemeForegroundColour')
00065 );
00066 }
00067
00071 function readInputData() {
00072 $this->readUserVars(array('customThemeHeaderColour', 'customThemeLinkColour', 'customThemeBackgroundColour', 'customThemeForegroundColour'));
00073 }
00074
00078 function execute() {
00079 $plugin = &$this->plugin;
00080 $journalId = $this->journalId;
00081 $css = '';
00082
00083
00084 $customThemeHeaderColour = $this->getData('customThemeHeaderColour');
00085 $plugin->updateSetting($journalId, 'customThemeHeaderColour', $customThemeHeaderColour, 'string');
00086 $css .= "#header {background-color: $customThemeHeaderColour;}\n";
00087 $css .= "#footer {background-color: $customThemeHeaderColour;}\n";
00088 $css .= "table.listing tr.fastTracked {background-color: $customThemeHeaderColour;}\n";
00089
00090
00091 $customThemeLinkColour = $this->getData('customThemeLinkColour');
00092 $plugin->updateSetting($journalId, 'customThemeLinkColour', $customThemeLinkColour, 'string');
00093 $css .= "a {color: $customThemeLinkColour;}\n";
00094 $css .= "a:link {color: $customThemeLinkColour;}\n";
00095 $css .= "a:active {color: $customThemeLinkColour;}\n";
00096 $css .= "a:visited {color: $customThemeLinkColour;}\n";
00097 $css .= "a:hover {color: $customThemeLinkColour;}\n";
00098 $css .= "input.defaultButton {color: $customThemeLinkColour;}\n";
00099
00100
00101 $customThemeBackgroundColour = $this->getData('customThemeBackgroundColour');
00102 $plugin->updateSetting($journalId, 'customThemeBackgroundColour', $customThemeBackgroundColour, 'string');
00103 $css .= "body {background-color: $customThemeBackgroundColour;}\n";
00104 $css .= "input.defaultButton {background-color: $customThemeBackgroundColour;}\n";
00105
00106
00107 $customThemeForegroundColour = $this->getData('customThemeForegroundColour');
00108 $plugin->updateSetting($journalId, 'customThemeForegroundColour', $customThemeForegroundColour, 'string');
00109 $css .= "body {color: $customThemeForegroundColour;}\n";
00110 $css .= "input.defaultButton {color: $customThemeForegroundColour;}\n";
00111
00112 import('file.FileManager');
00113 FileManager::writeFile(dirname(__FILE__) . '/custom.css', $css);
00114 }
00115 }
00116
00117 ?>