aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-05-16 22:57:34 -0700
committerzotlabs <mike@macgirvin.com>2017-05-16 23:00:28 -0700
commit21103f8bc4d4a54211ba4edaefc1bce694a8fa05 (patch)
treed3bc2fe01fffa4c17941a92c1f4b10a41daba2d1
parent3c22a7b4823d9b47e91d39f2984cb54d6fe0d80f (diff)
downloadvolse-hubzilla-21103f8bc4d4a54211ba4edaefc1bce694a8fa05.tar.gz
volse-hubzilla-21103f8bc4d4a54211ba4edaefc1bce694a8fa05.tar.bz2
volse-hubzilla-21103f8bc4d4a54211ba4edaefc1bce694a8fa05.zip
provide mechanism to arbitrarily sort the nav tray apps, currently the preferred order list needs to be manually created
-rw-r--r--Zotlabs/Lib/Apps.php44
-rw-r--r--include/nav.php2
2 files changed, 46 insertions, 0 deletions
diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php
index 2ace361ca..102ed8bd1 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));
diff --git a/include/nav.php b/include/nav.php
index 849e19d9a..0fd555abf 100644
--- a/include/nav.php
+++ b/include/nav.php
@@ -257,6 +257,8 @@ EOT;
usort($syslist,'Zotlabs\\Lib\\Apps::app_name_compare');
+ $syslist = Zlib\Apps::app_order(local_channel(),$syslist);
+
foreach($syslist as $app) {
$nav_apps[] = Zlib\Apps::app_render($app,'nav');
}