Initial commit
This commit is contained in:
105
app/plugins/blog/controllers/admin/blog.php
Normal file
105
app/plugins/blog/controllers/admin/blog.php
Normal file
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/**
|
||||
* app/plugins/blog/controllers/admin/blog.php
|
||||
*
|
||||
* This is the Blog admin controller.
|
||||
*
|
||||
* @package TP Blog
|
||||
* @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\Bedrock\Functions\Check;
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Houdini\Classes\Issues;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
use TheTempusProject\Houdini\Classes\Navigation;
|
||||
use TheTempusProject\Houdini\Classes\Components;
|
||||
use TheTempusProject\Classes\AdminController;
|
||||
use TheTempusProject\Classes\Forms;
|
||||
use TheTempusProject\Plugins\Blog as BlogPlugin;
|
||||
|
||||
class Blog extends AdminController {
|
||||
public static $posts;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$blog = new BlogPlugin;
|
||||
self::$posts = $blog->posts;
|
||||
self::$title = 'Admin - Blog';
|
||||
$view = Navigation::activePageSelect( 'nav.admin', '/admin/blog' );
|
||||
Components::set( 'ADMINNAV', $view );
|
||||
}
|
||||
|
||||
public function index( $data = null ) {
|
||||
Views::view( 'blog.admin.list', self::$posts->listPosts( ['includeDrafts' => true] ) );
|
||||
}
|
||||
|
||||
public function create( $data = null ) {
|
||||
if ( !Input::exists( 'submit' ) ) {
|
||||
return Views::view( 'blog.admin.create' );
|
||||
}
|
||||
if ( !Forms::check( 'newBlogPost' ) ) {
|
||||
Issues::add( 'error', [ 'There was an error with your request.' => Check::userErrors() ] );
|
||||
return $this->index();
|
||||
}
|
||||
|
||||
$result = self::$posts->newPost( Input::post( 'title' ), Input::post( 'blogPost' ), Input::post( 'submit' ) );
|
||||
if ( $result ) {
|
||||
Issues::add( 'success', 'Your post has been created.' );
|
||||
return $this->index();
|
||||
} else {
|
||||
Issues::add( 'error', [ 'There was an unknown error submitting your data.' => Check::userErrors() ] );
|
||||
return $this->index();
|
||||
}
|
||||
}
|
||||
|
||||
public function edit( $data = null ) {
|
||||
if ( !Input::exists( 'submit' ) ) {
|
||||
return Views::view( 'blog.admin.edit', self::$posts->findById( $data ) );
|
||||
}
|
||||
if ( Input::post( 'submit' ) == 'preview' ) {
|
||||
return Views::view( 'blog.admin.preview', self::$posts->preview( Input::post( 'title' ), Input::post( 'blogPost' ) ) );
|
||||
}
|
||||
if ( !Forms::check( 'editBlogPost' ) ) {
|
||||
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 ) {
|
||||
Issues::add( 'success', 'Post Updated.' );
|
||||
return $this->index();
|
||||
}
|
||||
Issues::add( 'error', 'There was an error with your request.' );
|
||||
$this->index();
|
||||
}
|
||||
|
||||
public function view( $data = null ) {
|
||||
$blogData = self::$posts->findById( $data );
|
||||
if ( $blogData !== false ) {
|
||||
return Views::view( 'blog.admin.view', $blogData );
|
||||
}
|
||||
Issues::add( 'error', 'Post not found.' );
|
||||
$this->index();
|
||||
}
|
||||
|
||||
public function delete( $data = null ) {
|
||||
if ( $data == null ) {
|
||||
if ( Input::exists( 'B_' ) ) {
|
||||
$data = Input::post( 'B_' );
|
||||
}
|
||||
}
|
||||
if ( !self::$posts->delete( (array) $data ) ) {
|
||||
Issues::add( 'error', 'There was an error with your request.' );
|
||||
} else {
|
||||
Issues::add( 'success', 'Post has been deleted' );
|
||||
}
|
||||
$this->index();
|
||||
}
|
||||
|
||||
public function preview( $data = null ) {
|
||||
Views::view( 'blog.admin.preview', self::$posts->preview( Input::post( 'title' ), Input::post( 'blogPost' ) ) );
|
||||
}
|
||||
}
|
158
app/plugins/blog/controllers/blog.php
Normal file
158
app/plugins/blog/controllers/blog.php
Normal file
@ -0,0 +1,158 @@
|
||||
<?php
|
||||
/**
|
||||
* app/plugins/blog/controllers/blog.php
|
||||
*
|
||||
* This is the blog controller.
|
||||
*
|
||||
* @package TP Blog
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Controllers;
|
||||
|
||||
use TheTempusProject\Bedrock\Functions\Check;
|
||||
use TheTempusProject\Canary\Canary as Debug;
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Houdini\Classes\Components;
|
||||
use TheTempusProject\Houdini\Classes\Issues;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
use TheTempusProject\Houdini\Classes\Template;
|
||||
use TheTempusProject\Classes\Controller;
|
||||
use TheTempusProject\Classes\Forms;
|
||||
use TheTempusProject\Hermes\Functions\Redirect;
|
||||
use TheTempusProject\Bedrock\Functions\Session;
|
||||
use TheTempusProject\Plugins\Blog as BlogPlugin;
|
||||
use TheTempusProject\TheTempusProject as App;
|
||||
use TheTempusProject\Plugins\Comments;
|
||||
use TheTempusProject\Models\Comments as CommentsModel;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function index() {
|
||||
self::$title = '{SITENAME} Blog';
|
||||
self::$pageDescription = 'The {SITENAME} blog is where you can find various posts containing information ranging from current projects and general information to editorial and opinion based content.';
|
||||
Views::view( 'blog.list', self::$posts->listPosts() );
|
||||
}
|
||||
|
||||
public function rss() {
|
||||
Debug::log( 'Controller initiated: ' . __METHOD__ . '.' );
|
||||
self::$title = '{SITENAME} RSS Feed';
|
||||
self::$pageDescription = '{SITENAME} blog RSS feed.';
|
||||
Template::setTemplate( 'rss' );
|
||||
header( 'Content-Type: text/xml' );
|
||||
return Views::view( 'blog.rss', self::$posts->listPosts( ['stripHtml' => true] ) );
|
||||
}
|
||||
|
||||
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' );
|
||||
}
|
||||
switch ( $sub ) {
|
||||
case 'post':
|
||||
$content = self::$posts->findById( (int) $data );
|
||||
if ( empty( $content ) ) {
|
||||
Session::flash( 'error', 'Unknown Post.' );
|
||||
Redirect::to( 'blog' );
|
||||
}
|
||||
return $plugin->formPost( self::$posts->tableName, $content, 'blog/post/' );
|
||||
return self::$comments->formPost( 'blog', $content, 'blog/post/' );
|
||||
case 'edit':
|
||||
$content = self::$comments->findById( $data );
|
||||
if ( empty( $content ) ) {
|
||||
Session::flash( 'error', 'Unknown Comment.' );
|
||||
Redirect::to( 'blog' );
|
||||
}
|
||||
return $plugin->formEdit( self::$posts->tableName, $content, 'blog/post/' );
|
||||
return self::$comments->formEdit( 'blog', $content, 'blog/post/' );
|
||||
case 'delete':
|
||||
$content = self::$comments->findById( $data );
|
||||
if ( empty( $content ) ) {
|
||||
Session::flash( 'error', 'Unknown Comment.' );
|
||||
Redirect::to( 'blog' );
|
||||
}
|
||||
return $plugin->formDelete( self::$posts->tableName, $content, 'blog/post/' );
|
||||
return self::$comments->formDelete( 'blog', $content, 'blog/post/' );
|
||||
}
|
||||
}
|
||||
|
||||
public function post( $id = null ) {
|
||||
if ( empty( $id ) ) {
|
||||
return $this->index();
|
||||
}
|
||||
$post = self::$posts->findById( $id );
|
||||
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( 'NEWCOMMENT', '' );
|
||||
}
|
||||
$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 );
|
||||
}
|
||||
|
||||
public function author( $data = null ) {
|
||||
if ( empty( $data ) ) {
|
||||
return $this->index();
|
||||
}
|
||||
Debug::log( 'Controller initiated: ' . __METHOD__ . '.' );
|
||||
self::$title = 'Posts by author - {SITENAME}';
|
||||
self::$pageDescription = '{SITENAME} blog posts easily and conveniently sorted by author.';
|
||||
Views::view( 'blog.list', self::$posts->byAuthor( $data ) );
|
||||
}
|
||||
|
||||
public function month( $month = null, $year = 0 ) {
|
||||
if ( empty( $month ) ) {
|
||||
return $this->index();
|
||||
}
|
||||
Debug::log( 'Controller initiated: ' . __METHOD__ . '.' );
|
||||
self::$title = 'Posts By Month - {SITENAME}';
|
||||
self::$pageDescription = '{SITENAME} blog posts easily and conveniently sorted by month.';
|
||||
Views::view( 'blog.list', self::$posts->byMonth( $month, $year ) );
|
||||
}
|
||||
|
||||
public function year( $year = null ) {
|
||||
if ( empty( $year ) ) {
|
||||
return $this->index();
|
||||
}
|
||||
Debug::log( 'Controller initiated: ' . __METHOD__ . '.' );
|
||||
self::$title = 'Posts by Year - {SITENAME}';
|
||||
self::$pageDescription = '{SITENAME} blog posts easily and conveniently sorted by years.';
|
||||
Views::view( 'blog.list', self::$posts->byYear( $year ) );
|
||||
}
|
||||
}
|
81
app/plugins/blog/forms.php
Normal file
81
app/plugins/blog/forms.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* app/plugins/blog/forms.php
|
||||
*
|
||||
* This houses all of the form checking functions for this plugin.
|
||||
*
|
||||
* @package TP Blog
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Plugins\Blog;
|
||||
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Bedrock\Functions\Check;
|
||||
use TheTempusProject\Classes\Forms;
|
||||
|
||||
class BlogForms extends Forms {
|
||||
/**
|
||||
* Adds these functions to the form list.
|
||||
*/
|
||||
public function __construct() {
|
||||
self::addHandler( 'newBlogPost', __CLASS__, 'newBlogPost' );
|
||||
self::addHandler( 'editBlogPost', __CLASS__, 'editBlogPost' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the new blog post form.
|
||||
*
|
||||
* @return {bool}
|
||||
*/
|
||||
public static function newBlogPost() {
|
||||
if ( !Input::exists( 'title' ) ) {
|
||||
self::addUserError( 'You must specify title' );
|
||||
return false;
|
||||
}
|
||||
if ( !self::dataTitle( Input::post( 'title' ) ) ) {
|
||||
self::addUserError( 'Invalid title' );
|
||||
return false;
|
||||
}
|
||||
if ( !Input::exists( 'blogPost' ) ) {
|
||||
self::addUserError( 'You must specify a post' );
|
||||
return false;
|
||||
}
|
||||
/** You cannot use the token check due to how tinymce reloads the page
|
||||
if (!self::token()) {
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the edit blog post form.
|
||||
*
|
||||
* @return {bool}
|
||||
*/
|
||||
public static function editBlogPost() {
|
||||
if ( !Input::exists( 'title' ) ) {
|
||||
self::addUserError( 'You must specify title' );
|
||||
return false;
|
||||
}
|
||||
if ( !self::dataTitle( Input::post( 'title' ) ) ) {
|
||||
self::addUserError( 'Invalid title' );
|
||||
return false;
|
||||
}
|
||||
if ( !Input::exists( 'blogPost' ) ) {
|
||||
self::addUserError( 'You must specify a post' );
|
||||
return false;
|
||||
}
|
||||
/** You cannot use the token check due to how tinymce reloads the page
|
||||
if (!self::token()) {
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
new BlogForms;
|
321
app/plugins/blog/models/posts.php
Normal file
321
app/plugins/blog/models/posts.php
Normal file
@ -0,0 +1,321 @@
|
||||
<?php
|
||||
/**
|
||||
* app/plugins/blog/models/blog.php
|
||||
*
|
||||
* This class is used for the manipulation of the blog database table.
|
||||
*
|
||||
* @package TP Blog
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Models;
|
||||
|
||||
use TheTempusProject\Canary\Canary as Debug;
|
||||
use TheTempusProject\Bedrock\Functions\Check;
|
||||
use TheTempusProject\Bedrock\Functions\Sanitize;
|
||||
use TheTempusProject\Classes\DatabaseModel;
|
||||
use TheTempusProject\TheTempusProject as App;
|
||||
use TheTempusProject\Bedrock\Classes\CustomException;
|
||||
use TheTempusProject\Houdini\Classes\Filters;
|
||||
|
||||
class Posts extends DatabaseModel {
|
||||
public $tableName = 'posts';
|
||||
|
||||
public $databaseMatrix = [
|
||||
[ 'author', 'int', '11' ],
|
||||
[ 'created', 'int', '10' ],
|
||||
[ 'edited', 'int', '10' ],
|
||||
[ 'draft', 'int', '1' ],
|
||||
[ 'title', 'varchar', '86' ],
|
||||
[ 'content', 'text', '' ],
|
||||
];
|
||||
|
||||
public $resourceMatrix = [
|
||||
[
|
||||
'title' => 'Welcome',
|
||||
'content' => '<p>This is just a simple message to say thank you for installing The Tempus Project. If you have any questions you can find everything through our website <a href="https://TheTempusProject.com">here</a>.</p>',
|
||||
'author' => 1,
|
||||
'created' => '{time}',
|
||||
'edited' => '{time}',
|
||||
'draft' => 0,
|
||||
],
|
||||
];
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function newPost( $title, $post, $draft ) {
|
||||
if ( !Check::dataTitle( $title ) ) {
|
||||
Debug::info( 'modelBlog: illegal title.' );
|
||||
|
||||
return false;
|
||||
}
|
||||
if ( $draft === 'saveDraft' ) {
|
||||
$draft = 1;
|
||||
} else {
|
||||
$draft = 0;
|
||||
}
|
||||
$fields = [
|
||||
'author' => App::$activeUser->ID,
|
||||
'draft' => $draft,
|
||||
'created' => time(),
|
||||
'edited' => time(),
|
||||
'content' => Sanitize::rich( $post ),
|
||||
'title' => $title,
|
||||
];
|
||||
if ( !self::$db->insert( $this->tableName, $fields ) ) {
|
||||
Debug::error( "Blog Post: $data not updated: $fields" );
|
||||
new customException( 'blogCreate' );
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function updatePost( $id, $title, $content, $draft ) {
|
||||
if ( empty( self::$log ) ) {
|
||||
self::$log = new Log;
|
||||
}
|
||||
if ( !Check::id( $id ) ) {
|
||||
Debug::info( 'modelBlog: illegal ID.' );
|
||||
|
||||
return false;
|
||||
}
|
||||
if ( !Check::dataTitle( $title ) ) {
|
||||
Debug::info( 'modelBlog: illegal title.' );
|
||||
|
||||
return false;
|
||||
}
|
||||
if ( $draft === 'saveDraft' ) {
|
||||
$draft = 1;
|
||||
} else {
|
||||
$draft = 0;
|
||||
}
|
||||
$fields = [
|
||||
'draft' => $draft,
|
||||
'edited' => time(),
|
||||
'content' => Sanitize::rich( $content ),
|
||||
'title' => $title,
|
||||
];
|
||||
if ( !self::$db->update( $this->tableName, $id, $fields ) ) {
|
||||
new CustomException( 'blogUpdate' );
|
||||
Debug::error( "Blog Post: $id not updated: $fields" );
|
||||
|
||||
return false;
|
||||
}
|
||||
self::$log->admin( "Updated Blog Post: $id" );
|
||||
return true;
|
||||
}
|
||||
|
||||
public function preview( $title, $content ) {
|
||||
if ( !Check::dataTitle( $title ) ) {
|
||||
Debug::info( 'modelBlog: illegal characters.' );
|
||||
|
||||
return false;
|
||||
}
|
||||
$fields = [
|
||||
'title' => $title,
|
||||
'content' => $content,
|
||||
'authorName' => App::$activeUser->username,
|
||||
'created' => time(),
|
||||
];
|
||||
return (object) $fields;
|
||||
}
|
||||
|
||||
public function filter( $postArray, $params = [] ) {
|
||||
foreach ( $postArray as $instance ) {
|
||||
if ( !is_object( $instance ) ) {
|
||||
$instance = $postArray;
|
||||
$end = true;
|
||||
}
|
||||
$draft = '';
|
||||
$authorName = self::$user->getUsername( $instance->author );
|
||||
$cleanPost = Sanitize::contentShort( $instance->content );
|
||||
$postSpace = explode( ' ', $cleanPost );
|
||||
$postLine = explode( "\n", $cleanPost );
|
||||
// summary by words: 100
|
||||
$spaceSummary = implode( ' ', array_splice( $postSpace, 0, 100 ) );
|
||||
// summary by lines: 5
|
||||
$lineSummary = implode( "\n", array_splice( $postLine, 0, 5 ) );
|
||||
if ( strlen( $spaceSummary ) < strlen( $lineSummary ) ) {
|
||||
$contentSummary = $spaceSummary;
|
||||
if ( count( $postSpace, 1 ) <= 100 ) {
|
||||
$contentSummaryNoLink = $contentSummary;
|
||||
$contentSummary .= '... <a href="{ROOT_URL}blog/post/' . $instance->ID . '">Read More</a>';
|
||||
}
|
||||
} else {
|
||||
// @todo: need to refine this after testing
|
||||
$contentSummaryNoLink = $lineSummary;
|
||||
$contentSummary = $lineSummary . '... <a href="{ROOT_URL}blog/post/' . $instance->ID . '">Read More</a>';
|
||||
}
|
||||
if ( $instance->draft != '0' ) {
|
||||
$draft = ' <b>Draft</b>';
|
||||
}
|
||||
$instance->isDraft = $draft;
|
||||
$instance->authorName = $authorName;
|
||||
$instance->contentSummaryNoLink = $contentSummaryNoLink;
|
||||
$instance->contentSummary = $contentSummary;
|
||||
if ( isset( $params['stripHtml'] ) && $params['stripHtml'] === true ) {
|
||||
$instance->contentSummary = strip_tags( $instance->content );
|
||||
}
|
||||
$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];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function archive( $includeDraft = false ) {
|
||||
$whereClause = [];
|
||||
$currentTimeUnix = time();
|
||||
$x = 0;
|
||||
$dataOut = [];
|
||||
$month = date( 'F', $currentTimeUnix );
|
||||
$year = date( 'Y', $currentTimeUnix );
|
||||
$previous = date( 'U', strtotime( "$month 1st $year" ) );
|
||||
if ( $includeDraft !== true ) {
|
||||
$whereClause = ['draft', '=', '0', 'AND'];
|
||||
}
|
||||
while ( $x <= 5 ) {
|
||||
$where = array_merge( $whereClause, ['created', '<=', $currentTimeUnix, 'AND', 'created', '>=', $previous] );
|
||||
$data = self::$db->get( $this->tableName, $where );
|
||||
$x++;
|
||||
$month = date( 'm', $previous );
|
||||
$montht = date( 'F', $previous );
|
||||
$year = date( 'Y', $previous );
|
||||
if ( !$data ) {
|
||||
$count = 0;
|
||||
} else {
|
||||
$count = $data->count();
|
||||
}
|
||||
$dataOut[] = (object) [
|
||||
'count' => $count,
|
||||
'month' => $month,
|
||||
'year' => $year,
|
||||
'monthText' => $montht,
|
||||
];
|
||||
$currentTimeUnix = $previous;
|
||||
$previous = date( 'U', strtotime( '-1 months', $currentTimeUnix ) );
|
||||
}
|
||||
if ( !$data ) {
|
||||
Debug::info( 'No Blog posts found.' );
|
||||
|
||||
return false;
|
||||
}
|
||||
return (object) $dataOut;
|
||||
}
|
||||
|
||||
public function recent( $limit = null, $includeDraft = false ) {
|
||||
$whereClause = [];
|
||||
if ( $includeDraft !== true ) {
|
||||
$whereClause = ['draft', '=', '0'];
|
||||
} else {
|
||||
$whereClause = '*';
|
||||
}
|
||||
if ( empty( $limit ) ) {
|
||||
$postData = self::$db->getPaginated( $this->tableName, $whereClause );
|
||||
} else {
|
||||
$postData = self::$db->getPaginated( $this->tableName, $whereClause, 'ID', 'DESC', [0, $limit] );
|
||||
}
|
||||
if ( !$postData->count() ) {
|
||||
Debug::info( 'No Blog posts found.' );
|
||||
|
||||
return false;
|
||||
}
|
||||
return $this->filter( $postData->results() );
|
||||
}
|
||||
|
||||
public function listPosts( $params = [] ) {
|
||||
if ( isset( $params['includeDrafts'] ) && $params['includeDrafts'] === true ) {
|
||||
$whereClause = '*';
|
||||
} else {
|
||||
$whereClause = ['draft', '=', '0'];
|
||||
}
|
||||
$postData = self::$db->getPaginated( $this->tableName, $whereClause );
|
||||
if ( !$postData->count() ) {
|
||||
Debug::info( 'No Blog posts found.' );
|
||||
|
||||
return false;
|
||||
}
|
||||
if ( isset( $params['stripHtml'] ) && $params['stripHtml'] === true ) {
|
||||
return $this->filter( $postData->results(), ['stripHtml' => true] );
|
||||
}
|
||||
return $this->filter( $postData->results() );
|
||||
}
|
||||
|
||||
public function byYear( $year, $includeDraft = false ) {
|
||||
if ( !Check::id( $year ) ) {
|
||||
Debug::info( 'Invalid Year' );
|
||||
return false;
|
||||
}
|
||||
$whereClause = [];
|
||||
if ( $includeDraft !== true ) {
|
||||
$whereClause = ['draft', '=', '0', 'AND'];
|
||||
}
|
||||
$firstDayUnix = date( 'U', strtotime( "first day of $year" ) );
|
||||
$lastDayUnix = date( 'U', strtotime( "last day of $year" ) );
|
||||
$whereClause = array_merge( $whereClause, ['created', '<=', $lastDayUnix, 'AND', 'created', '>=', $firstDayUnix] );
|
||||
$postData = self::$db->getPaginated( $this->tableName, $whereClause );
|
||||
if ( !$postData->count() ) {
|
||||
Debug::info( 'No Blog posts found.' );
|
||||
|
||||
return false;
|
||||
}
|
||||
return $this->filter( $postData->results() );
|
||||
}
|
||||
|
||||
public function byAuthor( $ID, $includeDraft = false ) {
|
||||
if ( !Check::id( $ID ) ) {
|
||||
Debug::info( 'Invalid Author' );
|
||||
return false;
|
||||
}
|
||||
$whereClause = [];
|
||||
if ( $includeDraft !== true ) {
|
||||
$whereClause = ['draft', '=', '0', 'AND'];
|
||||
}
|
||||
$whereClause = array_merge( $whereClause, ['author' => $ID] );
|
||||
$postData = self::$db->getPaginated( $this->tableName, $whereClause );
|
||||
if ( !$postData->count() ) {
|
||||
Debug::info( 'No Blog posts found.' );
|
||||
|
||||
return false;
|
||||
}
|
||||
return $this->filter( $postData->results() );
|
||||
}
|
||||
|
||||
public function byMonth( $month, $year = 0, $includeDraft = false ) {
|
||||
if ( 0 === $year ) {
|
||||
$year = date( 'Y' );
|
||||
}
|
||||
if ( !Check::id( $month ) ) {
|
||||
Debug::info( 'Invalid Month' );
|
||||
return false;
|
||||
}
|
||||
if ( !Check::id( $year ) ) {
|
||||
Debug::info( 'Invalid Year' );
|
||||
return false;
|
||||
}
|
||||
$whereClause = [];
|
||||
if ( $includeDraft !== true ) {
|
||||
$whereClause = ['draft', '=', '0', 'AND'];
|
||||
}
|
||||
$firstDayUnix = date( 'U', strtotime( "$month/01/$year" ) );
|
||||
$month = date( 'F', $firstDayUnix );
|
||||
$lastDayUnix = date( 'U', strtotime( "last day of $month $year" ) );
|
||||
$whereClause = array_merge( $whereClause, ['created', '<=', $lastDayUnix, 'AND', 'created', '>=', $firstDayUnix] );
|
||||
$postData = self::$db->getPaginated( $this->tableName, $whereClause );
|
||||
if ( !$postData->count() ) {
|
||||
Debug::info( 'No Blog posts found.' );
|
||||
|
||||
return false;
|
||||
}
|
||||
return $this->filter( $postData->results() );
|
||||
}
|
||||
}
|
47
app/plugins/blog/plugin.php
Normal file
47
app/plugins/blog/plugin.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* app/plugins/blog/plugin.php
|
||||
*
|
||||
* This houses all of the main plugin info and functionality.
|
||||
*
|
||||
* @package TP Blog
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @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\Models\Posts;
|
||||
use TheTempusProject\TheTempusProject as App;
|
||||
|
||||
class Blog extends Plugin {
|
||||
public $pluginName = 'TP Blog';
|
||||
public $pluginAuthor = 'JoeyK';
|
||||
public $pluginWebsite = 'https://TheTempusProject.com';
|
||||
public $modelVersion = '1.0';
|
||||
public $pluginVersion = '3.0';
|
||||
public $pluginDescription = 'A simple plugin to add a blog to your installation.';
|
||||
public $admin_links = [
|
||||
[
|
||||
'text' => '<i class="glyphicon glyphicon-text-size"></i> Blog',
|
||||
'url' => '{ROOT_URL}admin/blog',
|
||||
],
|
||||
];
|
||||
public $footer_links = [
|
||||
[
|
||||
'text' => 'Blog',
|
||||
'url' => '{ROOT_URL}blog/index',
|
||||
],
|
||||
];
|
||||
public $posts;
|
||||
|
||||
public function __construct( $load = false ) {
|
||||
$this->posts = new Posts;
|
||||
parent::__construct( $load );
|
||||
}
|
||||
}
|
37
app/plugins/blog/templates/blog.inc.php
Normal file
37
app/plugins/blog/templates/blog.inc.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* app/plugins/blog/templates/blog.inc.php
|
||||
*
|
||||
* This is the loader for the blog template.
|
||||
*
|
||||
* @package TP Blog
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Templates;
|
||||
|
||||
use TheTempusProject\Plugins\Blog;
|
||||
use TheTempusProject\Houdini\Classes\Components;
|
||||
use TheTempusProject\Houdini\Classes\Navigation;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
use TheTempusProject\Houdini\Classes\Template;
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
|
||||
class BlogLoader extends DefaultLoader {
|
||||
/**
|
||||
* This is the function used to generate any components that may be
|
||||
* needed by this template.
|
||||
*/
|
||||
public function __construct() {
|
||||
$blog = new Blog;
|
||||
$posts = $blog->posts;
|
||||
Components::set('SIDEBAR', Views::simpleView('blog.sidebar', $posts->recent(5)));
|
||||
Components::set('SIDEBAR2', Views::simpleView('blog.sidebar2', $posts->archive()));
|
||||
Navigation::setCrumbComponent( 'BLOG_BREADCRUMBS', Input::get( 'url' ) );
|
||||
Components::set( 'BLOG_TEMPLATE_URL', Template::parse( '{ROOT_URL}app/plugins/comments/' ) );
|
||||
$this->addCss( '<link rel="stylesheet" href="{BLOG_TEMPLATE_URL}css/comments.css">' );
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
112
app/plugins/blog/templates/blog.tpl
Normal file
112
app/plugins/blog/templates/blog.tpl
Normal file
@ -0,0 +1,112 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<!--
|
||||
* app/plugins/blog/templates/blog.tpl
|
||||
*
|
||||
* @package TP Blog
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta property="og:url" content="{CURRENT_URL}">
|
||||
<meta name='twitter:card' content='summary' />
|
||||
<title>{TITLE}</title>
|
||||
<meta itemprop="name" content="{TITLE}">
|
||||
<meta name="twitter:title" content="{TITLE}">
|
||||
<meta property="og:title" content="{TITLE}">
|
||||
<meta name="description" content="{PAGE_DESCRIPTION}">
|
||||
<meta itemprop="description" content="{PAGE_DESCRIPTION}">
|
||||
<meta name="twitter:description" content="{PAGE_DESCRIPTION}">
|
||||
<meta property="og:description" content="{PAGE_DESCRIPTION}">
|
||||
<meta itemprop="image" content="{META_IMAGE}">
|
||||
<meta name="twitter:image" content="{META_IMAGE}">
|
||||
<meta property="og:image" content="{META_IMAGE}">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="author" content="The Tempus Project">
|
||||
{ROBOT}
|
||||
<link rel="alternate" hreflang="en-us" href="alternateURL">
|
||||
<link rel="icon" href="{ROOT_URL}images/favicon.ico">
|
||||
<!-- Required CSS -->
|
||||
<link rel="stylesheet" href="{FONT_AWESOME_URL}font-awesome.min.css" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="{BOOTSTRAP_CDN}css/bootstrap-theme.min.css" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="{BOOTSTRAP_CDN}css/bootstrap.min.css" crossorigin="anonymous">
|
||||
<!-- RSS -->
|
||||
<link rel="alternate" href="{ROOT_URL}blog/rss" title="{TITLE} Feed" type="application/rss+xml" />
|
||||
<!-- Custom styles for this template -->
|
||||
{TEMPLATE_CSS_INCLUDES}
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
|
||||
<!--Brand and toggle should get grouped for better mobile display -->
|
||||
<div class="navbar-header">
|
||||
<a href="{ROOT_URL}" class="navbar-brand">{SITENAME}</a>
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse" style="">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="container-fluid">
|
||||
<div class="collapse navbar-collapse navbar-ex1-collapse">
|
||||
{topNavLeft}
|
||||
<div class="navbar-right">
|
||||
<ul class="nav navbar-nav">
|
||||
{topNavRight}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div class="container-fluid">
|
||||
<div class="foot-pad">
|
||||
{ISSUES}
|
||||
<div class="row">
|
||||
<div class="container">
|
||||
{ERROR}
|
||||
{NOTICE}
|
||||
{SUCCESS}
|
||||
</div>
|
||||
</div>
|
||||
{/ISSUES}
|
||||
<div class="row">
|
||||
<div class="container">
|
||||
<div class="page-header">
|
||||
<h1 class="blog-title">{SITENAME} Blog</h1>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-8 blog-main">
|
||||
{BLOG_BREADCRUMBS}
|
||||
{CONTENT}
|
||||
</div>
|
||||
<!-- /.blog-main -->
|
||||
<div class="col-sm-3 col-sm-offset-1 blog-sidebar">
|
||||
<div class="sidebar-module">
|
||||
{SIDEBAR}
|
||||
</div>
|
||||
<div class="sidebar-module">
|
||||
{SIDEBAR2}
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.blog-sidebar -->
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
{FOOT}
|
||||
{COPY}
|
||||
</footer>
|
||||
<!-- Bootstrap core JavaScript and jquery -->
|
||||
<script src="{JQUERY_CDN}jquery.min.js" crossorigin="anonymous"></script>
|
||||
<script src="{BOOTSTRAP_CDN}js/bootstrap.min.js" crossorigin="anonymous"></script>
|
||||
<!-- Custom javascript for this template -->
|
||||
{TEMPLATE_JS_INCLUDES}
|
||||
</body>
|
||||
</html>
|
19
app/plugins/blog/templates/rss.inc.php
Normal file
19
app/plugins/blog/templates/rss.inc.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* app/templates/rss/rss.inc.php
|
||||
*
|
||||
* This is the loader for the rss template.
|
||||
*
|
||||
* @package TP Blog
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Templates;
|
||||
|
||||
class RssLoader extends DefaultLoader {
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
11
app/plugins/blog/templates/rss.tpl
Normal file
11
app/plugins/blog/templates/rss.tpl
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
<title>{TITLE}</title>
|
||||
<link>{ROOT_URL}blog</link>
|
||||
<description>{PAGE_DESCRIPTION}</description>
|
||||
<language>en-us</language>
|
||||
<copyright>Copyright (C) 2023 {SITENAME}</copyright>
|
||||
{CONTENT}
|
||||
</channel>
|
||||
</rss>
|
31
app/plugins/blog/views/admin/create.html
Normal file
31
app/plugins/blog/views/admin/create.html
Normal file
@ -0,0 +1,31 @@
|
||||
<form action="" method="post" class="form-horizontal" enctype="multipart/form-data">
|
||||
<legend>New Blog Post</legend>
|
||||
<div class="form-group">
|
||||
<label for="title" class="col-lg-3 control-label">Title</label>
|
||||
<div class="col-lg-3">
|
||||
<input type="text" class="form-check-input" name="title" id="title">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-lg-6 col-lg-offset-3 btn-group">
|
||||
<button type="button" class="btn btn-sm btn-primary" onclick="insertTag ('blogPost', 'c');">✔</button>
|
||||
<button type="button" class="btn btn-sm btn-primary" onclick="insertTag ('blogPost', 'x');">✖</button>
|
||||
<button type="button" class="btn btn-sm btn-primary" onclick="insertTag ('blogPost', '!');">❕</button>
|
||||
<button type="button" class="btn btn-sm btn-primary" onclick="insertTag ('blogPost', '?');">❔</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="blogPost" class="col-lg-3 control-label">Post</label>
|
||||
<div class="col-lg-6">
|
||||
<textarea class="form-control" name="blogPost" maxlength="2000" rows="10" cols="50" id="blogPost"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-lg-6 col-lg-offset-3">
|
||||
<button name="submit" value="publish" type="submit" class="btn btn-lg btn-primary">Publish</button>
|
||||
<button name="submit" value="saveDraft" type="submit" class="btn btn-lg btn-primary">Save as Draft</button>
|
||||
<button name="submit" value="preview" type="submit" class="btn btn-lg btn-primary">Preview</button>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="token" value="{TOKEN}">
|
||||
</form>
|
30
app/plugins/blog/views/admin/dashboard.html
Normal file
30
app/plugins/blog/views/admin/dashboard.html
Normal file
@ -0,0 +1,30 @@
|
||||
<legend>New Posts</legend>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 20%"></th>
|
||||
<th style="width: 65%"></th>
|
||||
<th style="width: 5%"></th>
|
||||
<th style="width: 5%"></th>
|
||||
<th style="width: 5%"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{LOOP}
|
||||
<tr>
|
||||
<td>{title}</td>
|
||||
<td>{contentSummary}</td>
|
||||
<td><a href="{ROOT_URL}admin/blog/view/{ID}" class="btn btn-sm btn-primary" role="button"><i class="glyphicon glyphicon-open"></i></a></td>
|
||||
<td><a href="{ROOT_URL}admin/blog/edit/{ID}" class="btn btn-sm btn-warning" role="button"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
<td width="30px"><a href="{ROOT_URL}admin/blog/delete/{ID}" class="btn btn-sm btn-danger" role="button"><i class="glyphicon glyphicon-trash"></i></a></td>
|
||||
</tr>
|
||||
{/LOOP}
|
||||
{ALT}
|
||||
<tr>
|
||||
<td align="center" colspan="5">
|
||||
No results to show.
|
||||
</td>
|
||||
</tr>
|
||||
{/ALT}
|
||||
</tbody>
|
||||
</table>
|
31
app/plugins/blog/views/admin/edit.html
Normal file
31
app/plugins/blog/views/admin/edit.html
Normal file
@ -0,0 +1,31 @@
|
||||
<form action="" method="post" class="form-horizontal" enctype="multipart/form-data">
|
||||
<legend>Edit Blog Post</legend>
|
||||
<div class="form-group">
|
||||
<label for="title" class="col-lg-3 control-label">Title</label>
|
||||
<div class="col-lg-3">
|
||||
<input type="text" class="form-check-input" name="title" id="title" value="{title}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-lg-6 col-lg-offset-3 btn-group">
|
||||
<button type="button" class="btn btn-sm btn-primary" onclick="insertTag ('blogPost', 'c');">✔</button>
|
||||
<button type="button" class="btn btn-sm btn-primary" onclick="insertTag ('blogPost', 'x');">✖</button>
|
||||
<button type="button" class="btn btn-sm btn-primary" onclick="insertTag ('blogPost', '!');">❕</button>
|
||||
<button type="button" class="btn btn-sm btn-primary" onclick="insertTag ('blogPost', '?');">❔</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="blogPost" class="col-lg-3 control-label">Post</label>
|
||||
<div class="col-lg-6">
|
||||
<textarea class="form-control" name="blogPost" maxlength="2000" rows="10" cols="50" id="blogPost">{content}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-lg-6 col-lg-offset-3">
|
||||
<button name="submit" value="publish" type="submit" class="btn btn-lg btn-primary">Publish</button>
|
||||
<button name="submit" value="saveDraft" type="submit" class="btn btn-lg btn-primary">Save as Draft</button>
|
||||
<button name="submit" value="preview" type="submit" class="btn btn-lg btn-primary">Preview</button>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="token" value="{TOKEN}">
|
||||
</form>
|
45
app/plugins/blog/views/admin/list.html
Normal file
45
app/plugins/blog/views/admin/list.html
Normal file
@ -0,0 +1,45 @@
|
||||
<legend>Blog Posts</legend>
|
||||
{PAGINATION}
|
||||
<form action="{ROOT_URL}admin/blog/delete" method="post">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 30%">Title</th>
|
||||
<th style="width: 20%">Author</th>
|
||||
<th style="width: 10%">comments</th>
|
||||
<th style="width: 10%">Created</th>
|
||||
<th style="width: 10%">Updated</th>
|
||||
<th style="width: 5%"></th>
|
||||
<th style="width: 5%"></th>
|
||||
<th style="width: 10%">
|
||||
<INPUT type="checkbox" onchange="checkAll(this)" name="check.b" value="B_[]"/>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{LOOP}
|
||||
<tr>
|
||||
<td><a href="{ROOT_URL}admin/blog/view/{ID}">{title}</a>{isDraft}</td>
|
||||
<td>{authorName}</td>
|
||||
<td>{commentCount}</td>
|
||||
<td>{DTC}{created}{/DTC}</td>
|
||||
<td>{DTC}{edited}{/DTC}</td>
|
||||
<td><a href="{ROOT_URL}admin/blog/edit/{ID}" class="btn btn-sm btn-warning" role="button"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
<td><a href="{ROOT_URL}admin/blog/delete/{ID}" class="btn btn-sm btn-danger" role="button"><i class="glyphicon glyphicon-trash"></i></a></td>
|
||||
<td>
|
||||
<input type="checkbox" value="{ID}" name="B_[]">
|
||||
</td>
|
||||
</tr>
|
||||
{/LOOP}
|
||||
{ALT}
|
||||
<tr>
|
||||
<td colspan="7">
|
||||
No results to show.
|
||||
</td>
|
||||
</tr>
|
||||
{/ALT}
|
||||
</tbody>
|
||||
</table>
|
||||
<a href="{ROOT_URL}admin/blog/create" class="btn btn-sm btn-primary" role="button">Create</a>
|
||||
<button name="submit" value="submit" type="submit" class="btn btn-sm btn-danger">Delete</button>
|
||||
</form>
|
40
app/plugins/blog/views/admin/preview.html
Normal file
40
app/plugins/blog/views/admin/preview.html
Normal file
@ -0,0 +1,40 @@
|
||||
<div class="row">
|
||||
<div class="col-sm-8 blog-main">
|
||||
<div class="blog-post">
|
||||
<h2 class="blog-post-title">{title}</h2>
|
||||
<p class="blog-post-meta">{DTC}{created}{/DTC} by <a href="{ROOT_URL}admin/user/view/{author}">{authorName}</a></p>
|
||||
{content}
|
||||
</div><!-- /.blog-post -->
|
||||
</div><!-- /.blog-main -->
|
||||
</div><!-- /.row -->
|
||||
<form action="" method="post" class="form-horizontal" enctype="multipart/form-data">
|
||||
<legend>New Blog Post</legend>
|
||||
<div class="form-group">
|
||||
<label for="title" class="col-lg-3 control-label">Title</label>
|
||||
<div class="col-lg-3">
|
||||
<input type="text" class="form-check-input" name="title" id="title" value="{title}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-lg-6 col-lg-offset-3 btn-group">
|
||||
<button type="button" class="btn btn-sm btn-primary" onclick="insertTag ('blogPost', 'c');">✔</button>
|
||||
<button type="button" class="btn btn-sm btn-primary" onclick="insertTag ('blogPost', 'x');">✖</button>
|
||||
<button type="button" class="btn btn-sm btn-primary" onclick="insertTag ('blogPost', '!');">❕</button>
|
||||
<button type="button" class="btn btn-sm btn-primary" onclick="insertTag ('blogPost', '?');">❔</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="blogPost" class="col-lg-3 control-label">Post</label>
|
||||
<div class="col-lg-6">
|
||||
<textarea class="form-control" name="blogPost" maxlength="2000" rows="10" cols="50" id="blogPost">{content}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-lg-6 col-lg-offset-3">
|
||||
<button name="submit" value="publish" type="submit" class="btn btn-lg btn-primary">Publish</button>
|
||||
<button name="submit" value="saveasdraft" type="submit" class="btn btn-lg btn-primary">Save as Draft</button>
|
||||
<button name="submit" value="preview" type="submit" class="btn btn-lg btn-primary">Preview</button>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="token" value="{TOKEN}">
|
||||
</form>
|
11
app/plugins/blog/views/admin/view.html
Normal file
11
app/plugins/blog/views/admin/view.html
Normal file
@ -0,0 +1,11 @@
|
||||
<div class="row">
|
||||
<div class="col-sm-8 blog-main">
|
||||
<div class="page-header">
|
||||
<h1>{title} <small>{DTC}{created}{/DTC} by <a href="{ROOT_URL}admin/users/view/{author}">{authorName}</a></small></h1>
|
||||
</div>
|
||||
<div class="well">{content}</div>
|
||||
<a href="{ROOT_URL}admin/blog/delete/{ID}" class="btn btn-md btn-danger" role="button">Delete</a>
|
||||
<a href="{ROOT_URL}admin/blog/edit/{ID}" class="btn btn-md btn-warning" role="button">Edit</a>
|
||||
<a href="{ROOT_URL}admin/comments/blog/{ID}" class="btn btn-md btn-primary" role="button">View Comments</a>
|
||||
</div><!-- /.blog-main -->
|
||||
</div><!-- /.row -->
|
18
app/plugins/blog/views/list.html
Normal file
18
app/plugins/blog/views/list.html
Normal file
@ -0,0 +1,18 @@
|
||||
{PAGINATION}
|
||||
{LOOP}
|
||||
<div class="blog-post">
|
||||
<h2 class="blog-post-title"><a href="{ROOT_URL}blog/post/{ID}">{title}</a></h2>
|
||||
<hr>
|
||||
<div class="well">
|
||||
<p class="blog-post-meta">
|
||||
Posted on <i>{DTC date}{created}{/DTC}</i> by <a href="{ROOT_URL}home/profile/{author}"><strong>{authorName}</strong></a>
|
||||
</p>
|
||||
{contentSummary}
|
||||
</div>
|
||||
</div>
|
||||
{/LOOP}
|
||||
{ALT}
|
||||
<div class="blog-post">
|
||||
<p class="blog-post-meta">No Posts Found.</p>
|
||||
</div>
|
||||
{/ALT}
|
18
app/plugins/blog/views/post.html
Normal file
18
app/plugins/blog/views/post.html
Normal file
@ -0,0 +1,18 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-sm-12 blog-main">
|
||||
<div class="blog-post">
|
||||
<h2 class="blog-post-title">{title}</h2>
|
||||
<hr>
|
||||
<p class="blog-post-meta">{DTC date}{created}{/DTC} by <a href="{ROOT_URL}home/profile/{author}">{authorName}</a></p>
|
||||
{content}
|
||||
{ADMIN}
|
||||
<hr>
|
||||
<a href="{ROOT_URL}admin/blog/delete/{ID}" class="btn btn-md btn-danger" role="button">Delete</a>
|
||||
<a href="{ROOT_URL}admin/blog/edit/{ID}" class="btn btn-md btn-warning" role="button">Edit</a>
|
||||
<hr>
|
||||
{/ADMIN}
|
||||
</div><!-- /.blog-post -->
|
||||
{COMMENTS}
|
||||
{NEWCOMMENT}
|
||||
</div><!-- /.blog-main -->
|
||||
</div><!-- /.row -->
|
15
app/plugins/blog/views/recentWidget.html
Normal file
15
app/plugins/blog/views/recentWidget.html
Normal file
@ -0,0 +1,15 @@
|
||||
<div class="panel panel-info">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Recent Posts</h3>
|
||||
</div>
|
||||
<ul class="list-group">
|
||||
{LOOP}
|
||||
<li class="list-group-item">
|
||||
<a href="{ROOT_URL}blog/post/{ID}">{title}</a>
|
||||
</li>
|
||||
{/LOOP}
|
||||
{ALT}
|
||||
<li class="list-group-item">No Posts to show</li>
|
||||
{/ALT}
|
||||
</ul>
|
||||
</div>
|
10
app/plugins/blog/views/rss.html
Normal file
10
app/plugins/blog/views/rss.html
Normal file
@ -0,0 +1,10 @@
|
||||
{LOOP}
|
||||
<item>
|
||||
<title>{title}</title>
|
||||
<description>{contentSummary}</description>
|
||||
<link>{ROOT_URL}blog/post/{ID}</link>
|
||||
<pubDate>{DTC}{created}{/DTC}</pubDate>
|
||||
</item>
|
||||
{/LOOP}
|
||||
{ALT}
|
||||
{/ALT}
|
18
app/plugins/blog/views/sidebar.html
Normal file
18
app/plugins/blog/views/sidebar.html
Normal file
@ -0,0 +1,18 @@
|
||||
<div class="panel panel-info">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Recent Posts</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<ol class="list-unstyled">
|
||||
{LOOP}
|
||||
<li><a href="{ROOT_URL}blog/post/{ID}">{title}</a></li>
|
||||
{/LOOP}
|
||||
{ALT}
|
||||
<li>No Posts to show</li>
|
||||
{/ALT}
|
||||
</ol>
|
||||
</div>
|
||||
<div class="panel-footer">
|
||||
<a href="{ROOT_URL}blog">View All</a>
|
||||
</div>
|
||||
</div>
|
14
app/plugins/blog/views/sidebar2.html
Normal file
14
app/plugins/blog/views/sidebar2.html
Normal file
@ -0,0 +1,14 @@
|
||||
<div class="panel panel-info">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Archives</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<ol class="list-unstyled">
|
||||
{LOOP}
|
||||
<li>({count}) <a href="{ROOT_URL}blog/month/{month}/{year}">{monthText} {year}</a></li>
|
||||
{/LOOP}
|
||||
{ALT}
|
||||
{/ALT}
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
Reference in New Issue
Block a user