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'; } } } }
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'; } } } }
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 &getInstance(GantryRegistry $params) { global $gantry; $conf = JFactory::getConfig(); if ($conf->getValue('config.caching') && $params->get("module_cache", 0)) { $user =& JFactory::getUser(); $cache =& JFactory::getCache('Gantry'); $cache->setCaching(true); $cache->setLifeTime($gantry->get("cache-time", $conf->getValue('config.cachetime') * 60)); $args = array(&$params); $checksum = md5($args[0]->_raw); $gantrymenu = $cache->get(array('GantryMenu', '_getInstance'), $args, 'GantryMenu-' . $user->get('aid', 0) . '-' . $checksum); } else { $gantrymenu = GantryMenu::_getInstance($params); } return $gantrymenu; }
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); } } }
/** * 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(); }
/** * @param $param_name * @param $default * * @return mixed */ protected function _getParamValue($param_name, $default) { $original_param_name = $param_name; $value = $default; $exists = false; if ($this->_params_reg->exists($param_name)) { $exists = true; } // try forward dashes if (!$exists && strstr($param_name, '-') !== false) { $param_name_parts = explode('-', $param_name); $parts_count = count($param_name_parts); $dots = array(); for ($i = 0; $i < $parts_count; $i++) { array_unshift($dots, array_pop($param_name_parts)); $param_name = implode('-', $param_name_parts) . '.' . implode('.', $dots); if ($this->_params_reg->exists($param_name)) { $exists = true; break; } } // try backwards dashes if (!$exists) { $param_name = $original_param_name; $param_name_parts = explode('-', $param_name); $parts_count = count($param_name_parts); $dots = array(); for ($i = 0; $i < $parts_count; $i++) { array_unshift($dots, array_pop($param_name_parts)); $param_name = implode('.', $param_name_parts) . '.' . implode('-', $dots); if ($this->_params_reg->exists($param_name)) { $exists = true; break; } } } } if ($exists) { $value = $this->_params_reg->get($param_name, $default); } return $value; }