コード例 #1
0
ファイル: Gantry.php プロジェクト: legutierr/gantry5
 protected function loadGlobal()
 {
     $file = CompiledYamlFile::instance(PRIME_ROOT . '/config/global.yaml');
     $data = (array) $file->setCachePath(PRIME_ROOT . '/cache/global')->content();
     $file->free();
     return $data;
 }
コード例 #2
0
 public function __construct($theme)
 {
     $gantry = Gantry::instance();
     /** @var UniformResourceLocator $locator */
     $locator = $gantry['locator'];
     $this->items = CompiledYamlFile::instance($locator("gantry-themes://{$theme}/gantry/theme.yaml"))->content();
     $this->offsetSet('name', $theme);
     $parent = $this->offsetGet('configuration.theme.parent') ?: $theme;
     $this->offsetSet('parent', $theme !== $parent ? $parent : null);
 }
コード例 #3
0
ファイル: LayoutReader.php プロジェクト: naka211/myloyal
 /**
  * Read layout from yaml file and return parsed version of it.
  *
  * @param string $file
  * @return array
  */
 public static function read($file)
 {
     if (!$file) {
         return [];
     }
     $file = CompiledYamlFile::instance($file);
     $content = (array) $file->content();
     $file->free();
     return static::data($content);
 }
コード例 #4
0
ファイル: Content.php プロジェクト: juanmanunez/gantry5
 public function get($id)
 {
     if ($this->content[$id]) {
         return $this->content[$id];
     }
     $files = $this->locateBlueprints();
     if (empty($files[$id])) {
         throw new \RuntimeException("Settings for '{$id}' not found.", 404);
     }
     $filename = key($files[$id]);
     $item = CompiledYamlFile::instance(GANTRY5_ROOT . '/' . $filename)->content();
     return $item;
 }
コード例 #5
0
ファイル: ThemeDetails.php プロジェクト: nmsde/gantry5
 public function __construct($theme)
 {
     $gantry = Gantry::instance();
     /** @var UniformResourceLocator $locator */
     $locator = $gantry['locator'];
     $filename = $locator->findResource("gantry-themes://{$theme}/gantry/theme.yaml");
     $cache = $locator->findResource("gantry-cache://{$theme}/compiled/yaml", true, true);
     $file = CompiledYamlFile::instance($filename);
     $this->items = $file->setCachePath($cache)->content();
     $this->offsetSet('name', $theme);
     $file->free();
     $parent = $this->offsetGet('configuration.theme.parent') ?: $theme;
     $this->offsetSet('parent', $theme !== $parent ? $parent : null);
 }
コード例 #6
0
ファイル: Particles.php プロジェクト: naka211/myloyal
 public function get($id)
 {
     if ($this->particles[$id]) {
         return $this->particles[$id];
     }
     $files = $this->locateParticles();
     if (empty($files[$id])) {
         throw new \RuntimeException("Settings for '{$id}' not found.", 404);
     }
     $filename = key($files[$id]);
     $particle = CompiledYamlFile::instance(GANTRY5_ROOT . '/' . $filename)->content();
     $particle['subtype'] = $id;
     // TODO: can this be done better or is it fine like that?
     return $particle;
 }
コード例 #7
0
ファイル: Styles.php プロジェクト: ericssonm/JusCuzCustoms
 public function get($id)
 {
     if ($this->blocks[$id]) {
         return $this->blocks[$id];
     }
     $files = $this->locateBlocks();
     if (empty($files[$id])) {
         throw new \RuntimeException("Settings for '{$id}' not found.", 404);
     }
     $filename = key($files[$id]);
     $file = CompiledYamlFile::instance(GANTRY5_ROOT . '/' . $filename);
     $particle = $file->content();
     $file->free();
     return $particle;
 }
コード例 #8
0
 public function register(Container $gantry)
 {
     $sp = $this;
     $gantry['locator'] = function ($c) use($sp) {
         return new UniformResourceLocator(GANTRY5_ROOT);
     };
     $gantry['streams'] = function ($c) use($sp) {
         $schemes = (array) $c['platform']->get('streams');
         /** @var UniformResourceLocator $locator */
         $locator = $c['locator'];
         $streams = new Streams($locator);
         $streams->add($schemes);
         CompiledYamlFile::setCachePath($locator->findResource('gantry-cache://compiled/yaml', true, true));
         return $streams;
     };
 }
コード例 #9
0
ファイル: Translator.php プロジェクト: JozefAB/neoacu
 protected function load($language, $section)
 {
     $gantry = Gantry::instance();
     /** @var UniformResourceLocator $locator */
     $locator = $gantry['locator'];
     $section = strtolower($section);
     $filename = 'gantry-admin://translations/' . $language . '/' . $section . '.yaml';
     $file = CompiledYamlFile::instance($filename);
     if (!$file->exists() && ($pos = strpos($language, '-')) > 0) {
         $filename = 'gantry-admin://translations/' . substr($language, 0, $pos) . '/' . $section . '.yaml';
         $file = CompiledYamlFile::instance($filename);
     }
     $cachePath = $locator->findResource('gantry-cache://translations', true, true);
     $translations = (array) $file->setCachePath($cachePath)->content();
     $file->free();
     return $translations;
 }
コード例 #10
0
ファイル: ThemeDetails.php プロジェクト: legutierr/gantry5
 /**
  * Create new theme details.
  *
  * @param string $theme
  */
 public function __construct($theme)
 {
     $gantry = Gantry::instance();
     /** @var UniformResourceLocator $locator */
     $locator = $gantry['locator'];
     $filename = $locator->findResource("gantry-themes://{$theme}/gantry/theme.yaml");
     if (!$filename) {
         throw new \RuntimeException(sprintf('Theme %s not found', $theme), 404);
     }
     $cache = $locator->findResource("gantry-cache://{$theme}/compiled/yaml", true, true);
     $file = CompiledYamlFile::instance($filename);
     $this->items = $file->setCachePath($cache)->content();
     $file->free();
     $this->offsetSet('name', $theme);
     $parent = (string) $this->offsetGet('configuration.theme.parent', $theme);
     $parent = $parent != $theme ? $parent : null;
     $this->offsetSet('parent', $parent);
 }
コード例 #11
0
ファイル: ThemeTrait.php プロジェクト: Acidburn0zzz/gantry5
 /**
  * Returns style presets for the theme.
  *
  * @return Config
  */
 public function presets()
 {
     static $presets;
     if (!$presets) {
         $gantry = static::gantry();
         /** @var UniformResourceLocator $locator */
         $locator = $gantry['locator'];
         $filename = $locator->findResource("gantry-theme://gantry/presets.yaml");
         $presets = new Config(CompiledYamlFile::instance($filename)->content());
     }
     return $presets;
 }
コード例 #12
0
ファイル: Menu.php プロジェクト: nmsde/gantry5
 /**
  * Load blueprints.
  *
  * @param string $name
  *
  * @return BlueprintsForm
  */
 protected function loadBlueprints($name = 'menu')
 {
     /** @var UniformResourceLocator $locator */
     $locator = $this->container['locator'];
     $filename = $locator("gantry-admin://blueprints/menu/{$name}.yaml");
     $file = CompiledYamlFile::instance($filename);
     $content = new BlueprintsForm($file->content());
     $file->free();
     return $content;
 }
コード例 #13
0
ファイル: Layout.php プロジェクト: JozefAB/neoacu
 /**
  * @param  string $name
  * @return static
  */
 public static function loadIndex($name, $autoSave = false)
 {
     $gantry = Gantry::instance();
     /** @var UniformResourceLocator $locator */
     $locator = $gantry['locator'];
     // Attempt to load the index file.
     $indexFile = $locator("gantry-config://{$name}/index.yaml");
     if ($indexFile) {
         $file = CompiledYamlFile::instance($indexFile);
         $index = $file->content();
         $file->free();
     }
     // Find out the currently used layout file.
     $layoutFile = $locator("gantry-config://{$name}/layout.yaml");
     if (!$layoutFile) {
         /** @var Outlines $configurations */
         $configurations = $gantry['configurations'];
         $preset = isset($index['preset']['name']) ? $index['preset']['name'] : $configurations->preset($name);
         $layoutFile = $locator("gantry-layouts://{$preset}.yaml");
     }
     // Get timestamp for the layout file.
     $timestamp = $layoutFile ? filemtime($layoutFile) : 0;
     // If layout index file doesn't exist or is not up to date, build it.
     if (!isset($index['timestamp']) || $index['timestamp'] != $timestamp) {
         $layout = isset($preset) ? new static($name, static::preset($preset)) : static::instance($name);
         $layout->timestamp = $timestamp;
         $index = $layout->buildIndex();
     }
     if ($autoSave && isset($layout)) {
         $layout->saveIndex();
     }
     $index += ['name' => $name, 'timestamp' => $timestamp, 'preset' => ['name' => '', 'image' => 'gantry-admin://images/layouts/default.png'], 'positions' => []];
     return $index;
 }
コード例 #14
0
 /**
  * Load single configuration file and append it to the correct position.
  *
  * @param  string  $name  Name of the position.
  * @param  string  $filename  File to be loaded.
  */
 protected function loadFile($name, $filename)
 {
     $file = CompiledYamlFile::instance($filename);
     $this->object->join($name, $file->content(), '/');
 }
コード例 #15
0
 /**
  * Get menu configuration.
  *
  * @return Config
  */
 public function config()
 {
     if (!$this->config) {
         $gantry = static::gantry();
         /** @var UniformResourceLocator $locator */
         $locator = $gantry['locator'];
         $menu = $this->params['menu'];
         $this->config = new Config(CompiledYamlFile::instance($locator("gantry-config://menu/{$menu}.yaml"))->content());
     }
     return $this->config;
 }
コード例 #16
0
ファイル: Layout.php プロジェクト: ericssonm/JusCuzCustoms
 public function validate($particle)
 {
     // Validate only exists for JSON.
     if (empty($this->params['ajax'])) {
         $this->undefined();
     }
     // Load particle blueprints and default settings.
     $validator = new Blueprints();
     $name = $particle;
     if (in_array($particle, ['wrapper', 'section', 'container', 'grid', 'offcanvas'])) {
         $type = $particle;
         $particle = null;
         $file = CompiledYamlFile::instance("gantry-admin://blueprints/layout/{$type}.yaml");
         $validator->embed('options', $file->content());
         $file->free();
         $defaults = [];
     } else {
         $type = in_array($particle, ['spacer', 'system', 'position']) ? $particle : 'particle';
         $validator->embed('options', $this->container['particles']->get($particle));
         $defaults = (array) $this->container['config']->get("particles.{$particle}");
     }
     // Create configuration from the defaults.
     $data = new Config(['type' => $type], function () use($validator) {
         return $validator;
     });
     // Join POST data.
     $data->join('options', $this->request->post->getArray("particles." . $name));
     if ($particle) {
         $data->set('options.enabled', (int) $data->get('options.enabled', 1));
     }
     if ($particle) {
         if ($type != $particle) {
             $data->set('subtype', $particle);
         }
         $data->join('title', $this->request->post['title'] ?: ucfirst($particle));
     }
     $block = $this->request->post->getArray('block');
     if ($block) {
         // TODO: remove empty items in some other way:
         foreach ($block as $key => $param) {
             if ($param === '') {
                 unset($block[$key]);
                 continue;
             }
             if ($key == 'size') {
                 $param = round($param, 4);
                 if ($param < 5) {
                     $param = 5;
                 } elseif ($param > 100) {
                     $param = 100;
                 }
                 $block[$key] = $param;
             }
         }
         $data->join('block', $block);
     }
     // TODO: validate
     return new JsonResponse(['data' => $data->toArray()]);
 }
コード例 #17
0
ファイル: AbstractMenu.php プロジェクト: legutierr/gantry5
 /**
  * Get menu configuration.
  *
  * @return Config
  */
 public function config()
 {
     if (!$this->config) {
         $gantry = static::gantry();
         /** @var UniformResourceLocator $locator */
         $locator = $gantry['locator'];
         $menu = $this->params['menu'];
         $file = CompiledYamlFile::instance($locator("gantry-config://menu/{$menu}.yaml"));
         $this->config = new Config($file->content());
         $this->config->def('settings.title', ucfirst($menu));
         $file->free();
     }
     return $this->config;
 }