static function isCategoryList($context)
 {
     $hash = md5('isCategoryList_' . $context);
     if (NNCache::has($hash)) {
         return NNCache::get($hash);
     }
     // Return false if it is not a category page
     if ($context != 'com_content.category' || JFactory::getApplication()->input->get('view') != 'category') {
         return NNCache::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 NNCache::set($hash, false);
     }
     // Return true if it IS a list layout
     return NNCache::set($hash, true);
 }
Exemple #2
0
 static function isCategoryList($context)
 {
     $hash = md5('isCategoryList_' . $context);
     if (NNCache::has($hash)) {
         return NNCache::get($hash);
     }
     // Return false if it is not a category page
     if ($context != 'com_content.category' || JFactory::getApplication()->input->get('view') != 'category') {
         return false;
     }
     // Return false if it is not a list layout
     if (JFactory::getApplication()->input->get('layout') && JFactory::getApplication()->input->get('layout') != 'list') {
         return false;
     }
     // Return true if it IS a list layout
     if (JFactory::getApplication()->input->get('layout') == 'list') {
         return true;
     }
     // Layout is empty, so check if default layout is list (default)
     require_once JPATH_PLUGINS . '/system/nnframework/helpers/parameters.php';
     $parameters = NNParameters::getInstance();
     $parameters = $parameters->getComponentParams('content');
     return NNCache::set($hash, $parameters->category_layout == '_:default');
 }
Exemple #3
0
 public function makeArray($array = '', $onlycommas = false, $trim = true)
 {
     if (empty($array)) {
         return array();
     }
     $hash = md5('makeArray_' . json_encode($array) . '_' . $onlycommas . '_' . $trim);
     if (NNCache::has($hash)) {
         return NNCache::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 NNCache::set($hash, $array);
 }
Exemple #4
0
 public function getAssignmentsFromParams(&$params)
 {
     $hash = md5('getAssignmentsFromParams_' . json_encode($params));
     if (NNCache::has($hash)) {
         return NNCache::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 NNCache::set($hash, $types);
     return $types;
 }
Exemple #5
0
 protected function curl($url)
 {
     $hash = md5('curl_' . $url);
     if (NNCache::has($hash)) {
         return NNCache::get($hash);
     }
     $timeout = JFactory::getApplication()->input->getInt('timeout', 3);
     $timeout = min(array(30, max(array(3, $timeout))));
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_HEADER, false);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_USERAGENT, 'NoNumber/' . $this->_version);
     curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
     //follow on location problems
     if (!ini_get('safe_mode') && !ini_get('open_basedir')) {
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
         $html = curl_exec($ch);
     } else {
         $html = $this->curl_redir_exec($ch);
     }
     curl_close($ch);
     return NNCache::set($hash, $html);
 }
Exemple #6
0
 /**
  * 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 (NNCache::has($hash)) {
         return NNCache::get($hash);
     }
     foreach ($tags as $i => $tag) {
         if ($tag['0'] == '{') {
             continue;
         }
         $tags[$i] = '{' . $tag;
         if ($include_closing_tags) {
             $tags[] = '{/' . $tag;
         }
     }
     return NNCache::set($hash, array($tags, self::protectArray($tags, 1)));
 }
 function getObjectFromXML(&$xml)
 {
     $hash = md5('getObjectFromXML_' . json_encode($xml));
     if (NNCache::has($hash)) {
         return NNCache::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 NNCache::set($hash, $object);
 }
Exemple #8
0
 protected function curl($url)
 {
     $hash = md5('curl_' . $url);
     if (NNCache::has($hash)) {
         return NNCache::get($hash);
     }
     $timeout = JFactory::getApplication()->input->getInt('timeout', 3);
     $timeout = min(array(30, max(array(3, $timeout))));
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_HEADER, false);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_USERAGENT, 'NoNumber/' . $this->_version);
     curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
     jimport('joomla.filesystem.file');
     if (JFile::exists(JPATH_ADMINISTRATOR . '/components/com_nonumbermanager/nonumbermanager.php')) {
         $config = JComponentHelper::getParams('com_nonumbermanager');
         if ($config && $config->get('use_proxy', 0) && $config->get('proxy_host')) {
             curl_setopt($ch, CURLOPT_PROXY, $config->get('proxy_host') . ':' . $config->get('proxy_port'));
             curl_setopt($ch, CURLOPT_PROXYUSERPWD, $config->get('proxy_login') . ':' . $config->get('proxy_password'));
             curl_setopt($ch, CURLOPT_TIMEOUT, 30);
         }
     }
     //follow on location problems
     if (!ini_get('safe_mode') && !ini_get('open_basedir')) {
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
         $html = curl_exec($ch);
     } else {
         $html = $this->curl_redir_exec($ch);
     }
     curl_close($ch);
     return NNCache::set($hash, $html);
 }