1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
<?php
/**
* The Horde_UI_Language:: class provides a widget for changing the
* currently selected language.
*
* $Horde: framework/UI/UI/Language.php,v 1.5.10.7 2006/06/20 09:08:45 jan Exp $
*
* Copyright 2003-2006 Jason M. Felice <jfelice@cronosys.com>
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* @since Horde_UI 0.0.1
* @package Horde_UI
*/
class Horde_UI_Language {
/**
* Render the language selection.
*
* @abstract
*
* @param boolean $form Return the selection box as an complete standalone
* form.
*
* @return string The HTML selection box.
*/
function render()
{
$html = '';
if (!$GLOBALS['prefs']->isLocked('language')) {
Horde::addScriptFile('language.js', 'horde');
$_SESSION['horde_language'] = NLS::select();
$html = sprintf('<form name="language" action="%s">',
Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/services/language.php', false, -1));
$html .= '<input type="hidden" name="url" value="' . @htmlspecialchars(Horde::selfUrl(false, false, true)) . '" />';
$html .= '<select name="new_lang" onchange="document.language.submit()">';
foreach ($GLOBALS['nls']['languages'] as $key => $val) {
$sel = ($key == $_SESSION['horde_language']) ? ' selected="selected"' : '';
$html .= "<option value=\"$key\"$sel>$val</option>";
}
$html .= '</select></form>';
}
return $html;
}
}
|