Example #1
0
 /**
  * Callback function for sorting an array of objects on a key
  *
  * @param   array    $a	An array of objects
  * @param   array    $b	An array of objects
  *
  * @return  integer  	Comparison status
  * @since   11.1
  * @see		JArrayHelper::sortObjects()
  */
 protected static function _sortObjects(&$a, &$b)
 {
     $params = $GLOBALS['JAH_so'];
     for ($i = 0, $count = count($params['key']); $i < $count; $i++) {
         if (isset($params['direction'][$i])) {
             $direction = $params['direction'][$i];
         }
         if (isset($params['casesensitive'][$i])) {
             $casesensitive = $params['casesensitive'][$i];
         }
         if (isset($params['locale'][$i])) {
             $locale = $params['locale'][$i];
         }
         $va = $a->{$params}['key'][$i];
         $vb = $b->{$params}['key'][$i];
         if ((is_bool($va) or is_numeric($va)) and (is_bool($vb) or is_numeric($vb))) {
             $cmp = $va - $vb;
         } elseif ($casesensitive) {
             $cmp = JString::strcmp($va, $vb, $locale);
         } else {
             $cmp = JString::strcasecmp($va, $vb, $locale);
         }
         if ($cmp > 0) {
             return $direction;
         }
         if ($cmp < 0) {
             return -$direction;
         }
     }
     return 0;
 }
 /**
  * Callback function for sorting an array of objects on a key
  *
  * @param   array  &$a  An array of objects
  * @param   array  &$b  An array of objects
  *
  * @return  integer  Comparison status
  *
  * @see     JArrayHelper::sortObjects()
  * @since   11.1
  */
 protected static function _sortObjects(&$a, &$b)
 {
     $key = self::$sortKey;
     for ($i = 0, $count = count($key); $i < $count; $i++) {
         if (isset(self::$sortDirection[$i])) {
             $direction = self::$sortDirection[$i];
         }
         if (isset(self::$sortCase[$i])) {
             $caseSensitive = self::$sortCase[$i];
         }
         if (isset(self::$sortLocale[$i])) {
             $locale = self::$sortLocale[$i];
         }
         $va = $a->{$key[$i]};
         $vb = $b->{$key[$i]};
         if ((is_bool($va) || is_numeric($va)) && (is_bool($vb) || is_numeric($vb))) {
             $cmp = $va - $vb;
         } elseif ($caseSensitive) {
             $cmp = JString::strcmp($va, $vb, $locale);
         } else {
             $cmp = JString::strcasecmp($va, $vb, $locale);
         }
         if ($cmp > 0) {
             return $direction;
         }
         if ($cmp < 0) {
             return -$direction;
         }
     }
     return 0;
 }
Example #3
0
 function revert(&$url_array, $pos)
 {
     // V 1.2.4.l  // updated based on includes/sef.php.
     $url_array = array_filter($url_array);
     // V x : traling slash can cause empty array element
     $url_array = array_values($url_array);
     $uri = explode('content/', $_SERVER['REQUEST_URI']);
     $option = 'com_content';
     $pos = array_search('content', $url_array);
     // language hook for content
     $lang = '';
     foreach ($url_array as $key => $value) {
         if (!JString::strcasecmp(JString::substr($value, 0, 5), 'lang,')) {
             $temp = explode(',', $value);
             if (isset($temp[0]) && $temp[0] != '' && isset($temp[1]) && $temp[1] != '') {
                 $lang = $temp[1];
             }
             unset($url_array[$key]);
         }
     }
     if (isset($url_array[$pos + 8]) && $url_array[$pos + 8] != '' && in_array('category', $url_array) && strpos($url_array[$pos + 5], 'order,') !== false && strpos($url_array[$pos + 6], 'filter,') !== false) {
         // $option/$task/$sectionid/$id/$Itemid/$order/$filter/$limit/$limitstart
         $task = $url_array[$pos + 1];
         $sectionid = $url_array[$pos + 2];
         $id = $url_array[$pos + 3];
         $Itemid = $url_array[$pos + 4];
         $order = str_replace('order,', '', $url_array[$pos + 5]);
         $filter = str_replace('filter,', '', $url_array[$pos + 6]);
         $limit = $url_array[$pos + 7];
         $limitstart = $url_array[$pos + 8];
         $QUERY_STRING = "option=com_content&task={$task}&sectionid={$sectionid}&id={$id}&Itemid={$Itemid}&order={$order}&filter={$filter}&limit={$limit}&limitstart={$limitstart}";
     } else {
         if (isset($url_array[$pos + 7]) && $url_array[$pos + 7] != '' && $url_array[$pos + 5] > 1000 && (in_array('archivecategory', $url_array) || in_array('archivesection', $url_array))) {
             // $option/$task/$id/$limit/$limitstart/year/month/module
             $task = $url_array[$pos + 1];
             $id = $url_array[$pos + 2];
             $limit = $url_array[$pos + 3];
             $limitstart = $url_array[$pos + 4];
             $year = $url_array[$pos + 5];
             $month = $url_array[$pos + 6];
             $module = $url_array[$pos + 7];
             $QUERY_STRING = "option=com_content&task={$task}&id={$id}&limit={$limit}&limitstart={$limitstart}&year={$year}&month={$month}&module={$module}";
         } else {
             if (isset($url_array[$pos + 7]) && $url_array[$pos + 7] != '' && $url_array[$pos + 6] > 1000 && (in_array('archivecategory', $url_array) || in_array('archivesection', $url_array))) {
                 // $option/$task/$id/$Itemid/$limit/$limitstart/year/month
                 $task = $url_array[$pos + 1];
                 $id = $url_array[$pos + 2];
                 $Itemid = $url_array[$pos + 3];
                 $limit = $url_array[$pos + 4];
                 $limitstart = $url_array[$pos + 5];
                 $year = $url_array[$pos + 6];
                 $month = $url_array[$pos + 7];
                 $QUERY_STRING = "option=com_content&task={$task}&id={$id}&Itemid={$Itemid}&limit={$limit}&limitstart={$limitstart}&year={$year}&month={$month}";
             } else {
                 if (isset($url_array[$pos + 7]) && $url_array[$pos + 7] != '' && in_array('category', $url_array) && strpos($url_array[$pos + 5], 'order,') !== false) {
                     // $option/$task/$sectionid/$id/$Itemid/$order/$limit/$limitstart
                     $task = $url_array[$pos + 1];
                     $sectionid = $url_array[$pos + 2];
                     $id = $url_array[$pos + 3];
                     $Itemid = $url_array[$pos + 4];
                     $order = str_replace('order,', '', $url_array[$pos + 5]);
                     $limit = $url_array[$pos + 6];
                     $limitstart = $url_array[$pos + 7];
                     $QUERY_STRING = "option=com_content&task={$task}&sectionid={$sectionid}&id={$id}&Itemid={$Itemid}&order={$order}&limit={$limit}&limitstart={$limitstart}";
                 } else {
                     if (isset($url_array[$pos + 6]) && $url_array[$pos + 6] != '') {
                         // $option/$task/$sectionid/$id/$Itemid/$limit/$limitstart
                         $task = $url_array[$pos + 1];
                         $sectionid = $url_array[$pos + 2];
                         $id = $url_array[$pos + 3];
                         $Itemid = $url_array[$pos + 4];
                         $limit = $url_array[$pos + 5];
                         $limitstart = $url_array[$pos + 6];
                         $QUERY_STRING = "option=com_content&task={$task}&sectionid={$sectionid}&id={$id}&Itemid={$Itemid}&limit={$limit}&limitstart={$limitstart}";
                     } else {
                         if (isset($url_array[$pos + 5]) && $url_array[$pos + 5] != '') {
                             // $option/$task/$id/$Itemid/$limit/$limitstart
                             $task = $url_array[$pos + 1];
                             $id = $url_array[$pos + 2];
                             $Itemid = $url_array[$pos + 3];
                             $limit = $url_array[$pos + 4];
                             $limitstart = $url_array[$pos + 5];
                             $QUERY_STRING = "option=com_content&task={$task}&id={$id}&Itemid={$Itemid}&limit={$limit}&limitstart={$limitstart}";
                         } else {
                             if (isset($url_array[$pos + 4]) && $url_array[$pos + 4] != '' && (in_array('archivecategory', $url_array) || in_array('archivesection', $url_array))) {
                                 // $option/$task/$year/$month/$module
                                 $task = $url_array[$pos + 1];
                                 $year = $url_array[$pos + 2];
                                 $month = $url_array[$pos + 3];
                                 $module = $url_array[$pos + 4];
                                 $QUERY_STRING = "option=com_content&task={$task}&year={$year}&month={$month}&module={$module}";
                             } else {
                                 if (!(isset($url_array[$pos + 5]) && $url_array[$pos + 5] != '') && isset($url_array[$pos + 4]) && $url_array[$pos + 4] != '') {
                                     // $option/$task/$sectionid/$id/$Itemid
                                     $task = $url_array[$pos + 1];
                                     $sectionid = $url_array[$pos + 2];
                                     $id = $url_array[$pos + 3];
                                     $Itemid = $url_array[$pos + 4];
                                     $QUERY_STRING = "option=com_content&task={$task}&sectionid={$sectionid}&id={$id}&Itemid={$Itemid}";
                                 } else {
                                     if (!(isset($url_array[$pos + 4]) && $url_array[$pos + 4] != '') && (isset($url_array[$pos + 3]) && $url_array[$pos + 3] != '')) {
                                         // $option/$task/$id/$Itemid
                                         $task = $url_array[$pos + 1];
                                         $id = $url_array[$pos + 2];
                                         $Itemid = $url_array[$pos + 3];
                                         $QUERY_STRING = "option=com_content&task={$task}&id={$id}&Itemid={$Itemid}";
                                     } else {
                                         if (!(isset($url_array[$pos + 3]) && $url_array[$pos + 3] != '') && (isset($url_array[$pos + 2]) && $url_array[$pos + 2] != '')) {
                                             // $option/$task/$id
                                             $task = $url_array[$pos + 1];
                                             $id = $url_array[$pos + 2];
                                             $QUERY_STRING = "option=com_content&task={$task}&id={$id}";
                                         } else {
                                             if (!(isset($url_array[$pos + 2]) && $url_array[$pos + 2] != '') && (isset($url_array[$pos + 1]) && $url_array[$pos + 1] != '')) {
                                                 // $option/$task
                                                 $task = $url_array[$pos + 1];
                                                 $QUERY_STRING = 'option=com_content&task=' . $task;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($lang != '') {
         $QUERY_STRING .= '&amp;lang=' . $lang;
     }
     return $QUERY_STRING;
 }
Example #4
0
 /**
  * @group String
  * @covers JString::strcasecmp
  * @dataProvider strcasecmpData
  */
 public function testStrcasecmp($string1, $string2, $locale, $expect)
 {
     if (substr(php_uname(), 0, 6) == 'Darwin' && $locale != false) {
         $this->markTestSkipped('Darwin bug prevents foreign conversion from working properly');
     } else {
         $actual = JString::strcasecmp($string1, $string2, $locale);
         if ($actual != 0) {
             $actual = $actual / abs($actual);
         }
         $this->assertEquals($expect, $actual);
     }
 }
Example #5
0
 /**
  * @param $a
  * @param $b
  *
  * @return int
  */
 public static function compareByNameDesc($a, $b)
 {
     if (!isset(self::$_instances[$a]) || !isset(self::$_instances[$b])) {
         return 0;
     }
     return JString::strcasecmp(self::$_instances[$b]->name, self::$_instances[$a]->name);
 }
Example #6
0
 /**
  * Test...
  *
  * @param   string  $string1  @todo
  * @param   string  $string2  @todo
  * @param   string  $locale   @todo
  * @param   string  $expect   @todo
  *
  * @return  array
  *
  * @dataProvider  getStrcasecmpData
  * @since   11.2
  * @covers  JString::strcasecmp
  */
 public function testStrcasecmp($string1, $string2, $locale, $expect)
 {
     // Convert the $locale param to a string if it is an array
     if (is_array($locale)) {
         $locale = "'" . implode("', '", $locale) . "'";
     }
     if (substr(php_uname(), 0, 6) == 'Darwin' && $locale != false) {
         $this->markTestSkipped('Darwin bug prevents foreign conversion from working properly');
     } elseif ($locale != false && !setlocale(LC_COLLATE, $locale)) {
         $this->markTestSkipped("Locale {$locale} is not available.");
     } else {
         $actual = JString::strcasecmp($string1, $string2, $locale);
         if ($actual != 0) {
             $actual = $actual / abs($actual);
         }
         $this->assertEquals($expect, $actual);
     }
 }
Example #7
0
	/**
	 * @group String
	 * @covers JString::strcasecmp
	 * @dataProvider strcasecmpData
	 */
	public function testStrcasecmp($string1, $string2, $locale, $expect)
	{
		if (substr(php_uname(), 0, 6) != 'Darwin') {
			$actual = JString::strcasecmp ($string1, $string2, $locale);
			if ($actual != 0) {
				$actual = $actual/abs($actual);
			}
			$this->assertEquals($expect, $actual);
		}
	}