Commit 4dd337f6 authored by Σταύρος Παπαδάκης's avatar Σταύρος Παπαδάκης
Browse files

Admin subsystem skeleton

This is the first release of the administration module to support
administrative functions.
Changed main layout to add admin navigation.
Added /admin route for "admin home"
parent 40a9b385
......@@ -29,6 +29,7 @@ return [
'module/university_form/bootstrap.php',
'module/teacher_form/bootstrap.php',
'module/enable_db_login/bootstrap.php',
'module/admin/bootstrap.php',
],
'cache_config' => 'data/cache/config/settings.php',
];
......@@ -79,5 +79,11 @@ return [
],
],
'admin' => [
'adminhome' => [
'label' => 'Αρχική σελίδα διαχειριστή',
'route' => 'admin',
],
]
],
];
# Υποσύστημα διαχειριστή
Παρέχει πρόσβαση σε διαχειριστικές λειτουργίες. Εφόσον ο χρήστης πιστοποιείται
με ρόλο admin εμφανίζεται το μενού διαχειριστικών λειτουργιών.
## Routes
Διαθέσιμα routes (paths) και λειτουργίες.
- admin (/admin): αρχική σελίδα διαχειριστή
## Οδηγίες
Για να είναι προσβάσιμο, πρέπει:
- να προσθέσετε την παρακάτω γραμμή στο `acl.global.php` ή `acl.local.php`,
στο acl.guards.routes
```
['/admin', ['admin'], ['get']],
```
<?php
use Slim\App;
use Slim\Container;
use Slim\Http\Request;
use Slim\Http\Response;
/**
* gredu_labs.
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
*
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
return function (App $app) {
$container = $app->getContainer();
$events = $container['events'];
$events('on', 'app.autoload', function ($autoloader) {
$autoloader->addPsr4('GrEduLabs\\Admin\\', __DIR__ . '/src/');
});
$events('on', 'app.services', function (Container $container) {
// $nav = $container['settings']->get('navigation');
// $nav['admin'] = [
// 'adminhome' => [
// 'label' => 'Διαχειριστής',
// 'route' => 'admin',
// 'icon' => 'user-secret',
// ],
// ];
// $container['settings']->set('navigation', $nav);
$container[GrEduLabs\Admin\Action\Index::class] = function ($c) {
return new GrEduLabs\Admin\Action\Index($c['view']);
};
});
$events('on', 'app.bootstrap', function (App $app, Container $c) {
$view = $c->get('view');
$view->getEnvironment()->getLoader()->prependPath(__DIR__ . '/templates');
$app->get('/admin', GrEduLabs\Admin\Action\Index::class)
->setName('admin');
});
};
<?php
/**
* gredu_labs.
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
*
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace GrEduLabs\Admin\Action;
use Slim\Http\Request;
use Slim\Http\Response;
use Slim\Views\Twig;
class Index {
/**
* @var Twig
*/
protected $view;
/**
* Constructor.
*
* @param Twig $view
*/
public function __construct(Twig $view) {
$this->view = $view;
}
public function __invoke(Request $req, Response $res) {
return $this->view->render($res, 'admin/index.twig');
}
}
{% extends "layout.twig" %}
{% block content %}
<div id="adminarea">
<div class="panel panel-default">
<div class="panel-heading">
<h4>Σελίδα διαχειριστή</h4>
</div>
<div class="panel-body">
<p>Διαθέσιμες διαχειριστικές λειτουργίες</p>
</div>
<div class="panel-footer text-center">
<a class="btn btn-sm btn-default" href="{{ path_for('index') }}"><span class="fa fa-home"></span> Αρχική</a>
<a class="btn btn-sm btn-primary" href="{{ path_for('admin') }}"><span class="fa fa-user-secret"></span> Διαχειριστής</a>
<a class="btn btn-sm btn-default" href="{{ path_for('user.logout') }}"><span class="fa fa-lock"></span> Αποσύνδεση</a>
</div>
</div>
</div>
{% endblock %}
{% macro li(page) %}
<li role="presentation" class="{% if page.active %}active {% endif %}{{ page.class|default('') }}">
<a href="{{ page.href }}" {% if page.id %}id="{{ page.id }}"{% endif %} title="{{ page.label|striptags|e }}"
{% if page.target %}target="{{ page.target }}"{% endif %}>
......@@ -24,14 +24,24 @@
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
{% for page in nav('main') %}
{{ macros.li(page)}}
{% endfor %}
{% for page in nav('main') %}
{{ macros.li(page)}}
{% endfor %}
{% if not nav('admin') is empty %}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="fa fa-user-secret"></span> Διαχειριστής <span class="caret"></span></a>
<ul class="dropdown-menu">
{% for page in nav('admin') %}
{{ macros.li(page)}}
{% endfor %}
</ul>
</li>
{% endif %}
</ul>
<ul class="nav navbar-nav navbar-right">
{% for page in nav('authentication') %}
{{ macros.li(page)}}
{% endfor %}
{% for page in nav('authentication') %}
{{ macros.li(page)}}
{% endfor %}
</ul>
</div>
</div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment