/** * Update the Site to use the theme passed. Any options set on the theme * will be remembered. * * @param object Harmoni_Gui2_ThemeInterface $theme * @return null * @access public * @since 5/8/08 */ public function updateTheme(Harmoni_Gui2_ThemeInterface $theme) { $element = $this->getElement(); $doc = $element->ownerDocument; // Delete any existing theme-settings $this->useDefaultTheme(); // Add our new theme $themeElement = $element->appendChild($doc->createElement('theme')); $themeElement->setAttribute('id', $theme->getIdString()); // If the theme supports settings, save them. if ($theme->supportsOptions()) { $optionsSession = $theme->getOptionsSession(); // Only Store options if not using defaults if (!$optionsSession->usesDefaults()) { $themeElement->appendChild($doc->createCDATASection($optionsSession->getOptionsValue())); } } $this->_saveXml(); }
/** * Create a copy of a theme and return the new copy. * * @param object Harmoni_Gui2_ThemeInterface $theme * @return object Harmoni_Gui2_ThemeInterface * @access public * @since 5/16/08 */ public function createCopy(Harmoni_Gui2_ThemeInterface $theme) { $newTheme = $this->createTheme(); $newTheme->updateDisplayName($theme->getDisplayName() . " " . _("copy")); $newTheme->updateDescription($theme->getDescription()); $newTheme->updateThumbnail($theme->getThumbnail()); if ($theme->supportsOptions()) { $optionsSession = $theme->getOptionsSession(); $newOptionsSession = $newTheme->getOptionsSession(); $newOptionsSession->updateOptionsDocument($optionsSession->getOptionsDocument()); } $modSess = $newTheme->getModificationSession(); $modSess->updateGlobalCss($theme->getGlobalCss()); foreach ($theme->getComponentTypes() as $type) { $modSess->updateCssForType($type, $theme->getCssForType($type)); $modSess->updateTemplateForType($type, $theme->getTemplateForType($type)); } foreach ($theme->getImages() as $image) { $path = $image->getPath(); $dir = dirname($path); $prefixPath = ''; if (preg_match('/^(?:(?:.*\\/)?images\\/)?(.+)$/', $dir, $matches)) { $prefixPath = $matches[1]; } $modSess->addImage($image, $image->getBasename(), $prefixPath); } return $newTheme; }