/** * Load Gantry framework before dispatching to the component. */ private function onAfterRouteSite() { $template = $this->app->getTemplate(true); if (!file_exists(JPATH_THEMES . "/{$template->template}/gantry/theme.yaml")) { return; } $path = JPATH_THEMES . "/{$template->template}/includes/gantry.php"; if (is_file($path)) { // Manually setup Gantry 5 Framework from the template. include $path; return; } // Setup Gantry 5 Framework or throw exception. Gantry5\Loader::setup(); // Get Gantry instance. $gantry = Gantry\Framework\Gantry::instance(); // Initialize the template. $gantry['theme.path'] = JPATH_THEMES . "/{$template->template}"; $gantry['theme.name'] = $template->template; $themePath = $gantry['theme.path'] . '/includes/theme.php'; include_once $themePath; /** @var \Gantry\Framework\Configurations $configurations */ $configurations = $gantry['configurations']; /** @var Gantry\Framework\Theme $theme */ $theme = $gantry['theme']; $theme->setLayout($configurations->current()); }
function gantry5_layout_manager() { static $output = null; if (!current_user_can('manage_options')) { wp_die(__('You do not have sufficient permissions to access this page.')); } add_filter('admin_body_class', function () { return 'gantry5 gantry5-wordpress'; }); if ($output) { echo $output; return; } // Detect Gantry Framework or fail gracefully. if (!class_exists('Gantry5\\Loader')) { wp_die(__('Gantry 5 Framework not found.')); } // Initialize administrator or fail gracefully. try { Gantry5\Loader::setup(); $gantry = Gantry\Framework\Gantry::instance(); $gantry['router'] = function ($c) { return new \Gantry\Admin\Router($c); }; // Dispatch to the controller. $output = $gantry['router']->dispatch(); } catch (Exception $e) { throw $e; // wp_die( $e->getMessage() ); } }
protected function getInput() { $app = JFactory::getApplication(); // Detect Gantry Framework or fail gracefully. if (!class_exists('Gantry5\\Loader')) { $app->enqueueMessage(JText::sprintf('MOD_GANTRY5_PLUGIN_MISSING', JText::_('MOD_GANTRY5_PARTICLE')), 'error'); return ''; } if (!defined('GANTRYADMIN_PATH')) { define('GANTRYADMIN_PATH', JPATH_ADMINISTRATOR . '/components/com_gantry5'); } // Initialize administrator or fail gracefully. try { Gantry5\Loader::setup(); $this->container = Gantry\Framework\Gantry::instance(); $this->container['router'] = function ($c) { return new \Gantry\Admin\Router($c); }; } catch (Exception $e) { $app->enqueueMessage(JText::sprintf($e->getMessage()), 'error'); return ''; } // FIXME: Better style detection. $style = \Gantry\Joomla\StyleHelper::getStyle(['home' => 1, 'client_id' => 0]); $this->container['router']->setStyle($style->id)->load(); $field = ['default' => true, 'scope' => '', 'name' => $this->name, 'field' => ['type' => 'gantry.particle', 'label' => 'Particle', 'class' => 'input-small', 'picker_label' => 'Pick a Particle', 'overridable' => false], 'value' => json_decode($this->value, true)]; $params = ['content' => $this->container['admin.theme']->render('@gantry-admin/forms/fields/gantry/particle.html.twig', $field)]; return $this->container['admin.theme']->render('@gantry-admin/partials/layout.html.twig', $params); }
/** * Display Gantry 5 backend icon * * @param string $context * @return array|null */ public function onGetIcons($context) { $user = JFactory::getUser(); if ($context != $this->params->get('context', 'mod_quickicon') || !$user->authorise('core.manage', 'com_gantry5')) { return null; } try { $updates = null; if ($user->authorise('core.manage', 'com_installer')) { // Initialise Gantry. Gantry5\Loader::setup(); $gantry = Gantry\Framework\Gantry::instance(); $gantry['streams']; /** @var Gantry\Framework\Platform $platform */ $platform = $gantry['platform']; $updates = $platform->updates(); } } catch (Exception $e) { $app = JFactory::getApplication(); $app->enqueueMessage($e->getMessage(), 'warning'); $updates = false; } $quickicons = array(array('link' => JRoute::_('index.php?option=com_gantry5'), 'image' => 'eye', 'text' => JText::_('COM_GANTRY5'), 'group' => 'MOD_QUICKICON_EXTENSIONS', 'access' => array('core.manage', 'com_gantry5'))); if ($updates === false) { // Disabled $quickicons[] = array('link' => JRoute::_('index.php?option=com_gantry5'), 'image' => 'eye', 'text' => JText::_('PLG_QUICKICON_GANTRY5_UPDATES_DISABLED'), 'group' => 'MOD_QUICKICON_MAINTENANCE'); } elseif (!empty($updates)) { // Has updates $quickicons[] = array('link' => JRoute::_('index.php?option=com_installer&view=update'), 'image' => 'download', 'text' => JText::_('PLG_QUICKICON_GANTRY5_UPDATE_NOW'), 'group' => 'MOD_QUICKICON_MAINTENANCE'); } return $quickicons; }
public function preflight($type, $parent) { if ($type == 'uninstall') { return true; } $manifest = $parent->getManifest(); $name = JText::_($manifest->name); // Prevent installation if Gantry 5 isn't enabled. try { if (!class_exists('Gantry5\\Loader')) { throw new RuntimeException(sprintf('Please install Gantry 5 Framework before installing %s template!', $name)); } Gantry5\Loader::setup(); if (version_compare(GANTRY5_VERSION, $this->requiredGantryVersion, '<')) { throw new \RuntimeException(sprintf('Please upgrade Gantry 5 Framework to v%s (or later) before installing %s template!', strtoupper($this->requiredGantryVersion), $name)); } } catch (Exception $e) { $app = JFactory::getApplication(); $app->enqueueMessage(JText::sprintf($e->getMessage()), 'error'); return false; } return true; }
* @author RocketTheme http://www.rockettheme.com * @copyright Copyright (C) 2007 - 2015 RocketTheme, LLC * @license GNU/GPLv2 and later * * http://www.gnu.org/licenses/gpl-2.0.html */ defined('_JEXEC') or die; use Gantry\Framework\Gantry; try { $app = JFactory::getApplication('site'); $template = $app->getTemplate(true); if (!class_exists('Gantry5\\Loader')) { throw new RuntimeException(JText::_('GANTRY5_THEME_INSTALL_GANTRY')); } // Setup Gantry 5 Framework or throw exception. Gantry5\Loader::setup(); // Get Gantry instance and return it. $gantry = Gantry::instance(); // Initialize the template if not done already. if (!isset($gantry['theme.name'])) { $gantry['theme.path'] = dirname(__DIR__); $gantry['theme.name'] = $template->template; } // Only a single template can be loaded at any time. if (!isset($gantry['theme']) && file_exists(__DIR__ . '/theme.php')) { include_once __DIR__ . '/theme.php'; } return $gantry; } catch (Exception $e) { // Oops, something went wrong! header("HTTP/1.0 500 Internal Server Error");
/** * Load Gantry framework before dispatching to the component. */ private function onAfterRouteSite() { $template = $this->app->getTemplate(true); if (!file_exists(JPATH_THEMES . "/{$template->template}/gantry/theme.yaml")) { return; } $gantryPath = JPATH_THEMES . "/{$template->template}/includes/gantry.php"; if (is_file($gantryPath)) { // Manually setup Gantry 5 Framework from the template. include_once $gantryPath; } else { // Setup Gantry 5 Framework or throw exception. Gantry5\Loader::setup(); // Get Gantry instance. $gantry = Gantry\Framework\Gantry::instance(); // Initialize the template. $gantry['theme.path'] = JPATH_THEMES . "/{$template->template}"; $gantry['theme.name'] = $template->template; $themePath = $gantry['theme.path'] . '/includes/theme.php'; include_once $themePath; } /** @var Gantry\Framework\Theme $theme */ $theme = $gantry['theme']; /** @var \Gantry\Framework\Outlines $configurations */ $configurations = $gantry['configurations']; $theme->setLayout($configurations->current()); if (!$this->params->get('production', 0) || $this->params->get('asset_timestamps', 1)) { $age = (int) ($this->params->get('asset_timestamps_period', 7) * 86400); Gantry\Framework\Document::$timestamp_age = $age > 0 ? $age : PHP_INT_MAX; } else { Gantry\Framework\Document::$timestamp_age = 0; } }
protected function load($name) { Gantry5\Loader::setup(); $gantry = \Gantry\Framework\Gantry::instance(); if (!isset($gantry['theme.name']) || $name !== $gantry['theme.name']) { // Restart Gantry and initialize it. $gantry = Gantry\Framework\Gantry::restart(); $gantry['theme.name'] = $name; $gantry['streams']->register(); $patform = $gantry['platform']; $locator = $gantry['locator']; // Initialize theme stream. $details = new Gantry\Component\Theme\ThemeDetails($name); $locator->addPath('gantry-theme', '', $details->getPaths(), false, true); // Initialize theme cache stream. $cachePath = $patform->getCachePath() . '/' . $name; Gantry\Component\FileSystem\Folder::create($cachePath); $locator->addPath('gantry-cache', 'theme', array($cachePath), true, true); $gantry['file.yaml.cache.path'] = $locator->findResource('gantry-cache://theme/compiled/yaml', true, true); } return $gantry; }