diff --git a/app/classes/config.php b/app/classes/config.php
index b8f99d8..6f3609c 100644
--- a/app/classes/config.php
+++ b/app/classes/config.php
@@ -35,7 +35,7 @@ class Config extends BedrockConfig {
case 'radio':
case 'bool':
case 'boolean':
- $fieldHtml = Forms::getSwitchHtml( $fieldname, [ 'true', 'false' ], $node['value'] );
+ $fieldHtml = Forms::getSwitchHtml( $fieldname, $node['value'] );
break;
case 'select':
$fieldHtml = Forms::getSelectHtml( $fieldname, $options, $node['value'] );
diff --git a/app/classes/preferences.php b/app/classes/preferences.php
index 3bf15fa..3f05c9e 100644
--- a/app/classes/preferences.php
+++ b/app/classes/preferences.php
@@ -19,6 +19,7 @@ use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Bedrock\Functions\Upload;
use TheTempusProject\Bedrock\Functions\Input;
use TheTempusProject\TheTempusProject as App;
+use TheTempusProject\Bedrock\Classes\Config;
class Preferences {
public static $preferences = false;
@@ -208,6 +209,15 @@ class Preferences {
if ( $tempPrefsArray['type'] == 'checkbox' ) {
$tempPrefsArray['type'] = 'switch';
}
+
+ if ( 'file' === $tempPrefsArray['type'] ) {
+ // dv( Config::getValue( 'uploads/images' ) );
+ if ( ! Config::getValue( 'uploads/images' ) ) {
+ Debug::info( 'Preference hidden because uploads are disabled.' );
+ continue;
+ }
+ }
+
$inputTypes[ $tempPrefsArray['type'] ][] = self::getFormFieldHtml( $name, $tempPrefsArray['pretty'], $tempPrefsArray['type'], $tempPrefsArray['value'], $tempPrefsArray['options'] );
}
foreach ( $inputTypes as $skip => $items ) {
@@ -295,6 +305,7 @@ class Preferences {
$prefsArray[$name] = $route . Upload::last();
} else {
Issues::add( 'error', [ 'There was an error with your upload.' => Check::userErrors() ] );
+ unset( $prefsArray[$name] );
}
}
}
diff --git a/app/controllers/admin/groups.php b/app/controllers/admin/groups.php
index 44e8ccc..b6ed9d9 100644
--- a/app/controllers/admin/groups.php
+++ b/app/controllers/admin/groups.php
@@ -32,8 +32,6 @@ class Groups extends AdminController {
self::$title = 'Admin - Groups';
self::$group = new Group;
self::$permissions = new Permissions;
- $view = Navigation::activePageSelect( 'nav.admin', '/admin/groups' );
- Components::set( 'ADMINNAV', $view );
}
public function create( $data = null ) {
diff --git a/app/controllers/admin/home.php b/app/controllers/admin/home.php
index c4a7704..dedddb1 100644
--- a/app/controllers/admin/home.php
+++ b/app/controllers/admin/home.php
@@ -17,9 +17,12 @@ use TheTempusProject\Classes\AdminController;
use TheTempusProject\Models\User;
use TheTempusProject\Models\Comments;
use TheTempusProject\Models\Posts;
+use TheTempusProject\Models\Contact;
use TheTempusProject\Plugins\Comments as CommentPlugin;
use TheTempusProject\Plugins\Blog as BlogPlugin;
+use TheTempusProject\Plugins\Contact as ContactPlugin;
use TheTempusProject\Canary\Bin\Canary as Debug;
+use TheTempusProject\Bedrock\Functions\Input;
class Home extends AdminController {
public static $user;
@@ -32,12 +35,12 @@ class Home extends AdminController {
}
public function index() {
+ Components::set( 'commentDash', '' );
if ( class_exists( 'TheTempusProject\Plugins\Comments' ) ) {
$plugin = new CommentPlugin;
if ( ! $plugin->checkEnabled() ) {
Debug::info( 'Comments Plugin is disabled in the control panel.' );
- Components::set( 'commentDash', '' );
} else {
$comments = new Comments;
$commentList = Views::simpleView( 'comments.admin.dashboard', $comments->recent( 'all', 5 ) );
@@ -58,10 +61,28 @@ class Home extends AdminController {
}
}
+ if ( class_exists( 'TheTempusProject\Plugins\Contact' ) ) {
+ $plugin = new ContactPlugin;
+
+ if ( ! $plugin->checkEnabled() ) {
+ Debug::info( 'Contact Plugin is disabled in the control panel.' );
+ Components::set( 'contactDash', '' );
+ } else {
+ $posts = new Contact;
+ $postsList = Views::simpleView( 'contact.admin.dashboard', $posts->listPaginated( 5 ) );
+ Components::set( 'contactDash', $postsList );
+ }
+ }
+
self::$user = new User;
$users = Views::simpleView( 'admin.dashboard.users', self::$user->recent( 5 ) );
Components::set( 'userDash', $users );
+ if ( Input::exists( 'submit' ) ) {
+ $results = Views::simpleView( 'admin.dashboard.users', self::$user->search( Input::post('searchTerm') ) );
+ Components::set( 'searchResults', $results );
+ }
+
Views::view( 'admin.dashboard.dash' );
}
}
diff --git a/app/controllers/admin/images.php b/app/controllers/admin/images.php
new file mode 100644
index 0000000..0499c41
--- /dev/null
+++ b/app/controllers/admin/images.php
@@ -0,0 +1,114 @@
+
+ * @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 ) );
+ }
+}
diff --git a/app/controllers/admin/plugins.php b/app/controllers/admin/plugins.php
index ea152e8..34ae918 100644
--- a/app/controllers/admin/plugins.php
+++ b/app/controllers/admin/plugins.php
@@ -30,8 +30,6 @@ class Plugins extends AdminController {
self::$title = 'Admin - Installed Plugins';
$this->installer = new Installer;
$this->plugins = $this->installer->getAvailablePlugins();
- $view = Navigation::activePageSelect( 'nav.admin', '/admin/plugins' );
- Components::set( 'ADMINNAV', $view );
}
public function index() {
diff --git a/app/controllers/admin/routes.php b/app/controllers/admin/routes.php
index 1f8b84c..116394b 100644
--- a/app/controllers/admin/routes.php
+++ b/app/controllers/admin/routes.php
@@ -31,8 +31,6 @@ class Routes extends AdminController {
parent::__construct();
self::$title = 'Admin - Redirects';
self::$routes = new RoutesClass;
- $view = Navigation::activePageSelect( 'nav.admin', '/admin/routes' );
- Components::set( 'ADMINNAV', $view );
}
public function create() {
diff --git a/app/controllers/admin/send_mail.php b/app/controllers/admin/send_mail.php
index bf6e367..e2065e5 100644
--- a/app/controllers/admin/send_mail.php
+++ b/app/controllers/admin/send_mail.php
@@ -32,12 +32,12 @@ class SendMail extends AdminController {
if ( class_exists( 'TheTempusProject\Plugins\Subscribe' ) ) {
$plugin = new Plugin;
if ( ! $plugin->checkEnabled() ) {
- Issues::add( 'warn', 'Subscriptions are disabled so those feature will be unavailable.' );
+ Issues::add( 'notice', 'Subscriptions are disabled so those feature will be unavailable.' );
} else {
self::$subscribe = new Subscribe;
}
} else {
- Issues::add( 'warn', 'Subscriptions plugin is not installed so those feature will be unavailable.' );
+ Issues::add( 'notice', 'Subscriptions plugin is not installed so those feature will be unavailable.' );
}
}
diff --git a/app/controllers/admin/tokens.php b/app/controllers/admin/tokens.php
index 5655b22..a60aa75 100644
--- a/app/controllers/admin/tokens.php
+++ b/app/controllers/admin/tokens.php
@@ -31,8 +31,6 @@ class Tokens extends AdminController {
parent::__construct();
self::$title = 'Admin - Tokens';
self::$token = new Token;
- $view = Navigation::activePageSelect( 'nav.admin', '/admin/tokens' );
- Components::set( 'ADMINNAV', $view );
}
public function create() {
diff --git a/app/controllers/admin/users.php b/app/controllers/admin/users.php
index 0cff516..d97aa97 100644
--- a/app/controllers/admin/users.php
+++ b/app/controllers/admin/users.php
@@ -37,8 +37,6 @@ class Users extends AdminController {
self::$title = 'Admin - Users';
self::$user = new User;
self::$group = new Group;
- $view = Navigation::activePageSelect( 'nav.admin', '/admin/users' );
- Components::set( 'ADMINNAV', $view );
}
public function create() {
diff --git a/app/controllers/home.php b/app/controllers/home.php
index 7fd1262..367b656 100644
--- a/app/controllers/home.php
+++ b/app/controllers/home.php
@@ -98,12 +98,6 @@ class Home extends Controller {
Views::view( 'about' );
}
- public function contact() {
- self::$title = 'Contact Us - {SITENAME}';
- self::$pageDescription = 'On this page, you\'ll be able to reach out to the team directly with any questions, comments, or concerns you may have.';
- Views::view( 'contact' );
- }
-
public function privacy() {
self::$title = 'Privacy Policy - {SITENAME}';
self::$pageDescription = 'At {SITENAME} you privacy is very important to us. On this page you can find a detailed outline of all the information we collect and how its used.';
diff --git a/app/controllers/register.php b/app/controllers/register.php
index 275fdc2..da84cc5 100644
--- a/app/controllers/register.php
+++ b/app/controllers/register.php
@@ -24,6 +24,7 @@ use TheTempusProject\Houdini\Classes\Views;
use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Classes\Controller;
use TheTempusProject\Classes\Forms;
+use TheTempusProject\Bedrock\Classes\Config;
class Register extends Controller {
public function confirm( $code = null ) {
@@ -46,6 +47,11 @@ class Register extends Controller {
public function index() {
self::$title = '{SITENAME} Sign Up';
self::$pageDescription = 'Many features of {SITENAME} are disabled or hidden from unregistered users. On this page you can sign up for an account to access all the app has to offer.';
+
+ if ( ! Config::getValue( 'main/registrationEnabled' ) ) {
+ return Issues::add( 'notice', 'The site administrator has disable the ability to register a new account.' );
+ }
+
Components::set( 'TERMS', Views::simpleView( 'terms' ) );
if ( App::$isLoggedIn ) {
return Issues::add( 'notice', 'You are currently logged in.' );
diff --git a/app/controllers/usercp.php b/app/controllers/usercp.php
index c0b13cf..12b162d 100644
--- a/app/controllers/usercp.php
+++ b/app/controllers/usercp.php
@@ -101,7 +101,7 @@ class Usercp extends Controller {
$menu = Views::simpleView( 'nav.usercp', App::$userCPlinks );
Navigation::activePageSelect( $menu, null, true, true );
$prefs = new Preferences;
- $fields = App::$activePrefs;
+ $userPrefs = App::$activePrefs;
if ( Input::exists( 'submit' ) ) {
$fields = $prefs->convertFormToArray( true, false );
// @TODO now i may need to rework the form checker to work with this....
@@ -110,6 +110,12 @@ class Usercp extends Controller {
// }
self::$user->updatePrefs( $fields, App::$activeUser->ID );
Issues::add( 'success', 'Your preferences have been updated.' );
+ // if the image upload fails, need to fall back on original
+ if ( empty( $fields['avatar'] ) ) {
+ $fields['avatar'] = $userPrefs['avatar'];
+ }
+ } else {
+ $fields = $userPrefs;
}
Components::set( 'AVATAR_SETTINGS', $fields['avatar'] );
Components::set( 'PREFERENCES_FORM', $prefs->getFormHtml( $fields ) );
@@ -139,11 +145,9 @@ class Usercp extends Controller {
$prefs = new Preferences;
$fields1 = $prefs->convertFormToArray( true, false );
- $fields2 = [];
$fields3 = $fields1;
if ( isset( $fields1[ $name ] ) ) {
- $fields2[ $name ] = $value;
$fields3[ $name ] = $value;
}
$result = self::$user->updatePrefs( $fields3, App::$activeUser->ID );
diff --git a/app/css/main-dark.css b/app/css/main-dark.css
index ce195ba..ce8a267 100644
--- a/app/css/main-dark.css
+++ b/app/css/main-dark.css
@@ -21,9 +21,18 @@
.context-second-bg {
background-color: #1e1e1e;
}
+.context-third-bg {
+ background-color: #3a3a3a;
+}
.bg-default {
background-color: #2c2c2c;
}
+
+hr {
+ color: #f5f5f5;
+}
+
+
.bg-none,.bg-warning {
color: #000 !important;
}
@@ -140,11 +149,10 @@ body {
background-color: #1f1f1f;
color: #e0e0e0;
}
+
.form-control:focus {
color: #e0e0e0;
- /* border-color: #85bd3e; */
- border-color: #1b947f;
+ border-color: #1e90ff;
background-color: #1f1f1f;
- /* box-shadow: 0 0 0 .25rem #1b947f; */
- box-shadow: 0 0 0 .25rem #85bd3e;
+ box-shadow: 0 0 0 .25rem rgba(30, 144, 255, .5);
}
\ No newline at end of file
diff --git a/app/css/main.css b/app/css/main.css
index 42881ec..e6e2697 100644
--- a/app/css/main.css
+++ b/app/css/main.css
@@ -12,6 +12,14 @@
background-color: #eaeaea;
}
+.nav-link.active {
+ font-weight: bold; /* Make the text bold */
+}
+
+hr {
+ color: #000;
+}
+
.context-main-bg {
background-color: #f7f7f7;
}
@@ -55,7 +63,7 @@
bottom: 2.5px;
left: 5px;
transition: transform 0.3s ease-in-out;
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
+ box-shadow: 0 2px 4px #00000033;
}
/* Change background color when checked */
diff --git a/app/js/main.js b/app/js/main.js
index 3173ece..461b5fe 100644
--- a/app/js/main.js
+++ b/app/js/main.js
@@ -95,22 +95,45 @@ $(document).ready(function() {
});
document.addEventListener('DOMContentLoaded', function () {
+ const ttpDarkmode = document.getElementById('dark-mode-pref');
const toggleButton = document.getElementById('dark-mode-toggle');
const enableButton = document.getElementById('dark-mode-toggle-button');
const darkModeStylesheet = document.getElementById('dark-mode-stylesheet');
+ let currentState = '';
- // Check if dark mode is saved in localStorage
- if (localStorage.getItem('darkMode') === 'enabled') {
+ // Check if dark mode is set by ttp
+ if ( ttpDarkmode ) {
+ if ( 'true' == ttpDarkmode.value ) {
+ currentState = 'enabled';
+ }
+ if ( 'false' == ttpDarkmode.value ) {
+ currentState = 'disabled';
+ }
+ }
+
+ // Check if dark mode is set in localStorage
+ if ( '' == currentState ) {
+ if ( localStorage.getItem('darkMode') === 'enabled' ) {
+ currentState = 'enabled';
+ }
+ }
+
+ // Update current button states
+ if ( 'enabled' == currentState ) {
darkModeStylesheet.disabled = false;
- toggleButton.checked = true;
+
+ if ( toggleButton ) {
+ toggleButton.checked = true;
+ }
if ( enableButton ) {
enableButton.innerText = 'Disable Now';
}
}
+ // Style striped table elements
document.querySelectorAll('.table-striped').forEach((table) => {
- if (localStorage.getItem('darkMode') === 'enabled') {
+ if ( 'enabled' == currentState ) {
table.classList.add('table-dark');
} else {
table.classList.add('table-light')
@@ -119,7 +142,7 @@ document.addEventListener('DOMContentLoaded', function () {
if ( enableButton ) {
enableButton.addEventListener('click', function () {
- if (darkModeStylesheet.disabled) {
+ if ( darkModeStylesheet.disabled ) {
darkModeStylesheet.disabled = false;
localStorage.setItem('darkMode', 'enabled');
enableButton.innerText = 'Disable Now';
@@ -131,27 +154,29 @@ document.addEventListener('DOMContentLoaded', function () {
});
}
- toggleButton.addEventListener('click', function () {
- if (darkModeStylesheet.disabled) {
- toggleDarkModePref( true );
- darkModeStylesheet.disabled = false;
- 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');
+ if ( toggleButton ) {
+ toggleButton.addEventListener('click', function () {
+ if (darkModeStylesheet.disabled) {
+ toggleDarkModePref( true );
+ darkModeStylesheet.disabled = false;
+ localStorage.setItem('darkMode', 'enabled');
} else {
- table.classList.add('table-light');
- table.classList.remove('table-dark');
+ 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 {
+ table.classList.add('table-light');
+ table.classList.remove('table-dark');
+ }
+ });
});
- });
+ }
function toggleDarkModePref( value ) {
var fields = {};
diff --git a/app/models/group.php b/app/models/group.php
index bbc512b..f5331a3 100644
--- a/app/models/group.php
+++ b/app/models/group.php
@@ -31,13 +31,16 @@ class Group extends DatabaseModel {
'defaultGroup' => [
'type' => 'customSelect',
'pretty' => 'The Default Group for new registrations.',
- 'default' => 5,
+ 'default' => 4,
],
];
public $databaseMatrix = [
[ 'name', 'varchar', '32' ],
[ 'permissions', 'text', '' ],
];
+ public $searchFields = [
+ 'name',
+ ];
public $permissionMatrix = [
'adminAccess' => [
'pretty' => 'Access Administrator Areas',
diff --git a/app/models/log.php b/app/models/log.php
index efd7b4a..135758b 100644
--- a/app/models/log.php
+++ b/app/models/log.php
@@ -46,6 +46,9 @@ class Log extends DatabaseModel {
[ 'source', 'varchar', '64' ],
[ 'action', 'text', '' ],
];
+ public $searchFields = [
+ 'source',
+ ];
/**
* The model constructor.
diff --git a/app/models/routes.php b/app/models/routes.php
index 8333692..a48b834 100644
--- a/app/models/routes.php
+++ b/app/models/routes.php
@@ -24,6 +24,9 @@ class Routes extends DatabaseModel {
[ 'original_url', 'varchar', '32' ],
[ 'forwarded_url', 'text', '' ],
];
+ public $searchFields = [
+ 'nickname',
+ ];
public $resourceMatrix = [
[
'original_url' => 'fb',
diff --git a/app/models/sessions.php b/app/models/sessions.php
index 9edde85..427d573 100644
--- a/app/models/sessions.php
+++ b/app/models/sessions.php
@@ -36,6 +36,9 @@ class Sessions extends DatabaseModel {
[ 'username', 'varchar', '20' ],
[ 'token', 'varchar', '120' ],
];
+ public $searchFields = [
+ 'username',
+ ];
public static $activeSession = false;
/**
diff --git a/app/models/token.php b/app/models/token.php
index fe9198a..59cb422 100644
--- a/app/models/token.php
+++ b/app/models/token.php
@@ -31,6 +31,10 @@ class Token extends DatabaseModel {
[ 'createdBy', 'int', '10' ],
[ 'expiresAt', 'int', '10' ],
];
+ public $searchFields = [
+ 'name',
+ 'token',
+ ];
public $permissionMatrix = [
'addAppToken' => [
'pretty' => 'Add Application Tokens',
diff --git a/app/models/user.php b/app/models/user.php
index 62012fa..0c520d6 100644
--- a/app/models/user.php
+++ b/app/models/user.php
@@ -44,6 +44,9 @@ class User extends DatabaseModel {
[ 'confirmationCode', 'varchar', '80' ],
[ 'prefs', 'text', '' ],
];
+ public $searchFields = [
+ 'username',
+ ];
public $permissionMatrix = [
'uploadImages' => [
'pretty' => 'Upload images (such as avatars)',
diff --git a/app/plugins/blog/controllers/admin/blog.php b/app/plugins/blog/controllers/admin/blog.php
index adfc451..b97e319 100644
--- a/app/plugins/blog/controllers/admin/blog.php
+++ b/app/plugins/blog/controllers/admin/blog.php
@@ -29,8 +29,6 @@ class Blog extends AdminController {
parent::__construct();
self::$posts = new Posts;
self::$title = 'Admin - Blog';
- $view = Navigation::activePageSelect( 'nav.admin', '/admin/blog' );
- Components::set( 'ADMINNAV', $view );
}
public function index( $data = null ) {
@@ -46,7 +44,7 @@ class Blog extends AdminController {
return $this->index();
}
- $result = self::$posts->newPost( Input::post( 'title' ), Input::post( 'blogPost' ), Input::post( 'submit' ) );
+ $result = self::$posts->newPost( Input::post( 'title' ), Input::post( 'blogPost' ), Input::post( 'slug' ), Input::post( 'submit' ) );
if ( $result ) {
Issues::add( 'success', 'Your post has been created.' );
return $this->index();
@@ -67,7 +65,7 @@ class Blog extends AdminController {
Issues::add( 'error', [ 'There was an error with your form.' => Check::userErrors() ] );
return $this->index();
}
- if ( self::$posts->updatePost( $data, Input::post( 'title' ), Input::post( 'blogPost' ), Input::post( 'submit' ) ) === true ) {
+ if ( self::$posts->updatePost( $data, Input::post( 'title' ), Input::post( 'blogPost' ), Input::post( 'slug' ), Input::post( 'submit' ) ) === true ) {
Issues::add( 'success', 'Post Updated.' );
return $this->index();
}
diff --git a/app/plugins/blog/controllers/blog.php b/app/plugins/blog/controllers/blog.php
index b14100b..80cc7c8 100644
--- a/app/plugins/blog/controllers/blog.php
+++ b/app/plugins/blog/controllers/blog.php
@@ -62,12 +62,17 @@ class Blog extends Controller {
return $this->index();
}
- $plugin = new Comments;
- if ( ! $plugin->checkEnabled() ) {
- Issues::add( 'error', 'Comments are disabled.' );
+ if ( class_exists( 'TheTempusProject\Plugins\Comments' ) ) {
+ $plugin = new Comments;
+ if ( ! $plugin->checkEnabled() ) {
+ Issues::add( 'error', 'Comments are disabled.' );
+ return $this->index();
+ }
+ $comments = new CommentsModel;
+ } else {
+ Debug::info( 'error', 'Comments plugin missing.' );
return $this->index();
}
- $comments = new CommentsModel;
switch ( $sub ) {
case 'post':
@@ -100,7 +105,10 @@ class Blog extends Controller {
}
$post = self::$posts->findById( $id );
if ( empty( $post ) ) {
- return $this->index();
+ $post = self::$posts->findBySlug( $id );
+ if ( empty( $post ) ) {
+ return $this->index();
+ }
}
Debug::log( 'Controller initiated: ' . __METHOD__ . '.' );
self::$title = 'Blog Post';
@@ -111,25 +119,24 @@ class Blog extends Controller {
Components::set( 'CONTENT_ID', $id );
Components::set( 'COMMENT_TYPE', self::$posts->tableName );
+ Components::set( 'NEWCOMMENT', '' );
+ Components::set( 'count', '0' );
+ Components::set( 'COMMENTS', '' );
- $plugin = new Comments;
- if ( ! $plugin->checkEnabled() ) {
- Components::set( 'NEWCOMMENT', '' );
- Components::set( 'count', '0' );
- Components::set( 'COMMENTS', '' );
- } else {
- $comments = new CommentsModel;
- if ( App::$isLoggedIn ) {
- Components::set( 'NEWCOMMENT', Views::simpleView( 'comments.create' ) );
- } else {
- Components::set( 'NEWCOMMENT', '' );
+ if ( class_exists( 'TheTempusProject\Plugins\Comments' ) ) {
+ $plugin = new Comments;
+ if ( $plugin->checkEnabled() ) {
+ $comments = new CommentsModel;
+ if ( App::$isLoggedIn ) {
+ Components::set( 'NEWCOMMENT', Views::simpleView( 'comments.create' ) );
+ } else {
+ Components::set( 'NEWCOMMENT', '' );
+ }
+ Components::set( 'count', $comments->count( self::$posts->tableName, $post->ID ) );
+ Components::set( 'COMMENTS', Views::simpleView( 'comments.list', $comments->display( 10, self::$posts->tableName, $post->ID ) ) );
}
- Components::set( 'count', $comments->count( self::$posts->tableName, $post->ID ) );
- Components::set( 'COMMENTS', Views::simpleView( 'comments.list', $comments->display( 10, self::$posts->tableName, $post->ID ) ) );
}
- $post = self::$posts->findById( $id );
-
self::$title .= ' - ' . $post->title;
self::$pageDescription = strip_tags( $post->contentSummaryNoLink );
Views::view( 'blog.post', $post );
diff --git a/app/plugins/blog/models/posts.php b/app/plugins/blog/models/posts.php
index f55275d..7a4baac 100644
--- a/app/plugins/blog/models/posts.php
+++ b/app/plugins/blog/models/posts.php
@@ -32,6 +32,7 @@ class Posts extends DatabaseModel {
[ 'edited', 'int', '10' ],
[ 'draft', 'int', '1' ],
[ 'title', 'varchar', '86' ],
+ [ 'slug', 'varchar', '64' ],
[ 'content', 'text', '' ],
];
@@ -45,7 +46,7 @@ class Posts extends DatabaseModel {
}
}
- public function newPost( $title, $post, $draft ) {
+ public function newPost( $title, $post, $slug, $draft ) {
if ( !Check::dataTitle( $title ) ) {
Debug::info( 'modelBlog: illegal title.' );
@@ -59,6 +60,7 @@ class Posts extends DatabaseModel {
$fields = [
'author' => App::$activeUser->ID,
'draft' => $draft,
+ 'slug' => $slug,
'created' => time(),
'edited' => time(),
'content' => Sanitize::rich( $post ),
@@ -73,7 +75,7 @@ class Posts extends DatabaseModel {
return true;
}
- public function updatePost( $id, $title, $content, $draft ) {
+ public function updatePost( $id, $title, $content, $slug, $draft ) {
if ( empty( self::$log ) ) {
self::$log = new Log;
}
@@ -94,6 +96,7 @@ class Posts extends DatabaseModel {
}
$fields = [
'draft' => $draft,
+ 'slug' => $slug,
'edited' => time(),
'content' => Sanitize::rich( $content ),
'title' => $title,
@@ -132,22 +135,29 @@ class Posts extends DatabaseModel {
$draft = '';
$authorName = self::$user->getUsername( $instance->author );
+ // Summarize
+ if ( ! empty( $instance->slug ) ) {
+ $identifier = $instance->slug;
+ } else {
+ $identifier = $instance->ID;
+ }
+
$cleanPost = Sanitize::contentShort( $instance->content );
+ // By Word
$wordsArray = explode( ' ', $cleanPost );
- $postLine = explode( "\n", $cleanPost );
- $spaceSummary = implode( ' ', array_splice( $wordsArray, 0, 100 ) );
- $lineSummary = implode( "\n", array_splice( $postLine, 0, 5 ) );
- if ( strlen( $spaceSummary ) < strlen( $lineSummary ) ) {
- $contentSummaryNoLink = $spaceSummary;
- $contentSummary = $spaceSummary;
- if ( count( $wordsArray, 1 ) >= 100 ) {
- $contentSummaryNoLink = $contentSummary;
- $contentSummary .= '... Read More ';
- }
+ $wordSummary = implode( ' ', array_splice( $wordsArray, 0, 100 ) );
+ // By Line
+ $linesArray = explode( "\n", $cleanPost );
+ $lineSummary = implode( "\n", array_splice( $linesArray, 0, 5 ) );
+
+ if ( strlen( $wordSummary ) < strlen( $lineSummary ) ) {
+ $contentSummaryNoLink = $wordSummary;
+ $contentSummary = $wordSummary . '... Read More ';
} else {
$contentSummaryNoLink = $lineSummary;
- $contentSummary = $lineSummary . '... Read More ';
+ $contentSummary = $lineSummary . '... Read More ';
}
+
$instance->contentSummaryNoLink = $contentSummaryNoLink;
$instance->contentSummary = $contentSummary;
@@ -158,12 +168,15 @@ class Posts extends DatabaseModel {
$draft = ' Draft ';
}
$instance->isDraft = $draft;
- $instance->authorName = $authorName;
+ $instance->authorName = \ucfirst( $authorName );
if ( self::$comments !== false ) {
$instance->commentCount = self::$comments->count( 'blog', $instance->ID );
+ } else {
+ $instance->commentCount = 0;
}
$instance->content = Filters::applyOne( 'mentions.0', $instance->content, true );
$instance->content = Filters::applyOne( 'hashtags.0', $instance->content, true );
+
$out[] = $instance;
if ( !empty( $end ) ) {
$out = $out[0];
@@ -291,6 +304,22 @@ class Posts extends DatabaseModel {
return $this->filter( $postData->results() );
}
+ public function findBySlug( $slug, $includeDraft = false ) {
+ $whereClause = [];
+ if ( $includeDraft !== true ) {
+ $whereClause = ['draft', '=', '0', 'AND'];
+ }
+
+ $whereClause = array_merge( $whereClause, ['slug', '=', $slug] );
+
+ $postData = self::$db->get( $this->tableName, $whereClause );
+ if ( !$postData->count() ) {
+ Debug::info( 'No Blog posts found.' );
+ return false;
+ }
+ return $this->filter( $postData->first() );
+ }
+
public function byMonth( $month, $year = 0, $includeDraft = false ) {
if ( 0 === $year ) {
$year = date( 'Y' );
diff --git a/app/plugins/blog/views/admin/create.html b/app/plugins/blog/views/admin/create.html
index 7ae25f5..00d9d00 100644
--- a/app/plugins/blog/views/admin/create.html
+++ b/app/plugins/blog/views/admin/create.html
@@ -12,6 +12,14 @@
+
+
+
URL Slug (for pretty linking):
+
+
+
+
+
diff --git a/app/plugins/blog/views/admin/edit.html b/app/plugins/blog/views/admin/edit.html
index 986ff11..957a2e8 100644
--- a/app/plugins/blog/views/admin/edit.html
+++ b/app/plugins/blog/views/admin/edit.html
@@ -12,6 +12,14 @@
+
+
+
URL Slug (for pretty linking):
+
+
+
+
+
diff --git a/app/plugins/blog/views/admin/list.html b/app/plugins/blog/views/admin/list.html
index 62df2fb..7e40fc8 100644
--- a/app/plugins/blog/views/admin/list.html
+++ b/app/plugins/blog/views/admin/list.html
@@ -21,7 +21,7 @@
{LOOP}
- {title} {isDraft}
+ {title} {isDraft}
{authorName}
{commentCount}
{DTC}{created}{/DTC}
diff --git a/app/plugins/blog/views/list.html b/app/plugins/blog/views/list.html
index a0e7a20..ed220dc 100644
--- a/app/plugins/blog/views/list.html
+++ b/app/plugins/blog/views/list.html
@@ -1,7 +1,7 @@
{LOOP}
{title}
- {DTC date}{created}{/DTC} by {authorName}
+ {DTC date}{created}{/DTC} by {authorName}
{contentSummary}
diff --git a/app/plugins/blog/views/post.html b/app/plugins/blog/views/post.html
index f7c9003..489504d 100644
--- a/app/plugins/blog/views/post.html
+++ b/app/plugins/blog/views/post.html
@@ -3,7 +3,7 @@
{title}
-
{DTC date}{created}{/DTC} by {authorName}
+
{DTC date}{created}{/DTC} by {authorName}
{content}
{ADMIN}
diff --git a/app/plugins/blog/views/sidebar2.html b/app/plugins/blog/views/sidebar2.html
index 8be0657..cef0110 100644
--- a/app/plugins/blog/views/sidebar2.html
+++ b/app/plugins/blog/views/sidebar2.html
@@ -1,11 +1,15 @@
-
-
Archives
-
+
+
+
+
+ {LOOP}
+ ({count}) {monthText} {year}
+ {/LOOP}
+ {ALT}
+ None To Show
+ {/ALT}
+
+
\ No newline at end of file
diff --git a/app/plugins/comments/controllers/admin/comments.php b/app/plugins/comments/controllers/admin/comments.php
index 8967873..4c9ead6 100644
--- a/app/plugins/comments/controllers/admin/comments.php
+++ b/app/plugins/comments/controllers/admin/comments.php
@@ -49,13 +49,13 @@ class Comments extends AdminController {
$this->index();
}
- public function viewComments( $contentIID = null ) {
- if ( empty( $contentIID ) ) {
+ public function viewComments( $contentID = null ) {
+ if ( empty( $contentID ) ) {
Issues::add( 'error', 'Content ID not found.' );
return $this->index();
}
$contentData = self::$comments->findById( $data );
- if ( empty( $contentIID ) ) {
+ if ( empty( $contentID ) ) {
return Views::view( 'comments.list', $commentData );
}
Issues::add( 'error', 'Comment not found.' );
diff --git a/app/plugins/contact/controllers/admin/contact.php b/app/plugins/contact/controllers/admin/contact.php
index 1a1aa4a..be6fd11 100644
--- a/app/plugins/contact/controllers/admin/contact.php
+++ b/app/plugins/contact/controllers/admin/contact.php
@@ -27,8 +27,6 @@ class Contact extends AdminController {
parent::__construct();
self::$title = 'Admin - Contact';
self::$contact = new ContactModel;
- $view = Navigation::activePageSelect( 'nav.admin', '/admin/contact' );
- Components::set( 'ADMINNAV', $view );
}
public function view( $id = null ) {
diff --git a/app/plugins/contact/views/admin/dashboard.html b/app/plugins/contact/views/admin/dashboard.html
new file mode 100644
index 0000000..615217a
--- /dev/null
+++ b/app/plugins/contact/views/admin/dashboard.html
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+ {LOOP}
+
+ {ID}
+ {DTC}{time}{/DTC}
+ {feedback}
+
+
+
+ {/LOOP}
+ {ALT}
+
+
+ No Contact forms to show.
+
+
+ {/ALT}
+
+
\ No newline at end of file
diff --git a/app/plugins/messages/views/index.html b/app/plugins/messages/views/index.html
new file mode 100644
index 0000000..f35bcad
--- /dev/null
+++ b/app/plugins/messages/views/index.html
@@ -0,0 +1,8 @@
+
+
+ {message_inbox}
+
+
+ {message_outbox}
+
+
\ No newline at end of file
diff --git a/app/plugins/notifications/controllers/notifications.php b/app/plugins/notifications/controllers/notifications.php
index f18406b..6dfc3e1 100644
--- a/app/plugins/notifications/controllers/notifications.php
+++ b/app/plugins/notifications/controllers/notifications.php
@@ -17,6 +17,8 @@ use TheTempusProject\Houdini\Classes\Issues;
use TheTempusProject\Classes\Controller;
use TheTempusProject\Models\Notification as NotificationsModel;
use TheTempusProject\TheTempusProject as App;
+use TheTempusProject\Hermes\Functions\Redirect;
+use TheTempusProject\Bedrock\Functions\Session;
class Notifications extends Controller {
protected static $notifications;
@@ -26,6 +28,10 @@ class Notifications extends Controller {
self::$notifications = new NotificationsModel;
self::$title = 'Notifications - {SITENAME}';
self::$pageDescription = 'Your recent notifications';
+ if ( ! App::$isLoggedIn ) {
+ Session::flash( 'error', 'You do not have permission to access this page.' );
+ return Redirect::home();
+ }
}
public function index() {
diff --git a/app/plugins/notifications/models/notification.php b/app/plugins/notifications/models/notification.php
index 75af1c3..e83b6b2 100644
--- a/app/plugins/notifications/models/notification.php
+++ b/app/plugins/notifications/models/notification.php
@@ -115,7 +115,7 @@ class Notification extends DatabaseModel {
];
if ( !self::$db->update( $this->tableName, $id, $fields ) ) {
new CustomException( 'notificationDelete' );
- Debug::error( "Bookmarks: $id not updated" );
+ Debug::error( "Notifications: $id not updated" );
return false;
}
return true;
diff --git a/app/plugins/notifications/views/nav/recentNotificationsDropdown.html b/app/plugins/notifications/views/nav/recentNotificationsDropdown.html
index afffdaf..f3f0648 100644
--- a/app/plugins/notifications/views/nav/recentNotificationsDropdown.html
+++ b/app/plugins/notifications/views/nav/recentNotificationsDropdown.html
@@ -3,13 +3,13 @@
- {NBADGE}
+ {NBADGE}
-
+
{LOOP}
diff --git a/app/plugins/redirects/plugin.php b/app/plugins/redirects/plugin.php
deleted file mode 100644
index a84fd22..0000000
--- a/app/plugins/redirects/plugin.php
+++ /dev/null
@@ -1,40 +0,0 @@
-
- * @link https://TheTempusProject.com
- * @license https://opensource.org/licenses/MIT [MIT LICENSE]
- */
-namespace TheTempusProject\Plugins;
-
-use ReflectionClass;
-use TheTempusProject\Classes\Installer;
-use TheTempusProject\Houdini\Classes\Navigation;
-use TheTempusProject\Classes\Plugin;
-use TheTempusProject\TheTempusProject as App;
-
-class Redirects extends Plugin {
- public $pluginName = 'TP Redirects';
- public $pluginAuthor = 'JoeyK';
- public $pluginWebsite = 'https://TheTempusProject.com';
- public $modelVersion = '1.0';
- public $pluginVersion = '3.0';
- public $pluginDescription = 'A simple plugin which adds redirects.';
- public $permissionMatrix = [
- 'redirects' => [
- 'pretty' => 'Can modify redirects',
- 'default' => false,
- ],
- ];
- public $admin_links = [
- [
- 'text' => ' Redirects',
- 'url' => '{ROOT_URL}admin/routes',
- ],
- ];
-}
diff --git a/app/plugins/subscribe/plugin.php b/app/plugins/subscribe/plugin.php
index b6a023b..972cb33 100644
--- a/app/plugins/subscribe/plugin.php
+++ b/app/plugins/subscribe/plugin.php
@@ -38,7 +38,9 @@ class Subscribe extends Plugin {
public function __construct( $load = false ) {
parent::__construct( $load );
if ( ! self::$loaded ) {
- Components::append( 'FOOTER_RIGHT', Views::simpleView( 'subscribe.footer.right') );
+ if ( $this->checkEnabled() ) {
+ Components::append( 'FOOTER_RIGHT', Views::simpleView( 'subscribe.footer.right') );
+ }
self::$loaded = true;
}
}
diff --git a/app/templates/admin/admin.inc.php b/app/templates/admin/admin.inc.php
index 779b9b4..1a0fa59 100644
--- a/app/templates/admin/admin.inc.php
+++ b/app/templates/admin/admin.inc.php
@@ -34,14 +34,16 @@ class AdminLoader extends DefaultLoader {
}
$links[$key]->url = '#' . $name . 'Dropdown';
$links[$key]->text = '' . $link->text . ' ';
- $links[$key]->duuuuuuuh = Views::simpleView( 'nav.adminSub', $out );
+ $links[$key]->subnav = Views::simpleView( 'nav.adminSub', $out );
} else {
$links[$key]->linkClasses = 'nav-link';
$links[$key]->linkAttributes = '';
- $links[$key]->duuuuuuuh = '';
+ $links[$key]->subnav = '';
}
}
- Components::set( 'ADMIN_LINKS', Views::simpleView( 'nav.admin', $links ) );
+ $menu = Views::simpleView( 'nav.admin', $links );
+ $activeMenu = Navigation::activePageSelect( $menu, Input::get( 'url' ), false, true );
+ Components::set( 'ADMIN_LINKS', $activeMenu );
Navigation::setCrumbComponent( 'ADMIN_BREADCRUMBS', Input::get( 'url' ) );
}
}
diff --git a/app/templates/default/default.inc.php b/app/templates/default/default.inc.php
index fb6e077..6232f97 100644
--- a/app/templates/default/default.inc.php
+++ b/app/templates/default/default.inc.php
@@ -31,6 +31,7 @@ class DefaultLoader extends Loader {
if ( self::$loaded ) {
return;
}
+ Components::set( 'DARK_MODE_SETTING', '' );
Components::set( 'TEMPLATE_URL', Template::parse( '{ROOT_URL}app/templates/default/' ) );
if ( VENDOR_AUTOLOADED === true ) {
Components::set( 'FONT_AWESOME_URL', '/vendor/fortawesome/font-awesome/css/' );
@@ -54,9 +55,11 @@ class DefaultLoader extends Loader {
*/
if ( App::$isLoggedIn ) {
if ( ! empty( App::$activePrefs['darkMode'] ) ) {
+ Components::set( 'DARK_MODE_SETTING', 'true' );
$this->addCss( ' ' );
$this->addCss( ' ' );
} else {
+ Components::set( 'DARK_MODE_SETTING', 'false' );
$this->addCss( ' ' );
$this->addCss( ' ' );
}
@@ -70,7 +73,9 @@ class DefaultLoader extends Loader {
$this->addCss( ' ' );
}
Components::set( 'topNavRight', Template::parse( App::$topNavRight . '{STATUS}' ) );
- Components::set( 'topNavLeft', Views::simpleView( 'nav.main', Navigation::getMenuLinks( App::MAIN_MENU_NAME ) ) );
+ $menu = Views::simpleView( 'nav.main', Navigation::getMenuLinks( App::MAIN_MENU_NAME ) );
+ $activeMenu = Navigation::activePageSelect( $menu, Input::get( 'url' ), false, true );
+ Components::set( 'topNavLeft', $activeMenu );
Components::set( 'colorSelect', Views::simpleView( 'forms.colorSelect' ) );
Components::set( 'iconSelect', Views::simpleView( 'forms.iconSelect' ) );
Navigation::setCrumbComponent( 'BREADCRUMB', Input::get( 'url' ) );
diff --git a/app/templates/default/default.tpl b/app/templates/default/default.tpl
index 605b84c..4a7659a 100644
--- a/app/templates/default/default.tpl
+++ b/app/templates/default/default.tpl
@@ -55,6 +55,7 @@
+
{ISSUES}
{/ISSUES}
+
{CONTENT}
+
{FOOT}
+
+
@@ -77,4 +82,4 @@
{TEMPLATE_JS_INCLUDES}