better performance
This commit is contained in:
parent
67928354b2
commit
f87e73e816
|
@ -2551,35 +2551,10 @@ function pla_reverse_dn($dn) {
|
||||||
* Attribute sorting
|
* Attribute sorting
|
||||||
*/
|
*/
|
||||||
function sortAttrs($a,$b) {
|
function sortAttrs($a,$b) {
|
||||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
||||||
debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
||||||
|
|
||||||
if ($a == $b)
|
if ($a == $b)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
$server = $_SESSION[APPCONFIG]->getServer(get_request('server_id','REQUEST'));
|
return strcasecmp($a->getName(),$b->getName());
|
||||||
$attrs_display_order = arrayLower($_SESSION[APPCONFIG]->getValue('appearance','attr_display_order'));
|
|
||||||
|
|
||||||
# Check if $a is in $attrs_display_order, get its key
|
|
||||||
$a_key = array_search($a->getName(),$attrs_display_order);
|
|
||||||
$b_key = array_search($b->getName(),$attrs_display_order);
|
|
||||||
|
|
||||||
if ((! $a_key) && ($a_key !== 0))
|
|
||||||
if ((! $a_key = array_search(strtolower($a->getFriendlyName()),$attrs_display_order)) && ($a_key !== 0))
|
|
||||||
$a_key = count($attrs_display_order)+1;
|
|
||||||
|
|
||||||
if ((! $b_key) && ($b_key !== 0))
|
|
||||||
if ((! $b_key = array_search(strtolower($b->getFriendlyName()),$attrs_display_order)) && ($b_key !== 0))
|
|
||||||
$b_key = count($attrs_display_order)+1;
|
|
||||||
|
|
||||||
# Case where neither $a, nor $b are in $attrs_display_order, $a_key = $b_key = one greater than num elements.
|
|
||||||
# So we sort them alphabetically
|
|
||||||
if ($a_key === $b_key)
|
|
||||||
return strcasecmp($a->getFriendlyName(),$b->getFriendlyName());
|
|
||||||
|
|
||||||
# Case where at least one attribute or its friendly name is in $attrs_display_order
|
|
||||||
# return -1 if $a before $b in $attrs_display_order
|
|
||||||
return ($a_key < $b_key) ? -1 : 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue