コード例 #1
0
ファイル: dispatcher.php プロジェクト: tmaiaroto/li3_perf
                if (in_array($library, $li3_perf['skip']['library'])) {
                    $skip = true;
                }
            }
            // Check to see if the toolbar should be shown for this controller
            if (isset($li3_perf['skip']['controller'])) {
                if (in_array($controller, $li3_perf['skip']['controller'])) {
                    $skip = true;
                }
            }
            // Check to see if the toolbar should be shown for this action
            if (isset($li3_perf['skip']['action'])) {
                if (in_array($action, $li3_perf['skip']['action'])) {
                    $skip = true;
                }
            }
        }
        if ($skip || !isset($result->body[0])) {
            return $result;
        }
        $timers = Data::get('timers') + array('li3_perf_start' => 0, 'li3_perf_end' => 0, 'li3_perf_start_dispatch' => 0, 'li3_perf_has_route' => 0, 'li3_perf_start_call' => 0, 'li3_perf_end_call' => 0, '_filter_for_variables' => 0, '_filter_for_queries' => 0);
        $View = new View(array('paths' => array('template' => '{:library}/views/elements/{:template}.{:type}.php', 'layout' => '{:library}/views/layouts/{:layout}.{:type}.php')));
        $toolbar = $View->render('all', array('timers' => $timers += array('dispatch_cycle' => $timers['li3_perf_end'] - $timers['li3_perf_start_dispatch'], 'routing' => $timers['li3_perf_has_route'] - $timers['li3_perf_start_dispatch'], 'call' => isset($timers['li3_perf_end_call']) && isset($timers['li3_perf_start_call']) ? $timers['li3_perf_end_call'] - $timers['li3_perf_start_call'] : 0, 'complete_load_with_li3_perf' => microtime(true) - $timers['li3_perf_start'], 'complete_load' => $timers['li3_perf_end'] - $timers['li3_perf_start'] - $timers['_filter_for_variables'] - $timers['_filter_for_queries']), 'vars' => array('request' => $params['request']->params, 'view' => Data::get('view_vars')), 'queries' => Data::get('queries')), array('library' => 'li3_perf', 'template' => 'toolbar', 'layout' => 'default'));
        if (preg_match('/<!--\\s*LI3_PERF_TOOLBAR\\s*-->/si', $result->body[0], $match)) {
            $result->body[0] = str_replace($match[0], $toolbar, $result->body[0]);
        } else {
            $result->body[0] = $toolbar . $result->body[0];
        }
    }
    return $result;
});