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

Source for file function.array_field_isset.php

Documentation is available at function.array_field_isset.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.pnmodgetvar.php 22138 2007-06-01 10:19: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 check if an array subscript is set
  15.  *
  16.  * @author       Andreas Stratmann
  17.  * @since        03/05/19
  18.  * @param        array       $params      All attributes passed to this function from the template
  19.  * @param        object      &$smarty     Reference to the Smarty object
  20.  * @param        array       $array       The array we wish to check
  21.  * @param        field       string       The string name of the array subscript we wish to check
  22.  * @param        assign      string       The variable to assign the result to (optional)
  23.  * @return       bool                     Wheather or not the array subscript is set
  24.  */
  25. function smarty_function_array_field_isset ($params&$smarty)
  26. {
  27.     $array       = isset($params['array'])       $params['array']        null;
  28.     $field       = isset($params['field'])       $params['field']        null;
  29.     $returnValue = isset($params['returnValue']$params['returnValue']  null;
  30.     $assign      = isset($params['assign'])      $params['assign']       null;
  31.  
  32.     if ($array === null{
  33.         $smarty->trigger_error('array_isset: required parameter [array] not provided');
  34.         return false;
  35.     }
  36.  
  37.     if ($field === null{
  38.         $smarty->trigger_error('array_isset: required parameter [field] not provided');
  39.         return false;
  40.     }
  41.  
  42.     if (!$field{
  43.         $smarty->trigger_error('array_isset: required parameter [name] may not be empty');
  44.         return false;
  45.     }
  46.  
  47.     $result = isset($array[$field]);
  48.     if ($result && $returnValue{
  49.         $result $array[$field];
  50.     }
  51.  
  52.     if ($assign{
  53.         $smarty->assign($assign$result);
  54.     else {
  55.         return $result;
  56.     }
  57. }

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