Пример #1
0
 public function onLayoutSave(Event $event)
 {
     $positions = $event->gantry['configurations']->positions();
     $manifest = new Manifest($event->gantry['theme.name']);
     $manifest->setPositions(array_keys($positions));
     $manifest->save();
 }
Пример #2
0
 public function onLayoutSave(Event $event)
 {
     $gantry = Gantry::instance();
     /** @var Configurations $configurations */
     $configurations = $gantry['configurations'];
     $list = [];
     foreach ($configurations as $name => $title) {
         $list += Layout::instance($name)->positions();
     }
     $manifest = new Manifest($gantry['theme.name']);
     $manifest->setPositions(array_keys($list));
     $manifest->save();
 }
Пример #3
0
 public function onLayoutSave(Event $event)
 {
     $theme = $event->gantry['theme.name'];
     $positions = $event->gantry['configurations']->positions();
     $manifest = new Manifest($theme);
     $manifest->setPositions(array_keys($positions));
     $manifest->save();
     $translations = [];
     foreach ($positions as $key => $translation) {
         // Encode translation key in Joomla way.
         $key = preg_replace('/[^A-Z0-9_\\-]/', '_', strtoupper("TPL_{$theme}_POSITION_{$key}"));
         $translations[$key] = $translation;
     }
     /** @var UniformResourceLocator $locator */
     $locator = $event->gantry['locator'];
     $filename = "gantry-theme://language/en-GB/en-GB.tpl_{$theme}_positions.ini";
     $ini = IniFile::instance($locator->findResource($filename, true, true));
     $ini->save($translations);
 }
Пример #4
0
 public function cleanup()
 {
     $name = $this->extension->name;
     $path = JPATH_SITE . '/templates/' . $name;
     // Remove compiled CSS files if they exist.
     $cssPath = $path . '/custom/css-compiled';
     if (is_dir($cssPath)) {
         \JFolder::delete($cssPath);
     } elseif (is_file($cssPath)) {
         \JFile::delete($cssPath);
     }
     // Remove wrongly named file if it exists.
     $md5path = $path . '/MD5SUM';
     if (is_file($md5path)) {
         \JFile::delete($md5path);
     }
     // Restart Gantry and initialize it.
     $gantry = Gantry::restart();
     $gantry['theme.name'] = $name;
     $gantry['streams']->register();
     // Only add error service if debug mode has been enabled.
     if ($gantry->debug()) {
         $gantry->register(new ErrorServiceProvider());
     }
     /** @var Platform $patform */
     $patform = $gantry['platform'];
     /** @var UniformResourceLocator $locator */
     $locator = $gantry['locator'];
     // Initialize theme stream.
     $details = new ThemeDetails($name);
     $locator->addPath('gantry-theme', '', $details->getPaths(), false, true);
     // Initialize theme cache stream and clear theme cache.
     $cachePath = $patform->getCachePath() . '/' . $name;
     if (is_dir($cachePath)) {
         Folder::delete($cachePath);
     }
     Folder::create($cachePath);
     $locator->addPath('gantry-cache', 'theme', [$cachePath], true, true);
     $gantry['file.yaml.cache.path'] = $locator->findResource('gantry-cache://theme/compiled/yaml', true, true);
     /** @var Outlines $outlines */
     $outlines = $gantry['configurations'];
     // Update positions in manifest file.
     $positions = $outlines->positions();
     $manifest = new Manifest($name);
     $manifest->setPositions(array_keys($positions));
     $manifest->save();
 }