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

150 lines
3.2 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-10-04 23:42:14 +02:00
$content = $pages = array();
2017-05-09 00:24:15 +02:00
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
// Array with static content, each item is a Page Object
// Order by position
/*
array(
0 => Page Object,
1 => Page Object,
...
N => Page Object
)
*/
2017-10-13 00:15:13 +02:00
$staticContent = $staticPages = buildStaticPages();
2017-10-04 23:42:14 +02:00
2017-05-09 00:24:15 +02:00
// ============================================================================
// Main
// ============================================================================
// Execute the scheduler
2017-07-30 23:15:33 +02:00
if ($dbPages->scheduler()) {
2017-05-09 00:24:15 +02:00
// Reindex tags
reindexTags();
// Reindex categories
reindexCategories();
2017-06-23 00:41:00 +02:00
// Add to syslog
$Syslog->add(array(
2017-10-04 00:00:54 +02:00
'dictionaryKey'=>'content-published-from-scheduler',
2017-06-23 00:41:00 +02:00
'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-30 23:15:33 +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
}
// The filter blog alway show all the content
// Change the where am i to use
if ($Url->whereAmI()==='blog') {
//$Url->setWhereAmI('home');
}
2017-05-09 00:24:15 +02:00
// Build specific page
2017-07-30 23:15:33 +02:00
if ($Url->whereAmI()==='page') {
buildThePage();
2017-05-09 00:24:15 +02:00
}
// Build pages by tag
2017-07-30 23:15:33 +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-07-30 23:15:33 +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
elseif ( ($Url->whereAmI()==='home') || ($Url->whereAmI()==='blog') ) {
2017-05-16 00:46:20 +02:00
buildPagesForHome();
2017-05-09 00:24:15 +02:00
}
if (isset($pages[0])) {
$page = $Page = $pages[0];
}
2017-05-24 00:48:29 +02:00
// Set page 404 not found
2017-07-30 23:15:33 +02:00
if ($Url->notFound()) {
2017-09-21 20:42:03 +02:00
$pageNotFoundKey = $Site->pageNotFound();
$page = buildPage( $pageNotFoundKey );
if ($page===false) {
$page = buildErrorPage();
}
2017-10-04 23:42:14 +02:00
$content[0] = $pages[0] = $Page = $page;
2017-05-09 00:24:15 +02:00
}