CampSite::event PHP Method

event() public method

public event ( string $p_eventName )
$p_eventName string
    public function event($p_eventName)
    {
        $preview = CampTemplate::singleton()->context()->preview;
        switch ($p_eventName) {
            case 'beforeRender':
                return $preview ? CampRequest::GetVar('previewLang', null) : null;
            case 'afterRender':
                if ($preview) {
                    $errorList = '';
                    foreach ($GLOBALS['g_errorList'] as $error) {
                        $errorList = $errorList . '<p>' . addslashes($error->getMessage()) . '</p>';
                    }
                    ?>
                        <script>
                            parent.e.document.getElementById('error_count').innerHTML = '<?php 
                    echo count($GLOBALS['g_errorList']);
                    ?>
';
                            parent.e.document.getElementById('error_list').innerHTML = '<?php 
                    echo $errorList;
                    ?>
';
                        </script>
                    <?php 
                }
                break;
        }
    }

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::event