Ejemplo n.º 1
0
 /**
  * Answer a gui component for this theme listing
  * 
  * @param object Harmoni_Gui2_ThemeInterface $theme
  * @return object ComponentInterface
  * @access public
  * @since 5/7/08
  */
 public function getThemeListing(Harmoni_Gui2_ThemeInterface $theme)
 {
     ob_start();
     try {
         print "\n\t<h2>" . $theme->getDisplayName() . "</h2>";
     } catch (UnimplementedException $e) {
         print "\n\t<div style='font-style: italic'>" . _("Display-Name not available.") . "</div>";
     }
     try {
         $thumb = $theme->getThumbnail();
         $harmoni = Harmoni::instance();
         print "\n\t<img src='" . $harmoni->request->quickUrl('gui2', 'theme_thumbnail', array('theme' => $theme->getIdString())) . "' style='float: left; width: 200px; margin-right: 10px;'/>";
     } catch (UnimplementedException $e) {
         print "\n\t<div style='font-style: italic'>" . _("Thumbnail not available.") . "</div>";
     } catch (OperationFailedException $e) {
         print "\n\t<div style='font-style: italic'>" . _("Thumbnail not available.") . "</div>";
     }
     print _("Id") . ": " . $theme->getIdString();
     try {
         print "\n\t<p>" . $theme->getDescription() . "</p>";
     } catch (UnimplementedException $e) {
         print "\n\t<div style='font-style: italic'>" . _("Description not available.") . "</div>";
     }
     try {
         $history = $theme->getHistory();
         print "\n\t<h4>" . _("History") . "</h4>";
         print "\n\t<ul>";
         foreach ($history as $entry) {
             print "\n\t\t<li style='margin-left: 20px;'>";
             print $entry->getDateAndTime()->ymdString();
             print " - ";
             print $entry->getName();
             print "<br/><em>" . $entry->getComment() . "</em>";
             print "</li>";
         }
         print "\n\t</ul>";
     } catch (UnimplementedException $e) {
         print "\n\t<div style='font-style: italic'>" . _("History not available.") . "</div>";
     }
     return new Block(ob_get_clean(), STANDARD_BLOCK);
 }
 /**
  * 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();
 }
Ejemplo n.º 3
0
 /**
  * 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;
 }