public function registerEvents()
 {
     $app = $this->app;
     $events = $this->app->make('director');
     // Add the sitemap icons listener
     $events->addListener('on_before_render', function ($event) use($app) {
         $c = Page::getCurrentPage();
         $view = $event->getArgument('view');
         $assets = $app->make('asset_pipeline/helper/assets');
         $theme = null;
         if (is_object($c)) {
             $theme = $c->getCollectionThemeObject();
         } else {
             $theme = Theme::getSiteTheme();
         }
         // TODO: If there are page-specific styles set, should we use
         //       this one instead:
         //$style = $c->getCustomStyleObject();
         $style = $theme->getThemeCustomStyleObject();
         if (is_object($style)) {
             $valueList = $style->getValueList();
             if ($valueList instanceof \Concrete\Core\StyleCustomizer\Style\ValueList) {
                 $variables = array();
                 foreach ($valueList->getValues() as $value) {
                     $variables = array_merge($value->toLessVariablesArray(), $variables);
                 }
                 $assets->setStylesheetVariables('theme', $variables);
             }
         }
         $view->addScopeItems(array('assets' => $assets));
     });
 }
Пример #2
0
 public function setThemeContext($theme = null)
 {
     if ($theme === null) {
         $c = Page::getCurrentPage();
         if (is_object($c)) {
             $theme = $c->getCollectionThemeObject();
         } else {
             $theme = Theme::getSiteTheme();
         }
     }
     if (!is_object($theme)) {
         // TODO: Check whether this can happen or not...
         throw new Exception(t("No theme available for the page!"));
     }
     $env = Environment::get();
     $r = $env->getRecord(DIRNAME_THEMES . '/' . $theme->getThemeHandle(), $theme->getPackageHandle());
     $this->themeBasePath = $r->file;
 }
Пример #3
0
 /**
  * @return bool|int[] true on success, array of error codes on failure
  */
 public function testForUninstall()
 {
     $errors = array();
     $manager = new Manager($this->app);
     /**
      * @var $driver ItemInterface
      */
     $driver = $manager->driver('theme');
     $themes = $driver->getItems($this->getPackageEntity());
     /** @var Theme[] $themes */
     // Step 1, check for active themes
     $active_theme = Theme::getSiteTheme();
     foreach ($themes as $theme) {
         if ($active_theme->getThemeID() == $theme->getThemeID()) {
             $errors[] = self::E_PACKAGE_THEME_ACTIVE;
             break;
         }
     }
     if (count($errors) > 0) {
         $e = $this->app->make('error');
         foreach ($errors as $error) {
             $e->add($this->getErrorText($error));
         }
         return $e;
     } else {
         return true;
     }
 }