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

Source for file function.html_select_modules.php

Documentation is available at function.html_select_modules.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: outputfilter.pagevars.php 19321 2006-06-29 13:15:10Z 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 list box with a list of active modules
  15.  * either user or admin capable or all modules
  16.  *
  17.  * Available parameters:
  18.  *   - name:     Name for the control (optional) if not present then only the option tags are output
  19.  *   - id:       ID for the control
  20.  *   - selected: Selected value
  21.  *   - type:     Type of modules to show (all = All modules, user = user capable modules, admin = admin capable modules)
  22.  *   - assign:   If set, the results are assigned to the corresponding variable instead of printed out
  23.  *
  24.  * Example
  25.  *
  26.  *     <!--[html_select_modules name=mod selected=$mymod]-->
  27.  *
  28.  *     <select name="mod">
  29.  *         <option value="">&bsp;</option>
  30.  *         <!--[html_select_modules selected=$mythemechoice]-->
  31.  *     </select>
  32.  *
  33.  * @author       Mark West
  34.  * @since        10/01/04
  35.  * @see          function.html_select_modules.php::smarty_function_html_select_modules()
  36.  * @param        array       $params      All attributes passed to this function from the template
  37.  * @param        object      &$smarty     Reference to the Smarty object
  38.  * @return       string      a drop down containing a list of modules
  39.  */
  40. function smarty_function_html_select_modules($params&$smarty)
  41. {
  42.     extract($params);
  43.  
  44.     unset($params['name']);
  45.     unset($params['id']);
  46.     unset($params['selected']);
  47.     unset($params['type']);
  48.  
  49.     // we'll make use of the html_options plugin to simplfiy this plugin
  50.     require_once $smarty->_get_plugin_filepath('function','html_options');
  51.  
  52.     // set some defaults
  53.     if (!isset($type|| ($type != 'all' && $type != 'user' && $type != 'admin')) {
  54.         $type 'all';
  55.     }
  56.  
  57.     // get the modules
  58.     switch ($type{
  59.         case 'all' :
  60.             $modules pnModGetAllMods();
  61.             break;
  62.         case 'admin' :
  63.             $modules pnModGetAdminMods();
  64.             break;
  65.         case 'user' :
  66.             $modules pnModGetUserMods();
  67.             break;
  68.     }
  69.  
  70.     if (!isset($name)) {
  71.         $name null;
  72.     }
  73.     if (!isset($selected)) {
  74.         $selected null;
  75.     }
  76.  
  77.     // process our list of modules for input to the html_options plugin
  78.     $moduleslist array();
  79.     if (!empty($modules)) {
  80.         foreach ($modules as $module{
  81.             $moduleslist[$module['name']] $module['displayname'];
  82.         }
  83.     }
  84.     natcasesort($moduleslist);
  85.  
  86.     // get the formatted list
  87.     $output smarty_function_html_options(array('options'   => $moduleslist,
  88.                                                  'selected'  => isset($selected$selected null,
  89.                                                  'name'      => $name,
  90.                                                  'id'        => isset($id$id null),
  91.                                                  $smarty);
  92.     if (isset($assign)) {
  93.         $smarty->assign($assign$output);
  94.     else {
  95.         return $output;
  96.     }
  97. }

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