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

Source for file function.html_select_languages.php

Documentation is available at function.html_select_languages.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 drop down list of languages
  15.  *
  16.  * Available parameters:
  17.  *   - assign:   If set, the results are assigned to the corresponding variable instead of printed out
  18.  *   - name:     Name for the control
  19.  *   - id:       ID for the control
  20.  *   - selected: Selected value
  21.  *   - installed: if set only show languages existing in languages folder
  22.  *   - all:      show dummy entry '_ALL' on top of the list with empty value
  23.  *
  24.  * Example
  25.  *   <!--[html_select_languages name=language selected=eng]-->
  26.  *
  27.  *
  28.  * @author       Mark West
  29.  * @since        25 April 2004
  30.  * @param        array       $params      All attributes passed to this function from the template
  31.  * @param        object      &$smarty     Reference to the Smarty object
  32.  * @return       string      the value of the last status message posted, or void if no status message exists
  33.  */
  34. function smarty_function_html_select_languages($params&$smarty)
  35. {
  36.     if (!isset($params['name']|| empty($params['name'])) {
  37.         $smarty->trigger_error('html_select_languages:  parameter [name] required');
  38.         return false;
  39.     }
  40.  
  41.     require_once $smarty->_get_plugin_filepath('function','html_options');
  42.  
  43.     if (isset($params['all']&& $params['all']{
  44.         $values['';
  45.         $output[]DataUtil::formatForDisplay(_ALL);
  46.     }
  47.  
  48.     if (isset($params['installed']&& $params['installed']{
  49.         $languagelist LanguageUtil::getInstalledLanguages();
  50.     else {
  51.         $languagelist languagelist();
  52.     }
  53.  
  54.     foreach ($languagelist as $code => $text{
  55.          $values[DataUtil::formatForDisplay($code);
  56.          $output[DataUtil::formatForDisplay($text);
  57.     }
  58.  
  59.     $html_result smarty_function_html_options(array('output'       => $output,
  60.                                                       'values'       => $values,
  61.                                                       'selected'     => isset($params['selected']$params['selected'null,
  62.                                                       'id'           => isset($params['id']$params['id'null,
  63.                                                       'name'         => $params['name']),
  64.                                                 $smarty);
  65.  
  66.     if (isset($params['assign']&& !empty($params['assign'])) {
  67.         $smarty->assign($params['assign']$html_result);
  68.     else {
  69.         return $html_result;
  70.     }
  71. }

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