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

Source for file function.pnformlanguageselector.php

Documentation is available at function.pnformlanguageselector.php

  1. <?php
  2. /**
  3.  * Language selector plugin
  4.  *
  5.  * @copyright (c) 2006, Zikula Development Team
  6.  * @link http://www.zikula.org
  7.  * @version $Id: function.pnformtextinput.php 21046 2007-01-11 21:36:57Z jornlind $
  8.  * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
  9.  * @author Jorn Wildt
  10.  * @package Zikula_Template_Plugins
  11.  * @subpackage Functions
  12.  */
  13.  
  14. /** Make sure to use require_once() instead of Loader::requireOnce() since "function.pnformdropdownlist.php"
  15.  is loaded by Smarty (the base render class) with the use of require_once(). We do not want to
  16.  get in conflict with that.*/
  17. require_once 'system/pnForm/plugins/function.pnformdropdownlist.php';
  18.  
  19. // But this one is included by the Zikula framework, so use Loader::requireOnce
  20. Loader::loadClass('LanguageUtil');
  21.  
  22. /**
  23.  * Language selector
  24.  *
  25.  * This plugin creates a language selector using a dropdown list.
  26.  * The selected value of the base dropdown list will be set to the 3-letter language code of
  27.  * the selected language.
  28.  *
  29.  * @package pnForm
  30.  * @subpackage Plugins
  31.  */
  32. {
  33.   /**
  34.    * Enable or disable use of installed languages only
  35.    *
  36.    * Normally you can only choose one of the installed languages with the language selector,
  37.    * but by setting onlyInstalledLanguages to false you can get a list of all possible language.
  38.    * @var bool 
  39.    */
  40.   var $onlyInstalledLanguages = true;
  41.  
  42.   /**
  43.    * Add an option 'All' on top of the language list
  44.    *
  45.    * @var bool 
  46.    */
  47.   var $addAllOption = true;
  48.  
  49.  
  50.   function getFilename()
  51.   {
  52.       return __FILE__// FIXME: should be found in smarty's data???
  53.   }
  54.  
  55.  
  56.   function load(&$render$params)
  57.   {
  58.       if ($this->mandatory)
  59.           $this->addItem('---'null);
  60.  
  61.       if ($this->addAllOption{
  62.           $this->addItem(DataUtil::formatForDisplay(_ALL)'');
  63.       }
  64.  
  65.       if ($this->onlyInstalledLanguages)
  66.       {
  67.         $allLang languagelist();
  68.         $langList LanguageUtil::getLanguages();
  69.  
  70.         foreach ($langList as $key)
  71.         {
  72.             $this->addItem($allLang[$key]$key);
  73.         }
  74.       }
  75.       else
  76.       {
  77.         $langList languagelist();
  78.  
  79.         foreach ($langList as $key => $text)
  80.         {
  81.           $this->addItem($text$key);
  82.         }
  83.       }
  84.  
  85.       parent::load($render$params);
  86.   }
  87. }
  88.  
  89.  
  90. function smarty_function_pnformlanguageselector($params&$render)
  91. {
  92.   return $render->pnFormRegisterPlugin('pnFormLanguageSelector'$params);
  93. }

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