public function render()
{
global $g_errorList;
$themesService = \Zend_Registry::get('container')->getService('newscoop_newscoop.themes_service');
$errors = array();
if (array_key_exists('controller', $GLOBALS)) {
$errors = $GLOBALS['controller']->getRequest()->getParam('errors', null);
}
$uri = self::GetURIInstance();
$document = self::GetHTMLDocumentInstance();
$context = CampTemplate::singleton()->context();
// sets the appropiate template if site is not in mode online
if ($this->getSetting('site.online') == 'N') {
$templates_dir = CS_TEMPLATES_DIR . DIR_SEP . CS_SYS_TEMPLATES_DIR;
$template = '_campsite_offline.tpl';
} elseif (!$uri->publication->defined) {
$templates_dir = CS_TEMPLATES_DIR . DIR_SEP . CS_SYS_TEMPLATES_DIR;
$template = '_campsite_error.tpl';
$error_message = 'The site alias \'' . $_SERVER['HTTP_HOST'] . '\' was not assigned to a publication. Please create a publication and ' . ' assign it the current site alias.';
} elseif (is_array($g_errorList) && !empty($g_errorList)) {
$templates_dir = CS_TEMPLATES_DIR . DIR_SEP . CS_SYS_TEMPLATES_DIR;
$template = '_campsite_error.tpl';
$error_message = 'At initialization: ' . $g_errorList[0]->getMessage();
} elseif (!empty($errors)) {
$templates_dir = CS_TEMPLATES_DIR . DIR_SEP . CS_SYS_TEMPLATES_DIR;
$template = '_campsite_error.tpl';
if (defined('APPLICATION_ENV') && APPLICATION_ENV == 'development') {
$error_message = $errors->exception;
} else {
$error_message = 'Error occurred.';
}
} else {
$template = $uri->getTemplate(CampRequest::GetVar(CampRequest::TEMPLATE_ID));
switch ($template) {
case null:
$error_message = "Unable to select a template! " . "Please make sure the following conditions are met:\n" . "<li>there is at least one issue published and it had assigned " . "valid templates for the front, section and article pages;</li>\n" . "<li>a template was assigned for the URL error handling in " . "the publication configuration screen.";
$templates_dir = CS_TEMPLATES_DIR . DIR_SEP . CS_SYS_TEMPLATES_DIR;
$template = '_campsite_error.tpl';
break;
default:
$themePath = $themesService->getThemePath();
$templates_dir = CS_TEMPLATES_DIR . DIR_SEP . $themePath;
}
}
$params = array('context' => $context, 'template' => $template, 'templates_dir' => $templates_dir, 'error_message' => isset($error_message) ? $error_message : null);
$document->render($params);
}