1 <?php
defined('IN_CMS') or die('No direct access allowed.');
4 Theme helpers functions
9 function base_url($url = '') {
10 return Url
::make($url);
13 function theme_url($file = '') {
14 return Config
::get('application.base_url') . 'themes/' . Config
::get('metadata.theme') . '/' . ltrim($file, '/');
17 function current_url() {
18 return Url
::make(Request
::uri());
21 function admin_url($url = '') {
22 return Url
::make(Config
::get('application.admin_folder') . '/' . ltrim($url, '/'));
25 function search_url() {
26 return Url
::make('search');
30 return Url
::make('rss');
33 // Custom function helpers
34 function bind($page, $fn) {
35 Events
::bind($page, $fn);
38 function recieve($name = '') {
39 return Events
::call($name);
43 function is_homepage() {
44 if($itm = IoC
::resolve('page')) {
45 return $itm->id
== Config
::get('metadata.home_page');
51 function is_postspage() {
52 if($itm = IoC
::resolve('page')) {
53 return $itm->id
== Config
::get('metadata.posts_page');
60 return Config
::get('debug', false);
64 function execution_time() {
65 $miliseconds = microtime(true) - START
;
66 return round($miliseconds, 4);
70 function memory_usage() {
71 return memory_get_peak_usage(true) / 1024;
74 // database profile information
75 function db_profile() {
80 $html .= '.debug {display: none;font-size: 13px; margin-bottom: 1em;}';
81 $html .= '.debug td, .debug th {padding: 4px 6px; border-bottom: 1px solid #ddd;}';
82 $html .= '.debug th {font-weight: bold; text-align: center;}';
83 $html .= '.debug tfoot td:first-child {text-align: right;}';
86 $html .= '<table id="debug_table" class="debug">';
87 $html .= '<thead><tr><th>SQL</th><th>Bindings</th><th>Rows</th><th>Time</th></th></thead>';
91 foreach(Db
::profile() as $row) {
92 $html .= '<tr><td>' . $row['sql'] . '</td><td>' . implode(', ', $row['binds']) . '</td><td>' . $row['rows'] . '</td><td>' . $row['time'] . '</td></tr>';
93 $total +
= $row['time'];
99 $html .= '<tr><td colspan="3"><strong>Query Time</strong></td><td>' . round($total, 4) . '</td></tr>';
100 $html .= '<tr><td colspan="3"><strong>Execution Time</strong></td><td>' . execution_time() . '</td></tr>';
101 $html .= '<tr><td colspan="3"><strong>Memory Usage</strong></td><td>' . memory_usage() . 'Kb</td></tr>';