diff options
author | zotlabs <mike@macgirvin.com> | 2017-05-16 22:57:34 -0700 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2017-05-16 22:57:34 -0700 |
commit | a1ba44db720abab58d8b6b13035daa25710acd03 (patch) | |
tree | 7c5f2d750c46e99fb4598f1379ef593d4dc24719 /Zotlabs | |
parent | 7a39ccf7bb3c61a354207486f83b970641e54680 (diff) | |
download | volse-hubzilla-a1ba44db720abab58d8b6b13035daa25710acd03.tar.gz volse-hubzilla-a1ba44db720abab58d8b6b13035daa25710acd03.tar.bz2 volse-hubzilla-a1ba44db720abab58d8b6b13035daa25710acd03.zip |
provide mechanism to arbitrarily sort the nav tray apps, currently the preferred order list needs to be manually created
Diffstat (limited to 'Zotlabs')
-rw-r--r-- | Zotlabs/Lib/Apps.php | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index edf050b95..26d4b88b3 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -539,6 +539,50 @@ class Apps { return($r); } + static public function app_order($uid,$apps) { + + if(! $apps) + return $apps; + + $x = (($uid) ? get_pconfig($uid,'system','app_order') : get_config('system','app_order')); + if(($x) && (! is_array($x))) { + $y = explode(',',$x); + $y = array_map('trim',$y); + $x = $y; + } + + if(! (is_array($x) && ($x))) + return $apps; + + $ret = []; + foreach($x as $xx) { + $y = self::find_app_in_array($xx,$apps); + if($y) { + $ret[] = $y; + } + } + foreach($apps as $ap) { + if(! self::find_app_in_array($ap['name'],$ret)) { + $ret[] = $ap; + } + } + return $ret; + + } + + static function find_app_in_array($name,$arr) { + if(! $arr) + return false; + foreach($arr as $x) { + if($x['name'] === $name) { + return $x; + } + } + return false; + } + + + static public function app_decode($s) { $x = base64_decode(str_replace(array('<br />',"\r","\n",' '),array('','','',''),$s)); |