Skip to content
Permalink
Browse files

user sorted alphabetical navs possible (pref)

  • Loading branch information...
NB-Core committed May 3, 2015
1 parent bf1a629 commit 119dc388339b6588ba0c617aaa7b26bf40c6d2ac
Showing with 34 additions and 1 deletion.
  1. +33 −1 lib/nav.php
  2. +1 −0 prefs.php
@@ -282,6 +282,7 @@ function checknavs() {
function buildnavs(){
global $navbysection, $navschema, $session, $navnocollapse;
$builtnavs="";
if ($session['user']['prefs']['sortedmenus']==1) navsort();
foreach ($navbysection as $key=>$val) {
$tkey = $key;
$navbanner="";
@@ -559,6 +560,38 @@ function clearnav(){
$session['allowednavs']=array();
}
function navsort(){
//sort each section
//user sorted by alphabet
global $session,$navbysection;
if (!is_array($navbysection)) return;
foreach ($navbysection as $key=>$val) {
if (is_array($val)) {
usort($val,"nav_a_sort");
$navbysection[$key] =$val;
}
}
return;
}
//sort function. mind the sprintf arrays in the structure and compare without the possible hotkey preset
function nav_a_sort($a,$b) {
$a = $a[0];
$b = $b[0];
if (is_array($a)) $a=call_user_func_array("sprintf",$a);
if (is_array($b)) $b=call_user_func_array("sprintf",$b);
$a=sanitize($a);
$b=sanitize($b);
$pos = strpos(substr($a,0,2),"?");
$pos2 = strpos(substr($b,0,2),"?");
if ($pos===false) $pos=-1;
if ($pos2===false) $pos2=-1;
$a = substr($a,$pos+1);
$b = substr($b,$pos2+1);
return strcmp($a,$b);
}
/**
* Reset the output and wipe the navs
*
@@ -572,4 +605,3 @@ function clearoutput(){
$nav="";
}
?>
@@ -247,6 +247,7 @@
"Display Preferences,title",
"template"=>"Skin,theme",
"sortedmenus"=>"Menus are sorted by alphabet?,bool",
"language"=>"Language,enum,".getsetting("serverlanguages","en,English,de,Deutsch,fr,Français,dk,Danish,es,Español,it,Italian"),
"tabconfig"=>"Show config sections in tabs,bool",
"forestcreaturebar"=>"Forest Creatures show health ...,enum,0,Only Text,1,Only Healthbar,2,Healthbar AND Text",

0 comments on commit 119dc38

Please sign in to comment.
You can’t perform that action at this time.