Browse Source

Call Block: Partial support for Country Code.

Nate 4 years ago
parent
commit
d2e0b60ed6
1 changed files with 15 additions and 3 deletions
  1. 15 3
      resources/functions.php

+ 15 - 3
resources/functions.php

@@ -2058,13 +2058,25 @@ function number_pad($number,$n) {
 //validate and format order by clause of select statement
 	if (!function_exists('order_by')) {
 		function order_by($col, $dir, $col_default = '', $dir_default = 'asc') {
+			$order_by = ' order by ';
 			$col = preg_replace('#[^a-zA-Z0-9-_.]#', '', $col);
 			$dir = strtolower($dir) == 'desc' ? 'desc' : 'asc';
 			if ($col != '') {
-				return ' order by '.$col.' '.$dir.' ';
+				return $order_by.$col.' '.$dir.' ';
 			}
-			else if ($col_default != '') {
-				return ' order by '.$col_default.' '.$dir_default.' ';
+			else if (is_array($col_default) || $col_default != '') {
+				if (is_array($col_default) && @sizeof($col_default) != 0) {
+					foreach ($col_default as $k => $column) {
+						$direction = (is_array($dir_default) && @sizeof($dir_default) != 0 && (strtolower($dir_default[$k]) == 'asc' || strtolower($dir_default[$k]) == 'desc')) ? $dir_default[$k] : 'asc';
+						$order_bys[] = $column.' '.$direction.' ';
+					}
+					if (is_array($order_bys) && @sizeof($order_bys) != 0) {
+						return $order_by.implode(', ', $order_bys);
+					}
+				}
+				else {
+					return $order_by.$col_default.' '.$dir_default.' ';
+				}
 			}
 		}
 	}