public function executeFilter(HttpRequestInterface $request, HttpResponseInterface $response) { // webdebug must be enabled in configuration if (isset($this->config['error']['webdebug']) and $this->config['error']['webdebug'] == 1) { return; } // DEBUG mode must be on if (defined('DEBUG') and DEBUG == true) { return; } /** * ================================================ * Initialize PHP_Debug Web-Debugging Console * ================================================ */ // Additional ini path for PHPDEBUG define('ADD_PHPDEBUG_ROOT', ROOT_LIBRARIES . 'phpdebug'); set_include_path(ADD_PHPDEBUG_ROOT . PATH_SEPARATOR . get_include_path()); // Load Library if (false === class_exists('PHP_Debug', false)) { include ROOT_LIBRARIES . 'phpdebug/PHP/Debug.php'; } // Setup Options for the PHPDebug Object $options = array('render_type' => 'HTML', 'render_mode' => 'div', 'restrict_access' => false, 'allow_url_access' => true, 'url_key' => 'key', 'url_pass' => 'nounou', 'enable_watch' => true, 'replace_errorhandler' => true, 'lang' => 'EN', 'HTML_DIV_view_source_script_name' => ROOT . 'libraries/phpdebug/PHP_Debug_ShowSource.php', 'HTML_DIV_images_path' => WWW_ROOT . 'libraries/phpdebug/images', 'HTML_DIV_css_path' => WWW_ROOT . 'libraries/phpdebug/css', 'HTML_DIV_js_path' => WWW_ROOT . 'libraries/phpdebug/js', 'HTML_DIV_remove_templates_pattern' => true); // Initialiaze Object $debug = new PHP_Debug($options); // Set Title to Debug Console $debug->add('Koch Framework DEBUG INFO'); /** * Load JS / CSS for PHP Debug Console into the Output Buffer */ $html = '<script type="text/javascript" src="' . $options['HTML_DIV_js_path'] . '/html_div.js"></script>'; $html .= '<link rel="stylesheet" type="text/css" media="screen" href="' . $options['HTML_DIV_css_path'] . '/html_div.css" />'; unset($options); // combine the html output $debugbarHTML = $html . $debug->getOutput(); // push output into event object $event = new DebugConsoleResponse_Event($debugbarHTML); // and output the debugging console at the end of the application runtime Koch_Eventdispatcher::instantiate()->addEventHandler('onApplicationShutdown', $event); }
/** * Registers multiple Events by Name * * @param array $events_array eventname => filename * @param array $event_objects eventname => object */ public static function loadEventHandlers($events) { if (empty($events) or is_array($events) === false) { return; } else { // ok, we got an array with some event names foreach ($events as $event) { // array[0] filename $filename = $array[0]; // array[1] classname $classname = Koch_Functions::ensurePrefixedWith($array[1], 'Koch_Event_'); // load eventhandler Koch_Loader::requireFile($filename, $classname); // instantiate eventhandler $event_object = new $classname(); // add the eventhandler to the dispatcher $eventdispatcher = Koch_Eventdispatcher::instantiate(); $eventdispatcher->addEventHandler($event, $event_object); } } }
/** * Name: triggerevent * Type: function * Purpose: This TAG is acts a trigger to an possibly registered event for the eventname $name. * * @example * {triggerEvent name="onRenderXY"} * * @param $params mixed $params['name'] the eventname * @param Smarty $smarty * @return string */ function smarty_function_triggerevent($params, $smarty) { // we need an valid eventname to trigger it if (empty($params['name'])) { trigger_error("name: Please add an event name."); return; } // @todo consider passing smarty or more template infos as context to the event $context = array(); $context['params'] = $params; // pass the modulename as info $info = array(); $info['modulename'] = Koch_Module_Controller_Resolver::getModuleName(); /** * direct return to the template * this implies that events should generate HTML output * or just transform the $context for the later occuring rendering process * @see todo at context above */ return Koch_Eventdispatcher::instantiate()->triggerEvent($params['name'], $context, $info); }