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

Source for file function.category_path.php

Documentation is available at function.category_path.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.v4b_selector_object_array.php 19260 2006-06-12 13:08:15Z markwest $
  8.  * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
  9.  * @author Robert Gasch
  10.  * @package Zikula_Template_Plugins
  11.  * @subpackage Functions
  12.  */
  13.  
  14. /**
  15.  * Available parameters:
  16.  *   - btnText:  If set, the results are assigned to the corresponding variable instead of printed out
  17.  *   - cid:      category ID
  18.  *
  19.  * Example
  20.  * <!--[v4b_rbs_getcategory cid="1" assign="category"]-->
  21.  *
  22.  */
  23. function smarty_function_category_path ($params&$smarty)
  24. {
  25.     $assign    = isset($params['assign'])   $params['assign']   null;
  26.     $id        = isset($params['id'])       $params['id']       0;
  27.     $idcolumn  = isset($params['idcolumn']$params['idcolumn''id';
  28.     $field     = isset($params['field'])    $params['field']    'path';
  29.     $html      = isset($params['html'])     $params['html']     false;
  30.  
  31.     if (!$id{
  32.         return 'Required parameter [id] not provided in smarty_function_category_path';
  33.     }
  34.  
  35.     if (!$field{
  36.         return 'Required parameter [field] not provided in smarty_function_category_path';
  37.     }
  38.  
  39.     Loader::loadClass('CategoryUtil');
  40.  
  41.     $result null;
  42.     if (is_numeric($id)) {
  43.         $cat CategoryUtil::getCategoryByID ($id);
  44.     else {
  45.         $cat CategoryUtil::getCategoryByPath ($id$field);
  46.     }
  47.  
  48.     if ($cat{
  49.         if (isset($cat[$field])) {
  50.             $result $cat[$field];
  51.         else {
  52.             return "Category [$id] doesn't have [$field] set in in smarty_function_category_path";
  53.         }
  54.     else {
  55.         return "No category for id [$id] in smarty_function_category_path";
  56.     }
  57.  
  58.     if ($assign{
  59.         $smarty->assign($params['assign']$result);
  60.     else {
  61.         if (isset($html&& is_bool($html&& $html{
  62.             return DataUtil::formatForDisplayHTML($result);
  63.         else {
  64.             return DataUtil::formatForDisplay($result);
  65.         }
  66.     }
  67. }

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