Beispiel #1
0
 public function __construct($container)
 {
     parent::__construct($container);
     $app = \JFactory::getApplication();
     $document = \JFactory::getDocument();
     $input = $app->input;
     $this->tmpl = $input->getCmd('tmpl', '');
     $this->option = $input->getCmd('option', '');
     $this->view = $input->getCmd('view', '');
     $this->layout = $input->getCmd('layout', '');
     $this->task = $input->getCmd('task', '');
     $this->itemid = $input->getCmd('Itemid', '');
     $this->printing = $input->getCmd('print', '');
     $this->class = '';
     if ($this->itemid) {
         $menuItem = $app->getMenu()->getActive();
         if ($menuItem && $menuItem->id) {
             $this->class = $menuItem->params->get('pageclass_sfx', '');
         }
     }
     $templateParams = $app->getTemplate(true);
     $this->outline = Gantry::instance()['configuration'];
     $this->sitename = $app->get('sitename');
     $this->theme = $templateParams->template;
     $this->baseUrl = \JUri::base(true);
     $this->title = $document->title;
     $this->description = $document->description;
     $this->language = $document->language;
     $this->direction = $document->direction;
 }
Beispiel #2
0
 public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new Gantry();
     }
     return self::$instance;
 }
Beispiel #3
0
 public function htmlAttributes()
 {
     $site = Gantry::instance()['site'];
     $dir = [];
     if (function_exists('is_rtl') && is_rtl()) {
         $dir['dir'] = 'rtl';
     }
     $attributes = ['lang' => (string) $site->language] + (array) $dir + (array) $this->config->get('page.html', []);
     return $this->getAttributes($attributes);
 }
Beispiel #4
0
 public function bodyAttributes($attributes = [])
 {
     // TODO: we might need something like
     // class="{{body_class}}" data-template="{{ twigTemplate|default('base.twig') }}"
     $body_classes = apply_filters('gantry5_body_classes', ['site', 'outline-' . Gantry::instance()['configuration']]);
     is_rtl() ? $body_classes[] = 'dir-rtl' : ($body_classes[] = 'dir-ltr');
     $wp_body_class = get_body_class($body_classes);
     if (is_array($wp_body_class) && !empty($wp_body_class)) {
         $attributes['class'] = array_merge_recursive($attributes['class'], $wp_body_class);
     }
     return $this->getAttributes((array) $this->config->get('page.body.attribs'), $attributes);
 }
Beispiel #5
0
 *
 */
// no direct access
defined('_JEXEC') or die('Restricted index access');
echo "<h1>Gantry::getParams();</h1>";
var_dump(Gantry::getParams());
echo "<h1>Gantry::get('primaryStyle');</h1>";
var_dump(Gantry::get('primaryStyle'));
echo "<h1>Gantry::set('primaryStyle', 'moo');</h1>";
var_dump(Gantry::set('primaryStyle', 'moo'));
echo "<h1>Gantry::get('primaryStyle');</h1>";
var_dump(Gantry::get('primaryStyle'));
echo "<h1>Current Browser. Gantry::\$browser</h1>";
var_dump(Gantry::getBrowser());
echo "<h1>Gantry::getPositions()</h1>";
var_dump(Gantry::getPositions());
echo "<h1>Gantry::getPositions('top')</h1>";
var_dump(Gantry::getPositions('top'));
echo "<h1>Gantry::getPositions('top', '-')</h1>";
var_dump(Gantry::getPositions('top', '-'));
echo "<h1>Gantry::getPositions('user', '([0-9])?')</h1>";
var_dump(Gantry::getPositions('user', '([0-9])?'));
echo "<h1>Gantry::getPositions('user', '(\\d)?')</h1>";
var_dump(Gantry::getPositions('user', '(\\d)?'));
echo "<h1>Gantry::countModules('user', '(\\d)?')</h1>";
var_dump(Gantry::countModules('user', '(\\d)?'));
echo "<h1>Gantry::countModules('top')</h1>";
var_dump(Gantry::countModules('top'));
echo "<h1>Gantry::countModules('top', '-')</h1>";
var_dump(Gantry::countModules('top', '-'));
Beispiel #6
0
 /**
  * Loads the params.ini content
  *
  * @param  $gantry
  *
  * @return bool
  */
 protected function loadParamsContent(Gantry &$gantry)
 {
     if ($gantry->isAdmin()) {
         $styleId = JFactory::getApplication()->input->getInt('id', 0);
         if ($styleId == 0) {
             $template = self::getMasterTemplateStyleByName($gantry->templateName);
             $styleId = $template->id;
         }
     } else {
         // TODO:  get style ID from front end
         $site = JFactory::getApplication();
         $template = $site->getTemplate(true);
         $styleId = $template->id;
     }
     $return = false;
     if ($gantry->isAdmin()) {
         JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_templates/tables');
         $table = JTable::getInstance('Style', 'TemplatesTable', array());
         // Attempt to load the row.
         $return = $table->load($styleId);
         $site = JFactory::getApplication();
         $registry = new GantryRegistry();
         $registry->loadString($table->params);
         if ($registry->get('master') != 'true') {
             $return = $table->load($registry->get('master'));
             $registry = new GantryRegistry();
             $registry->loadString($table->params);
         }
         // Check for a table object error.
         if ($return === false && $table->getError()) {
             $this->setError($table->getError());
             return false;
         }
         $this->_params_content = $table->params;
     } else {
         $site = JFactory::getApplication();
         $template = self::getTemplateById($site->getTemplate(true)->id);
         $master = $template->params->get('master', 'true');
         if ($master !== 'true') {
             $master_params = self::getTemplateParams((int) $master);
             $registry =& $master_params;
             $this->masterParams = $master_params->toString();
             $master_params->merge($template->params);
             $this->_params_content = $master_params->toString();
         } else {
             $registry =& $template->params;
             $this->_params_content = $template->params->toString();
             $this->masterParams = $this->_params_content;
         }
     }
     $this->_params_reg = $registry;
     return true;
 }
Beispiel #7
0
    function gantry_setup(){
        gantry_import('core.gantry');
        gantry_import('core.utilities.gantrycache');

        global $gantry;

        $app = JFactory::getApplication();
        $template = $app->getTemplate();
        $template_params = null;

        if (is_readable( JPATH_SITE.DS."templates".DS.$template.DS.'params.ini' ) )
		{
			$content = file_get_contents(JPATH_SITE.DS."templates".DS.$template.DS.'params.ini');
			$template_params = new JParameter($content);
		}
        $conf = & JFactory :: getConfig();

        if (!empty($template_params) && ($template_params->get("cache-enabled", 0) == 1)) {
            $cache = GantryCache::getInstance($app->isAdmin());
            $cache->setLifetime($template_params->get('cache-time', $conf->getValue('config.cachetime') * 60));
            $cache->addWatchFile(JPATH_SITE.'/templates/'.$template.'/params.ini');
            $cache->addWatchFile(JPATH_SITE.'/templates/'.$template.'/templateDetails.xml');
            $gantry = $cache->call('Gantry-'.$template, array('Gantry','getInstance'));
        }
        else {
            $gantry = Gantry::getInstance();
        }
         $gantry->init();
    }
Beispiel #8
0
 public function htmlAttributes()
 {
     $site = Gantry::instance()['site'];
     $attributes = ['lang' => (string) $site->language] + (array) $this->config->get('page.html', []);
     return $this->getAttributes($attributes);
 }
Beispiel #9
0
 function gantry_setup()
 {
     gantry_import('core.gantry');
     gantry_import('core.utilities.gantrycache');
     jimport('joomla.html.parameter');
     global $gantry;
     $template = gantry_getTemplate();
     $template_name = $template->template;
     if ($template->params->get('master') != 'true') {
         $template->params = gantry_getTemplateParams($template->params->get('master'));
     }
     $conf =& JFactory::getConfig();
     if ($template->params->get("cache-enabled", 0) == 1) {
         $cache = GantryCache::getInstance($app->isAdmin());
         $cache->setLifetime($template->params->get('cache-time', $conf->getValue('config.cachetime') * 60));
         $cache->addWatchFile(JPATH_SITE . '/templates/' . $template_name . '/templateDetails.xml');
         $cache->addWatchFile(JPATH_SITE . '/templates/' . $template_name . '/template-options.xml');
         $gantry = $cache->call('Gantry-' . $template_name, array('Gantry', 'getInstance'), array($template_name));
     } else {
         $gantry = Gantry::getInstance($template_name);
     }
     $gantry->init();
 }
Beispiel #10
0
 /**
  *
  */
 function gantry_setup()
 {
     gantry_import('core.gantry');
     gantry_import('core.utilities.gantrycache');
     jimport('joomla.html.parameter');
     /** @var $gantry Gantry */
     global $gantry;
     $template = gantry_getTemplate();
     $template_name = $template->template;
     if ($template->params->get('master') != 'true') {
         $template->params = gantry_getTemplateParams($template->params->get('master'));
     }
     $conf = JFactory::getConfig();
     $app = JFactory::getApplication();
     if ($template->params->get("cache.enabled", 1) == 1) {
         $cache = GantryCache::getCache(GantryCache::GROUP_NAME);
         $cache->addWatchFile(JPATH_SITE . '/templates/' . $template_name . '/templateDetails.xml');
         $cache->addWatchFile(JPATH_SITE . '/templates/' . $template_name . '/template-options.xml');
         $gantry = $cache->call('Gantry-' . $template_name, array('Gantry', 'getInstance'), array($template_name));
     } else {
         $gantry = Gantry::getInstance($template_name);
     }
     $gantry->init();
 }
Beispiel #11
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;
 function addScripts($scripts = array())
 {
     foreach ($scripts as $script) {
         Gantry::addScript($script);
     }
 }
Beispiel #13
0
function gantry_construct()
{
    global $gantry, $gantry_path, $wp_query, $current_blog;
    $gantry_templatepath = get_template_directory() . '/templateDetails.xml';
    if (!file_exists($gantry_templatepath)) {
        define('NONGANTRY_TEMPLATE', 'NONGANTRY_TEMPLATE');
        return;
    }
    if (!defined('GANTRY_VERSION')) {
        /**
         * @name GANTRY_VERSION
         */
        define('GANTRY_VERSION', '1.26');
        if (!defined('DS')) {
            define('DS', DIRECTORY_SEPARATOR);
        }
        // Turn on sessions for Wordpress
        if (!defined('GANTRY_SESSIONS_ENABLED')) {
            if (!session_id()) {
                define('GANTRY_SESSIONS_ENABLED', true);
                session_start();
            }
        }
        $options = get_option(get_template() . "-template-options");
        $cache_enabled = $options['cache']['enabled'];
        $cache_lifetime = $options['cache']['time'];
        load_plugin_textdomain('gantry', false, basename($gantry_path) . '/languages');
        // Get the gantry instance
        gantry_import('core.gantry');
        if ($cache_enabled) {
            gantry_import('core.utilities.gantrycache');
            $cache = GantryCache::getInstance();
            $cache->setLifetime($cache_lifetime);
            $cache->init();
            $gantry = $cache->get('gantry', 'gantry', array('Gantry', 'getInstance'));
        } else {
            $gantry = Gantry::getInstance();
        }
        // Load the widget positions for the template
        $gantry->_loadWidgetPositions();
        add_filter('query_vars', array('GantryTemplateDetails', 'add_url_vars'));
    }
}