Esempio n. 1
0
function show_load_time($layout)
{
    $layout .= '<style type="text/css">
				div.cms_debug{
				background-color: white;
				position: fixed;
				bottom:0;
				-moz-box-shadow:0 -1px 4px #000;
				box-shadow:0 -1px 4px #000;
				-webkit-box-shadow:0 -1px 4px #000;
				padding: 2px 4px 0 4px;
				left:10px;
				opacity:0.3;
			}
			div.cms_debug:hover{
				opacity:1;
			}
		</style>';
    Benchmark::stop('Load Time');
    $layout .= '<div class="cms_debug">';
    foreach (Benchmark::get_totals() as $total) {
        $layout .= $total . '<br>';
    }
    $layout .= '</div>';
}
Esempio n. 2
0
 public static function render($print = false)
 {
     Benchmark::start(self::$benchmark_name);
     $template = new View('toolbar');
     if (Kohana::config('debug_toolbar.panels.database')) {
         $template->set('queries', self::queries());
     }
     if (Kohana::config('debug_toolbar.panels.logs')) {
         $template->set('logs', self::logs());
     }
     if (Kohana::config('debug_toolbar.panels.vars_and_config')) {
         $template->set('configs', self::configs());
     }
     if (Kohana::config('debug_toolbar.panels.files')) {
         $template->set('files', self::files());
     }
     if (Kohana::config('debug_toolbar.firephp_enabled')) {
         self::firephp();
     }
     switch (Kohana::config('debug_toolbar.align')) {
         case 'right':
         case 'center':
         case 'left':
             $template->set('align', Kohana::config('debug_toolbar.align'));
             break;
         default:
             $template->set('align', 'left');
     }
     $template->set('scripts', file_get_contents(Kohana::find_file('views', 'toolbar', true, 'js')));
     Benchmark::stop(self::$benchmark_name);
     if (Kohana::config('debug_toolbar.panels.benchmarks')) {
         $template->set('benchmarks', self::benchmarks());
     }
     if (Event::$data) {
         if (Kohana::config('debug_toolbar.auto_render') or Kohana::config('debug_toolbar.secret_key') !== FALSE and isset($_GET[Kohana::config('debug_toolbar.secret_key')])) {
             // try to add css to <head>, otherwise, send to template
             $styles = file_get_contents(Kohana::find_file('views', 'toolbar', false, 'css'));
             if (stripos(Event::$data, '</head>') !== FALSE) {
                 Event::$data = str_ireplace('</head>', $styles . '</head>', Event::$data);
             } else {
                 $template->set('styles', $styles);
             }
             // try to add js and HTML just before the </body> tag,
             // otherwise just append it to the output
             if (stripos(Event::$data, '</body>') !== FALSE) {
                 Event::$data = str_ireplace('</body>', $template->render() . '</body>', Event::$data);
             } else {
                 Event::$data .= $template->render();
             }
         }
     } else {
         if ($print) {
             $template->render(TRUE);
         } else {
             return $template->render();
         }
     }
 }
Esempio n. 3
0
 public function add_as_author_of(User_Model $author, ORM $object)
 {
     if ($this->is_possible_to_add_authors_to($object)) {
         Benchmark::start('add_as_author_of');
         try {
             $database = new Database();
             $database->from('workshop_data');
             $database->set(array('object_name' => $object->object_name, 'user_id' => $author->id, 'object_id' => $object->id));
             $database->insert();
         } catch (Kohana_Database_Exception $e) {
             if (strstr($e->getMessage(), 'Duplicate entry')) {
                 throw new Workshop_Duplicate_Author_Exception($author, $object);
             } else {
                 throw $e;
             }
         }
         Benchmark::stop('add_as_author_of');
     } else {
         throw new Workshop_Max_Limit_Exception($object, $this->get_number_of_authors_of($object), 1, $this->config_delegate->max_authors_for($object));
     }
 }
Esempio n. 4
0
define('KOHANA_CODENAME', 'efímera');
// Test of Kohana is running in Windows
define('KOHANA_IS_WIN', PHP_SHLIB_SUFFIX === 'dll');
// Kohana benchmarks are prefixed to prevent collisions
define('SYSTEM_BENCHMARK', 'system_benchmark');
// Load benchmarking support
require SYSPATH . 'core/Benchmark' . EXT;
// Start total_execution
Benchmark::start(SYSTEM_BENCHMARK . '_total_execution');
// Start kohana_loading
Benchmark::start(SYSTEM_BENCHMARK . '_kohana_loading');
// Load core files
require SYSPATH . 'core/utf8' . EXT;
require SYSPATH . 'core/Event' . EXT;
require SYSPATH . 'core/Kohana' . EXT;
// Prepare the environment
Kohana::setup();
// End kohana_loading
Benchmark::stop(SYSTEM_BENCHMARK . '_kohana_loading');
// Start system_initialization
Benchmark::start(SYSTEM_BENCHMARK . '_system_initialization');
// Prepare the system
Event::run('system.ready');
// Determine routing
Event::run('system.routing');
// End system_initialization
Benchmark::stop(SYSTEM_BENCHMARK . '_system_initialization');
// Make the magic happen!
Event::run('system.execute');
// Clean up and exit
Event::run('system.shutdown');
Esempio n. 5
0
 private function echo_formatted_data($data, $datatype)
 {
     Benchmark::start('echo_formatted_data');
     switch (strtolower($datatype)) {
         case 'json':
             header('Content-type: application/json');
             $json = json_encode($data);
             $callback = $this->input->get('jsonp_callback');
             if ($callback) {
                 echo $callback . '(' . $json . ');';
             } else {
                 echo $json;
             }
             break;
         case 'xml':
             header('Content-type: application/xml');
             $xml = '<?xml version="1.0" encoding="UTF-8"?><result></result>';
             $xml = simplexml_load_string($xml);
             $this->create_xml_object($xml, $data);
             $dom = new DOMDocument('1.0');
             $dom->preserveWhiteSpace = false;
             $dom->formatOutput = true;
             $dom->loadXML($xml->asXML());
             echo $dom->saveXML();
             break;
         default:
             throw new Kohana_404_Exception();
             break;
     }
     Benchmark::stop('echo_formatted_data');
 }
Esempio n. 6
0
 private function echo_formatted_data($data, $datatype)
 {
     Benchmark::start('echo_formatted_data');
     switch (strtolower($datatype)) {
         case 'json':
             header('Content-type: application/json');
             $json = json_encode($data);
             $callback = $this->input->get('jsonp_callback');
             if ($callback) {
                 echo $callback . '(' . $json . ');';
             } else {
                 echo $json;
             }
             break;
         case 'xml':
             header('Content-type: application/xml');
             $xml = '<?xml version="1.0" encoding="UTF-8"?><result></result>';
             $xml = simplexml_load_string($xml);
             $this->create_xml_object($xml, $data);
             $dom = new DOMDocument('1.0');
             $dom->preserveWhiteSpace = false;
             $dom->formatOutput = true;
             $dom->loadXML($xml->asXML());
             echo $dom->saveXML();
             break;
         case 'csv':
             header('Content-type: text/csv');
             $outstream = fopen("php://output", 'w');
             if (!isset($data[0])) {
                 $data = current($data);
             }
             $firstElm = current($data);
             if (!isset($firstElm[0])) {
                 fputcsv($outstream, array_keys(get_object_vars(current(current($data)))), ',', '"');
             } else {
                 fputcsv($outstream, array_keys(get_object_vars(current($data))), ',', '"');
             }
             function __outputCSV(&$vals, $key, $filehandler)
             {
                 if (!isset($vals[0])) {
                     fputcsv($filehandler, get_object_vars(current($vals)), ',', '"');
                 } else {
                     fputcsv($filehandler, get_object_vars($vals), ',', '"');
                 }
             }
             array_walk($data, '__outputCSV', $outstream);
             fclose($outstream);
             break;
         default:
             throw new Kohana_404_Exception();
             break;
     }
     Benchmark::stop('echo_formatted_data');
 }
    /**
     * Função renderizadora das views
     * @access public
     * @param String $view
     * @return void
     */
    public function render($view)
    {
        $this->loadHelpers();
        $view = $view[0] == '/' ? substr($view, 1) : 'views/' . strtolower($this->request->controller_name) . '/' . $view;
        $content = $this->template->renderPage($view . ".php");
        // Para não redenrizar layout.
        // Setar no controller: var $layout = null;
        if (!empty($this->layout)) {
            $this->add('content', $content);
            $content = $this->template->fetch('views/layouts/' . $this->layout . '.php');
        }
        echo $content;
        if (BENCHMARK) {
            echo '<style type="text/css">
					div.cms_debug{
						background-color: white;
						position: fixed;
						bottom:0;
						-moz-box-shadow:0 -1px 4px #000;
						box-shadow:0 -1px 4px #000;
						-webkit-box-shadow:0 -1px 4px #000;
						padding: 2px 4px 0 4px;
						left:10px;
						opacity:0.3;
					}
					div.cms_debug:hover{
						opacity:1;
					}
				</style>';
            Benchmark::stop('Load Time');
            echo '<div class="cms_debug">';
            foreach (Benchmark::getTotals() as $total) {
                echo $total . '<br>';
            }
            echo '</div>';
        }
        die;
        // Para garantir e não chamar 2 render.
    }
Esempio n. 8
0
 * @package    Core
 * @author     Kohana Team
 * @copyright  (c) 2007 Kohana Team
 * @license    http://kohanaphp.com/license.html
 */
define('KOHANA_VERSION', '2.3.1');
define('KOHANA_CODENAME', 'accipiter');
// Test of Kohana is running in Windows
define('KOHANA_IS_WIN', DIRECTORY_SEPARATOR === '\\');
// Kohana benchmarks are prefixed to prevent collisions
define('SYSTEM_BENCHMARK', 'system_benchmark');
// Load benchmarking support
require SYSPATH . 'core/Benchmark' . EXT;
// Start total_execution
Benchmark::start(SYSTEM_BENCHMARK . '_total_execution');
// Start kohana_loading
Benchmark::start(SYSTEM_BENCHMARK . '_kohana_loading');
// Load core files
require SYSPATH . 'core/utf8' . EXT;
require SYSPATH . 'core/Event' . EXT;
require SYSPATH . 'core/Kohana' . EXT;
// Prepare the environment
Kohana::setup();
// End kohana_loading
Benchmark::stop(SYSTEM_BENCHMARK . '_kohana_loading');
// Start system_initialization
Benchmark::start(SYSTEM_BENCHMARK . '_system_initialization');
// Prepare the system
Event::run('system.ready');
// Clean up and exit
Event::run('system.shutdown');
Esempio n. 9
0
File: t.php Progetto: bgads/adsbg
    $sql = "INSERT INTO posts (category_id, title, contents) VALUES (0, '%s', '%s')";
    for ($i = 0; $i < 5000; $i++) {
        $r = mt_rand(0, 2);
        $db->query(sprintf($sql, $records[$r]->title, $records[$r]->contents));
    }
}
if (isset($_SERVER['argv'][1]) and $_SERVER['argv'][1] == 'fill') {
    echo 'Generating test data.' . PHP_EOL;
    for ($i = 0; $i < 10; $i++) {
        fill_db();
        echo ($i + 1) * 5000 . ' records generated.' . PHP_EOL;
    }
    exit;
}
Benchmark::start('select records');
$records = $db->query('SELECT id, title, contents FROM posts')->fetchAll(PDO::FETCH_OBJ);
Benchmark::stop('select records');
Benchmark::start('index');
$data = array('title' => 'Craiglist ads', 'records' => $records);
$index = parse('index.tpl', $data);
create('index', $index);
Benchmark::stop('index');
Benchmark::start('pages');
foreach ($records as $page) {
    $data = array('page' => $page);
    $content = parse('page.tpl', $data);
    create($page->id, $content);
}
Benchmark::stop('pages');
Benchmark::stop('page');
var_dump(Benchmark::get(TRUE));
Esempio n. 10
0
 /**
  * Loads the controller and initializes it. Runs the pre_controller,
  * post_controller_constructor, and post_controller events. Triggers
  * a system.404 event when the route cannot be mapped to a controller.
  *
  * This method is benchmarked as controller_setup and controller_execution.
  *
  * @return  object  instance of controller
  */
 public static function &instance()
 {
     if (self::$instance === nil) {
         // Routing has been completed
         Event::run('system.post_routing');
         Benchmark::start(SYSTEM_BENCHMARK . '_controller_setup');
         // Log the current routing state for debugging purposes
         Eight::log('debug', 'Routing "' . Router::$current_uri . '" using the "' . Router::$current_route . '" route, ' . Router::$controller . '::' . Router::$method);
         try {
             // Start validation of the controller
             $class = new ReflectionClass('Controller_' . ucfirst(Router::$controller));
         } catch (ReflectionException $e) {
             // Controller does not exist
             Event::run('system.404');
         }
         if ($class->isAbstract() or IN_PRODUCTION and $class->getConstant('ALLOW_PRODUCTION') == FALSE) {
             // Controller is not allowed to run in production
             Event::run('system.404');
         }
         // Run system.pre_controller
         Event::run('system.pre_controller');
         // Create a new controller instance
         $controller = $class->newInstance();
         // Controller constructor has been executed
         Event::run('system.post_controller_constructor');
         try {
             // Load the controller method
             $method = $class->getMethod(Router::$method);
             // Method exists
             if (Router::$method[0] === '_') {
                 // Do not allow access to hidden methods
                 Event::run('system.404');
             }
             if ($method->isProtected() or $method->isPrivate()) {
                 // Do not attempt to invoke protected or private methods
                 throw new ReflectionException('protected controller method');
             }
             // Default arguments
             $arguments = Router::$arguments;
         } catch (ReflectionException $e) {
             // Use __call instead
             $method = $class->getMethod('__call');
             // Use arguments in __call format
             $arguments = array(Router::$method, Router::$arguments);
         }
         // Stop the controller setup benchmark
         Benchmark::stop(SYSTEM_BENCHMARK . '_controller_setup');
         // Start the controller execution benchmark
         Benchmark::start(SYSTEM_BENCHMARK . '_controller_execution');
         // We MAY want to prevent a method from running sometimes
         if (Eight::$run_method) {
             // Execute the controller method
             $method->invokeArgs($controller, $arguments);
         }
         // Controller method has been executed
         Event::run('system.post_controller');
         // Stop the controller execution benchmark
         Benchmark::stop(SYSTEM_BENCHMARK . '_controller_execution');
     }
     return Eight::$instance;
 }
Esempio n. 11
0
 /**
  * request to load controller
  */
 static function action()
 {
     // benchmark
     $benchmark = new Benchmark();
     $benchmark->start();
     $request = new Request();
     $request->setBaseUri(Application::getBaseUrl());
     // auth checkc
     if (self::$auth) {
         foreach (self::$auth as $auth) {
             $auth->check($request->getUri());
         }
     }
     $routing = new Routing();
     if (!($data = $routing::getRouleClass($request->getUri()))) {
         if ($data = $routing::getRouleClass($request->getUri() . '/')) {
             Server::redirect(Application::getBaseUrl() . $request->getUri() . '/');
         }
     }
     if (empty($data)) {
         $data = array('class' => 'core:default:error_404');
     } else {
         if ($data['class'] == '') {
             $data = array('class' => 'core:default:index');
         }
     }
     // pearse class method
     if (preg_match("/^([0-9a-zA-Z\\-_]+):([0-9a-zA-Z\\-_]+):?([0-9a-zA-Z\\-_]*)\$/", $data['class'], $matchs)) {
         $project = $matchs[1];
         $class = $matchs[2];
         $method = $matchs[3];
         $method = !empty($method) ? $method : "index";
     } else {
         throw new PMPException('Error Class Method or Class Name(`' . $data['class'] . '` is not routing find).');
     }
     $benchmark->setMark("routing");
     try {
         $path = self::$source_dir . '/' . $project;
         $filename = $path . '/conf';
         dir_include_all($filename);
         $filename = $path . '/class';
         dir_include_all($filename);
         $filename = $path . '/controller/' . $class . '.php';
         if (file_exists($filename)) {
             include_once $filename;
         } else {
             $path = dirname(__FILE__) . '/../../component';
             $filename = $path . '/controller/' . $class . '.php';
             if (file_exists($filename)) {
                 include_once $filename;
             }
         }
         $classname = $class . 'Controller';
         $controller = new $classname($path, $class, $method, $project);
         $controller->addDefaultTemplatefiles(dirname(__FILE__) . '/../../component/view/form.tpl');
         $benchmark->setMark('included');
         if (isset($data['param'])) {
             $reflection = new \ReflectionClass($controller);
             $reflection_method = $reflection->getMethod($method);
             $params = array();
             foreach ($reflection_method->getParameters() as $key => $p) {
                 if (array_key_exists($p->getName(), $data['param'])) {
                     $params[$key] = $data['param'][$p->getName()];
                 } else {
                     if ($p->isDefaultValueAvailable()) {
                         $params[$key] = $p->getDefaultValue();
                     } else {
                         throw new PMPException(sprintf('Not Found Controller Paramater %s In %s', get_class($controller) . ':' . $method, $p->getName()));
                     }
                 }
             }
             call_user_func_array(array($controller, $method), $params);
         } else {
             $controller->{$method}();
         }
         $benchmark->setMark("action");
         $benchmark->stop();
         //$benchmark->display(false);
     } catch (\Exception $e) {
         throw new PMPException($e);
     }
 }
 /**
  * Renders the Debug Toolbar
  *
  * @param bool print rendered output
  * @return string debug toolbar rendered output
  */
 public static function render($print = false)
 {
     Benchmark::start(self::$benchmark_name);
     $template = new View('toolbar');
     // Database panel
     if (Kohana::config('debug_toolbar.panels.database') === TRUE) {
         $template->set('queries', self::get_queries());
     }
     // Logs panel
     if (Kohana::config('debug_toolbar.panels.logs') === TRUE) {
         $template->set('logs', self::get_logs());
     }
     // Vars and Config panel
     if (Kohana::config('debug_toolbar.panels.vars_and_config') === TRUE) {
         $template->set('configs', self::get_configs());
     }
     // Files panel
     if (Kohana::config('debug_toolbar.panels.files') === TRUE) {
         $template->set('files', self::get_files());
     }
     // FirePHP
     if (Kohana::config('debug_toolbar.firephp_enabled') === TRUE) {
         self::firephp();
     }
     // Set alignment for toolbar
     switch (Kohana::config('debug_toolbar.align')) {
         case 'right':
         case 'center':
         case 'left':
             $template->set('align', Kohana::config('debug_toolbar.align'));
             break;
         default:
             $template->set('align', 'left');
     }
     // Javascript for toolbar
     $template->set('scripts', file_get_contents(Kohana::find_file('views', 'toolbar', TRUE, 'js')));
     // CSS for toolbar
     $styles = file_get_contents(Kohana::find_file('views', 'toolbar', FALSE, 'css'));
     Benchmark::stop(self::$benchmark_name);
     // Benchmarks panel
     if (Kohana::config('debug_toolbar.panels.benchmarks') === TRUE) {
         $template->set('benchmarks', self::get_benchmarks());
     }
     if (Event::$data and self::is_enabled()) {
         // Try to add css just before the </head> tag
         if (stripos(Event::$data, '</head>') !== FALSE) {
             Event::$data = str_ireplace('</head>', $styles . '</head>', Event::$data);
         } else {
             // No </head> tag found, append styles to output
             $template->set('styles', $styles);
         }
         // Try to add js and HTML just before the </body> tag
         if (stripos(Event::$data, '</body>') !== FALSE) {
             Event::$data = str_ireplace('</body>', $template->render() . '</body>', Event::$data);
         } else {
             // Closing <body> tag not found, just append toolbar to output
             Event::$data .= $template->render();
         }
     } else {
         $template->set('styles', $styles);
         return $template->render($print);
     }
 }
Esempio n. 13
0
 public function testBenchmarkObjectMethod()
 {
     Benchmark::__reset();
     $b = Benchmark::start($this, __METHOD__);
     $this->assertEqual($b->get_benchmark_class(), "TestBenchmark", "La classe del benchmark non corrisponde");
     $this->assertEqual($b->get_benchmark_method(), "testBenchmarkObjectMethod", "Il metodo del benchmark non corrisponde");
     $this->assertEqual($b->get_benchmark_signature(), "TestBenchmark@testBenchmarkObjectMethod");
     $this->assertFalse($b->is_finished(), "Il benchmark risulta terminato!");
     Benchmark::stop();
     $this->assertTrue($b->is_finished(), "Il benchmark non risulta terminato!");
 }
Esempio n. 14
0
 /** 
  * Destrcutor
  * 
  * Stops benchmarking
  *
  * @access	public
  *
  * @author Thorsten Schmidt
  * @date 10.08.2009
  * @version 1.0
  * @since 1.0
  */
 public function __destruct()
 {
     Benchmark::stop('GridModule Loading');
 }
Esempio n. 15
0
 /**
  * Parse the CSS
  *
  * @return string - The processes css file as a string
  * @author Anthony Short
  **/
 public static function parse_css()
 {
     # If the cache is stale or doesn't exist
     if (self::config('core.cache.mod_time') <= self::config('core.request.mod_time')) {
         # Start the timer
         Benchmark::start("parse_css");
         # Compress it before parsing
         CSS::compress(CSS::$css);
         # Import CSS files
         Import::parse();
         if (self::config('core.auto_include_mixins') === true) {
             # Import the mixins in the plugin/module folders
             Mixins::import_mixins('framework/mixins');
         }
         # Parse our css through the plugins
         foreach (self::$plugins as $plugin) {
             call_user_func(array($plugin, 'import_process'));
         }
         # Compress it before parsing
         CSS::compress(CSS::$css);
         # Parse the constants
         Constants::parse();
         foreach (self::$plugins as $plugin) {
             call_user_func(array($plugin, 'pre_process'));
         }
         # Parse the @grid
         Layout::parse_grid();
         # Replace the constants
         Constants::replace();
         # Parse @for loops
         Iteration::parse();
         foreach (self::$plugins as $plugin) {
             call_user_func(array($plugin, 'process'));
         }
         # Compress it before parsing
         CSS::compress(CSS::$css);
         # Parse the mixins
         Mixins::parse();
         # Find missing constants
         Constants::replace();
         # Compress it before parsing
         CSS::compress(CSS::$css);
         foreach (self::$plugins as $plugin) {
             call_user_func(array($plugin, 'post_process'));
         }
         # Parse the expressions
         Expression::parse();
         # Parse the nested selectors
         NestedSelectors::parse();
         # Convert all url()'s to absolute paths if required
         if (self::config('core.absolute_urls') === true) {
             CSS::convert_to_absolute_urls();
         }
         # Replaces url()'s that start with ~ to lead to the CSS directory
         CSS::replace_css_urls();
         # Add the extra string we've been storing
         CSS::$css .= CSS::$append;
         # If they want to minify it
         if (self::config('core.minify_css') === true) {
             Minify::compress();
         } else {
             CSS::pretty();
         }
         # Formatting hook
         foreach (self::$plugins as $plugin) {
             call_user_func(array($plugin, 'formatting_process'));
         }
         # Validate the CSS
         if (self::config('core.validate') === true) {
             Validate::check();
         }
         # Stop the timer...
         Benchmark::stop("parse_css");
         if (self::config('core.show_header') === TRUE) {
             CSS::$css = "/* Processed by CSScaffold on " . gmdate('r') . " in " . Benchmark::get("parse_css", "time") . " seconds */\n\n" . CSS::$css;
         }
         # Write the css file to the cache
         self::cache_write(CSS::$css);
         # Output process hook for plugins to display views.
         # Doesn't run in production mode.
         if (!IN_PRODUCTION) {
             foreach (array_merge(self::$plugins, self::$modules) as $plugin) {
                 call_user_func(array($plugin, 'output'));
             }
         }
     }
 }
Esempio n. 16
0
 /**
  * Loads the controller and initializes it. Runs the pre_controller,
  * post_controller_constructor, and post_controller events. Triggers
  * a system.404 event when the route cannot be mapped to a controller.
  *
  * This method is benchmarked as controller_setup and controller_execution.
  *
  * @return  object  instance of controller
  */
 public static function &instance()
 {
     if (self::$instance === NULL) {
         Benchmark::start(SYSTEM_BENCHMARK . '_controller_setup');
         if (Router::$method[0] === '_') {
             // Do not allow access to hidden methods
             Event::run('system.404');
         }
         // Include the Controller file
         require Router::$controller_path;
         try {
             // Start validation of the controller
             $class = new ReflectionClass(ucfirst(Router::$controller) . '_Controller');
         } catch (ReflectionException $e) {
             // Controller does not exist
             Event::run('system.404');
         }
         if ($class->isAbstract() or IN_PRODUCTION and $class->getConstant('ALLOW_PRODUCTION') == FALSE) {
             // Controller is not allowed to run in production
             Event::run('system.404');
         }
         // Run system.pre_controller
         Event::run('system.pre_controller');
         // Begin benchmark for the controller
         Benchmark::f_start(ucfirst(Router::$controller) . '_Controller');
         // Create a new controller instance
         $controller = $class->newInstance();
         // End benchmark for the controller
         Benchmark::f_stop(ucfirst(Router::$controller) . '_Controller');
         // Controller constructor has been executed
         Event::run('system.post_controller_constructor');
         try {
             // Load the controller method
             $method = $class->getMethod(Router::$method);
             if ($method->isProtected() or $method->isPrivate()) {
                 // Do not attempt to invoke protected methods
                 throw new ReflectionException('protected controller method');
             }
             // Default arguments
             $arguments = Router::$arguments;
         } catch (ReflectionException $e) {
             // Use __call instead
             $method = $class->getMethod('__call');
             // Use arguments in __call format
             $arguments = array(Router::$method, Router::$arguments);
         }
         // Stop the controller setup benchmark
         Benchmark::stop(SYSTEM_BENCHMARK . '_controller_setup');
         // Start the controller execution benchmark
         Benchmark::start(SYSTEM_BENCHMARK . '_controller_execution');
         // Execute the controller method
         $method->invokeArgs($controller, $arguments);
         // Controller method has been executed
         Event::run('system.post_controller');
         // Stop the controller execution benchmark
         Benchmark::stop(SYSTEM_BENCHMARK . '_controller_execution');
     }
     return self::$instance;
 }
Esempio n. 17
0
 public function partials()
 {
     $data = $this->templateData();
     Benchmark::start('grid');
     $grid = DataGrid_Factory::create('test');
     $grid->table->border = 1;
     for ($column = 1; $column <= count($data['head']); $column++) {
         $grid->addField('key' . $column, 'Header ' . $column);
     }
     $grid->addColumn('static data', 'Static Head');
     $template = $grid->render('partials');
     $this->view->template = $template['template'];
     Benchmark::stop('grid');
     $benchmark = Benchmark::get('grid');
     $this->view->time = $benchmark['time'];
     $this->view->partials = json_encode($template['partials']);
     $this->view->data = json_encode($this->templateData());
 }