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

Source for file function.pnconfiggetvar.php

Documentation is available at function.pnconfiggetvar.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.pnconfiggetvar.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 configuration variable
  15.  *
  16.  * This function obtains a configuration variable from the Zikula system.
  17.  *
  18.  * Note that the results should be handled by the pnvarprepfordisplay or the
  19.  * pnvarprephtmldisplay modifier before being displayed.
  20.  *
  21.  *
  22.  * Available parameters:
  23.  *   - name:     The name of the config variable to obtain
  24.  *   - assign:   If set, the results are assigned to the corresponding variable instead of printed out
  25.  *
  26.  * Example
  27.  *   Welcome to <!--[pnconfiggetvar name="sitename"]-->!
  28.  *
  29.  *
  30.  * @author       Andreas Stratmann
  31.  * @since        03/05/19
  32.  * @param        array       $params      All attributes passed to this function from the template
  33.  * @param        object      &$smarty     Reference to the Smarty object
  34.  * @param        bool        $html        (optional) If true then result will be treated as html content
  35.  * @param        string      $assign      (optional) If set then result will be assigned to this template variable
  36.  * @param        string      $default     (optional) The default value to return if the config variable is not set
  37.  * @return       string      the value of the last status message posted, or void if no status message exists
  38.  */
  39. function smarty_function_pnconfiggetvar($params&$smarty)
  40. {
  41.     $name      = isset($params['name'])    $params['name']    null;
  42.     $default   = isset($params['default']$params['default'null;
  43.     $html      = isset($params['html'])    $params['html']    null;
  44.     $assign    = isset($params['assign'])  $params['assign']  null;
  45.  
  46.     if (!$name{
  47.         $smarty->trigger_error("pnconfiggetvar: parameter [name] required");
  48.         return false;
  49.     }
  50.  
  51.     $result pnConfigGetVar($name$default);
  52.  
  53.     if ($assign{
  54.         $smarty->assign($assign$result);
  55.     else {
  56.         if (is_bool($html&& $html{
  57.             return DataUtil::formatForDisplayHTML($result);
  58.         else {
  59.             return DataUtil::formatForDisplay($result);
  60.         }
  61.     }
  62. }

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