|
|
|
@ -76,27 +76,34 @@ class TableSort |
|
|
|
|
$colA = strip_tags($a[$column]); |
|
|
|
|
$colB = strip_tags($b[$column]); |
|
|
|
|
|
|
|
|
|
if ('>' === $compareOperator && $colA > $colB) { |
|
|
|
|
return 1; |
|
|
|
|
if ('<=' === $compareOperator) { |
|
|
|
|
return $colA < $colB |
|
|
|
|
? 1 |
|
|
|
|
: ($colA > $colB ? -1 : 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $colA < $colB ? -1 : 0; |
|
|
|
|
if ('>' === $compareOperator) { |
|
|
|
|
return $colB < $colA |
|
|
|
|
? 1 |
|
|
|
|
: ($colB > $colA ? -1 : 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
}; |
|
|
|
|
break; |
|
|
|
|
case SORT_IMAGE: |
|
|
|
|
$function = function ($a, $b) use ($column, $compareOperator) { |
|
|
|
|
$result = api_strnatcmp( |
|
|
|
|
api_strtolower(strip_tags($a[$column], "<img>")), |
|
|
|
|
api_strtolower(strip_tags($b[$column], "<img>")) |
|
|
|
|
); |
|
|
|
|
if ('>' === $compareOperator) { |
|
|
|
|
$result = api_strnatcmp( |
|
|
|
|
api_strtolower(strip_tags($a[$column], "<img>")), |
|
|
|
|
api_strtolower(strip_tags($b[$column], "<img>")) |
|
|
|
|
if ('<=' === $compareOperator) { |
|
|
|
|
return api_strnatcmp( |
|
|
|
|
api_strtolower(strip_tags($b[$column], '<img>')), |
|
|
|
|
api_strtolower(strip_tags($a[$column], '<img>')) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $result; |
|
|
|
|
return api_strnatcmp( |
|
|
|
|
api_strtolower(strip_tags($a[$column], '<img>')), |
|
|
|
|
api_strtolower(strip_tags($b[$column], '<img>')) |
|
|
|
|
); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
@ -105,28 +112,35 @@ class TableSort |
|
|
|
|
$dateA = strtotime(strip_tags($a[$column])); |
|
|
|
|
$dateB = strtotime(strip_tags($b[$column])); |
|
|
|
|
|
|
|
|
|
if ('>' === $compareOperator && $dateA > $dateB) { |
|
|
|
|
return 1; |
|
|
|
|
if ('<=' === $compareOperator) { |
|
|
|
|
return $dateA < $dateB |
|
|
|
|
? 1 |
|
|
|
|
: ($dateA > $dateB ? -1 : 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ('>' === $compareOperator) { |
|
|
|
|
return $dateB < $dateA |
|
|
|
|
? 1 |
|
|
|
|
: ($dateB > $dateA ? -1 : 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $dateA < $dateB ? -1 : 0; |
|
|
|
|
return 0; |
|
|
|
|
}; |
|
|
|
|
break; |
|
|
|
|
case SORT_STRING: |
|
|
|
|
default: |
|
|
|
|
$function = function ($a, $b) use ($column, $compareOperator) { |
|
|
|
|
$result = api_strnatcmp( |
|
|
|
|
api_strtolower(strip_tags($a[$column])), |
|
|
|
|
api_strtolower(strip_tags($b[$column])) |
|
|
|
|
); |
|
|
|
|
if ('>' === $compareOperator) { |
|
|
|
|
$result = api_strnatcmp( |
|
|
|
|
api_strtolower(strip_tags($a[$column])), |
|
|
|
|
api_strtolower(strip_tags($b[$column])) |
|
|
|
|
if ('<=' === $compareOperator) { |
|
|
|
|
return api_strnatcmp( |
|
|
|
|
api_strtolower(strip_tags($b[$column])), |
|
|
|
|
api_strtolower(strip_tags($a[$column])) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $result; |
|
|
|
|
return api_strnatcmp( |
|
|
|
|
api_strtolower(strip_tags($a[$column])), |
|
|
|
|
api_strtolower(strip_tags($b[$column])) |
|
|
|
|
); |
|
|
|
|
}; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|