mirror of
https://github.com/Karaka-Management/oms-Navigation.git
synced 2026-01-11 16:18:42 +00:00
september update 1
This commit is contained in:
parent
1106d74676
commit
97c90ca519
|
|
@ -8,11 +8,23 @@
|
|||
"null": false,
|
||||
"primary": true
|
||||
},
|
||||
"nav_app": {
|
||||
"name": "nav_app",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "app",
|
||||
"foreignKey": "app_id"
|
||||
},
|
||||
"nav_pid": {
|
||||
"name": "nav_pid",
|
||||
"type": "VARCHAR(40)",
|
||||
"null": false
|
||||
},
|
||||
"nav_pid_raw": {
|
||||
"name": "nav_pid_raw",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"nav_name": {
|
||||
"name": "nav_name",
|
||||
"type": "VARCHAR(40)",
|
||||
|
|
@ -23,6 +35,11 @@
|
|||
"type": "TINYINT",
|
||||
"null": false
|
||||
},
|
||||
"nav_status": {
|
||||
"name": "nav_status",
|
||||
"type": "TINYINT",
|
||||
"null": false
|
||||
},
|
||||
"nav_subtype": {
|
||||
"name": "nav_subtype",
|
||||
"type": "TINYINT",
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ final class Installer extends InstallerAbstract
|
|||
}
|
||||
|
||||
foreach ($navData as $link) {
|
||||
self::installLink($app->dbPool, $link);
|
||||
self::installLink($app->dbPool, $link, $data['app'] ?? null);
|
||||
}
|
||||
|
||||
return [];
|
||||
|
|
@ -74,17 +74,19 @@ final class Installer extends InstallerAbstract
|
|||
*
|
||||
* @param DatabasePool $dbPool Database instance
|
||||
* @param array $data Link info
|
||||
* @param int $app App
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static function installLink($dbPool, $data) : void
|
||||
private static function installLink(DatabasePool $dbPool, array $data, int $app = null) : void
|
||||
{
|
||||
$navElement = new NavElement();
|
||||
|
||||
$navElement->id = (int) ($data['id'] ?? 0);
|
||||
$navElement->pid = \sha1(\str_replace('/', '', $data['pid'] ?? ''));
|
||||
$navElement->pidRaw = $data['pid'] ?? '';
|
||||
$navElement->name = (string) ($data['name'] ?? '');
|
||||
$navElement->type = (int) ($data['type'] ?? 1);
|
||||
$navElement->subtype = (int) ($data['subtype'] ?? 2);
|
||||
|
|
@ -92,6 +94,7 @@ final class Installer extends InstallerAbstract
|
|||
$navElement->uri = $data['uri'] ?? null;
|
||||
$navElement->target = (string) ($data['target'] ?? 'self');
|
||||
$navElement->action = $data['action'] ?? null;
|
||||
$navElement->app = (int) ($data['app'] ?? ($app ?? 2));
|
||||
$navElement->from = (string) ($data['from'] ?? '0');
|
||||
$navElement->order = (int) ($data['order'] ?? 1);
|
||||
$navElement->parent = (int) ($data['parent'] ?? 0);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,32 @@
|
|||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
return [];
|
||||
use Modules\Navigation\Controller\BackendController;
|
||||
use Modules\Navigation\Models\PermissionState;
|
||||
use phpOMS\Account\PermissionType;
|
||||
use phpOMS\Router\RouteVerb;
|
||||
|
||||
return [
|
||||
'^.*/admin/module/settings\?id=Navigation.*$' => [
|
||||
[
|
||||
'dest' => '\Modules\Navigation\Controller\BackendController:viewModuleSettings',
|
||||
'verb' => RouteVerb::GET,
|
||||
'permission' => [
|
||||
'module' => BackendController::MODULE_NAME,
|
||||
'type' => PermissionType::READ,
|
||||
'state' => \Modules\Admin\Models\PermissionState::MODULE,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
|
|
|||
157
Admin/Settings/Theme/Backend/settings.tpl.php
Normal file
157
Admin/Settings/Theme/Backend/settings.tpl.php
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\Auditor
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use phpOMS\Uri\UriFactory;
|
||||
|
||||
/**
|
||||
* @var \phpOMS\Views\View $this
|
||||
* @var \Modules\Navigation\Models\NavElement[] $navs
|
||||
*/
|
||||
$navs = $this->getData('navigation') ?? [];
|
||||
|
||||
$previous = empty($navs) ? '{/prefix}admin/nav/list' : '{/prefix}admin/nav/list?{?}&id=' . \reset($navs)->id . '&ptype=p';
|
||||
$next = empty($navs) ? '{/prefix}admin/nav/list' : '{/prefix}admin/nav/list?{?}&id=' . \end($navs)->id . '&ptype=n';
|
||||
|
||||
echo $this->getData('nav')->render(); ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="portlet">
|
||||
<div class="portlet-head"><?= $this->getHtml('Navigation'); ?><i class="fa fa-download floatRight download btn"></i></div>
|
||||
<div class="slider">
|
||||
<table id="navList" class="default sticky">
|
||||
<thead>
|
||||
<tr>
|
||||
<td><?= $this->getHtml('ID', '0', '0'); ?>
|
||||
<label for="navList-sort-1">
|
||||
<input type="radio" name="navList-sort" id="navList-sort-1">
|
||||
<i class="sort-asc fa fa-chevron-up"></i>
|
||||
</label>
|
||||
<label for="navList-sort-2">
|
||||
<input type="radio" name="navList-sort" id="navList-sort-2">
|
||||
<i class="sort-desc fa fa-chevron-down"></i>
|
||||
</label>
|
||||
<label>
|
||||
<i class="filter fa fa-filter"></i>
|
||||
</label>
|
||||
<td><?= $this->getHtml('PageId'); ?>
|
||||
<label for="navList-sort-3">
|
||||
<input type="radio" name="navList-sort" id="navList-sort-3">
|
||||
<i class="sort-asc fa fa-chevron-up"></i>
|
||||
</label>
|
||||
<label for="navList-sort-4">
|
||||
<input type="radio" name="navList-sort" id="navList-sort-4">
|
||||
<i class="sort-desc fa fa-chevron-down"></i>
|
||||
</label>
|
||||
<label>
|
||||
<i class="filter fa fa-filter"></i>
|
||||
</label>
|
||||
<td><?= $this->getHtml('Name'); ?>
|
||||
<label for="navList-sort-5">
|
||||
<input type="radio" name="navList-sort" id="navList-sort-5">
|
||||
<i class="sort-asc fa fa-chevron-up"></i>
|
||||
</label>
|
||||
<label for="navList-sort-6">
|
||||
<input type="radio" name="navList-sort" id="navList-sort-6">
|
||||
<i class="sort-desc fa fa-chevron-down"></i>
|
||||
</label>
|
||||
<label>
|
||||
<i class="filter fa fa-filter"></i>
|
||||
</label>
|
||||
<td><?= $this->getHtml('Type'); ?>
|
||||
<label for="navList-sort-7">
|
||||
<input type="radio" name="navList-sort" id="navList-sort-7">
|
||||
<i class="sort-asc fa fa-chevron-up"></i>
|
||||
</label>
|
||||
<label for="navList-sort-8">
|
||||
<input type="radio" name="navList-sort" id="navList-sort-8">
|
||||
<i class="sort-desc fa fa-chevron-down"></i>
|
||||
</label>
|
||||
<label>
|
||||
<i class="filter fa fa-filter"></i>
|
||||
</label>
|
||||
<td class="wf-100"><?= $this->getHtml('Subtype'); ?>
|
||||
<label for="navList-sort-9">
|
||||
<input type="radio" name="navList-sort" id="navList-sort-9">
|
||||
<i class="sort-asc fa fa-chevron-up"></i>
|
||||
</label>
|
||||
<label for="navList-sort-10">
|
||||
<input type="radio" name="navList-sort" id="navList-sort-10">
|
||||
<i class="sort-desc fa fa-chevron-down"></i>
|
||||
</label>
|
||||
<label>
|
||||
<i class="filter fa fa-filter"></i>
|
||||
</label>
|
||||
<td><?= $this->getHtml('Uri'); ?>
|
||||
<label for="navList-sort-13">
|
||||
<input type="radio" name="navList-sort" id="navList-sort-13">
|
||||
<i class="sort-asc fa fa-chevron-up"></i>
|
||||
</label>
|
||||
<label for="navList-sort-14">
|
||||
<input type="radio" name="navList-sort" id="navList-sort-14">
|
||||
<i class="sort-desc fa fa-chevron-down"></i>
|
||||
</label>
|
||||
<label>
|
||||
<i class="filter fa fa-filter"></i>
|
||||
</label>
|
||||
<td><?= $this->getHtml('From'); ?>
|
||||
<label for="navList-sort-15">
|
||||
<input type="radio" name="navList-sort" id="navList-sort-15">
|
||||
<i class="sort-asc fa fa-chevron-up"></i>
|
||||
</label>
|
||||
<label for="navList-sort-16">
|
||||
<input type="radio" name="navList-sort" id="navList-sort-16">
|
||||
<i class="sort-desc fa fa-chevron-down"></i>
|
||||
</label>
|
||||
<label>
|
||||
<i class="filter fa fa-filter"></i>
|
||||
</label>
|
||||
<td><?= $this->getHtml('Parent'); ?>
|
||||
<label for="navList-sort-17">
|
||||
<input type="radio" name="navList-sort" id="navList-sort-17">
|
||||
<i class="sort-asc fa fa-chevron-up"></i>
|
||||
</label>
|
||||
<label for="navList-sort-18">
|
||||
<input type="radio" name="navList-sort" id="navList-sort-18">
|
||||
<i class="sort-desc fa fa-chevron-down"></i>
|
||||
</label>
|
||||
<label>
|
||||
<i class="filter fa fa-filter"></i>
|
||||
</label>
|
||||
<tbody>
|
||||
<?php $count = 0;
|
||||
foreach ($navs as $key => $nav) : ++$count;
|
||||
$url = UriFactory::build('{/prefix}admin/module/settings?id=Navigation&nav=' . $nav->id); ?>
|
||||
<tr tabindex="0" data-href="<?= $url; ?>">
|
||||
<td><a href="<?= $url; ?>"><?= $nav->id; ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $nav->pidRaw; ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $nav->name; ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $nav->type; ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $nav->subtype; ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $nav->uri; ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $nav->from; ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $nav->parent; ?></a>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($count === 0) : ?>
|
||||
<tr><td colspan="8" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
</div>
|
||||
<div class="portlet-foot">
|
||||
<a tabindex="0" class="button" href="<?= UriFactory::build($previous); ?>"><?= $this->getHtml('Previous', '0', '0'); ?></a>
|
||||
<a tabindex="0" class="button" href="<?= UriFactory::build($next); ?>"><?= $this->getHtml('Next', '0', '0'); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -18,6 +18,11 @@ use Modules\Navigation\Models\Navigation;
|
|||
use Modules\Navigation\Views\NavigationView;
|
||||
use phpOMS\Message\RequestAbstract;
|
||||
use phpOMS\Message\ResponseAbstract;
|
||||
use Model\SettingMapper;
|
||||
use Model\NullSetting;
|
||||
use Modules\Navigation\Models\NavElementMapper;
|
||||
use phpOMS\Views\View;
|
||||
use phpOMS\Contract\RenderableInterface;
|
||||
|
||||
/**
|
||||
* Navigation class.
|
||||
|
|
@ -149,4 +154,39 @@ final class BackendController extends Controller
|
|||
|
||||
return $navView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method which generates the module profile view.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return RenderableInterface Response can be rendered
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function viewModuleSettings(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
|
||||
{
|
||||
$view = new View($this->app->l11nManager, $request, $response);
|
||||
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000105001, $request, $response));
|
||||
|
||||
$id = $request->getData('id') ?? '';
|
||||
|
||||
$settings = SettingMapper::getFor($id, 'module');
|
||||
if (!($settings instanceof NullSetting)) {
|
||||
$view->setData('settings', !\is_array($settings) ? [$settings] : $settings);
|
||||
}
|
||||
|
||||
$navigation = NavElementMapper::getAll();
|
||||
$view->setData('navigation', $navigation);
|
||||
|
||||
if (\is_file(__DIR__ . '/../Admin/Settings/Theme/Backend/settings.tpl.php')) {
|
||||
$view->setTemplate('/Modules/' . static::MODULE_NAME . '/Admin/Settings/Theme/Backend/settings');
|
||||
} else {
|
||||
$view->setTemplate('/Modules/Admin/Theme/Backend/modules-settings');
|
||||
}
|
||||
|
||||
return $view;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
36
Models/LinkStatus.php
Normal file
36
Models/LinkStatus.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\Navigation\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Navigation\Models;
|
||||
|
||||
use phpOMS\Stdlib\Base\Enum;
|
||||
|
||||
/**
|
||||
* Link status enum.
|
||||
*
|
||||
* @package Modules\Navigation\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract class LinkStatus extends Enum
|
||||
{
|
||||
public const ACTIVE = 1;
|
||||
|
||||
public const INACTIVE = 2;
|
||||
|
||||
public const HIDDEN = 3;
|
||||
|
||||
public const ANY = 4;
|
||||
}
|
||||
|
|
@ -32,6 +32,14 @@ class NavElement
|
|||
*/
|
||||
public int $id = 0;
|
||||
|
||||
/**
|
||||
* App.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $app = 0;
|
||||
|
||||
/**
|
||||
* Page Id.
|
||||
*
|
||||
|
|
@ -42,6 +50,16 @@ class NavElement
|
|||
*/
|
||||
public string $pid = '';
|
||||
|
||||
/**
|
||||
* Page Id.
|
||||
*
|
||||
* Generated from the path from a URI (sha1)
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public string $pidRaw = '';
|
||||
|
||||
/**
|
||||
* Name of the link.
|
||||
*
|
||||
|
|
@ -150,4 +168,12 @@ class NavElement
|
|||
* @since 1.0.0
|
||||
*/
|
||||
public ?int $permissionElement = null;
|
||||
|
||||
/**
|
||||
* Status.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $status = LinkStatus::ACTIVE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,9 @@ final class NavElementMapper extends DataMapperAbstract
|
|||
*/
|
||||
protected static array $columns = [
|
||||
'nav_id' => ['name' => 'nav_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'nav_app' => ['name' => 'nav_app', 'type' => 'int', 'internal' => 'app'],
|
||||
'nav_pid' => ['name' => 'nav_pid', 'type' => 'string', 'internal' => 'pid'],
|
||||
'nav_pid_raw' => ['name' => 'nav_pid_raw', 'type' => 'string', 'internal' => 'pidRaw'],
|
||||
'nav_name' => ['name' => 'nav_name', 'type' => 'string', 'internal' => 'name'],
|
||||
'nav_type' => ['name' => 'nav_type', 'type' => 'int', 'internal' => 'type'],
|
||||
'nav_subtype' => ['name' => 'nav_subtype', 'type' => 'int', 'internal' => 'subtype'],
|
||||
|
|
@ -48,6 +50,7 @@ final class NavElementMapper extends DataMapperAbstract
|
|||
'nav_permission_permission' => ['name' => 'nav_permission_permission', 'type' => 'int', 'internal' => 'permissionPerm'],
|
||||
'nav_permission_type' => ['name' => 'nav_permission_type', 'type' => 'int', 'internal' => 'permissionType'],
|
||||
'nav_permission_element' => ['name' => 'nav_permission_element', 'type' => 'int', 'internal' => 'permissionElement'],
|
||||
'nav_status' => ['name' => 'nav_status', 'type' => 'int', 'internal' => 'status'],
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ class Navigation
|
|||
$sth = $query->select('*')
|
||||
->from('nav')
|
||||
->whereIn('nav.nav_pid', $hashes)
|
||||
->andWhere('nav.nav_status', '=', LinkStatus::ACTIVE)
|
||||
->orderBy('nav.nav_order', 'ASC')
|
||||
->execute();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user