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

81 lines
1.8 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
// ============================================================================
2015-10-31 19:54:42 -03:00
// Array with all pages.
2015-03-08 14:02:59 -03:00
$pages = array();
2015-10-31 19:54:42 -03:00
2016-09-21 23:03:30 -03:00
// Array with all published pages, order by position.
2016-05-28 00:18:13 -03:00
$pagesPublished = array();
2015-10-31 19:54:42 -03:00
// Array with all pages, order by parent.
2016-09-21 23:03:30 -03:00
// array = {
// NO_PARENT_CHAR => array(), all pages parents
// PageParent1 => array(), all children of the parent1
// ... => array(), all children of the parent...
// PageParent9 => array(), all children of the parent9
// }
2015-05-05 01:00:01 +00:00
$pagesParents = array(NO_PARENT_CHAR=>array());
2015-03-08 14:02:59 -03:00
2016-09-20 23:17:45 -03:00
// Array with all published pages, ordery by parent.
2016-05-28 00:18:13 -03:00
$pagesParentsPublished = array();
2016-09-20 23:17:45 -03:00
// Array with all published parent pages
$parents = array();
2015-06-26 19:12:26 -03:00
// ============================================================================
// Main
// ============================================================================
2015-09-09 23:33:31 -03:00
// Search for changes on pages by the user.
2016-05-07 00:10:10 -03:00
if( CLI_MODE ) {
$dbPages->cliMode();
2015-09-09 23:33:31 -03:00
}
2016-01-08 17:12:17 -03:00
// Build specific page.
2015-03-08 14:02:59 -03:00
if( ($Url->whereAmI()==='page') && ($Url->notFound()===false) )
{
2016-01-07 20:43:09 -03:00
$Page = buildPage( $Url->slug() );
2015-03-08 14:02:59 -03:00
2016-01-08 17:12:17 -03:00
// The page doesn't exist.
2015-03-08 14:02:59 -03:00
if($Page===false)
{
$Url->setNotFound(true);
unset($Page);
}
2016-01-08 17:12:17 -03:00
// The page is not published yet.
2015-03-08 14:02:59 -03:00
elseif( !$Page->published() )
{
$Url->setNotFound(true);
unset($Page);
}
}
2016-01-08 17:12:17 -03:00
// Homepage
if( ($Url->whereAmI()==='home') && ($Url->notFound()===false) )
2015-03-08 14:02:59 -03:00
{
2016-01-08 17:12:17 -03:00
// The user defined as homepage a particular page.
if( Text::isNotEmpty( $Site->homepage() ) )
2015-03-08 14:02:59 -03:00
{
$Url->setWhereAmI('page');
2016-01-07 20:43:09 -03:00
$Page = buildPage( $Site->homepage() );
2015-05-05 01:00:01 +00:00
2015-08-13 22:36:03 -03:00
if($Page===false) {
2015-03-08 14:02:59 -03:00
$Url->setWhereAmI('home');
}
}
}
2015-06-02 22:17:09 -03:00
if($Url->notFound())
{
$Url->setWhereAmI('page');
$Page = new Page('error');
}
2015-03-08 14:02:59 -03:00
// Build all pages
2016-01-07 21:00:40 -03:00
$pages = buildAllPages();
2016-05-28 00:18:13 -03:00