2017-05-09 00:24:15 +02:00
|
|
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// Variables
|
|
|
|
// ============================================================================
|
|
|
|
|
2017-07-11 23:53:53 +02:00
|
|
|
// Array with pages, each page is a Page Object
|
2017-05-09 00:24:15 +02:00
|
|
|
$pages = array();
|
|
|
|
|
2017-07-11 23:53:53 +02:00
|
|
|
// Page filtered by the user, is a Page Object
|
2017-07-09 22:59:54 +02:00
|
|
|
$page = $Page = false;
|
2017-05-09 00:24:15 +02:00
|
|
|
|
2017-07-10 23:40:46 +02:00
|
|
|
// Array with pages order by parent
|
2017-07-11 23:53:53 +02:00
|
|
|
// This variable is initializade only when the site is order by position to not degradate the peromance on blogs
|
2017-07-10 23:40:46 +02:00
|
|
|
/*
|
2017-07-11 23:53:53 +02:00
|
|
|
array(
|
|
|
|
PARENT => array(), // all parent pages
|
|
|
|
parentKey1 => array(), // all children of parentKey1
|
|
|
|
parentKey2 => array(), // all children of parentKey2
|
|
|
|
...
|
|
|
|
parentKeyN => array(), // all children of parentKeyN
|
|
|
|
)
|
2017-07-10 23:40:46 +02:00
|
|
|
*/
|
|
|
|
$pagesByParent = array(PARENT=>array());
|
2017-05-16 00:46:20 +02:00
|
|
|
|
2017-07-11 23:53:53 +02:00
|
|
|
// Array with pages,
|
|
|
|
/*
|
|
|
|
array(
|
|
|
|
pageKey1 => Page Object,
|
|
|
|
pageKey2 => Page Object,
|
|
|
|
...
|
|
|
|
pageKeyN => Page Object,
|
|
|
|
)
|
|
|
|
*/
|
2017-05-27 19:46:46 +02:00
|
|
|
$pagesByKey = array();
|
2017-05-16 00:46:20 +02:00
|
|
|
|
2017-05-09 00:24:15 +02:00
|
|
|
// ============================================================================
|
|
|
|
// Main
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
// Execute the scheduler
|
|
|
|
if( $dbPages->scheduler() ) {
|
|
|
|
// Reindex tags
|
|
|
|
reindexTags();
|
|
|
|
|
|
|
|
// Reindex categories
|
|
|
|
reindexCategories();
|
2017-06-23 00:41:00 +02:00
|
|
|
|
|
|
|
// Add to syslog
|
|
|
|
$Syslog->add(array(
|
|
|
|
'dictionaryKey'=>'page-published-from-scheduler',
|
|
|
|
'notes'=>''
|
|
|
|
));
|
2017-05-09 00:24:15 +02:00
|
|
|
}
|
|
|
|
|
2017-07-11 23:53:53 +02:00
|
|
|
if( $Site->homepage() && $Url->whereAmI()==='home' ) {
|
|
|
|
$Url->setWhereAmI('page');
|
|
|
|
$slug = $Site->homepage();
|
|
|
|
$Url->setSlug($slug);
|
|
|
|
}
|
|
|
|
|
2017-05-09 00:24:15 +02:00
|
|
|
// Build specific page
|
|
|
|
if( $Url->whereAmI()==='page' ) {
|
|
|
|
// Build the page
|
2017-07-09 22:59:54 +02:00
|
|
|
$page = $Page = buildPage( $Url->slug() );
|
2017-05-09 00:24:15 +02:00
|
|
|
|
|
|
|
// The page doesn't exist
|
|
|
|
if($page===false) {
|
|
|
|
$Url->setNotFound(true);
|
|
|
|
}
|
2017-07-10 23:40:46 +02:00
|
|
|
// The page is not published, scheduled or draft
|
2017-06-22 23:50:12 +02:00
|
|
|
elseif( $page->scheduled() || $page->draft() ) {
|
2017-05-09 00:24:15 +02:00
|
|
|
$Url->setNotFound(true);
|
|
|
|
}
|
2017-05-12 20:18:44 +02:00
|
|
|
else {
|
|
|
|
$pages[0] = $page;
|
|
|
|
}
|
2017-05-09 00:24:15 +02:00
|
|
|
}
|
|
|
|
elseif( $Url->whereAmI()==='tag' ) {
|
2017-05-16 00:46:20 +02:00
|
|
|
buildPagesByTag();
|
2017-05-09 00:24:15 +02:00
|
|
|
}
|
|
|
|
elseif( $Url->whereAmI()==='category' ) {
|
2017-05-16 00:46:20 +02:00
|
|
|
buildPagesByCategory();
|
2017-05-09 00:24:15 +02:00
|
|
|
}
|
|
|
|
elseif( $Url->whereAmI()==='home' ) {
|
2017-05-16 00:46:20 +02:00
|
|
|
buildPagesForHome();
|
2017-05-09 00:24:15 +02:00
|
|
|
}
|
|
|
|
elseif( $Url->whereAmI()==='admin' ) {
|
2017-05-16 00:46:20 +02:00
|
|
|
buildPagesForAdmin();
|
2017-05-09 00:24:15 +02:00
|
|
|
}
|
|
|
|
|
2017-07-10 23:40:46 +02:00
|
|
|
if(ORDER_BY==='position') {
|
|
|
|
$allPages = false; // All pages are published, draft, scheduled
|
|
|
|
buildPagesByParent(false);
|
|
|
|
}
|
|
|
|
|
2017-05-24 00:48:29 +02:00
|
|
|
// Set page 404 not found
|
2017-05-09 00:24:15 +02:00
|
|
|
if( $Url->notFound() ) {
|
|
|
|
$Url->setWhereAmI('page');
|
2017-06-25 22:54:59 +02:00
|
|
|
$page = buildPage('error');
|
|
|
|
$pages[0] = $page;
|
2017-05-09 00:24:15 +02:00
|
|
|
}
|