<?php
require 'settings.php';
require $GLOBALS['library'].'precheck.php';
require $GLOBALS['library'].'Timer.php'; // Debug
function_exists('require_once_path') or require $GLOBALS['library'].'requirepath.php';
Timer::start();
/**
* Try to produce a nice output...
*/
try
{
require_once_path($GLOBALS['library'].'autoload/');
set_error_handler(array('Mocovi', 'errorHandler'));
$header = Header::getInstance(); // Event Listener
$out = new String();
EventHandler::observe('write', get_class($out), $header);
Framework::autosensing();
// Domain specific content
$GLOBALS['filesystem'] = FSFactory::load
(
( is_file($GLOBALS['filesystemDefinition']->path) // domain model available ?
? $GLOBALS['filesystemDefinition']->path // choose domain model
: $GLOBALS['filesystemDefinition']->default // otherwise the default model
)
, $GLOBALS['filesystemDefinition']->type
);
$GLOBALS['defaulttheme'] = $GLOBALS['filesystem']->getDefaultTheme();
$GLOBALS['defaultmedia'] = $GLOBALS['filesystem']->getDefaultMedia();
$GLOBALS['defaultcharset'] = Charsets::UTF_8;
$GLOBALS['header'] = $header;
$GLOBALS['page'] = isset($_GET['menu']) && strlen($_GET['menu']) > 0 ? $_GET['menu'] : $GLOBALS['defaultpage'];
$GLOBALS['media'] = isset($_GET['media']) && strlen($_GET['media']) > 0 ? $_GET['media'] : $GLOBALS['defaultmedia'];
$GLOBALS['path'] = sprintf($GLOBALS['pathformat'], $GLOBALS['basepath'], $GLOBALS['linkprefix'], $GLOBALS['page'], $GLOBALS['media']);
if(isset($_GET['language']) && strlen($_GET['language']) > 0)
$GLOBALS['language'] = $_GET['language']; // user defined language
else
$GLOBALS['language'] = Translator::getPreferredLanguage(); // preferred language from filesystem
if(isset($_GET['theme']) && strlen($_GET['theme']) > 0)
$GLOBALS['theme'] = $_GET['theme']; // user defined theme
elseif($theme = $GLOBALS['filesystem']->getTheme($GLOBALS['page']))
$GLOBALS['theme'] = $theme; // theme from filesystem
else
$GLOBALS['theme'] = $GLOBALS['defaulttheme']; // default theme
$mvc = new MvcFactory();
$out->append // Output
( $mvc
->model($GLOBALS['filesystem']->getModel($GLOBALS['page']))
->view
( array
( 'media' => &$GLOBALS['media']
, 'theme' => &$GLOBALS['theme']
)
)
->build()
);
// <Debug>
Timer::stop('After building the site.');
Timer::$currentPage = $GLOBALS['page']; // Needed for file dumping
$timevalues = Timer::getValues();
if(in_array($GLOBALS['media'], array('html', 'rss', 'sitemap')))
$out->append
( '<!-- powered by mocovi v'.Mocovi::version.' -->'.PHP_EOL
//. '<!--'.PHP_EOL.Timer::getValuesFormated(4).PHP_EOL.'-->'.PHP_EOL
. '<!-- rendered in: '.end($timevalues).' seconds -->'
);
//</Debug>
echo $out;
exit(0);
}
/**
* End of the normal procedure.
*
*...otherwise catch Exceptions.
*/
catch(Exception $e)
{
if(is_file($file = get_class($e)))
require('mocovi/exceptionpages/'.$file.'.html');
else
require('mocovi/exceptionpages/Exception.html');
}