⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lang.php

📁 Typo3, 开源里边最强大的
💻 PHP
📖 第 1 页 / 共 2 页
字号:
	/**	 * Converts the input string to a JavaScript function returning the same string, but charset-safe.	 * Used for confirm and alert boxes where we must make sure that any string content does not break the script AND want to make sure the charset is preserved.	 * Originally I used the JS function unescape() in combination with PHP function rawurlencode() in order to pass strings in a safe way. This could still be done for iso-8859-1 charsets but now I have applied the same method here for all charsets.	 *	 * @param	string		Input string, encoded with $this->charSet	 * @return	string		Output string, a JavaScript function: "String.fromCharCode(......)"	 */	function JScharCode($str)	{			// Convert string to UTF-8:		if ($this->charSet!='utf-8')	$str = $this->csConvObj->utf8_encode($str,$this->charSet);			// Convert the UTF-8 string into a array of char numbers:		$nArr = $this->csConvObj->utf8_to_numberarray($str);		return 'String.fromCharCode('.implode(',',$nArr).')';	}	/**	 * Returns the label with key $index form the globally loaded $LOCAL_LANG array.	 * Mostly used from modules with only one LOCAL_LANG file loaded into the global space.	 *	 * @param	string		Label key	 * @param	boolean		If set, the return value is htmlspecialchar'ed	 * @return	string	 */	function getLL($index,$hsc=0)	{		// Get Local Language		if (strcmp($GLOBALS['LOCAL_LANG'][$this->lang][$index],''))	{			$output = $this->hscAndCharConv($GLOBALS['LOCAL_LANG'][$this->lang][$index], $hsc);	// Returns local label if not blank.		} else {			$output = $this->hscAndCharConv($GLOBALS['LOCAL_LANG']['default'][$index], $hsc);	// Returns default label		}		return $output.($this->debugKey ? ' ['.$index.']':'');	}	/**	 * Works like ->getLL() but takes the $LOCAL_LANG array used as the second argument instead of using the global array.	 *	 * @param	string		Label key	 * @param	array		$LOCAL_LANG array to get label key from	 * @param	boolean		If set, the return value is htmlspecialchar'ed	 * @return	string	 */	function getLLL($index,$LOCAL_LANG,$hsc=0)	{		// Get Local Language		if (strcmp($LOCAL_LANG[$this->lang][$index],''))	{			$output = $this->hscAndCharConv($LOCAL_LANG[$this->lang][$index], $hsc);	// Returns local label if not blank.		} else {			$output = $this->hscAndCharConv($LOCAL_LANG['default'][$index], $hsc);		// Returns default label		}		return $output.($this->debugKey ? ' ['.$index.']':'');	}	/**	 * splitLabel function	 * Historically labels were exploded by '|' and each part would correspond to the translation of the language found at the same 'index' in the TYPO3_languages constant.	 * Today all translations are based on $LOCAL_LANG variables. 'language-splitted' labels can therefore refer to a local-lang file + index instead!	 * It's highly recommended to use the 'local_lang' method (and thereby it's highly deprecated to use 'language-splitted' label strings)	 * Refer to 'Inside TYPO3' for more details	 *	 * @param	string		Label key/reference	 * @param	boolean		If set, the return value is htmlspecialchar'ed	 * @return	string	 */	function sL($input,$hsc=0)	{		if (strcmp(substr($input,0,4),'LLL:'))	{	// Using obsolete 'language-splitted' labels:			$t = explode('|',$input);			$out = $t[$this->langSplitIndex] ? $t[$this->langSplitIndex] : $t[0];			return $this->hscAndCharConv($out, $hsc);		} else {	// LOCAL_LANG:			if (!isset($this->LL_labels_cache[$this->lang][$input])) {	// If cached label				$restStr = trim(substr($input,4));				$extPrfx='';				if (!strcmp(substr($restStr,0,4),'EXT:'))	{	// ll-file refered to is found in an extension.					$restStr = trim(substr($restStr,4));					$extPrfx='EXT:';				}				$parts = explode(':',$restStr);				$parts[0]=$extPrfx.$parts[0];				if (!isset($this->LL_files_cache[$parts[0]]))	{	// Getting data if not cached					$this->LL_files_cache[$parts[0]] = $this->readLLfile($parts[0]);						// If the current language is found in another file, load that as well:					$lFileRef = $this->localizedFileRef($parts[0]);					if ($lFileRef && is_string($this->LL_files_cache[$parts[0]][$this->lang]) && $this->LL_files_cache[$parts[0]][$this->lang]=='EXT')	{						$tempLL = $this->readLLfile($lFileRef);						$this->LL_files_cache[$parts[0]][$this->lang] = $tempLL[$this->lang];					}						// Overriding file?					if (isset($GLOBALS['TYPO3_CONF_VARS']['BE']['XLLfile'][$parts[0]]))	{						$ORarray = $this->readLLfile($GLOBALS['TYPO3_CONF_VARS']['BE']['XLLfile'][$parts[0]]);						$this->LL_files_cache[$parts[0]] = t3lib_div::array_merge_recursive_overrule($this->LL_files_cache[$parts[0]],$ORarray);					}				}				$this->LL_labels_cache[$this->lang][$input] = $this->getLLL($parts[1],$this->LL_files_cache[$parts[0]]);			}			$output = $hsc ? t3lib_div::deHSCentities(htmlspecialchars($this->LL_labels_cache[$this->lang][$input])) : $this->LL_labels_cache[$this->lang][$input]; // For the cached output charset conversion has already happend! So perform HSC right here.			return $output.($this->debugKey ? ' ['.$input.']':'');		}	}	/**	 * Loading $TCA_DESCR[$table]['columns'] with content from locallang files as defined in $TCA_DESCR[$table]['refs']	 * $TCA_DESCR is a global var	 *	 * @param	string		Table name found as key in global array $TCA_DESCR	 * @return	void	 */	function loadSingleTableDescription($table)	{		global $TCA_DESCR;		if (is_array($TCA_DESCR[$table])				&& !isset($TCA_DESCR[$table]['columns'])				&& is_array($TCA_DESCR[$table]['refs']))	 {	// First the 'table' cannot already be loaded in [columns] and secondly there must be a references to locallang files available in [refs]				// Init $TCA_DESCR for $table-key			$TCA_DESCR[$table]['columns']=array();				// Get local-lang for each file in $TCA_DESCR[$table]['refs'] as they are ordered.			foreach ($TCA_DESCR[$table]['refs'] as $llfile)	{				$LOCAL_LANG = $this->includeLLFile($llfile,0,1);					// Traverse all keys				if (is_array($LOCAL_LANG['default']))	{					foreach($LOCAL_LANG['default'] as $lkey => $lVal)	{							// exploding by '.':							// 0 => fieldname,							// 1 => type from (alttitle,description,details,syntax,image_descr,image,seeAlso),							// 2 => special instruction, see switch construct						$kParts = explode('.',$lkey);							// Detecting 'hidden' labels, converting to normal fieldname						if ($kParts[0]=='_')	$kParts[0]='';						if (substr($kParts[0],0,1)=='_')	{ $kParts[0] = substr($kParts[0],1); }							// Add label:						switch((string)$kParts[2])	{							case '+':	// adding								$TCA_DESCR[$table]['columns'][$kParts[0]][$kParts[1]].= chr(10).$lVal;							break;							default:	// Substituting:								$TCA_DESCR[$table]['columns'][$kParts[0]][$kParts[1]] = $lVal;							break;						}					}				}			}		}	}	/**	 * Includes locallang file (and possibly additional localized version if configured for)	 * Read language labels will be merged with $LOCAL_LANG (if $setGlobal=1).	 *	 * @param	string		$fileRef is a file-reference (see t3lib_div::getFileAbsFileName)	 * @param	boolean		Setting in global variable $LOCAL_LANG (or returning the variable)	 * @param	boolean		If $mergeLocalOntoDefault is set the local part of the $LOCAL_LANG array is merged onto the default part (if the local part exists) and the local part is unset.	 * @return	mixed		If $setGlobal is true the LL-files will set the $LOCAL_LANG in the global scope. Otherwise the $LOCAL_LANG array is returned from function	 */	function includeLLFile($fileRef,$setGlobal=1,$mergeLocalOntoDefault=0)	{			// Configure for global flag:		if ($setGlobal)	{			global $LOCAL_LANG;		}			// Get default file:		$llang = $this->readLLfile($fileRef);		if (count($llang))	{			$LOCAL_LANG = t3lib_div::array_merge_recursive_overrule($LOCAL_LANG,$llang);				// Localized addition?			$lFileRef = $this->localizedFileRef($fileRef);			if ($lFileRef && (string)$LOCAL_LANG[$this->lang]=='EXT')	{				$llang = $this->readLLfile($lFileRef);				$LOCAL_LANG = t3lib_div::array_merge_recursive_overrule($LOCAL_LANG,$llang);			}				// Overriding file?			if (isset($GLOBALS['TYPO3_CONF_VARS']['BE']['XLLfile'][$fileRef]))	{				$ORarray = $this->readLLfile($GLOBALS['TYPO3_CONF_VARS']['BE']['XLLfile'][$fileRef]);				$LOCAL_LANG = t3lib_div::array_merge_recursive_overrule($LOCAL_LANG,$ORarray);			}				// Merge local onto default:			if ($mergeLocalOntoDefault && strcmp($this->lang,'default') && is_array($LOCAL_LANG[$this->lang]) && is_array($LOCAL_LANG['default']))	{				$LOCAL_LANG['default'] = array_merge($LOCAL_LANG['default'],$LOCAL_LANG[$this->lang]);	// array_merge can be used so far the keys are not numeric - which we assume they are not...				unset($LOCAL_LANG[$this->lang]);			}		}			// Return value if not global is set.		if (!$setGlobal)	{			return $LOCAL_LANG;		}	}	/**	 * Includes a locallang file and returns the $LOCAL_LANG array found inside.	 *	 * @param	string		Input is a file-reference (see t3lib_div::getFileAbsFileName) which, if exists, is included. That file is expected to be a 'local_lang' file containing a $LOCAL_LANG array.	 * @return	array		Value of $LOCAL_LANG found in the included file. If that array is found it's returned. Otherwise an empty array	 */	function readLLfile($fileRef)	{		return t3lib_div::readLLfile($fileRef,$this->lang);	}	/**	 * Returns localized fileRef (.[langkey].php)	 *	 * @param	string		Filename/path of a 'locallang.php' file	 * @return	string		Input filename with a '.[lang-key].php' ending added if $this->lang is not 'default'	 */	function localizedFileRef($fileRef)	{		if ($this->lang!='default' && substr($fileRef,-4)=='.php')	{			return substr($fileRef,0,-4).'.'.$this->lang.'.php';		}	}}// Include extension to the template class?if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/lang/lang.php'])	{	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/lang/lang.php']);}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -