Skip to content

Commit

Permalink
Merge pull request #309 from AntonShevchuk/master
Browse files Browse the repository at this point in the history
Added hooks inside application bootstrap
  • Loading branch information
Anton committed Oct 24, 2017
2 parents 308159e + 50262e3 commit 3323b45
Show file tree
Hide file tree
Showing 26 changed files with 213 additions and 172 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.DS_Store
.idea
/vendor/*
vendor
composer.lock
composer.phar
codecept.phar
Expand Down
10 changes: 6 additions & 4 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
MIT License

Copyright (c) 2012-2017 by Bluz PHP Team

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand All @@ -7,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 1 addition & 3 deletions application/configs/default/php.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,4 @@
* @link http://php.net/manual/en/configuration.changes.modes.php
* @return array
*/
return [
'session.cache_expire' => '180', // 180 is default value
];
return [];
9 changes: 1 addition & 8 deletions application/configs/phinx.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,8 @@
'environments' => [
'default_migration_table' => 'migrations',
'default' => (function () {
$config = new \Bluz\Config\Config();

$config->setPath(PATH_APPLICATION);
$config->setEnvironment(getenv('BLUZ_ENV') ?: 'production');
$config->init();

$data = $config->getData('db', 'connect');
$data = \Bluz\Proxy\Config::getData('db', 'connect');
$data['adapter'] = $data['type'];

return $data;
})()
]
Expand Down
11 changes: 11 additions & 0 deletions application/configs/production/php.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
/**
* PHP configuration
*
* @link http://php.net/manual/en/session.configuration.php
* @link http://php.net/manual/en/configuration.changes.modes.php
* @return array
*/
return [
'session.cache_expire' => '180', // 180 is default value
];
73 changes: 1 addition & 72 deletions application/layouts/dashboard.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,78 +4,7 @@
<?php require __DIR__ . '/partial/nav-bar.phtml'; ?>
<div class="container-fluid">
<div class="row">
<nav class="col-sm-3 col-md-2 d-none d-sm-block bg-light sidebar">
<hr/>
<ul class="nav nav-pills flex-column">
<li class="nav-item <?= ($this->module('pages') ? 'class="active"' : '') ?>">
<?= $this->ahref(
'<i class="fa fa-edit fa-fw"></i> ' . __('Pages'),
['pages', 'grid', [], true],
['class' => 'nav-link']
) ?>
</li>
<li class="nav-item <?= ($this->module('users') ? 'class="active"' : '') ?>">
<?= $this->ahref(
'<i class="fa fa-user fa-fw"></i> ' . __('Users'),
['users', 'grid', [], true],
['class' => 'nav-link']
) ?>
</li>
<?php if ($this->hasModule('media')) : ?>
<li class="nav-item <?= ($this->module('media') ? 'class="active"' : '') ?>">
<?= $this->ahref(
'<i class="fa fa-picture-o fa-fw"></i> ' . __('Media'),
['media', 'grid', [], true],
['class' => 'nav-link']
) ?>
</li>
<?php endif; ?>
<?php if ($this->hasModule('categories')) : ?>
<li class="nav-item <?= ($this->module('categories') ? 'class="active"' : '') ?>">
<?= $this->ahref(
'<i class="fa fa-folder-o fa-fw"></i> ' . __('Categories'),
['categories', 'tree', [], true],
['class' => 'nav-link']
) ?>
</li>
<?php endif; ?>
<li class="nav-item <?= ($this->module('acl') ? 'class="active"' : '') ?>">
<?= $this->ahref(
'<i class="fa fa-lock fa-fw"></i> ' . __('Permissions'),
['acl', 'index', [], true],
['class' => 'nav-link']
) ?>
</li>
<?php if ($this->hasModule('options')) : ?>
<li class="nav-item <?= ($this->module('options') ? 'class="active"' : '') ?>">
<?= $this->ahref(
'<i class="fa fa-th-list fa-fw"></i> ' . __('Options'),
['options', 'grid', [], true],
['class' => 'nav-link']
) ?>
</li>
<?php endif; ?>
<?php if ($this->hasModule('contact-us')) : ?>
<li class="nav-item <?= ($this->module('contact-us') ? 'class="active"' : '') ?>">
<?= $this->ahref(
'<i class="fa fa-envelope-o fa-fw"></i> ' . __('Contact Us'),
['contact-us', 'grid', [], true],
['class' => 'nav-link']
) ?>
</li>
<?php endif; ?>
</ul>
<hr/>
<ul class="nav nav-pills flex-column">
<li class="nav-item <?= ($this->module('system') ? 'class="active"' : '') ?>">
<?= $this->ahref(
'<i class="fa fa-wrench fa-fw"></i> ' . __('System'),
['system', 'index', [], true],
['class' => 'nav-link']
) ?>
</li>
</ul>
</nav>
<?php require __DIR__ . '/partial/nav-menu.phtml'; ?>
<main class="col-sm-9 ml-sm-auto col-md-10 pt-3" role="main">
<?php require __DIR__.'/partial/breadcrumbs.phtml'; ?>
<?php
Expand Down
2 changes: 1 addition & 1 deletion application/layouts/partial/nav-bar.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</li>
<?php endif; ?>
</ul>
<div id="loading"></div>
<div id="loading" data-ajax-loading-show="1" data-ajax-loading-hide="1"></div>
<span class="navbar-text">
<?php if ($identity = $this->user()) : ?>
<?= __(
Expand Down
82 changes: 82 additions & 0 deletions application/layouts/partial/nav-menu.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@

<nav class="col-sm-3 col-md-2 d-none d-sm-block bg-light sidebar">
<hr/>
<ul class="nav nav-pills flex-column">
<li class="nav-item <?= ($this->module('pages') ? 'active' : '') ?>">
<?= $this->ahref(
'<i class="fa fa-edit fa-fw"></i> ' . __('Pages'),
['pages', 'grid', [], true],
['class' => 'nav-link']
) ?>
</li>
<li class="nav-item <?= ($this->module('users') ? 'active' : '') ?>">
<?= $this->ahref(
'<i class="fa fa-user fa-fw"></i> ' . __('Users'),
['users', 'grid', [], true],
['class' => 'nav-link']
) ?>
</li>
<?php if ($this->hasModule('wallet')) : ?>
<li class="nav-item <?= ($this->module('wallet') ? 'active' : '') ?>">
<?= $this->ahref(
'<i class="fa fa-credit-card fa-fw"></i> ' . __('Wallets'),
['wallet', 'grid', [], true],
['class' => 'nav-link']
) ?>
</li>
<?php endif; ?>
<?php if ($this->hasModule('media')) : ?>
<li class="nav-item <?= ($this->module('media') ? 'active' : '') ?>">
<?= $this->ahref(
'<i class="fa fa-picture-o fa-fw"></i> ' . __('Media'),
['media', 'grid', [], true],
['class' => 'nav-link']
) ?>
</li>
<?php endif; ?>
<?php if ($this->hasModule('categories')) : ?>
<li class="nav-item <?= ($this->module('categories') ? 'active' : '') ?>">
<?= $this->ahref(
'<i class="fa fa-folder-o fa-fw"></i> ' . __('Categories'),
['categories', 'tree', [], true],
['class' => 'nav-link']
) ?>
</li>
<?php endif; ?>
<li class="nav-item <?= ($this->module('acl') ? 'active' : '') ?>">
<?= $this->ahref(
'<i class="fa fa-lock fa-fw"></i> ' . __('Permissions'),
['acl', 'index', [], true],
['class' => 'nav-link']
) ?>
</li>
<?php if ($this->hasModule('options')) : ?>
<li class="nav-item <?= ($this->module('options') ? 'active' : '') ?>">
<?= $this->ahref(
'<i class="fa fa-th-list fa-fw"></i> ' . __('Options'),
['options', 'grid', [], true],
['class' => 'nav-link']
) ?>
</li>
<?php endif; ?>
<?php if ($this->hasModule('contact-us')) : ?>
<li class="nav-item <?= ($this->module('contact-us') ? 'active' : '') ?>">
<?= $this->ahref(
'<i class="fa fa-envelope-o fa-fw"></i> ' . __('Contact Us'),
['contact-us', 'grid', [], true],
['class' => 'nav-link']
) ?>
</li>
<?php endif; ?>
</ul>
<hr/>
<ul class="nav nav-pills flex-column">
<li class="nav-item <?= ($this->module('system') ? 'active' : '') ?>">
<?= $this->ahref(
'<i class="fa fa-wrench fa-fw"></i> ' . __('System'),
['system', 'index', [], true],
['class' => 'nav-link']
) ?>
</li>
</ul>
</nav>
13 changes: 13 additions & 0 deletions application/library/Application/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@
*/
class Bootstrap extends Application
{
/**
* {@inheritdoc}
*/
protected function preProcess()
{
parent::preProcess();

$path = $this->getPath() . '/modules';
foreach (glob($path .'/*/init.php') as $initial) {
(include $initial)($this);
}
}

/**
* {@inheritdoc}
*
Expand Down
6 changes: 2 additions & 4 deletions application/modules/acl/controllers/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,8 @@
$meta = $controllerInstance->getMeta();


if ($privilege = $meta->getPrivilege()) {
if (!in_array($privilege, $set[$module])) {
$set[$module][] = $privilege;
}
if (($privilege = $meta->getPrivilege()) && !in_array($privilege, $set[$module], true)) {
$set[$module][] = $privilege;
}

if ($acl = $meta->getAcl()) {
Expand Down
4 changes: 0 additions & 4 deletions application/modules/error/controllers/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,6 @@
'error' => $message
];
}
// dialog AJAX call, accept HTML
if (!Request::isXmlHttpRequest()) {
$this->useLayout('small.phtml');
}
}

Layout::title($error);
Expand Down
1 change: 1 addition & 0 deletions application/modules/users/controllers/change-email.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
* @var Users\Row $user
*/
$user = $this->user();
$this->assign('user', $user);

if (Request::isPost()) {
// process form
Expand Down
2 changes: 2 additions & 0 deletions application/modules/users/controllers/change-password.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
* @var Users\Row $user
*/
$user = $this->user();
$this->assign('user', $user);

if (Request::isPost()) {
// process form
try {
Expand Down
14 changes: 1 addition & 13 deletions application/modules/users/views/change-email.phtml
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
<?php $uid = uniqid('form_', false); ?>
<div class="card text-center">
<div class="card-header">
<ul class="nav nav-tabs card-header-tabs">
<li class="nav-item">
<?= $this->ahref(__('Profile'), ['users', 'profile'], ['class' => 'nav-link']) ?>
</li>
<li class="nav-item">
<?= $this->ahref(__('Change email'), ['users', 'change-email'], ['class' => 'nav-link active']) ?>
</li>
<li class="nav-item">
<?= $this->ahref(__('Change password'), ['users', 'change-password'], ['class' => 'nav-link']) ?>
</li>
</ul>
</div>
<?php require_once __DIR__ .'/partial/card-header.phtml' ?>
<div class="card-body">
<h4 class="card-title"><?= __('Change email') ?></h4>
<p class="card-text"><?= __('Email will be changed after confirmation') ?></p>
Expand Down
14 changes: 1 addition & 13 deletions application/modules/users/views/change-password.phtml
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
<?php $uid = uniqid('form_', false); ?>
<div class="card text-center">
<div class="card-header">
<ul class="nav nav-tabs card-header-tabs">
<li class="nav-item">
<?= $this->ahref(__('Profile'), ['users', 'profile'], ['class' => 'nav-link']) ?>
</li>
<li class="nav-item">
<?= $this->ahref(__('Change email'), ['users', 'change-email'], ['class' => 'nav-link']) ?>
</li>
<li class="nav-item">
<?= $this->ahref(__('Change password'), ['users', 'change-password'], ['class' => 'nav-link active']) ?>
</li>
</ul>
</div>
<?php require_once __DIR__ .'/partial/card-header.phtml' ?>
<div class="card-body">
<h4 class="card-title"><?= __('Change password') ?></h4>
<div class="card w-50 center">
Expand Down
7 changes: 4 additions & 3 deletions application/modules/users/views/crud.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ $uid = uniqid('form_', false); ?>
<label class="col-form-label col-lg-2" for="status"><?= __('Status') ?></label>
<div class="col-lg-10">
<select id="status" name="status" class="form-control">
<option <?= $row->status == Table::STATUS_ACTIVE ? 'selected' : '' ?>>active</option>
<option <?= $row->status == Table::STATUS_DISABLED ? 'selected' : '' ?>>disabled</option>
<option <?= $row->status == Table::STATUS_PENDING ? 'selected' : '' ?>>pending</option>
<option <?= $row->status === Table::STATUS_PENDING ? 'selected' : '' ?>>pending</option>
<option <?= $row->status === Table::STATUS_ACTIVE ? 'selected' : '' ?>>active</option>
<option <?= $row->status === Table::STATUS_DISABLED ? 'selected' : '' ?>>disabled</option>
<option <?= $row->status === Table::STATUS_DELETED ? 'selected' : '' ?>>deleted</option>
</select>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions application/modules/users/views/grid.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ if (!$grid) {
<nav class="navbar navbar-light bg-light justify-content-between">
<div>
<a href="<?= $grid->filter('roleId', 'eq', '', true) ?>"
class="btn btn-secondary ajax <?= (is_null($grid->getFilter('roleId', 'eq')) ? 'btn-info' : '') ?>">
class="btn btn-secondary ajax <?= (null === $grid->getFilter('roleId', 'eq') ? 'btn-info' : '') ?>">
<?= __('all') ?>
</a>
<?php foreach ($roles as $role) : ?>
<a href="<?= $grid->filter('roleId', 'eq', $role['id']) ?>"
class="btn btn-secondary ajax <?= ($grid->getFilter('roleId', 'eq') == $role['id'] ? 'btn-info' : '') ?>">
class="btn btn-secondary ajax <?= ($role['id'] === $grid->getFilter('roleId', 'eq')? 'btn-info' : '') ?>">
<?= $role['name'] ?>
</a>
<?php endforeach; ?>
Expand Down
Loading

0 comments on commit 3323b45

Please sign in to comment.