Zikula_Template_Plugins
[ class tree: Zikula_Template_Plugins ] [ index: Zikula_Template_Plugins ] [ all elements ]

Source for file function.pagerendertime.php

Documentation is available at function.pagerendertime.php

  1. <?php
  2. /**
  3.  * Zikula Application Framework
  4.  *
  5.  * @copyright (c) 2004, Zikula Development Team
  6.  * @link http://www.zikula.org
  7.  * @version $Id: function.pagerendertime.php 24342 2008-06-06 12:03:14Z markwest $
  8.  * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
  9.  * @package Zikula_Template_Plugins
  10.  * @subpackage Functions
  11.  */
  12.  
  13. /**
  14.  * Smarty function to get the site's page render time
  15.  *
  16.  * available parameters:
  17.  *  - assign      if set, the message will be assigned to this variable
  18.  *  - round       if the, the time will be rounded to this number of decimal places
  19.  *                (optional: default 2)
  20.  *
  21.  * Example
  22.  * <!--[pagerendertime]--> outputs 'Page created in 0.18122792243958 seconds.'
  23.  *
  24.  * <!--[pagerendertime round=2]--> outputs 'Page created in 0.18 seconds.'
  25.  *
  26.  * @author   Mark West
  27.  * @since    08/02/04
  28.  * @param    array    $params     All attributes passed to this function from the template
  29.  * @param    object   $smarty     Reference to the Smarty object
  30.  * @param    string   $round      format to apply to the number (based on the round php function)
  31.  * @return   string   the page render time in seconds
  32.  */
  33. function smarty_function_pagerendertime($params&$smarty)
  34. {
  35.     // show time to render
  36.     if ($GLOBALS['PNConfig']['Debug']['pagerendertime']){
  37.         // calcultate time to render
  38.         $mtime explode(' ',microtime());
  39.         $dbg_endtime $mtime[1$mtime[0];
  40.         $dbg_totaltime ($dbg_endtime $GLOBALS['PNRuntime']['dbg_starttime']);
  41.  
  42.         // log time to render
  43.         if ($GLOBALS['PNConfig']['Debug']['debug']){
  44.             $GLOBALS['PNRuntime']['dbg']->v($dbg_totaltime,"Page created in (seconds)");
  45.         }
  46.  
  47.         $round = isset($params['round']$params['round'2;
  48.         $dbg_totaltime round($dbg_totaltime$round);
  49.  
  50.         if (isset($params['assign'])) {
  51.             $smarty->assign('rendertime'$dbg_totaltime);
  52.         else {
  53.             // load language files
  54.             pnModLangLoad('themes''userapi');
  55.             $message '<div class="pn-sub" style="text-align:center;">' pnML('_THEME_PAGECREATEDINSECONDS'array('sec' => $dbg_totaltime)) '</div>';
  56.             return $message;
  57.         }
  58.     }
  59. }

Documentation generated on Fri, 18 Jul 2008 21:45:34 +0200 by phpDocumentor 1.4.1