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

Source for file function.pndebug.php

Documentation is available at function.pndebug.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.pndebug.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 display a Zikula specific debug window
  15.  *
  16.  * This function shows a Zikula debug window if the user has sufficient access rights
  17.  *
  18.  * You need to have:
  19.  * modulename::debug     .*     ACCESS_ADMIN
  20.  * permission to see this.
  21.  *
  22.  *
  23.  * Example
  24.  *   <!--[ pndebug ]-->
  25.  *
  26.  *
  27.  * @author       Frank Schummertz
  28.  * @since        23/08/2004
  29.  * @param        array       $params      All attributes passed to this function from the template
  30.  * @param        object      &$smarty     Reference to the Smarty object
  31.  * @param        string      $output      if html, show debug in rendered page, otherwise open popup window
  32.  * @param        string      $template    specify different debug template, default pndebug.html,
  33.  *                                         must be stored in pnRender/pntemplates
  34.  * @return       string      debug output
  35.  *
  36.  *  This plugin is basing on the original debug plugin written by Monte Ohrt <monte@ispi.net>
  37.  */
  38. function smarty_function_pndebug($params&$smarty)
  39. {
  40.     $out '';
  41.     $thismodule pnModGetName();
  42.     if (SecurityUtil::checkPermission($thismodule.'::debug''::'ACCESS_ADMIN)) {
  43.         // load language file
  44.         pnModLangLoad('pnRender''pndebug');
  45.         
  46.         if (isset($params['output']&& !empty($params['output'])) {
  47.             $smarty->assign('_smarty_debug_output',$params['output']);
  48.         }
  49.         
  50.         $modinfo pnModGetInfo(pnModGetIDFromName('pnRender'));
  51.         $modpath ($modinfo['type'== 3'system' 'modules';
  52.         $osmoddir DataUtil::formatForOS($modinfo['directory']);
  53.  
  54.         $_template_dir_orig $smarty->template_dir;
  55.         $_default_resource_type_orig $smarty->default_resource_type;
  56.  
  57.         $smarty->template_dir "$modpath/$osmoddir/pntemplates";
  58.         $smarty->default_resource_type 'file';
  59.         $smarty->_plugins['outputfilter'null;
  60.  
  61.         if (isset($params['template']&& !empty($params['template'])) {
  62.             $debug_tpl $smarty->template_dir '/' $params['template'];
  63.             if (file_exists($debug_tpl&& is_readable($debug_tpl)) {
  64.                 $smarty->debug_tpl $params['template'];
  65.             }
  66.         else {
  67.             $smarty->debug_tpl "pndebug.html";
  68.         }
  69.  
  70.         if ($smarty->security && is_file($smarty->debug_tpl)) {
  71.             $smarty->secure_dir[dirname(realpath($smarty->debug_tpl));
  72.         }
  73.  
  74.         $_compile_id_orig $smarty->_compile_id;
  75.         $smarty->_compile_id null;
  76.  
  77.         $_compile_path $smarty->_get_compile_path($smarty->debug_tpl);
  78.         if ($smarty->_compile_resource($smarty->debug_tpl$_compile_path)) {
  79.             ob_start();
  80.             $smarty->_include($_compile_path);
  81.             $out ob_get_contents();
  82.             ob_end_clean();
  83.         }
  84.  
  85.         $smarty->_compile_id $_compile_id_orig;
  86.         $smarty->template_dir $_template_dir_orig;
  87.         $smarty->default_resource_type $_default_resource_type_orig;
  88.     }
  89.     return $out;
  90. }

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