function _getCurrentLeadingArticles() { $num_leading_articles = false; $menus =& JSite::getMenu(); $menu = $menus->getActive(); if (null != $menu) { $params = new GantryRegistry($menu->params->toObject()); $num_leading_articles = $params->get('num_leading_articles', 0) + $params->get('num_intro_articles', 0); } return $num_leading_articles !== false ? $num_leading_articles : 0; }
protected static function _populateSingleItem($itemId) { /** @var $gantry Gantry */ global $gantry; $site = JFactory::getApplication(); $template = $site->getTemplate(true); $app = JFactory::getApplication(); $menus = $app->getMenu(); $current_menu_item = $menus->getItem($itemId); if (empty($current_menu_item)) { $current_menu_item = $menus->getDefault(); } $menu_item_style_id = (int) $current_menu_item->template_style_id; // if the assigned menu item is the "default" or it doesn't exists in the template styles // fallback to the assigned default template style if ($menu_item_style_id == 0 || !array_key_exists($menu_item_style_id, GantryTemplate::getAllTemplates())) { $menu_item_style_id = $app->getTemplate(true)->id; } $menu_params = GantryTemplate::getTemplateParams($menu_item_style_id); // if its the master no need ot apply per menu items if ($menu_params->get('master') == 'true') { return; } $array = $menu_params->toArray(); $menu_params = new GantryRegistry(); $menu_params->loadArray(gantry_flattenParams($array)); foreach ($gantry->_preset_names as $param_name) { $menuitem_param_name = $param_name; if (in_array($param_name, $gantry->_setbyoverride) && !is_null($menu_params->get($menuitem_param_name, null))) { $param =& $gantry->_working_params[$param_name]; $menuitem_value = $menu_params->get($menuitem_param_name); $menuitem_preset_params = $gantry->getPresetParams($param['name'], $menuitem_value); foreach ($menuitem_preset_params as $menuitem_preset_param_name => $menuitem_preset_param_value) { if (!is_null($menuitem_preset_param_value)) { $gantry->_working_params[$menuitem_preset_param_name]['value'] = $menuitem_preset_param_value; $gantry->_working_params[$menuitem_preset_param_name]['setby'] = 'menuitem'; } } } } // set individual values foreach ($gantry->_param_names as $param_name) { $menuitem_param_name = $param_name; if (in_array($param_name, $gantry->_setbyoverride) && !is_null($menu_params->get($menuitem_param_name, null))) { $param =& $gantry->_working_params[$param_name]; $menuitem_value = $menu_params->get($menuitem_param_name); if (!is_null($menuitem_value)) { $gantry->_working_params[$param['name']]['value'] = $menuitem_value; $gantry->_working_params[$param['name']]['setby'] = 'menuitem'; } } } }
function init() { global $gantry; $gantry->addBodyClass('option-' . str_replace("_", "-", JRequest::getString('option'))); $menus =& JSite::getMenu(); $menu = $menus->getActive(); if (is_object($menu)) { $gantry->addBodyClass('menu-' . str_replace("_", "-", $menu->alias)); $params = new GantryRegistry($menu->params->toObject()); $pageclass = $params->get('pageclass_sfx'); if (isset($pageclass)) { $gantry->addBodyClass($pageclass); } } }
function render($position = "") { global $gantry; if ($gantry->browser->platform != 'iphone' && $gantry->browser->platform != 'ipad' && $gantry->browser->platform != 'android') { return false; } gantry_import('facets.menu.gantrymenu'); $params = $gantry->getParams($this->_feature_name, true); $module_params = ''; foreach ($params as $param_name => $param_value) { $module_params .= $param_name . "=" . $param_value['value'] . "\n"; } $passing_params = new GantryRegistry(); $passing_params->loadString($module_params, 'INI'); $gantrymenu = GantryMenu::getInstance($passing_params); return $gantrymenu->render($passing_params); }
function init() { /** @var $gantry Gantry */ global $gantry; $gantry->addBodyClass('option-' . str_replace("_", "-", JFactory::getApplication()->input->getCmd('option'))); $app = JFactory::getApplication(); $menus = $app->getMenu(); $menu = $menus->getActive(); if (is_object($menu)) { $gantry->addBodyClass('menu-' . str_replace("_", "-", $menu->alias)); $params = new GantryRegistry($menu->params->toObject()); $pageclass = $params->get('pageclass_sfx'); if (isset($pageclass)) { $gantry->addBodyClass($pageclass); } } }
function render($position) { /** @var $gantry Gantry */ global $gantry; JHTML::_('behavior.framework', true); if ($gantry->browser->platform != 'iphone' && $gantry->browser->platform != 'ipad' && $gantry->browser->platform != 'android') { return false; } gantry_import('facets.menu.gantrymenu'); $params = $gantry->getParams($this->_feature_name, true); $module_params = ''; foreach ($params as $param_name => $param_value) { $module_params .= $param_name . "=" . $param_value['value'] . "\n"; } $passing_params = new GantryRegistry(); $passing_params->loadString($module_params, 'INI'); $gantrymenu = new GantryMenu($passing_params); return $gantrymenu->render($passing_params); }
function GantryMenu($params) { if (empty($params)) { $params = new GantryRegistry(); } $params->def('menutype', 'mainmenu'); $params->def('class_sfx', ''); $params->def('menu_images', 0); // Added in 1.5 $params->def('startLevel', 0); $params->def('endLevel', 0); $params->def('showAllChildren', 0); $this->_menudata = GantryMenu::_getMenuData($params); }
protected static function _populateSingleItem($itemId) { /** @var $gantry Gantry */ global $gantry; $site = JFactory::getApplication(); $template = $site->getTemplate(true); $app = JFactory::getApplication(); $menus = $app->getMenu(); $current_menu_item = $menus->getItem($itemId); if (empty($current_menu_item)) { $current_menu_item = $menus->getDefault(); } if (($current_style_id = (int) $current_menu_item->template_style_id) == 0) { $current_style_id = $app->getTemplate(true)->params->get('current_id'); if ($current_style_id == 'true') { $current_style_id = $app->getTemplate(true)->id; } } $menu_params = GantryTemplate::getTemplateParams($current_style_id); $array = $menu_params->toArray(); $menu_params = new GantryRegistry(); $menu_params->loadArray(gantry_flattenParams($array)); foreach ($gantry->_preset_names as $param_name) { $menuitem_param_name = $param_name; if (in_array($param_name, $gantry->_setbyoverride) && !is_null($menu_params->get($menuitem_param_name, null))) { $param =& $gantry->_working_params[$param_name]; $menuitem_value = $menu_params->get($menuitem_param_name); $menuitem_preset_params = $gantry->getPresetParams($param['name'], $menuitem_value); foreach ($menuitem_preset_params as $menuitem_preset_param_name => $menuitem_preset_param_value) { if (!is_null($menuitem_preset_param_value)) { $gantry->_working_params[$menuitem_preset_param_name]['value'] = $menuitem_preset_param_value; $gantry->_working_params[$menuitem_preset_param_name]['setby'] = 'menuitem'; } } } } // set individual values foreach ($gantry->_param_names as $param_name) { $menuitem_param_name = $param_name; if (in_array($param_name, $gantry->_setbyoverride) && !is_null($menu_params->get($menuitem_param_name, null))) { $param =& $gantry->_working_params[$param_name]; $menuitem_value = $menu_params->get($menuitem_param_name); if (!is_null($menuitem_value)) { $gantry->_working_params[$param['name']]['value'] = $menuitem_value; $gantry->_working_params[$param['name']]['setby'] = 'menuitem'; } } } }
/** * Method to filter the form data. * * @param array $data An array of field values to filter. * @param string $group The dot-separated form group path on which to filter the fields. * * @return mixed boolean True on sucess. * @since 1.6 */ public function filter($data, $group = null) { // Make sure there is a valid GantryForm XML document. if (!$this->xml instanceof GantrySimpleXMLElement) { return false; } // Initialize variables. $input = new GantryRegistry($data); $output = new GantryRegistry(); // Get the fields for which to filter the data. $fields = $this->findFieldsByGroup($group); if (!$fields) { // PANIC! return false; } // Filter the fields. foreach ($fields as $field) { // Initialise variables. $name = (string) $field['name']; // Get the field groups for the element. $attrs = $field->xpath('ancestor::fields[@name]/@name'); $groups = array_map('strval', $attrs ? $attrs : array()); $group = implode('.', $groups); // Get the field value from the data input. if ($group) { // Filter the value if it exists. if ($input->exists($group . '.' . $name)) { $output->set($group . '.' . $name, $this->filterField($field, $input->get($group . '.' . $name, (string) $field['default']))); } } else { // Filter the value if it exists. if ($input->exists($name)) { $output->set($name, $this->filterField($field, $input->get($name, (string) $field['default']))); } } } return $output->toArray(); }
/** * @static * @return mixed */ public static function getAllTemplates() { $cache = JFactory::getCache('com_templates', ''); $tag = JFactory::getLanguage()->getTag(); $templates = $cache->get('gantrytemplates0' . $tag); if ($templates === false) { // Load styles $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('id, home, template, s.params'); $query->from('#__template_styles as s'); $query->where('s.client_id = 0'); $query->where('e.enabled = 1'); $query->leftJoin('#__extensions as e ON e.element=s.template AND e.type=' . $db->quote('template') . ' AND e.client_id=s.client_id'); $db->setQuery($query); $templates = $db->loadObjectList('id'); foreach ($templates as &$template) { $registry = new GantryRegistry(); $registry->loadString($template->params); $template->params = $registry; } $cache->store($templates, 'gantrytemplates0' . $tag); } return $templates; }
public static function getAllTemplates() { $cache = JFactory::getCache('com_templates', ''); $tag = JFactory::getLanguage()->getTag(); $templates = $cache->get('templates0' . $tag); if ($templates === false) { // Load styles $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('id, home, template, params'); $query->from('#__template_styles'); $query->where('client_id = 0'); $db->setQuery($query); $templates = $db->loadObjectList('id'); foreach ($templates as &$template) { $registry = new GantryRegistry(); $registry->loadString($template->params); $template->params = $registry; } $cache->store($templates, 'templates0' . $tag); } return $templates; }