streams/Code/Module/Apporder.php

62 lines
1.7 KiB
PHP
Raw Normal View History

<?php
2022-02-16 04:08:28 +00:00
namespace Code\Module;
2022-02-16 04:08:28 +00:00
use Code\Web\Controller;
use Code\Lib\Apps;
use Code\Lib\Navbar;
use Code\Render\Theme;
2022-02-12 20:43:29 +00:00
2021-12-02 22:33:36 +00:00
class Apporder extends Controller
{
2021-12-02 23:02:31 +00:00
public function get()
{
if (!local_channel()) {
return;
}
2022-02-20 08:12:31 +00:00
2022-01-25 04:16:38 +00:00
Navbar::set_selected('Order Apps');
2021-12-02 23:02:31 +00:00
2022-02-20 08:12:31 +00:00
$nav_apps = [];
$navbar_apps = [];
2021-12-02 23:02:31 +00:00
foreach (['nav_featured_app', 'nav_pinned_app'] as $l) {
$syslist = [];
$list = Apps::app_list(local_channel(), false, [$l]);
if ($list) {
foreach ($list as $li) {
$syslist[] = Apps::app_encode($li);
}
}
Apps::translate_system_apps($syslist);
2022-02-16 04:08:28 +00:00
usort($syslist, 'Code\\Lib\\Apps::app_name_compare');
2021-12-02 23:02:31 +00:00
$syslist = Apps::app_order(local_channel(), $syslist, $l);
foreach ($syslist as $app) {
if ($l === 'nav_pinned_app') {
$navbar_apps[] = Apps::app_render($app, 'nav-order-pinned');
2022-02-20 08:12:31 +00:00
}
else {
2021-12-02 23:02:31 +00:00
$nav_apps[] = Apps::app_render($app, 'nav-order');
}
}
}
2022-02-12 20:43:29 +00:00
return replace_macros(Theme::get_template('apporder.tpl'), [
'$arrange' => t('Arrange Apps'),
'$header' => [t('Change order of pinned navbar apps'), t('Change order of app tray apps')],
2021-12-02 23:02:31 +00:00
'$desc' => [t('Use arrows to move the corresponding app left (top) or right (bottom) in the navbar'),
t('Use arrows to move the corresponding app up or down in the app tray')],
'$nav_apps' => $nav_apps,
'$navbar_apps' => $navbar_apps
]);
}
}