📄 lang.php
字号:
<?php/**************************************************************** Copyright notice** (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)* 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!***************************************************************//** * Contains the TYPO3 Backend Language class * * $Id: lang.php 1421 2006-04-10 09:27:15Z mundaun $ * Revised for TYPO3 3.6.0 * * @author Kasper Skaarhoj <kasperYYYY@typo3.com> *//** * [CLASS/FUNCTION INDEX of SCRIPT] * * * * 88: class language * 138: function init($lang,$altPath='') * 183: function addModuleLabels($arr,$prefix) * 209: function hscAndCharConv($lStr,$hsc) * 224: function makeEntities($str) * 241: function JScharCode($str) * 260: function getLL($index,$hsc=0) * 278: function getLLL($index,$LOCAL_LANG,$hsc=0) * 299: function sL($input,$hsc=0) * 344: function loadSingleTableDescription($table) * 396: function includeLLFile($fileRef,$setGlobal=1,$mergeLocalOntoDefault=0) * 441: function readLLfile($fileRef) * 451: function localizedFileRef($fileRef) * * TOTAL FUNCTIONS: 12 * (This index is automatically created/updated by the extension "extdeveval") * *//** * Contains the TYPO3 Backend Language class * * For detailed information about how localization is handled, * please refer to the 'Inside TYPO3' document which descibes this. * * This class is normally instantiated as the global variable $LANG in typo3/template.php * It's only available in the backend and under certain circumstances in the frontend * * @author Kasper Skaarhoj <kasperYYYY@typo3.com> * @package TYPO3 * @subpackage core * @see typo3/template.php, template */class language { var $lang='default'; // This is set to the language that is currently running for the user var $langSplit='default'; // Values like the labels in the tables.php-document are split by '|'. This values defines which language is represented by which position in the resulting array after splitting a value. (NOTICE: Obsolete concept!) // Default charset in backend var $charSet = 'iso-8859-1'; // Array with alternative charsets for other languages. (Moved to t3lib_cs, Set from csConvObj!) var $charSetArray = array(); // This is the url to the TYPO3 manual var $typo3_help_url= 'http://www.typo3.com/man_uk/'; // Array with alternative URLs based on language. var $helpUrlArray = array( 'dk' => 'http://www.typo3.com/man_dk/', ); var $debugKey = FALSE; // If true, will show the key/location of labels in the backend. var $moduleLabels = Array(); // Can contain labels and image references from the backend modules. Relies on t3lib_loadmodules to initialize modules after a global instance of $LANG has been created. // Internal var $langSplitIndex=0; // Points to the position of the current language key as found in constant TYPO3_languages var $LL_files_cache=array(); // Internal cache for read LL-files var $LL_labels_cache=array(); // Internal cache for ll-labels (filled as labels are requested) // Internal charset conversion: var $origCharSet=''; // If set, then it means that the this->charSet is set to a forced, common value for the WHOLE backend regardless of user language. And THIS variable will contain the original charset for the language labels. With ->csConvObj we must then convert the original charset to the charset used in the backend from now on. var $csConvObj; // An instance of the "t3lib_cs" class. May be used by any application. /** * Initializes the backend language. * This is for example done in typo3/template.php with lines like these: * * require (PATH_typo3.'sysext/lang/lang.php'); * $LANG = t3lib_div::makeInstance('language'); * $LANG->init($BE_USER->uc['lang']); * * @param string The language key (two character string from backend users profile) * @param string IGNORE. Not used. * @return void */ function init($lang,$altPath='') { // Initialize the conversion object: $this->csConvObj = t3lib_div::makeInstance('t3lib_cs'); $this->charSetArray = $this->csConvObj->charSetArray; // Internally setting the list of TYPO3 backend languages. $this->langSplit=TYPO3_languages; // Finding the requested language in this list based on the $lang key being inputted to this function. $ls = explode('|',$this->langSplit); while(list($i,$v)=each($ls)) { if ($v==$lang) { // Language is found. Configure it: $this->langSplitIndex=$i; // The index of the language as found in the TYPO3_languages list $this->lang = $lang; // The current language key if ($this->helpUrlArray[$this->lang]) $this->typo3_help_url=$this->helpUrlArray[$this->lang]; // The help URL if different from the default. if ($this->charSetArray[$this->lang]) $this->charSet=$this->charSetArray[$this->lang]; // The charset if different from the default. } } // If a forced charset is used and different from the charset otherwise used: if ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] && $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset']!=$this->charSet) { // Set the forced charset: $this->origCharSet = $this->charSet; $this->charSet = $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset']; if ($this->charSet!='utf-8' && !$this->csConvObj->initCharset($this->charSet)) { t3lib_BEfunc::typo3PrintError ('The forced character set "'.$this->charSet.'" was not found in t3lib/csconvtbl/','Forced charset not found'); exit; } if ($this->origCharSet!='utf-8' && !$this->csConvObj->initCharset($this->origCharSet)) { t3lib_BEfunc::typo3PrintError ('The original character set "'.$this->origCharSet.'" was not found in t3lib/csconvtbl/','Forced charset not found'); exit; } } } /** * Adds labels and image references from the backend modules to the internal moduleLabels array * * @param array Array with references to module labels, keys: ['labels']['tablabel'], ['labels']['tabdescr'], ['tabs']['tab'] * @param string Module name prefix * @return void * @see t3lib_loadModules */ function addModuleLabels($arr,$prefix) { if (is_array($arr)) { reset($arr); while(list($k,$larr)=each($arr)) { if (!isset($this->moduleLabels[$k])) { $this->moduleLabels[$k]=array(); } if (is_array($larr)) { reset($larr); while(list($l,$v)=each($larr)) { $this->moduleLabels[$k][$prefix.$l]=$v; } } } } } /** * Will htmlspecialchar() the input string and before that any charset conversion will also have taken place if needed (see init()) * Used to pipe language labels through just before they are returned. * * @param string The string to process * @param boolean If set, then the string is htmlspecialchars()'ed * @return string The processed string * @see init() */ function hscAndCharConv($lStr,$hsc) { $lStr = $hsc ? htmlspecialchars($lStr) : $lStr; if ($this->origCharSet) { $lStr = $this->csConvObj->conv($lStr,$this->origCharSet,$this->charSet,1); } return $lStr; } /** * Will convert the input strings special chars (all above 127) to entities. The string is expected to be encoded in the charset, $this->charSet * This function is used to create strings that can be used in the Click Menu (Context Sensitive Menus). The reason is that the values that are dynamically written into the <div> layer is decoded as iso-8859-1 no matter what charset is used in the document otherwise (only MSIE, Mozilla is OK). So by converting we by-pass this problem. * * @param string Input string * @return string Output string */ function makeEntities($str) { // Convert string to UTF-8: if ($this->charSet!='utf-8') $str = $this->csConvObj->utf8_encode($str,$this->charSet); // Convert string back again, but using the full entity conversion: $str = $this->csConvObj->utf8_to_entities($str); return $str; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -