bludit/bl-kernel/boot/rules/69.pages.php

146 lines
3.0 KiB
PHP
Raw Normal View History

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-07-13 00:44:39 +02:00
// Filtered by pagenumber, amount of items per page and sorted by date/position
/*
array(
0 => Page Object,
1 => Page Object,
...
N => Page Object
)
*/
2017-05-09 00:24:15 +02:00
$pages = array();
2017-07-13 00:44:39 +02:00
// Array with pages, each page is a Page Object
// Filtered by pagenumber and amount of items per page
/*
array(
"pageKey1" => Page Object,
"pageKey2" => Page Object,
...
"pageKeyN" => Page Object,
)
*/
$pagesByKey = 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-13 00:44:39 +02:00
// Sorted by position or date
2017-07-10 23:40:46 +02:00
/*
2017-07-11 23:53:53 +02:00
array(
2017-07-13 00:44:39 +02:00
PARENT => array(
0 => Page Object,
...,
N => Page Object),
"parentKey1" => array(
0 => Page Object,
...,
N => Page Object),
"parentKey2" => array(
0 => Page Object,
...,
N => Page Object),
2017-07-11 23:53:53 +02:00
...
2017-07-13 00:44:39 +02:00
"parentKeyN" => array(
0 => Page Object,
...,
N => Page Object),
2017-07-11 23:53:53 +02:00
)
2017-07-10 23:40:46 +02:00
*/
$pagesByParent = array(PARENT=>array());
2017-05-16 00:46:20 +02:00
2017-07-13 00:44:39 +02:00
// Array with pages order by parent and by key
2017-07-11 23:53:53 +02:00
/*
array(
2017-07-13 00:44:39 +02:00
PARENT => array(
"parentKey1" => Page Object,
...,
"parentKeyN" => Page Object),
"parentKey1" => array(
"childKeyA" => Page Object,
...,
"childKeyB" => Page Object),
"parentKey2" => array(
"childKeyJ" => Page Object,
...,
"childKeyO" => Page Object),
2017-07-11 23:53:53 +02:00
...
2017-07-13 00:44:39 +02:00
"parentKeyN" => array(
"childKeyW" => Page Object,
...,
"childKeyZ" => Page Object),
2017-07-11 23:53:53 +02:00
)
*/
2017-07-13 00:44:39 +02:00
$pagesByParentByKey = array(PARENT=>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-13 00:44:39 +02:00
// Generate pages parent tree, only published pages
2017-07-23 00:25:20 +02:00
buildPagesByParent(true);
2017-07-13 00:44:39 +02:00
// Set home page is the user defined one
2017-07-11 23:53:53 +02:00
if( $Site->homepage() && $Url->whereAmI()==='home' ) {
2017-07-13 00:44:39 +02:00
$pageKey = $Site->homepage();
if( $dbPages->exists($pageKey) ) {
$Url->setSlug($pageKey);
$Url->setWhereAmI('page');
}
2017-07-11 23:53:53 +02:00
}
2017-05-09 00:24:15 +02:00
// Build specific page
if( $Url->whereAmI()==='page' ) {
buildThePage();
2017-05-09 00:24:15 +02:00
}
// Build pages by tag
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
}
// Build pages by category
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
}
// Build pages for the homepage
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
}
// Build pages for the admin area
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-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');
$Url->setHttpCode(404);
$page = $Page = buildPage('error');
if ($page===false) {
$page = buildErrorPage();
}
2017-06-25 22:54:59 +02:00
$pages[0] = $page;
2017-05-09 00:24:15 +02:00
}