From ec7ecc285ec10a7990db09bda436fd498e05245a Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 21 May 2017 22:23:36 -0700 Subject: apporder module and all the associated backend stuff to make it work; probably needs a bit of UI cleanup and a link to it from somewhere --- Zotlabs/Lib/Apps.php | 87 ++++++++++++++++++++++++++++++++++++++++++++- Zotlabs/Module/Appman.php | 14 ++++++++ Zotlabs/Module/Apporder.php | 40 +++++++++++++++++++++ view/tpl/app.tpl | 7 +++- view/tpl/apporder.tpl | 7 ++++ 5 files changed, 153 insertions(+), 2 deletions(-) create mode 100644 Zotlabs/Module/Apporder.php create mode 100644 view/tpl/apporder.tpl diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 102ed8bd1..a655f47b0 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -370,7 +370,8 @@ class Apps { '$deleted' => $papp['deleted'], '$feature' => (($papp['embed']) ? false : true), '$featured' => ((strpos($papp['categories'], 'nav_featured_app') === false) ? false : true), - '$navapps' => (($mode == 'nav') ? true : false), + '$navapps' => (($mode == 'nav' || $mode='nav-order') ? true : false), + '$order' => (($mode='nav-order') ? true : false), '$add' => t('Add to app-tray'), '$remove' => t('Remove from app-tray') )); @@ -581,6 +582,90 @@ class Apps { return false; } + static function moveup($uid,$guid) { + $syslist = array(); + $list = self::app_list($uid, false, 'nav_featured_app'); + if($list) { + foreach($list as $li) { + $syslist[] = self::app_encode($li); + } + } + self::translate_system_apps($syslist); + + usort($syslist,'self::app_name_compare'); + + $syslist = self::app_order($uid,$syslist); + + if(! $syslist) + return; + + $newlist = []; + + foreach($syslist as $k => $li) { + if($li['guid'] === $guid) { + $position = $k; + break; + } + } + if(! $position) + return; + $dest_position = $position - 1; + $saved = $syslist[$dest_position]; + $syslist[$dest_position] = $syslist[$position]; + $syslist[$position] = $saved; + + $narr = []; + foreach($syslist as $x) { + $narr[] = $x['name']; + } + + set_pconfig($uid,'system','app_order',implode(',',$narr)); + + } + + static function movedown($uid,$guid) { + $syslist = array(); + $list = self::app_list($uid, false, 'nav_featured_app'); + if($list) { + foreach($list as $li) { + $syslist[] = self::app_encode($li); + } + } + self::translate_system_apps($syslist); + + usort($syslist,'self::app_name_compare'); + + $syslist = self::app_order($uid,$syslist); + + if(! $syslist) + return; + + $newlist = []; + + foreach($syslist as $k => $li) { + if($li['guid'] === $guid) { + $position = $k; + break; + } + } + if($position >= count($syslist) - 1) + return; + $dest_position = $position + 1; + $saved = $syslist[$dest_position]; + $syslist[$dest_position] = $syslist[$position]; + $syslist[$position] = $saved; + + $narr = []; + foreach($syslist as $x) { + $narr[] = $x['name']; + } + + set_pconfig($uid,'system','app_order',implode(',',$narr)); + + } + + + diff --git a/Zotlabs/Module/Appman.php b/Zotlabs/Module/Appman.php index 70cc7e44b..5c0667357 100644 --- a/Zotlabs/Module/Appman.php +++ b/Zotlabs/Module/Appman.php @@ -84,6 +84,20 @@ class Appman extends \Zotlabs\Web\Controller { } $channel = \App::get_channel(); + + if(argc() > 2) { + if(argv(2) === 'moveup') { + Zlib\Apps::moveup(local_channel(),argv(1)); + } + if(argv(2) === 'movedown') { + Zlib\Apps::movedown(local_channel(),argv(1)); + } + goaway(z_root() . '/apporder'); + } + + + + $app = null; $embed = null; if($_REQUEST['appid']) { diff --git a/Zotlabs/Module/Apporder.php b/Zotlabs/Module/Apporder.php new file mode 100644 index 000000000..1097a01eb --- /dev/null +++ b/Zotlabs/Module/Apporder.php @@ -0,0 +1,40 @@ + t('Change Order of Navigation Apps'), + '$desc' => t('Use arrows to move the corresponding app up or down in the display list'), + '$nav_apps' => $nav_apps + ] + ); + } +} diff --git a/view/tpl/app.tpl b/view/tpl/app.tpl index 28f28611e..f45510a58 100644 --- a/view/tpl/app.tpl +++ b/view/tpl/app.tpl @@ -25,6 +25,11 @@ {{/if}} {{else}} +{{if $order}} + + +{{if $icon}}{{else}}{{/if}}{{$app.name}}
+{{else}} {{if $icon}}{{else}}{{/if}}{{$app.name}} {{/if}} - +{{/if}} diff --git a/view/tpl/apporder.tpl b/view/tpl/apporder.tpl new file mode 100644 index 000000000..fdb726131 --- /dev/null +++ b/view/tpl/apporder.tpl @@ -0,0 +1,7 @@ +

{{$header}}

+ +
{{$desc}}
+


+{{foreach $nav_apps as $nav_app}} +{{$nav_app}} +{{/foreach}} -- cgit v1.2.3