Exemplo n.º 1
0
 /**
  * Save the theme step
  * 
  * @param array $values
  * @param object SiteNavBlockSiteComponent $site
  * @return boolean
  * @access protected
  * @since 5/8/08
  */
 protected function saveThemeStep(array $values, SiteNavBlockSiteComponent $site)
 {
     $themeMgr = Services::getService("GUIManager");
     /*********************************************************
      * Set the default theme of the site.
      *********************************************************/
     $themeMgr = Services::getService('GUIManager');
     try {
         // Set the chosen theme.
         if (is_null($values['theme']['selected'])) {
             if (defined('SEGUE_DEFAULT_SITE_THEME')) {
                 $site->updateTheme($themeMgr->getTheme(SEGUE_DEFAULT_SITE_THEME));
             } else {
                 $site->updateTheme($themeMgr->getDefaultTheme());
             }
         } else {
             $site->updateTheme($themeMgr->getTheme($values['theme']['selected']));
         }
     } catch (UnknownIdException $e) {
         $site->updateTheme($themeMgr->getDefaultTheme());
     }
     return true;
 }
 /**
  * Apply the theme if one is defined.
  * 
  * @param object SiteNavBlockSiteComponent $site
  * @return void
  * @access protected
  * @since 6/6/08
  */
 protected function applyTheme(SiteNavBlockSiteComponent $site)
 {
     // Get the theme specified in the source
     $themeElements = $this->xpath->evaluate('/Segue2/SiteNavBlock/theme');
     if ($themeElements->length) {
         $themeElement = $themeElements->item(0);
         $themeMgr = Services::getService("GUIManager");
         try {
             $theme = $themeMgr->getTheme($themeElement->getAttribute("id"));
         } catch (UnknownIdException $e) {
             return null;
             // Give up and use default theme.
         }
         if ($theme->supportsOptions()) {
             $optSession = $theme->getOptionsSession();
             $optionChoices = $this->xpath->evaluate('./theme_option_choice', $themeElement);
             foreach ($optionChoices as $choiceElement) {
                 $this->applyThemeOption($optSession, $choiceElement);
             }
         }
         // update theme with options from source
         $site->updateTheme($theme);
     }
 }