Skip to content

Commit

Permalink
Merge pull request #24 from arodu/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
arodu authored Nov 20, 2021
2 parents ae6ba8f + 9309128 commit 1649b2f
Show file tree
Hide file tree
Showing 1,555 changed files with 397,063 additions and 226,152 deletions.
53 changes: 41 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# CakeLTE: AdminLTE plugin for CakePHP 4.x

## Installation
## Getting Started

### Dependencies

- [FriendsOfCake/bootstrap-ui](https://github.com/FriendsOfCake/bootstrap-ui), transparently use Bootstrap 4 with CakePHP 4.
- [AdminLTE 3.1.0](https://adminlte.io/), bootstrap 4 admin theme.

### Installing

You can install this plugin into your CakePHP application using [composer](https://getcomposer.org).

Expand All @@ -10,11 +17,6 @@ The recommended way to install composer packages is:
composer require arodu/cakelte
```

## Dependencies

- [FriendsOfCake/bootstrap-ui](https://github.com/FriendsOfCake/bootstrap-ui), transparently use Bootstrap 4 with CakePHP 4.
- [AdminLTE 3.0.5](https://adminlte.io/), bootstrap 4 admin theme.

## Configuration

You can load the plugin using the shell command:
Expand Down Expand Up @@ -77,8 +79,28 @@ Inpunt options:
```php
//initializeCakeLte() \$options
[
'appName' => 'Cake<b>LTE</b>', // [string] default='Cake<b>LTE</b>'
'appLogo' => 'CakeLte.cake.icon.png', // [string] default='CakeLte.cake.icon.png'
'app-name' => 'Cake<b>LTE</b>',
'app-logo' => 'CakeLte.cake.icon.svg',
'small-text' => false,
'dark-mode' => false,
'layout-boxed' => false,
'header.fixed' => false,
'header.border' => true,
'header.style' => \CakeLte\View\Styles\Header::STYLE_WHITE,
'header.dropdown-legacy' => false,
'sidebar.fixed' => true,
'sidebar.collapsed' => false,
'sidebar.mini' => true,
'sidebar.mini-md' => false,
'sidebar.mini-xs' => false,
'sidebar.style' => \CakeLte\View\Styles\Sidebar::STYLE_DARK_PRIMARY,
'sidebar.flat-style' => false,
'sidebar.legacy-style' => false,
'sidebar.compact' => false,
'sidebar.child-indent' => false,
'sidebar.child-hide-collapse' => false,
'sidebar.disabled-auto-expand' => false,
'footer.fixed' => false,
];
```

Expand All @@ -94,6 +116,8 @@ Options layouts
bin/cake bake all [command] -t CakeLte

bin/cake bake template [command] -t CakeLte login
bin/cake bake template [command] -t CakeLte register
bin/cake bake template [command] -t CakeLte recovery
```

### To modify the template you can copy one or all the files within your project
Expand All @@ -104,20 +128,21 @@ Replace the files elements
- `src/templates/layout/default.php`
- `src/templates/layout/login.php`
- `src/templates/layout/top-nav.php`
- Content info
- `src/templates/element/content/breadcrumb.php`
- Content
- `src/templates/element/content/header.php`
- Header navbar
- `src/templates/element/header/main.php`
- `src/templates/element/header/menu.php`
- `src/templates/element/header/messages.php`
- `src/templates/element/header/notifications.php`
- `src/templates/element/header/search.php`
- `src/templates/element/header/search-default.php`
- `src/templates/element/header/search-block.php`
- Footer
- `src/templates/element/footer/main.php`
- Left sidebar
- `src/templates/element/sidebar/main.php`
- `src/templates/element/sidebar/menu.php`
- `src/templates/element/sidebar/search.php`
- `src/templates/element/sidebar/user.php`
- Right sidebar
- `src/templates/element/aside/main.php`
Expand All @@ -132,6 +157,10 @@ echo $this->Html->link(__('CakeLTE debug page'), '/cake_lte/debug' );
// {your-url}/cake_lte/debug
```

![Page Debug with starter layout](docs/page-debug_default.png)
![Page Debug with default layout](docs/page-debug_default.png)

![Page Debug with top-nav layour](docs/page-debug_top-nav.png)

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details
20 changes: 0 additions & 20 deletions config/app_paginator.php

This file was deleted.

Binary file modified docs/page-debug_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/page-debug_top-nav.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/Controller/AppController.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

declare(strict_types=1);

namespace CakeLte\Controller;

use App\Controller\AppController as BaseController;

class AppController extends BaseController {
class AppController extends BaseController
{
}
12 changes: 5 additions & 7 deletions src/Controller/PagesController.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<?php

declare(strict_types=1);

namespace CakeLte\Controller;

use CakeLte\Controller\AppController;

class PagesController extends AppController {

public function debug() {
}
class PagesController extends AppController
{
public function debug()
{
}
}
93 changes: 49 additions & 44 deletions src/Plugin.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

declare(strict_types=1);

namespace CakeLte;
Expand All @@ -9,53 +8,59 @@
use Cake\Http\MiddlewareQueue;
use Cake\Routing\RouteBuilder;

define('CAKELTE_VERSION', '1.0.0');

/**
* Plugin for CakeLte
*/
class Plugin extends BasePlugin {
/**
* Load all the plugin configuration and bootstrap logic.
*
* The host application is provided as an argument. This allows you to load
* additional plugin dependencies, or attach events.
*
* @param \Cake\Core\PluginApplicationInterface $app The host application
* @return void
*/
public function bootstrap(PluginApplicationInterface $app): void {
$app->addPlugin('BootstrapUI');
}
class Plugin extends BasePlugin
{
/**
* Load all the plugin configuration and bootstrap logic.
*
* The host application is provided as an argument. This allows you to load
* additional plugin dependencies, or attach events.
*
* @param \Cake\Core\PluginApplicationInterface $app The host application
* @return void
*/
public function bootstrap(PluginApplicationInterface $app): void
{
$app->addPlugin('BootstrapUI');
}

/**
* Add routes for the plugin.
*
* If your plugin has many routes and you would like to isolate them into a separate file,
* you can create `$plugin/config/routes.php` and delete this method.
*
* @param \Cake\Routing\RouteBuilder $routes The route builder to update.
* @return void
*/
public function routes(RouteBuilder $routes): void {
$routes->plugin(
'CakeLte',
['path' => '/cake_lte'],
function (RouteBuilder $builder) {
// Add custom routes here
$builder->connect('/debug', ['controller' => 'Pages', 'action' => 'debug']);
}
);
parent::routes($routes);
}
/**
* Add routes for the plugin.
*
* If your plugin has many routes and you would like to isolate them into a separate file,
* you can create `$plugin/config/routes.php` and delete this method.
*
* @param \Cake\Routing\RouteBuilder $routes The route builder to update.
* @return void
*/
public function routes(RouteBuilder $routes): void
{
$routes->plugin(
'CakeLte',
['path' => '/cake_lte'],
function (RouteBuilder $builder) {
// Add custom routes here
$builder->connect('/debug', ['controller' => 'Pages', 'action' => 'debug']);
}
);
parent::routes($routes);
}

/**
* Add middleware for the plugin.
*
* @param \Cake\Http\MiddlewareQueue $middleware The middleware queue to update.
* @return \Cake\Http\MiddlewareQueue
*/
public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue {
// Add your middlewares here
/**
* Add middleware for the plugin.
*
* @param \Cake\Http\MiddlewareQueue $middlewareQueue The middleware queue to update.
* @return \Cake\Http\MiddlewareQueue
*/
public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
{
// Add your middlewares here

return $middlewareQueue;
}
return $middlewareQueue;
}
}
72 changes: 30 additions & 42 deletions src/View/CakeLteTrait.php
Original file line number Diff line number Diff line change
@@ -1,52 +1,40 @@
<?php

declare(strict_types=1);

namespace CakeLte\View;

use BootstrapUI\View\UIViewTrait;

trait CakeLteTrait {

use UIViewTrait;

protected $settings = [
// configure layout options
'appName' => 'Cake<b>LTE</b>', // [string] default='Cake<b>LTE</b>'
'appLogo' => 'CakeLte.cake.icon.png', // [string] default='CakeLte.cake.icon.png'

'small-text' => false,
'fixed-navbar' => false,
'fixed-footer' => false,
'fixed-sidebar' => false,
'collapsed-sidebar' => false,
'boxed-layout' => false,

'navbar-style' => 'white',
];

protected $navbar = [
'primary' => 'navbar-dark navbar-primary',
'secondary' => 'navbar-dark navbar-secondary',
'info' => 'navbar-dark navbar-info',
'success' => 'navbar-dark navbar-success',
'danger' => 'navbar-dark navbar-danger',
'light' => 'navbar-light',
'warning' => 'navbar-light navbar-warning',
'white' => 'navbar-light navbar-white',
];

public function initializeCakeLte(array $options = []): void {
$this->settings = array_merge($this->settings, $options);
$this->initializeUI();
}
trait CakeLteTrait
{
use UIViewTrait;

/**
* Initialize CakeLte plugin
*
* @param array $options Options
* @return void
*/
public function initializeCakeLte(array $options = []): void
{
$this->initializeUI();
$this->loadHelper('CakeLte.CakeLte', $options);
}

public function element(string $name, array $data = [], array $options = []): string {
if ($this->_getElementFileName($name, false)) {
$options = array_merge($options, ['plugin' => false]);
} else {
$name = 'CakeLte.' . $name;
/**
* @param string $name Name
* @param array $data data
* @param array $options Options
* @return string
*/
public function element(string $name, array $data = [], array $options = []): string
{
if ($this->_getElementFileName($name, false)) {
$options = array_merge($options, ['plugin' => false]);
} else {
$name = 'CakeLte.' . $name;
}

return parent::element($name, $data, $options);
}
return parent::element($name, $data, $options);
}
}
20 changes: 12 additions & 8 deletions src/View/CakeLteView.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
<?php

declare(strict_types=1);

namespace CakeLte\View;

use Cake\View\View;

class CakeLteView extends View {
use CakeLteTrait;
class CakeLteView extends View
{
use CakeLteTrait;

public $layout = 'CakeLte.default';
public $layout = 'CakeLte.default';

public function initialize(): void {
parent::initialize();
$this->initializeCakeLte();
}
/**
* @inheritDoc
*/
public function initialize(): void
{
parent::initialize();
$this->initializeCakeLte();
}
}
Loading

0 comments on commit 1649b2f

Please sign in to comment.