mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 07:15:13 +00:00
Merge pull request #783 from zotlabs/app_order
provide mechanism to arbitrarily sort the nav tray apps, currently th…
This commit is contained in:
commit
ed4d589077
2 changed files with 46 additions and 0 deletions
|
@ -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));
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue