2015-03-08 18:02:59 +01:00
|
|
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
|
|
|
|
2015-06-27 00:12:26 +02:00
|
|
|
// ============================================================================
|
|
|
|
// Variables
|
|
|
|
// ============================================================================
|
|
|
|
|
2016-01-08 21:12:17 +01:00
|
|
|
// Array with all posts specified by a filter.
|
|
|
|
// Filter by page number, by tag, etc.
|
2015-03-08 18:02:59 +01:00
|
|
|
$posts = array();
|
|
|
|
|
2015-06-27 00:12:26 +02:00
|
|
|
// ============================================================================
|
|
|
|
// Main
|
|
|
|
// ============================================================================
|
|
|
|
|
2015-09-10 04:33:31 +02:00
|
|
|
// Search for changes on posts by the user.
|
2016-07-17 01:19:10 +02:00
|
|
|
if( CLI_MODE && false) {
|
|
|
|
if($dbPosts->cliMode()) {
|
2015-09-20 23:46:50 +02:00
|
|
|
reIndexTagsPosts();
|
|
|
|
}
|
2015-09-10 04:33:31 +02:00
|
|
|
}
|
|
|
|
|
2015-09-02 02:42:21 +02:00
|
|
|
// Execute the scheduler.
|
|
|
|
if( $dbPosts->scheduler() ) {
|
|
|
|
// Reindex dbTags.
|
|
|
|
reIndexTagsPosts();
|
|
|
|
}
|
|
|
|
|
2015-08-31 03:18:06 +02:00
|
|
|
// Build specific post.
|
2015-03-08 18:02:59 +01:00
|
|
|
if( ($Url->whereAmI()==='post') && ($Url->notFound()===false) )
|
|
|
|
{
|
2015-05-05 03:00:01 +02:00
|
|
|
$Post = buildPost( $Url->slug() );
|
2015-03-08 18:02:59 +01:00
|
|
|
|
2016-01-08 21:12:17 +01:00
|
|
|
// The post doesn't exist.
|
2015-03-08 18:02:59 +01:00
|
|
|
if($Post===false)
|
|
|
|
{
|
|
|
|
$Url->setNotFound(true);
|
|
|
|
unset($Post);
|
|
|
|
}
|
2016-01-08 21:12:17 +01:00
|
|
|
// The post is not published yet.
|
2015-03-08 18:02:59 +01:00
|
|
|
elseif( !$Post->published() )
|
|
|
|
{
|
|
|
|
$Url->setNotFound(true);
|
|
|
|
unset($Post);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$posts[0] = $Post;
|
|
|
|
}
|
|
|
|
|
2015-08-29 20:07:47 +02:00
|
|
|
}
|
2015-08-31 03:18:06 +02:00
|
|
|
// Build posts by specific tag.
|
2015-08-29 20:07:47 +02:00
|
|
|
elseif( ($Url->whereAmI()==='tag') && ($Url->notFound()===false) )
|
|
|
|
{
|
2016-01-08 01:00:40 +01:00
|
|
|
$posts = buildPostsForPage($Url->pageNumber(), $Site->postsPerPage(), true, $Url->slug());
|
2015-03-08 18:02:59 +01:00
|
|
|
}
|
2015-08-31 03:18:06 +02:00
|
|
|
// Build posts for homepage or admin area.
|
2015-03-08 18:02:59 +01:00
|
|
|
else
|
|
|
|
{
|
2015-08-31 03:18:06 +02:00
|
|
|
// Posts for admin area.
|
2015-05-05 03:00:01 +02:00
|
|
|
if($Url->whereAmI()==='admin') {
|
2016-01-08 01:00:40 +01:00
|
|
|
$posts = buildPostsForPage($Url->pageNumber(), POSTS_PER_PAGE_ADMIN, false);
|
2015-05-05 03:00:01 +02:00
|
|
|
}
|
2016-01-08 21:12:17 +01:00
|
|
|
// Posts for home and blog filter.
|
|
|
|
elseif( ( ($Url->whereAmI()==='home') || ($Url->whereAmI()==='blog') ) && ($Url->notFound()===false) ) {
|
2016-01-08 01:00:40 +01:00
|
|
|
$posts = buildPostsForPage($Url->pageNumber(), $Site->postsPerPage(), true);
|
2015-05-05 03:00:01 +02:00
|
|
|
}
|
2015-11-28 15:47:03 +01:00
|
|
|
}
|