CampSite::render PHP Method

render() public method

Displays the site.
public render ( ) : void
return void
    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);
    }

Usage Example

コード例 #1
0
 public function indexAction()
 {
     global $controller;
     $controller = $this;
     require_once $GLOBALS['g_campsiteDir'] . DIRECTORY_SEPARATOR . 'include' . DIRECTORY_SEPARATOR . 'campsite_constants.php';
     require_once CS_PATH_CONFIG . DIR_SEP . 'install_conf.php';
     $local_path = dirname(__FILE__) . '/include';
     set_include_path($local_path . PATH_SEPARATOR . get_include_path());
     require_once CS_PATH_INCLUDES . DIR_SEP . 'campsite_init.php';
     // initializes the campsite object
     $campsite = new CampSite();
     // loads site configuration settings
     $campsite->loadConfiguration(CS_PATH_CONFIG . DIR_SEP . 'configuration.php');
     // starts the session
     $campsite->initSession();
     // initiates the context
     $campsite->init();
     // dispatches campsite
     $campsite->dispatch();
     if (APPLICATION_ENV !== 'development' || APPLICATION_ENV !== 'dev') {
         set_error_handler(create_function('', 'return true;'));
     }
     // renders the site
     $campsite->render();
     // triggers an event after displaying
     $campsite->event('afterRender');
 }
All Usage Examples Of CampSite::render