Merge branch 'w17_MDL-32575_m23_typo3' of git://github.com/skodak/moodle

This commit is contained in:
Dan Poltawski
2012-04-23 10:07:07 +08:00
10 changed files with 1470 additions and 1516 deletions
+1
View File
@@ -1427,6 +1427,7 @@ function purge_all_caches() {
js_reset_all_caches();
theme_reset_all_caches();
get_string_manager()->reset_caches();
textlib::reset_caches();
// purge all other caches: rss, simplepie, etc.
remove_dir($CFG->cachedir.'', true);
+1
View File
@@ -530,6 +530,7 @@ class phpunit_util {
accesslib_clear_all_caches(true);
get_string_manager()->reset_caches();
events_get_handlers('reset');
textlib::reset_caches();
//TODO: add more resets here and probably refactor them to new core function
// purge dataroot directory
+4
View File
@@ -205,6 +205,10 @@ class core_textlib_testcase extends basic_testcase {
$str = pack("H*", "bcf2cce5d6d0cec4"); //GB18030
$this->assertSame(textlib::strtolower($str, 'GB18030'), $str);
// typo3 has problems with integers
$str = 1309528800;
$this->assertSame((string)$str, textlib::strtolower($str));
}
/**
+32 -14
View File
@@ -51,11 +51,17 @@ class textlib {
/**
* Return t3lib helper class, which is used for conversion between charsets
*
* @param bool $reset
* @return t3lib_cs
*/
protected static function typo3() {
protected static function typo3($reset = false) {
static $typo3cs = null;
if ($reset) {
$typo3cs = null;
return null;
}
if (isset($typo3cs)) {
return $typo3cs;
}
@@ -65,6 +71,8 @@ class textlib {
// Required files
require_once($CFG->libdir.'/typo3/class.t3lib_cs.php');
require_once($CFG->libdir.'/typo3/class.t3lib_div.php');
require_once($CFG->libdir.'/typo3/interface.t3lib_singleton.php');
require_once($CFG->libdir.'/typo3/class.t3lib_l10n_locales.php');
// do not use mbstring or recode because it may return invalid results in some corner cases
$GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_convMethod'] = 'iconv';
@@ -85,16 +93,26 @@ class textlib {
// This full path constants must be defined too, transforming backslashes
// to forward slashed because Typo3 requires it.
define ('PATH_t3lib', str_replace('\\','/',$CFG->libdir.'/typo3/'));
define ('PATH_typo3', str_replace('\\','/',$CFG->libdir.'/typo3/'));
define ('PATH_site', str_replace('\\','/',$CFG->tempdir.'/'));
define ('TYPO3_OS', stristr(PHP_OS,'win')&&!stristr(PHP_OS,'darwin')?'WIN':'');
if (!defined('PATH_t3lib')) {
define('PATH_t3lib', str_replace('\\','/',$CFG->libdir.'/typo3/'));
define('PATH_typo3', str_replace('\\','/',$CFG->libdir.'/typo3/'));
define('PATH_site', str_replace('\\','/',$CFG->tempdir.'/'));
define('TYPO3_OS', stristr(PHP_OS,'win')&&!stristr(PHP_OS,'darwin')?'WIN':'');
}
$typo3cs = new t3lib_cs();
return $typo3cs;
}
/**
* Reset internal textlib caches.
* @static
*/
public static function reset_caches() {
self::typo3(true);
}
/**
* Standardise charset name
*
@@ -166,7 +184,7 @@ class textlib {
if ($result === false or $result === '') {
// note: iconv is prone to return empty string when invalid char encountered, or false if encoding unsupported
$oldlevel = error_reporting(E_PARSE);
$result = self::typo3()->conv($text, $fromCS, $toCS);
$result = self::typo3()->conv((string)$text, $fromCS, $toCS);
error_reporting($oldlevel);
}
@@ -208,9 +226,9 @@ class textlib {
$oldlevel = error_reporting(E_PARSE);
if ($len === null) {
$result = self::typo3()->substr($charset, $text, $start);
$result = self::typo3()->substr($charset, (string)$text, $start);
} else {
$result = self::typo3()->substr($charset, $text, $start, $len);
$result = self::typo3()->substr($charset, (string)$text, $start, $len);
}
error_reporting($oldlevel);
@@ -236,7 +254,7 @@ class textlib {
}
$oldlevel = error_reporting(E_PARSE);
$result = self::typo3()->strlen($charset, $text);
$result = self::typo3()->strlen($charset, (string)$text);
error_reporting($oldlevel);
return $result;
@@ -257,7 +275,7 @@ class textlib {
}
$oldlevel = error_reporting(E_PARSE);
$result = self::typo3()->conv_case($charset, $text, 'toLower');
$result = self::typo3()->conv_case($charset, (string)$text, 'toLower');
error_reporting($oldlevel);
return $result;
@@ -278,7 +296,7 @@ class textlib {
}
$oldlevel = error_reporting(E_PARSE);
$result = self::typo3()->conv_case($charset, $text, 'toUpper');
$result = self::typo3()->conv_case($charset, (string)$text, 'toUpper');
error_reporting($oldlevel);
return $result;
@@ -328,7 +346,7 @@ class textlib {
public static function specialtoascii($text, $charset='utf-8') {
$charset = self::parse_charset($charset);
$oldlevel = error_reporting(E_PARSE);
$result = self::typo3()->specCharsToASCII($charset, $text);
$result = self::typo3()->specCharsToASCII($charset, (string)$text);
error_reporting($oldlevel);
return $result;
}
@@ -469,9 +487,9 @@ class textlib {
// Avoid some notices from Typo3 code
$oldlevel = error_reporting(E_PARSE);
if ($nonnum) {
$str = self::typo3()->entities_to_utf8($str, true);
$str = self::typo3()->entities_to_utf8((string)$str, true);
}
$result = self::typo3()->utf8_to_entities($str);
$result = self::typo3()->utf8_to_entities((string)$str);
if ($dec) {
$result = preg_replace('/&#x([0-9a-f]+);/ie', "'&#'.hexdec('$1').';'", $result);
}
+1 -1
View File
@@ -200,7 +200,7 @@
<location>typo3</location>
<name>Typo3</name>
<license>GPL</license>
<version>4.5.0</version>
<version>4.6.8</version>
<licenseversion>2.0+</licenseversion>
</library>
<library>
+110 -113
View File
@@ -24,69 +24,9 @@
/**
* Class for conversion between charsets.
*
* $Id$
*
* @author Kasper Skårhøj <kasperYYYY@typo3.com>
* @author Martin Kutschker <martin.t.kutschker@blackbox.net>
*/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*
*
*
* 136: class t3lib_cs
* 488: function parse_charset($charset)
* 507: function get_locale_charset($locale)
*
* SECTION: Charset Conversion functions
* 560: function conv($str,$fromCS,$toCS,$useEntityForNoChar=0)
* 600: function convArray(&$array,$fromCS,$toCS,$useEntityForNoChar=0)
* 617: function utf8_encode($str,$charset)
* 663: function utf8_decode($str,$charset,$useEntityForNoChar=0)
* 706: function utf8_to_entities($str)
* 739: function entities_to_utf8($str,$alsoStdHtmlEnt=0)
* 773: function utf8_to_numberarray($str,$convEntities=0,$retChar=0)
* 823: function UnumberToChar($cbyte)
* 868: function utf8CharToUnumber($str,$hex=0)
*
* SECTION: Init functions
* 911: function initCharset($charset)
* 973: function initUnicodeData($mode=null)
* 1198: function initCaseFolding($charset)
* 1260: function initToASCII($charset)
*
* SECTION: String operation functions
* 1331: function substr($charset,$string,$start,$len=null)
* 1384: function strlen($charset,$string)
* 1414: function crop($charset,$string,$len,$crop='')
* 1467: function strtrunc($charset,$string,$len)
* 1501: function conv_case($charset,$string,$case)
* 1527: function specCharsToASCII($charset,$string)
*
* SECTION: Internal string operation functions
* 1567: function sb_char_mapping($str,$charset,$mode,$opt='')
*
* SECTION: Internal UTF-8 string operation functions
* 1622: function utf8_substr($str,$start,$len=null)
* 1655: function utf8_strlen($str)
* 1676: function utf8_strtrunc($str,$len)
* 1698: function utf8_strpos($haystack,$needle,$offset=0)
* 1723: function utf8_strrpos($haystack,$needle)
* 1745: function utf8_char2byte_pos($str,$pos)
* 1786: function utf8_byte2char_pos($str,$pos)
* 1809: function utf8_char_mapping($str,$mode,$opt='')
*
* SECTION: Internal EUC string operation functions
* 1885: function euc_strtrunc($str,$len,$charset)
* 1914: function euc_substr($str,$start,$charset,$len=null)
* 1939: function euc_strlen($str,$charset)
* 1966: function euc_char2byte_pos($str,$pos,$charset)
* 2007: function euc_char_mapping($str,$charset,$mode,$opt='')
*
* TOTAL FUNCTIONS: 35
* (This index is automatically created/updated by the extension "extdeveval")
*
*/
/**
@@ -127,6 +67,12 @@
* @subpackage t3lib
*/
class t3lib_cs {
/**
* @var t3lib_l10n_Locales
*/
protected $locales;
var $noCharByteVal = 63; // ASCII Value for chars with no equivalent.
// This is the array where parsed conversion tables are stored (cached)
@@ -466,60 +412,76 @@ class t3lib_cs {
// TYPO3 specific: Array with the system charsets used for each system language in TYPO3:
// Empty values means "iso-8859-1"
var $charSetArray = array(
'dk' => '',
'de' => '',
'no' => '',
'it' => '',
'fr' => '',
'es' => '',
'nl' => '',
'cz' => 'windows-1250',
'pl' => 'iso-8859-2',
'si' => 'windows-1250',
'fi' => '',
'tr' => 'iso-8859-9',
'se' => '',
'pt' => '',
'ru' => 'windows-1251',
'ro' => 'iso-8859-2',
'ch' => 'gb2312',
'sk' => 'windows-1250',
'lt' => 'windows-1257',
'is' => 'utf-8',
'hr' => 'windows-1250',
'hu' => 'iso-8859-2',
'gl' => '',
'th' => 'iso-8859-11',
'gr' => 'iso-8859-7',
'hk' => 'big5',
'eu' => '',
'ar' => 'iso-8859-6',
'ba' => 'iso-8859-2',
'bg' => 'windows-1251',
'br' => '',
'et' => 'iso-8859-4',
'ar' => 'iso-8859-6',
'he' => 'utf-8',
'ua' => 'windows-1251',
'jp' => 'shift_jis',
'lv' => 'utf-8',
'vn' => 'utf-8',
'ca' => 'iso-8859-15',
'ba' => 'iso-8859-2',
'kr' => 'euc-kr',
'ch' => 'gb2312',
'cs' => 'windows-1250',
'cz' => 'windows-1250',
'da' => '',
'de' => '',
'dk' => '',
'el' => 'iso-8859-7',
'eo' => 'utf-8',
'my' => '',
'hi' => 'utf-8',
'fo' => 'utf-8',
'es' => '',
'et' => 'iso-8859-4',
'eu' => '',
'fa' => 'utf-8',
'sr' => 'utf-8',
'sq' => 'utf-8',
'ge' => 'utf-8',
'fi' => '',
'fo' => 'utf-8',
'fr' => '',
'fr_CA' => '',
'ga' => '',
'ge' => 'utf-8',
'gl' => '',
'gr' => 'iso-8859-7',
'he' => 'utf-8',
'hi' => 'utf-8',
'hk' => 'big5',
'hr' => 'windows-1250',
'hu' => 'iso-8859-2',
'is' => 'utf-8',
'it' => '',
'ja' => 'shift_jis',
'jp' => 'shift_jis',
'ka' => 'utf-8',
'kl' => 'utf-8',
'km' => 'utf-8',
'ko' => 'euc-kr',
'kr' => 'euc-kr',
'lt' => 'windows-1257',
'lv' => 'utf-8',
'ms' => '',
'my' => '',
'nl' => '',
'no' => '',
'pl' => 'iso-8859-2',
'pt' => '',
'pt_BR' => '',
'qc' => '',
'ro' => 'iso-8859-2',
'ru' => 'windows-1251',
'se' => '',
'si' => 'windows-1250',
'sk' => 'windows-1250',
'sl' => 'windows-1250',
'sq' => 'utf-8',
'sr' => 'utf-8',
'sv' => '',
'th' => 'iso-8859-11',
'tr' => 'iso-8859-9',
'ua' => 'windows-1251',
'uk' => 'windows-1251',
'vi' => 'utf-8',
'vn' => 'utf-8',
'zh' => 'big5',
);
// TYPO3 specific: Array with the iso names used for each system language in TYPO3:
// Missing keys means: same as Typo3
// Missing keys means: same as TYPO3
// @deprecated since TYPO3 4.6, will be removed in TYPO3 4.8 - use t3lib_l10n_Locales::getIsoMapping()
var $isoArray = array(
'ba' => 'bs',
'br' => 'pt_BR',
@@ -540,6 +502,13 @@ class t3lib_cs {
'ga' => 'gl',
);
/**
* Default constructor.
*/
public function __construct() {
$this->locales = t3lib_div::makeInstance('t3lib_l10n_Locales');
}
/**
* Normalize - changes input character set to lowercase letters.
*
@@ -634,7 +603,7 @@ class t3lib_cs {
$conv_str = mb_convert_encoding($str, $toCS, $fromCS);
if (FALSE !== $conv_str) {
return $conv_str;
} // returns false for unsupported charsets
} // returns FALSE for unsupported charsets
break;
case 'iconv':
@@ -1028,7 +997,7 @@ class t3lib_cs {
*/
function initCharset($charset) {
// Only process if the charset is not yet loaded:
if (empty($this->parsedCharsets[$charset]) || !is_array($this->parsedCharsets[$charset])) {
if (!is_array($this->parsedCharsets[$charset])) {
// Conversion table filename:
$charsetConvTableFile = PATH_t3lib . 'csconvtbl/' . $charset . '.tbl';
@@ -1240,17 +1209,23 @@ class t3lib_cs {
$utf8_char = $this->UnumberToChar(hexdec($char));
if ($char != $lower) {
$arr = explode(' ', $lower);
for ($i = 0; isset($arr[$i]); $i++) $arr[$i] = $this->UnumberToChar(hexdec($arr[$i]));
for ($i = 0; isset($arr[$i]); $i++) {
$arr[$i] = $this->UnumberToChar(hexdec($arr[$i]));
}
$utf8CaseFolding['toLower'][$utf8_char] = implode('', $arr);
}
if ($char != $title && $title != $upper) {
$arr = explode(' ', $title);
for ($i = 0; isset($arr[$i]); $i++) $arr[$i] = $this->UnumberToChar(hexdec($arr[$i]));
for ($i = 0; isset($arr[$i]); $i++) {
$arr[$i] = $this->UnumberToChar(hexdec($arr[$i]));
}
$utf8CaseFolding['toTitle'][$utf8_char] = implode('', $arr);
}
if ($char != $upper) {
$arr = explode(' ', $upper);
for ($i = 0; isset($arr[$i]); $i++) $arr[$i] = $this->UnumberToChar(hexdec($arr[$i]));
for ($i = 0; isset($arr[$i]); $i++) {
$arr[$i] = $this->UnumberToChar(hexdec($arr[$i]));
}
$utf8CaseFolding['toUpper'][$utf8_char] = implode('', $arr);
}
}
@@ -1623,7 +1598,7 @@ class t3lib_cs {
}
/*
if (abs($len)<$this->strlen($charset,$string)) { // Has to use ->strlen() - otherwise multibyte strings ending with a multibyte char will return true here (which is not a catastrophe, but...)
if (abs($len)<$this->strlen($charset,$string)) { // Has to use ->strlen() - otherwise multibyte strings ending with a multibyte char will return TRUE here (which is not a catastrophe, but...)
if ($len > 0) {
return substr($string,0,$i).$crop;
} else {
@@ -1702,6 +1677,22 @@ class t3lib_cs {
return $string;
}
/**
* Equivalent of lcfirst/ucfirst but using character set.
*
* @param string $charset
* @param string $string
* @param string $case
* @return string
* @see t3lib_cs::conv_case()
*/
public function convCaseFirst($charset, $string, $case) {
$firstChar = $this->substr($charset, $string, 0, 1);
$firstChar = $this->conv_case($charset, $firstChar, $case);
$remainder = $this->substr($charset, $string, 1);
return $firstChar . $remainder;
}
/**
* Converts special chars (like æøåÆØÅ, umlauts etc) to ascii equivalents (usually double-bytes, like æ => ae etc.)
*
@@ -1743,7 +1734,7 @@ class t3lib_cs {
// get all languages where TYPO3 code differs from ISO code
// or needs the country part
// the iso codes will here overwrite the default typo3 language in the key
foreach ($this->isoArray as $typo3Lang => $isoLang) {
foreach ($this->locales->getIsoMapping() as $typo3Lang => $isoLang) {
$isoLang = join('-', explode('_', $isoLang));
$allLanguageCodes[$typo3Lang] = $isoLang;
}
@@ -1921,11 +1912,17 @@ class t3lib_cs {
function utf8_strtrunc($str, $len) {
$i = $len - 1;
if (ord($str{$i}) & 0x80) { // part of a multibyte sequence
for (; $i > 0 && !(ord($str{$i}) & 0x40); $i--) ; // find the first byte
for (; $i > 0 && !(ord($str{$i}) & 0x40); $i--) {
// find the first byte
;
}
if ($i <= 0) {
return '';
} // sanity check
for ($bc = 0, $mbs = ord($str{$i}); $mbs & 0x80; $mbs = $mbs << 1) $bc++; // calculate number of bytes
for ($bc = 0, $mbs = ord($str{$i}); $mbs & 0x80; $mbs = $mbs << 1) {
// calculate number of bytes
$bc++;
}
if ($bc + $i > $len) {
return substr($str, 0, $i);
}
@@ -2345,4 +2342,4 @@ if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLA
include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_cs.php']);
}
?>
?>
File diff suppressed because it is too large Load Diff
+284
View File
@@ -0,0 +1,284 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2011 Xavier Perseguers <typo3@perseguers.ch>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Locales.
*
* Defining backend system languages
* When adding new keys, remember to:
* - Add character encoding for lang. key in t3lib/class.t3lib_cs.php (default for new languages is "utf-8")
* - Add mappings for language in t3lib/class.t3lib_cs.php (TYPO3/ISO, language/script, script/charset)
* - Update 'setup' extension labels (sysext/setup/mod/locallang.xlf)
* That's it!
*
* @package Core
* @subpackage t3lib
* @author Xavier Perseguers <typo3@perseguers.ch>
*/
class t3lib_l10n_Locales implements t3lib_Singleton {
/**
* Supported TYPO3 languages with locales
* @var array
*/
protected $languages = array(
'default' => 'English',
'ar' => 'Arabic',
'bs' => 'Bosnian',
'bg' => 'Bulgarian',
'ca' => 'Catalan',
'ch' => 'Chinese (Simpl.)',
'cs' => 'Czech',
'da' => 'Danish',
'de' => 'German',
'el' => 'Greek',
'eo' => 'Esperanto',
'es' => 'Spanish',
'et' => 'Estonian',
'eu' => 'Basque',
'fa' => 'Persian',
'fi' => 'Finnish',
'fo' => 'Faroese',
'fr' => 'French',
'fr_CA' => 'French (Canada)',
'gl' => 'Galician',
'he' => 'Hebrew',
'hi' => 'Hindi',
'hr' => 'Croatian',
'hu' => 'Hungarian',
'is' => 'Icelandic',
'it' => 'Italian',
'ja' => 'Japanese',
'ka' => 'Georgian',
'kl' => 'Greenlandic',
'km' => 'Khmer',
'ko' => 'Korean',
'lt' => 'Lithuanian',
'lv' => 'Latvian',
'ms' => 'Malay',
'nl' => 'Dutch',
'no' => 'Norwegian',
'pl' => 'Polish',
'pt' => 'Portuguese',
'pt_BR' => 'Brazilian Portuguese',
'ro' => 'Romanian',
'ru' => 'Russian',
'sk' => 'Slovak',
'sl' => 'Slovenian',
'sq' => 'Albanian',
'sr' => 'Serbian',
'sv' => 'Swedish',
'th' => 'Thai',
'tr' => 'Turkish',
'uk' => 'Ukrainian',
'vi' => 'Vietnamese',
'zh' => 'Chinese (Trad.)',
);
/**
* Supported TYPO3 locales
* @deprecated since TYPO3 4.6, will be removed in TYPO3 4.8
* @var array
*/
protected $locales = array();
/**
* Mapping with codes used by TYPO3 4.5 and below
* @var array
*/
protected $isoReverseMapping = array(
'bs' => 'ba', // Bosnian
'cs' => 'cz', // Czech
'da' => 'dk', // Danish
'el' => 'gr', // Greek
'fr_CA' => 'qc', // French (Canada)
'gl' => 'ga', // Galician
'ja' => 'jp', // Japanese
'ka' => 'ge', // Georgian
'kl' => 'gl', // Greenlandic
'ko' => 'kr', // Korean
'ms' => 'my', // Malay
'pt_BR' => 'br', // Portuguese (Brazil)
'sl' => 'si', // Slovenian
'sv' => 'se', // Swedish
'uk' => 'ua', // Ukrainian
'vi' => 'vn', // Vietnamese
'zh' => 'hk', // Chinese (China)
'zh_CN' => 'ch', // Chinese (Simplified)
'zh_HK' => 'hk', // Chinese (China)
);
/**
* @var array
*/
protected $isoMapping;
/**
* Dependencies for locales
* @var array
*/
protected $localeDependencies;
/**
* Initializes the languages.
*
* @static
* @return void
*/
public static function initialize() {
/** @var $instance t3lib_l10n_Locales */
$instance = t3lib_div::makeInstance('t3lib_l10n_Locales');
$instance->isoMapping = array_flip($instance->isoReverseMapping);
// Allow user-defined locales
if (isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['localization']['locales']['user']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['localization']['locales']['user'])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['SYS']['localization']['locales']['user'] as $locale => $name) {
if (!isset($instance->languages[$locale])) {
$instance->languages[$locale] = $name;
}
}
}
// Initializes the locale dependencies with TYPO3 supported locales
$instance->localeDependencies = array();
foreach ($instance->languages as $locale => $name) {
if (strlen($locale) == 5) {
$instance->localeDependencies[$locale] = array(substr($locale, 0, 2));
}
}
// Merge user-provided locale dependencies
if (isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['localization']['locales']['dependencies']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['localization']['locales']['dependencies'])) {
$instance->localeDependencies = t3lib_div::array_merge_recursive_overrule($instance->localeDependencies, $GLOBALS['TYPO3_CONF_VARS']['SYS']['localization']['locales']['dependencies']);
}
/**
* @deprecated since TYPO3 4.6, will be removed in TYPO3 4.8
*/
$instance->locales = array_keys($instance->languages);
/**
* @deprecated since TYPO3 4.6, will be removed in TYPO3 4.8
*/
define('TYPO3_languages', implode('|', $instance->getLocales()));
}
/**
* Returns the locales.
*
* @return array
*/
public function getLocales() {
return array_keys($this->languages);
}
/**
* Returns the supported languages indexed by their corresponding locale.
*
* @return array
*/
public function getLanguages() {
return $this->languages;
}
/**
* Returns the mapping between TYPO3 (old) language codes and ISO codes.
*
* @return array
*/
public function getIsoMapping() {
return $this->isoMapping;
}
/**
* Returns the locales as referenced by the TER and TYPO3 localization files.
*
* @return array
* @deprecated since TYPO3 4.6
*/
public function getTerLocales() {
return $this->convertToTerLocales(array_keys($this->languages));
}
/**
* Returns the dependencies of a given locale, if any.
*
* @param string $locale
* @return array
*/
public function getLocaleDependencies($locale) {
$dependencies = array();
if (isset($this->localeDependencies[$locale])) {
$dependencies = $this->localeDependencies[$locale];
// Search for dependencies recursively
$localeDependencies = $dependencies;
foreach ($localeDependencies as $dependency) {
if (isset($this->localeDependencies[$dependency])) {
$dependencies = array_merge($dependencies, $this->getLocaleDependencies($dependency));
}
}
}
return $dependencies;
}
/**
* Returns the dependencies of a given locale using TER compatible locale codes.
*
* @param string $locale
* @return array
* @deprecated since TYPO3 4.6
*/
public function getTerLocaleDependencies($locale) {
$terLocale = isset($this->isoMapping[$locale])
? $this->isoMapping[$locale]
: $locale;
return $this->convertToTerLocales($this->getLocaleDependencies($terLocale));
}
/**
* Converts an array of ISO locale codes into their TER equivalent.
*
* @param array $locales
* @return array
* @deprecated since TYPO3 4.6
*/
protected function convertToTerLocales(array $locales) {
$terLocales = array();
foreach ($locales as $locale) {
$terLocales[] = isset($this->isoReverseMapping[$locale]) ? $this->isoReverseMapping[$locale] : $locale;
}
return $terLocales;
}
}
if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/l10n/class.t3lib_l10n_locales.php'])) {
include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/l10n/class.t3lib_l10n_locales.php']);
}
?>
+40
View File
@@ -0,0 +1,40 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2008-2011 Robert Lemke <robert@typo3.org>, Martin Kutschker <masi@typo3.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* "empty" interface for singletons (marker interface pattern)
*
* @author Martin Kutschker <masi@typo3.org>
* @package TYPO3
* @subpackage t3lib
* @see t3lib_div::makeInstance()
*/
interface t3lib_Singleton {
// deliberately empty
}
?>
+3 -1
View File
@@ -1,4 +1,6 @@
Description of Typo3 libraries (v 4.5.0) import into Moodle
Description of Typo3 libraries (v 4.6.8) import into Moodle
Changes: none
skodak, stronk7