Ejemplo n.º 1
0
 /**
  * Initialize Gantry admin if in Grav admin.
  */
 public function initializeGantryAdmin()
 {
     if (!$this->isAdmin()) {
         return;
     }
     $this->enable(['onAdminMenu' => ['onAdminMenu', 0]]);
     /** @var \Grav\Plugin\Admin $admin */
     $admin = $this->grav['admin'];
     if ($admin->location != 'gantry' && ($admin->location != 'themes' || !$admin->route)) {
         return;
     }
     $results = explode('/', $admin->route, 2);
     $theme = array_shift($results);
     // Do not initialize Gantry on non-Gantry themes.
     if ($theme && !is_file("themes://{$theme}/gantry/theme.yaml")) {
         return;
     }
     $this->enable(['onAdminThemeInitialized' => ['runAdmin', 0]]);
     // Setup Gantry 5 Framework or throw exception.
     \Gantry5\Loader::setup();
     if (!defined('GANTRYADMIN_PATH')) {
         define('GANTRYADMIN_PATH', 'plugins://gantry5/admin');
     }
     $base = rtrim($this->grav['base_url'], '/');
     $this->base = rtrim("{$base}{$admin->base}/{$admin->location}/{$theme}", '/');
     if ($theme) {
         // Switch theme and initialize it.
         $this->config->set('system.pages.theme', $theme);
     }
 }
Ejemplo n.º 2
0
 public function onThemeInitialized()
 {
     /** @var UniformResourceLocator $locator */
     $locator = $this->grav['locator'];
     $path = $locator('theme://');
     $name = $this->name;
     if (!class_exists('\\Gantry5\\Loader')) {
         if ($this->isAdmin()) {
             $messages = $this->grav['messages'];
             $messages->add('Please enable Gantry 5 plugin in order to use current theme!', 'error');
             return;
         } else {
             throw new \LogicException('Please install and enable Gantry 5 Framework plugin!');
         }
     }
     // Setup Gantry 5 Framework or throw exception.
     \Gantry5\Loader::setup();
     // Get Gantry instance.
     $gantry = Gantry::instance();
     // Set the theme path from Grav variable.
     $gantry['theme.path'] = $path;
     $gantry['theme.name'] = $name;
     // Define the template.
     require $locator('theme://includes/theme.php');
     // Define Gantry services.
     $gantry['theme'] = function ($c) {
         return new \Gantry\Theme\Hydrogen($c['theme.path'], $c['theme.name']);
     };
 }
Ejemplo n.º 3
0
<?php

/**
 * @package   Gantry5
 * @author    RocketTheme http://www.rockettheme.com
 * @copyright Copyright (C) 2007 - 2015 RocketTheme, LLC
 * @license   Dual License: MIT or GNU/GPLv2 and later
 *
 * http://opensource.org/licenses/MIT
 * http://www.gnu.org/licenses/gpl-2.0.html
 *
 * Gantry Framework code that extends GPL code is considered GNU/GPLv2 and later
 */
include __DIR__ . '/Loader.php';
return \Gantry5\Loader::get();
Ejemplo n.º 4
0
<?php

namespace Gantry\Framework;

/** @var $locator */
/** @var $path */
if (!class_exists('\\Gantry5\\Loader')) {
    throw new \LogicException('Please install Gantry 5 Framework plugin!');
}
// Setup Gantry 5 Framework or throw exception.
\Gantry5\Loader::setup();
// Get Gantry instance.
$gantry = Gantry::instance();
// Set the theme path from Grav variable.
$gantry['theme.path'] = $locator('theme://');
$gantry['theme.name'] = basename($gantry['theme.path']);
// Initialize theme stream.
$gantry['platform']->set('streams.gantry-theme.prefixes', ['' => ["gantry-themes://{$gantry['theme.name']}/custom", "gantry-themes://{$gantry['theme.name']}", "gantry-themes://{$gantry['theme.name']}/common"]]);
$gantry['streams'];
return $gantry;
Ejemplo n.º 5
0
 public function initializeGantryAdmin()
 {
     if (!isset($this->grav['admin'])) {
         return;
     }
     $this->enable(['onAdminMenu' => ['onAdminMenu', 0]]);
     /** @var \Grav\Plugin\Admin $admin */
     $admin = $this->grav['admin'];
     if ($admin->location != 'gantry' && ($admin->location != 'themes' || !$admin->route)) {
         return;
     }
     // Setup Gantry 5 Framework or throw exception.
     \Gantry5\Loader::setup();
     if (!defined('GANTRYADMIN_PATH')) {
         define('GANTRYADMIN_PATH', 'plugins://gantry5/admin');
     }
     $base = rtrim($this->grav['base_url'], '/');
     $results = explode('/', $admin->route, 3);
     $theme = array_shift($results);
     $this->template = array_shift($results) ?: 'about';
     $this->route = array_shift($results);
     $this->base = "{$base}{$admin->base}/{$admin->location}/{$theme}";
     $this->config->set('system.pages.theme', $theme);
     $this->runAdmin();
 }