/** * Execute the form, but first: * Make sure we're not saving an empty entry for sponsors. (This would * result in a possibly empty heading for the Sponsors section in About * the Press.) */ function execute() { foreach (array('sponsors', 'contributors') as $element) { $elementValue = (array) $this->getData($element); foreach (array_keys($elementValue) as $key) { $values = array_values((array) $elementValue[$key]); $isEmpty = true; foreach ($values as $value) { if (!empty($value)) { $isEmpty = false; } } if ($isEmpty) { unset($elementValue[$key]); } } $this->setData($element, $elementValue); } $press =& Request::getPress(); if ($press->getEnabled() !== $this->getData('pressEnabled')) { $pressDao =& DAORegistry::getDAO('PressDAO'); $press->setEnabled($this->getData('pressEnabled')); $pressDao->updatePress($press); } return parent::execute(); }
function execute() { // Save the block plugin layout settings. $blockVars = array('blockSelectLeft', 'blockUnselected', 'blockSelectRight'); foreach ($blockVars as $varName) { ${$varName} = split(' ', Request::getUserVar($varName)); } $plugins =& PluginRegistry::loadCategory('blocks'); foreach ($plugins as $key => $junk) { $plugin =& $plugins[$key]; // Ref hack $plugin->setEnabled(!in_array($plugin->getName(), $blockUnselected)); if (in_array($plugin->getName(), $blockSelectLeft)) { $plugin->setBlockContext(BLOCK_CONTEXT_LEFT_SIDEBAR); $plugin->setSeq(array_search($key, $blockSelectLeft)); } else { if (in_array($plugin->getName(), $blockSelectRight)) { $plugin->setBlockContext(BLOCK_CONTEXT_RIGHT_SIDEBAR); $plugin->setSeq(array_search($key, $blockSelectRight)); } } unset($plugin); } // Save alt text for images $press =& Request::getPress(); $pressId = $press->getId(); $locale = $this->getFormLocale(); $settingsDao =& DAORegistry::getDAO('PressSettingsDAO'); $images = $this->images; foreach ($images as $settingName) { $value = $press->getSetting($settingName); if (!empty($value)) { $imageAltText = $this->getData($this->image_settings[$settingName]); $value[$locale]['altText'] = $imageAltText[$locale]; $settingsDao->updateSetting($pressId, $settingName, $value, 'object', true); } } // Save remaining settings return parent::execute(); }