static function isCategoryList($context) { $hash = md5('isCategoryList_' . $context); if (RLCache::has($hash)) { return RLCache::get($hash); } // Return false if it is not a category page if ($context != 'com_content.category' || JFactory::getApplication()->input->get('view') != 'category') { return RLCache::set($hash, false); } // Return false if it is not a list layout if (JFactory::getApplication()->input->get('layout') && JFactory::getApplication()->input->get('layout') != 'list') { return RLCache::set($hash, false); } // Return true if it IS a list layout return RLCache::set($hash, true); }
function getObjectFromXML(&$xml) { $hash = md5('getObjectFromXML_' . json_encode($xml)); if (RLCache::has($hash)) { return RLCache::get($hash); } if (!is_array($xml)) { $xml = array($xml); } $object = new stdClass(); foreach ($xml as $item) { $key = $this->_getKeyFromXML($item); $val = $this->_getValFromXML($item); if (isset($object->{$key})) { if (!is_array($object->{$key})) { $object->{$key} = array($object->{$key}); } $object->{$key}[] = $val; } $object->{$key} = $val; } return RLCache::set($hash, $object); }
public function makeArray($array = '', $onlycommas = false, $trim = true) { if (empty($array)) { return array(); } $hash = md5('makeArray_' . json_encode($array) . '_' . $onlycommas . '_' . $trim); if (RLCache::has($hash)) { return RLCache::get($hash); } $array = $this->mixedDataToArray($array, $onlycommas); if (empty($array)) { return $array; } if (!$trim) { return $array; } foreach ($array as $k => $v) { if (!is_string($v)) { continue; } $array[$k] = trim($v); } return RLCache::set($hash, $array); }
/** * prepare the tags and protected tags array */ private static function prepareTags($tags, $include_closing_tags = true) { if (!is_array($tags)) { $tags = array($tags); } $hash = md5('prepareTags_' . json_encode($tags) . '_' . $include_closing_tags); if (RLCache::has($hash)) { return RLCache::get($hash); } foreach ($tags as $i => $tag) { if (RLText::is_alphanumeric($tag['0'])) { $tag = '{' . $tag; } $tags[$i] = $tag; if ($include_closing_tags) { $tags[] = preg_replace('#^([^a-z0-9]+)#', '\\1/', $tag); } } return RLCache::set($hash, array($tags, self::protectArray($tags, 1))); }
public static function xmlToObject($url, $root = '') { $hash = md5('xmlToObject_' . $url . '_' . $root); if (RLCache::has($hash)) { return RLCache::get($hash); } if (JFile::exists($url)) { $xml = @new SimpleXMLElement($url, LIBXML_NONET | LIBXML_NOCDATA, 1); } else { $xml = simplexml_load_string($url, "SimpleXMLElement", LIBXML_NONET | LIBXML_NOCDATA); } if (!@count($xml)) { return RLCache::set($hash, new stdClass()); } if ($root) { if (!isset($xml->{$root})) { return RLCache::set($hash, new stdClass()); } $xml = $xml->{$root}; } $json = json_encode($xml); $xml = json_decode($json); if (is_null($xml)) { $xml = new stdClass(); } if ($root && isset($xml->{$root})) { $xml = $xml->{$root}; } return RLCache::set($hash, $xml); }
public function getAssignmentsFromParams(&$params) { $hash = md5('getAssignmentsFromParams_' . json_encode($params)); if (RLCache::has($hash)) { return RLCache::get($hash); } $types = array(); foreach ($this->types as $id => $type) { if (!isset($params->{'assignto_' . $id}) || !$params->{'assignto_' . $id}) { continue; } $types[$type] = (object) array('assignment' => $params->{'assignto_' . $id}, 'selection' => array(), 'params' => new stdClass()); if (isset($params->{'assignto_' . $id . '_selection'})) { $selection = $params->{'assignto_' . $id . '_selection'}; $types[$type]->selection = in_array($type, $this->nonarray) ? $selection : $this->makeArray($selection); } $this->addParams($types[$type], $type, $id, $params); } return RLCache::set($hash, $types); return $types; }