bludit/bl-kernel/boot/rules/70.posts.php

68 lines
1.7 KiB
PHP
Raw Normal View History

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