public function render() { if (Kohana::config('core.render_stats') === TRUE) { // Replace the global template variables Kohana::$output = str_replace(array('{hanami_version}', '{hanami_codename}'), array(HANAMI_VERSION, HANAMI_CODENAME), Kohana::$output); } }
/** * Kohana output handler. * * @param string current output buffer * @return string */ public static function output_buffer($output) { if (!Event::has_run('system.send_headers')) { // Run the send_headers event, specifically for cookies being set Event::run('system.send_headers'); } // Set final output self::$output = $output; // Set and return the final output return $output; }
/** * Kohana output handler. Called during ob_clean, ob_flush, and their variants. * * @param string current output buffer * @return string */ public static function output_buffer($output) { // Could be flushing, so send headers first if (!Event::has_run('system.send_headers')) { // Run the send_headers event Event::run('system.send_headers'); } self::$output = $output; // Set and return the final output return self::$output; }
/** * Prevent any output from being displayed. Executed during system.display. * * @return void */ public static function prevent_output() { Kohana::$output = ''; }
/** * Render the profiler. Output is added to the bottom of the page by default. * * @param boolean return the output if TRUE * @return void|string */ public function render($return = FALSE) { $start = microtime(TRUE); $get = isset($_GET['profiler']) ? explode(',', $_GET['profiler']) : array(); $this->show = empty($get) ? Kohana::config('profiler.show') : $get; Event::run('profiler.run', $this); $styles = ''; foreach ($this->profiles as $profile) { $styles .= $profile->styles(); } // Don't display if there's no profiles if (empty($this->profiles)) { return; } // Load the profiler view $data = array('profiles' => $this->profiles, 'styles' => $styles, 'execution_time' => microtime(TRUE) - $start); $view = new View('kohana_profiler', $data); // Return rendered view if $return is TRUE if ($return == TRUE) { return $view->render(); } // Add profiler data to the output if (stripos(Kohana::$output, '</body>') !== FALSE) { // Closing body tag was found, insert the profiler data before it Kohana::$output = str_ireplace('</body>', $view->render() . '</body>', Kohana::$output); } else { // Append the profiler data to the output Kohana::$output .= $view->render(); } }