cleanup and added admin images control
This commit is contained in:
@ -32,8 +32,6 @@ class Groups extends AdminController {
|
|||||||
self::$title = 'Admin - Groups';
|
self::$title = 'Admin - Groups';
|
||||||
self::$group = new Group;
|
self::$group = new Group;
|
||||||
self::$permissions = new Permissions;
|
self::$permissions = new Permissions;
|
||||||
$view = Navigation::activePageSelect( 'nav.admin', '/admin/groups' );
|
|
||||||
Components::set( 'ADMINNAV', $view );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create( $data = null ) {
|
public function create( $data = null ) {
|
||||||
|
114
app/controllers/admin/images.php
Normal file
114
app/controllers/admin/images.php
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* app/controllers/admin/tokens.php
|
||||||
|
*
|
||||||
|
* This is the admin app/user tokens controller.
|
||||||
|
*
|
||||||
|
* @version 3.0
|
||||||
|
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||||
|
* @link https://TheTempusProject.com
|
||||||
|
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||||
|
*/
|
||||||
|
namespace TheTempusProject\Controllers\Admin;
|
||||||
|
|
||||||
|
use TheTempusProject\Classes\Forms as TTPForms;
|
||||||
|
use TheTempusProject\Houdini\Classes\Views;
|
||||||
|
use TheTempusProject\Houdini\Classes\Issues;
|
||||||
|
use TheTempusProject\Houdini\Classes\Navigation;
|
||||||
|
use TheTempusProject\Houdini\Classes\Components;
|
||||||
|
use TheTempusProject\Houdini\Classes\Forms;
|
||||||
|
use TheTempusProject\Classes\AdminController;
|
||||||
|
use TheTempusProject\Models\Token;
|
||||||
|
use TheTempusProject\Bedrock\Functions\Input;
|
||||||
|
use TheTempusProject\Bedrock\Functions\Check;
|
||||||
|
use TheTempusProject\Hermes\Functions\Redirect;
|
||||||
|
use TheTempusProject\Bedrock\Functions\Session;
|
||||||
|
|
||||||
|
class Images extends AdminController {
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
parent::__construct();
|
||||||
|
self::$title = 'Admin - Images';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create() {
|
||||||
|
if ( Input::exists( 'submit' ) ) {
|
||||||
|
if ( !TTPForms::check( 'addImage' ) ) {
|
||||||
|
Issues::add( 'error', [ 'There was an error with your image.' => Check::userErrors() ] );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( Input::exists( 'folder' ) ) {
|
||||||
|
$folder = Input::post('folder');
|
||||||
|
} else {
|
||||||
|
// IMAGE_DIRECTORY
|
||||||
|
$folder = UPLOAD_DIRECTORY . App::$activeUser->username . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
$upload = Upload::image( 'upload', $folder );
|
||||||
|
|
||||||
|
if ( $upload ) {
|
||||||
|
$route = str_replace( APP_ROOT_DIRECTORY, '', $folder );
|
||||||
|
$out = $route . Upload::last();
|
||||||
|
} else {
|
||||||
|
Debug::error( 'There was an error with your upload.');
|
||||||
|
Issues::add( 'error', [ 'There was an error with your upload.' => Check::userErrors() ] );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// if ( self::$token->create(
|
||||||
|
// Input::post( 'name' ),
|
||||||
|
// Input::post( 'notes' ),
|
||||||
|
// Input::post( 'token_type' )
|
||||||
|
// ) ) {
|
||||||
|
// Session::flash( 'success', 'Token Created' );
|
||||||
|
// Redirect::to( 'admin/images' );
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
Views::view( 'admin.images.create' );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete( $id = null ) {
|
||||||
|
if ( self::$token->delete( [ $id ] ) ) {
|
||||||
|
Session::flash( 'success', 'Token deleted.' );
|
||||||
|
}
|
||||||
|
Redirect::to( 'admin/images' );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit( $id = null ) {
|
||||||
|
$token = self::$token->findById( $id );
|
||||||
|
if ( Input::exists( 'submit' ) ) {
|
||||||
|
if ( !TTPForms::check( 'adminEditToken' ) ) {
|
||||||
|
Issues::add( 'error', [ 'There was an error with your token.' => Check::userErrors() ] );
|
||||||
|
} else {
|
||||||
|
if ( self::$token->update(
|
||||||
|
$id,
|
||||||
|
Input::post( 'name' ),
|
||||||
|
Input::post( 'notes' ),
|
||||||
|
Input::post( 'token_type' )
|
||||||
|
) ) {
|
||||||
|
Session::flash( 'success', 'Token Updated' );
|
||||||
|
Redirect::to( 'admin/images' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Forms::selectOption( $token->token_type );
|
||||||
|
return Views::view( 'admin.images.edit', $token );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index() {
|
||||||
|
return Views::view( 'admin.images.list', self::$token->listPaginated() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function view( $id = null ) {
|
||||||
|
return Views::view( 'admin.images.view', self::$token->findById( $id ) );
|
||||||
|
}
|
||||||
|
}
|
@ -30,8 +30,6 @@ class Plugins extends AdminController {
|
|||||||
self::$title = 'Admin - Installed Plugins';
|
self::$title = 'Admin - Installed Plugins';
|
||||||
$this->installer = new Installer;
|
$this->installer = new Installer;
|
||||||
$this->plugins = $this->installer->getAvailablePlugins();
|
$this->plugins = $this->installer->getAvailablePlugins();
|
||||||
$view = Navigation::activePageSelect( 'nav.admin', '/admin/plugins' );
|
|
||||||
Components::set( 'ADMINNAV', $view );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
|
@ -31,8 +31,6 @@ class Routes extends AdminController {
|
|||||||
parent::__construct();
|
parent::__construct();
|
||||||
self::$title = 'Admin - Redirects';
|
self::$title = 'Admin - Redirects';
|
||||||
self::$routes = new RoutesClass;
|
self::$routes = new RoutesClass;
|
||||||
$view = Navigation::activePageSelect( 'nav.admin', '/admin/routes' );
|
|
||||||
Components::set( 'ADMINNAV', $view );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create() {
|
public function create() {
|
||||||
|
@ -31,8 +31,6 @@ class Tokens extends AdminController {
|
|||||||
parent::__construct();
|
parent::__construct();
|
||||||
self::$title = 'Admin - Tokens';
|
self::$title = 'Admin - Tokens';
|
||||||
self::$token = new Token;
|
self::$token = new Token;
|
||||||
$view = Navigation::activePageSelect( 'nav.admin', '/admin/tokens' );
|
|
||||||
Components::set( 'ADMINNAV', $view );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create() {
|
public function create() {
|
||||||
|
@ -37,8 +37,6 @@ class Users extends AdminController {
|
|||||||
self::$title = 'Admin - Users';
|
self::$title = 'Admin - Users';
|
||||||
self::$user = new User;
|
self::$user = new User;
|
||||||
self::$group = new Group;
|
self::$group = new Group;
|
||||||
$view = Navigation::activePageSelect( 'nav.admin', '/admin/users' );
|
|
||||||
Components::set( 'ADMINNAV', $view );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create() {
|
public function create() {
|
||||||
|
@ -158,21 +158,21 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
toggleButton.addEventListener('click', function () {
|
toggleButton.addEventListener('click', function () {
|
||||||
if (darkModeStylesheet.disabled) {
|
if (darkModeStylesheet.disabled) {
|
||||||
toggleDarkModePref( true );
|
toggleDarkModePref( true );
|
||||||
darkModeStylesheet.disabled = false;
|
darkModeStylesheet.disabled = false;
|
||||||
localStorage.setItem('darkMode', 'enabled');
|
localStorage.setItem('darkMode', 'enabled');
|
||||||
} else {
|
|
||||||
toggleDarkModePref( false );
|
|
||||||
darkModeStylesheet.disabled = true;
|
|
||||||
localStorage.setItem('darkMode', 'disabled');
|
|
||||||
}
|
|
||||||
|
|
||||||
document.querySelectorAll('.table-striped').forEach((table) => {
|
|
||||||
if (localStorage.getItem('darkMode') === 'enabled') {
|
|
||||||
table.classList.add('table-dark');
|
|
||||||
table.classList.remove('table-light');
|
|
||||||
} else {
|
} else {
|
||||||
table.classList.add('table-light');
|
toggleDarkModePref( false );
|
||||||
table.classList.remove('table-dark');
|
darkModeStylesheet.disabled = true;
|
||||||
|
localStorage.setItem('darkMode', 'disabled');
|
||||||
|
}
|
||||||
|
|
||||||
|
document.querySelectorAll('.table-striped').forEach((table) => {
|
||||||
|
if (localStorage.getItem('darkMode') === 'enabled') {
|
||||||
|
table.classList.add('table-dark');
|
||||||
|
table.classList.remove('table-light');
|
||||||
|
} else {
|
||||||
|
table.classList.add('table-light');
|
||||||
|
table.classList.remove('table-dark');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -29,8 +29,6 @@ class Blog extends AdminController {
|
|||||||
parent::__construct();
|
parent::__construct();
|
||||||
self::$posts = new Posts;
|
self::$posts = new Posts;
|
||||||
self::$title = 'Admin - Blog';
|
self::$title = 'Admin - Blog';
|
||||||
$view = Navigation::activePageSelect( 'nav.admin', '/admin/blog' );
|
|
||||||
Components::set( 'ADMINNAV', $view );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index( $data = null ) {
|
public function index( $data = null ) {
|
||||||
|
@ -27,8 +27,6 @@ class Contact extends AdminController {
|
|||||||
parent::__construct();
|
parent::__construct();
|
||||||
self::$title = 'Admin - Contact';
|
self::$title = 'Admin - Contact';
|
||||||
self::$contact = new ContactModel;
|
self::$contact = new ContactModel;
|
||||||
$view = Navigation::activePageSelect( 'nav.admin', '/admin/contact' );
|
|
||||||
Components::set( 'ADMINNAV', $view );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function view( $id = null ) {
|
public function view( $id = null ) {
|
||||||
|
@ -100,6 +100,10 @@ class TheTempusProject extends Bedrock {
|
|||||||
'text' => '<i class="fa fa-fw fa-shield-halved"></i> Tokens',
|
'text' => '<i class="fa fa-fw fa-shield-halved"></i> Tokens',
|
||||||
'url' => '{ROOT_URL}admin/tokens',
|
'url' => '{ROOT_URL}admin/tokens',
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'text' => '<i class="fa-solid fa-image"></i> Images',
|
||||||
|
'url' => '{ROOT_URL}admin/images',
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'text' => '<i class="fa fa-fw fa-arrow-down"></i> Modules',
|
'text' => '<i class="fa fa-fw fa-arrow-down"></i> Modules',
|
||||||
'url' => [
|
'url' => [
|
||||||
|
Reference in New Issue
Block a user