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
This commit is contained in:
parent
21103f8bc4
commit
e4448423fb
@ -370,7 +370,8 @@ class Apps {
|
|||||||
'$deleted' => $papp['deleted'],
|
'$deleted' => $papp['deleted'],
|
||||||
'$feature' => (($papp['embed']) ? false : true),
|
'$feature' => (($papp['embed']) ? false : true),
|
||||||
'$featured' => ((strpos($papp['categories'], 'nav_featured_app') === false) ? 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'),
|
'$add' => t('Add to app-tray'),
|
||||||
'$remove' => t('Remove from app-tray')
|
'$remove' => t('Remove from app-tray')
|
||||||
));
|
));
|
||||||
@ -581,6 +582,90 @@ class Apps {
|
|||||||
return false;
|
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));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,6 +84,20 @@ class Appman extends \Zotlabs\Web\Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$channel = \App::get_channel();
|
$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;
|
$app = null;
|
||||||
$embed = null;
|
$embed = null;
|
||||||
if($_REQUEST['appid']) {
|
if($_REQUEST['appid']) {
|
||||||
|
40
Zotlabs/Module/Apporder.php
Normal file
40
Zotlabs/Module/Apporder.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Zotlabs\Module;
|
||||||
|
|
||||||
|
use \Zotlabs\Lib as Zlib;
|
||||||
|
|
||||||
|
class Apporder extends \Zotlabs\Web\Controller {
|
||||||
|
|
||||||
|
function post() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function get() {
|
||||||
|
$syslist = array();
|
||||||
|
$list = Zlib\Apps::app_list(local_channel(), false, 'nav_featured_app');
|
||||||
|
if($list) {
|
||||||
|
foreach($list as $li) {
|
||||||
|
$syslist[] = Zlib\Apps::app_encode($li);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Zlib\Apps::translate_system_apps($syslist);
|
||||||
|
|
||||||
|
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-order');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return replace_macros(get_markup_template('apporder.tpl'),
|
||||||
|
[
|
||||||
|
'$header' => 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
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -25,6 +25,11 @@
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
{{else}}
|
{{else}}
|
||||||
|
{{if $order}}
|
||||||
|
<a href="{{$hosturl}}appman/{{$app.guid}}/moveup"><i class="generic-icons-nav fa fa-fw fa-arrow-up"></i></a>
|
||||||
|
<a href="{{$hosturl}}appman/{{$app.guid}}/movedown"><i class="generic-icons-nav fa fa-fw fa-arrow-down"></i></a>
|
||||||
|
{{if $icon}}<i class="generic-icons-nav fa fa-fw fa-{{$icon}}"></i>{{else}}<img src="{{$app.photo}}" width="16" height="16" style="margin-right:9px;"/>{{/if}}{{$app.name}}<br>
|
||||||
|
{{else}}
|
||||||
<a class="dropdown-item" href="{{$app.url}}">{{if $icon}}<i class="generic-icons-nav fa fa-fw fa-{{$icon}}"></i>{{else}}<img src="{{$app.photo}}" width="16" height="16" style="margin-right:9px;"/>{{/if}}{{$app.name}}</a>
|
<a class="dropdown-item" href="{{$app.url}}">{{if $icon}}<i class="generic-icons-nav fa fa-fw fa-{{$icon}}"></i>{{else}}<img src="{{$app.photo}}" width="16" height="16" style="margin-right:9px;"/>{{/if}}{{$app.name}}</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
|
7
view/tpl/apporder.tpl
Normal file
7
view/tpl/apporder.tpl
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<h2>{{$header}}</h2>
|
||||||
|
|
||||||
|
<div class="descriptive-text">{{$desc}}</div>
|
||||||
|
<br><br><br>
|
||||||
|
{{foreach $nav_apps as $nav_app}}
|
||||||
|
{{$nav_app}}
|
||||||
|
{{/foreach}}
|
Reference in New Issue
Block a user