Bugfixes and Bootstrap 5 finalized

This commit is contained in:
Joey Kimsey
2024-12-17 22:57:55 -05:00
parent 2220c6cda3
commit a859fb7ace
79 changed files with 2011 additions and 1597 deletions

View File

@ -20,15 +20,14 @@ use TheTempusProject\Houdini\Classes\Navigation;
use TheTempusProject\Houdini\Classes\Components;
use TheTempusProject\Classes\AdminController;
use TheTempusProject\Classes\Forms;
use TheTempusProject\Plugins\Blog as BlogPlugin;
use TheTempusProject\Models\Posts;
class Blog extends AdminController {
public static $posts;
public function __construct() {
parent::__construct();
$blog = new BlogPlugin;
self::$posts = $blog->posts;
self::$posts = new Posts;
self::$title = 'Admin - Blog';
$view = Navigation::activePageSelect( 'nav.admin', '/admin/blog' );
Components::set( 'ADMINNAV', $view );

View File

@ -27,17 +27,16 @@ use TheTempusProject\Plugins\Blog as BlogPlugin;
use TheTempusProject\TheTempusProject as App;
use TheTempusProject\Plugins\Comments;
use TheTempusProject\Models\Comments as CommentsModel;
use TheTempusProject\Models\Posts as PostsModel;
class Blog extends Controller {
protected static $blog;
protected static $comments;
protected static $posts;
public function __construct() {
parent::__construct();
Template::setTemplate( 'blog' );
$blog = new BlogPlugin;
self::$posts = $blog->posts;
self::$posts = new PostsModel;
}
public function index() {
@ -57,39 +56,41 @@ class Blog extends Controller {
public function comments( $sub = null, $data = null ) {
Debug::log( 'Controller initiated: ' . __METHOD__ . '.' );
if ( empty( self::$comments ) ) {
self::$comments = new CommentsModel;
}
$plugin = new Comments;
if ( empty( $sub ) || empty( $data ) ) {
Session::flash( 'error', 'Whoops, try again.' );
Redirect::to( 'blog' );
Issues::add( 'error', 'There was an issue with your request. Please check the url and try again.' );
return $this->index();
}
$plugin = new Comments;
if ( ! $plugin->checkEnabled() ) {
Issues::add( 'error', 'Comments are disabled.' );
return $this->index();
}
$comments = new CommentsModel;
switch ( $sub ) {
case 'post':
$content = self::$posts->findById( (int) $data );
if ( empty( $content ) ) {
Session::flash( 'error', 'Unknown Post.' );
Redirect::to( 'blog' );
Issues::add( 'error', 'Unknown Content.' );
return $this->index();
}
return $plugin->formPost( self::$posts->tableName, $content, 'blog/post/' );
return self::$comments->formPost( 'blog', $content, 'blog/post/' );
case 'edit':
$content = self::$comments->findById( $data );
$content = $comments->findById( $data );
if ( empty( $content ) ) {
Session::flash( 'error', 'Unknown Comment.' );
Redirect::to( 'blog' );
Issues::add( 'error', 'Unknown Comment.' );
return $this->index();
}
return $plugin->formEdit( self::$posts->tableName, $content, 'blog/post/' );
return self::$comments->formEdit( 'blog', $content, 'blog/post/' );
case 'delete':
$content = self::$comments->findById( $data );
$content = $comments->findById( $data );
if ( empty( $content ) ) {
Session::flash( 'error', 'Unknown Comment.' );
Redirect::to( 'blog' );
Issues::add( 'error', 'Unknown Comment.' );
return $this->index();
}
return $plugin->formDelete( self::$posts->tableName, $content, 'blog/post/' );
return self::$comments->formDelete( 'blog', $content, 'blog/post/' );
}
}
@ -101,26 +102,34 @@ class Blog extends Controller {
if ( empty( $post ) ) {
return $this->index();
}
if ( empty( self::$comments ) ) {
self::$comments = new CommentsModel;
}
Debug::log( 'Controller initiated: ' . __METHOD__ . '.' );
self::$title = 'Blog Post';
// I removed this once because i didn't realize.
// this triggers the comment post controller method when the comment form is submitted on the post viewing page
if ( Input::exists( 'contentId' ) ) {
$this->comments( 'post', Input::post( 'contentId' ) );
}
Components::set( 'CONTENT_ID', $id );
Components::set( 'COMMENT_TYPE', 'blog' );
if ( App::$isLoggedIn ) {
Components::set( 'NEWCOMMENT', Views::simpleView( 'comments.create' ) );
} else {
Components::set( 'COMMENT_TYPE', self::$posts->tableName );
$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', '' );
}
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 );
Components::set( 'count', self::$comments->count( self::$posts->tableName, $post->ID ) );
Components::set( 'COMMENTS', Views::simpleView( 'comments.list', self::$comments->display( 10, self::$posts->tableName, $post->ID ) ) );
self::$title .= ' - ' . $post->title;
self::$pageDescription = strip_tags( $post->contentSummaryNoLink );
Views::view( 'blog.post', $post );