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

📄 acp_language.php

📁 这些都是我以前学习是用到的源码
💻 PHP
📖 第 1 页 / 共 3 页
字号:
				exit;			break;		}		$sql = 'SELECT user_lang, COUNT(user_lang) AS lang_count			FROM ' . USERS_TABLE . ' 			GROUP BY user_lang';		$result = $db->sql_query($sql);		$lang_count = array();		while ($row = $db->sql_fetchrow($result))		{			$lang_count[$row['user_lang']] = $row['lang_count'];		}		$db->sql_freeresult($result);		$sql = 'SELECT *  			FROM ' . LANG_TABLE . '			ORDER BY lang_english_name';		$result = $db->sql_query($sql);		$installed = array();		while ($row = $db->sql_fetchrow($result))		{			$installed[] = $row['lang_iso'];			$tagstyle = ($row['lang_iso'] == $config['default_lang']) ? '*' : '';			$template->assign_block_vars('lang', array(				'U_DETAILS'			=> $this->u_action . "&amp;action=details&amp;id={$row['lang_id']}",				'U_DOWNLOAD'		=> $this->u_action . "&amp;action=download&amp;id={$row['lang_id']}",				'U_DELETE'			=> $this->u_action . "&amp;action=delete&amp;id={$row['lang_id']}",				'ENGLISH_NAME'		=> $row['lang_english_name'],				'TAG'				=> $tagstyle,				'LOCAL_NAME'		=> $row['lang_local_name'],				'ISO'				=> $row['lang_iso'],				'USED_BY'			=> (isset($lang_count[$row['lang_iso']])) ? $lang_count[$row['lang_iso']] : 0,			));		}		$db->sql_freeresult($result);		$new_ary = $iso = array();		$dp = opendir("{$phpbb_root_path}language");		while (($file = readdir($dp)) !== false)		{			if ($file[0] != '.' && file_exists("{$phpbb_root_path}language/$file/iso.txt"))			{				if (!in_array($file, $installed))				{					if ($iso = file("{$phpbb_root_path}language/$file/iso.txt"))					{						if (sizeof($iso) == 3)						{							$new_ary[$file] = array(								'iso'		=> $file,								'name'		=> trim($iso[0]),								'local_name'=> trim($iso[1]),								'author'	=> trim($iso[2])							);						}					}				}			}		}		unset($installed);		@closedir($dp);		if (sizeof($new_ary))		{			foreach ($new_ary as $iso => $lang_ary)			{				$template->assign_block_vars('notinst', array(					'ISO'			=> htmlspecialchars($lang_ary['iso']),					'LOCAL_NAME'	=> htmlspecialchars($lang_ary['local_name'], ENT_COMPAT, 'UTF-8'),					'NAME'			=> htmlspecialchars($lang_ary['name'], ENT_COMPAT, 'UTF-8'),					'U_INSTALL'		=> $this->u_action . '&amp;action=install&amp;iso=' . urlencode($lang_ary['iso']))				);			}		}		unset($new_ary);	}	/**	* Set default language variables/header	*/	function default_variables()	{		global $phpEx;		$this->language_file_header = '<?php/** ** {FILENAME} [{LANG_NAME}]** @package language* @copyright (c) 2006 phpBB Group * @author {CHANGED} - {AUTHOR}* @license http://opensource.org/licenses/gpl-license.php GNU Public License **//*** DO NOT CHANGE*/if (empty($lang) || !is_array($lang)){	$lang = array();}// DEVELOPERS PLEASE NOTE//// All language files should use UTF-8 as their encoding and the files must not contain a BOM.//// Placeholders can now contain order information, e.g. instead of// \'Page %s of %s\' you can (and should) write \'Page %1$s of %2$s\', this allows// translators to re-order the output of data while ensuring it remains correct//// You do not need this where single placeholders are used, e.g. \'Message %d\' is fine// equally where a string contains only two placeholders which are used to wrap text// in a url you again do not need to specify an order e.g., \'Click %sHERE%s\' is fine';		$this->lang_header = '$lang = array_merge($lang, array(';		// Language files in language root directory		$this->main_files = array("common.$phpEx", "groups.$phpEx", "install.$phpEx", "mcp.$phpEx", "memberlist.$phpEx", "posting.$phpEx", "search.$phpEx", "ucp.$phpEx", "viewforum.$phpEx", "viewtopic.$phpEx", "help_bbcode.$phpEx", "help_faq.$phpEx");	}	/**	* Get filename/location of language file	*/	function get_filename($lang_iso, $directory, $filename, $check_store = false, $only_return_filename = false)	{		global $phpbb_root_path, $safe_mode;				$check_filename = "language/$lang_iso/" . (($directory) ? $directory . '/' : '') . $filename;		if ($check_store)		{			$check_store_filename = ($safe_mode) ? "store/langfile_{$lang_iso}" . (($directory) ? '_' . $directory : '') . "_{$filename}" : "store/language/$lang_iso/" . (($directory) ? $directory . '/' : '') . $filename;			if (!$only_return_filename && file_exists($phpbb_root_path . $check_store_filename))			{				return $check_store_filename;			}			else if ($only_return_filename)			{				return $check_store_filename;			}		}		return $check_filename;	}	/**	* Add files to archive	*/	function add_to_archive(&$compress, $filelist, $lang_iso, $directory = '')	{		global $phpbb_root_path;		foreach ($filelist as $file)		{			// Get source filename			$source = $this->get_filename($lang_iso, $directory, $file, true);			$destination = 'language/' . $lang_iso . '/' . (($directory) ? $directory . '/' : '') . $file;			// Add file to archive			$compress->add_custom_file($phpbb_root_path . $source, $destination);		}	}	/**	* Print language entries	*/	function print_language_entries(&$lang_ary, $key_prefix = '', $input_field = true)	{		$tpl = '';		foreach ($lang_ary as $key => $value)		{			if (is_array($value))			{				$tpl .= '				<tr>					<td class="row3" colspan="2">' . htmlspecialchars($key_prefix, ENT_COMPAT, 'UTF-8') . '<b>' . htmlspecialchars($key, ENT_COMPAT, 'UTF-8') . '</b></td>				</tr>';				foreach ($value as $_key => $_value)				{					if (is_array($_value))					{						$tpl .= '							<tr>								<td class="row3" colspan="2">' . htmlspecialchars($key_prefix, ENT_COMPAT, 'UTF-8') . '&nbsp; &nbsp;<b>' . htmlspecialchars($_key, ENT_COMPAT, 'UTF-8') . '</b></td>							</tr>';						foreach ($_value as $__key => $__value)						{							$tpl .= '								<tr>									<td class="row1" style="white-space: nowrap;">' . htmlspecialchars($key_prefix, ENT_COMPAT, 'UTF-8') . '<b>' . htmlspecialchars($__key, ENT_COMPAT, 'UTF-8') . '</b></td>									<td class="row2">';							if ($input_field)							{								$tpl .= '<input type="text" name="entry[' . htmlspecialchars($key, ENT_COMPAT, 'UTF-8') . '][' . htmlspecialchars($_key, ENT_COMPAT, 'UTF-8') . '][' . htmlspecialchars($__key, ENT_COMPAT, 'UTF-8') . ']" value="' . htmlspecialchars($__value, ENT_COMPAT, 'UTF-8') . '" size="50" />';							}							else							{								$tpl .= '<b>' . htmlspecialchars($__value, ENT_COMPAT, 'UTF-8') . '</b>';							}														$tpl .= '</td>								</tr>';						}					}					else					{						$tpl .= '							<tr>								<td class="row1" style="white-space: nowrap;">' . htmlspecialchars($key_prefix, ENT_COMPAT, 'UTF-8') . '<b>' . htmlspecialchars($_key, ENT_COMPAT, 'UTF-8') . '</b></td>								<td class="row2">';						if ($input_field)						{							$tpl .= '<input type="text" name="entry[' . htmlspecialchars($key, ENT_COMPAT, 'UTF-8') . '][' . htmlspecialchars($_key, ENT_COMPAT, 'UTF-8') . ']" value="' . htmlspecialchars($_value, ENT_COMPAT, 'UTF-8') . '" size="50" />';						}						else						{							$tpl .= '<b>' . htmlspecialchars($_value, ENT_COMPAT, 'UTF-8') . '</b>';						}												$tpl .= '</td>							</tr>';					}				}				$tpl .= '				<tr>					<td class="spacer" colspan="2">&nbsp;</td>				</tr>';			}			else			{				$tpl .= '				<tr>					<td class="row1" style="white-space: nowrap;">' . htmlspecialchars($key_prefix, ENT_COMPAT, 'UTF-8') . '<b>' . htmlspecialchars($key, ENT_COMPAT, 'UTF-8') . '</b></td>					<td class="row2">';				if ($input_field)				{					$tpl .= '<input type="text" name="entry[' . htmlspecialchars($key, ENT_COMPAT, 'UTF-8') . ']" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '" size="50" />';				}				else				{					$tpl .= '<b>' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '</b>';				}								$tpl .= '</td>					</tr>';			}		}		return $tpl;	}	/**	* Print help entries	*/	function print_help_entries(&$lang_ary, $key_prefix = '', $text_field = true)	{		$tpl = '';				foreach ($lang_ary as $key => $value)		{			if (is_array($value))			{				$tpl .= '				<tr>					<td class="row3" colspan="2">' . htmlspecialchars($key_prefix, ENT_COMPAT, 'UTF-8') . '<b>' . htmlspecialchars($key, ENT_COMPAT, 'UTF-8') . '</b></td>				</tr>';				foreach ($value as $_key => $_value)				{					$tpl .= '						<tr>							<td class="row1" style="width: 10%; white-space: nowrap;">' . htmlspecialchars($key_prefix, ENT_COMPAT, 'UTF-8') . '<b>' . htmlspecialchars($_key, ENT_COMPAT, 'UTF-8') . '</b></td>							<td class="row2">';										if ($text_field)					{						$tpl .= '<textarea name="entry[' . htmlspecialchars($key, ENT_COMPAT, 'UTF-8') . '][' . htmlspecialchars($_key, ENT_COMPAT, 'UTF-8') . ']" cols="80" rows="5" style="width: 90%;">' . htmlspecialchars($_value, ENT_COMPAT, 'UTF-8') . '</textarea>';					}					else					{						$tpl .= '<b>' . htmlspecialchars($_value, ENT_COMPAT, 'UTF-8') . '</b>';					}										$tpl .= '</td>						</tr>';				}				$tpl .= '				<tr>					<td class="spacer" colspan="2">&nbsp;</td>				</tr>';			}			else			{				$tpl .= '				<tr>					<td class="row1" style="width: 10%; white-space: nowrap;">' . htmlspecialchars($key_prefix, ENT_COMPAT, 'UTF-8') . '<b>' . htmlspecialchars($key, ENT_COMPAT, 'UTF-8') . '</b></td>					<td class="row2">';				if ($text_field)				{					$tpl .= '<textarea name="entry[' . htmlspecialchars($key, ENT_COMPAT, 'UTF-8') . ']" cols="80" rows="5" style="width: 90%;">' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '</textarea>';				}				else				{					$tpl .= '<b>' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '</b>';				}				$tpl .= '</td>					</tr>';			}		}		return $tpl;	}	/**	* Compare two language files	*/	function compare_language_files($source_lang, $dest_lang, $directory, $file)	{		global $phpbb_root_path, $phpEx;		$return_ary = array();		$lang = array();		include("{$phpbb_root_path}language/{$source_lang}/" . (($directory) ? $directory . '/' : '') . $file);		$lang_entry_src = $lang;		$lang = array();		if (!file_exists($phpbb_root_path . $this->get_filename($dest_lang, $directory, $file, true)))		{			return array();		}		include($phpbb_root_path . $this->get_filename($dest_lang, $directory, $file, true));		$lang_entry_dst = $lang;		unset($lang);		$diff_array_keys = array_diff(array_keys($lang_entry_src), array_keys($lang_entry_dst));		unset($lang_entry_dst);		foreach ($diff_array_keys as $key)		{			$return_ary[$key] = $lang_entry_src[$key];		}		unset($lang_entry_src);		return $return_ary;	}	/**	* Return language string value for storage	*/	function prepare_lang_entry($text, $store = true)	{		$text = (STRIP) ? stripslashes($text) : $text;		// Adjust for storage...		if ($store)		{			$text = str_replace("'", "\\'", str_replace('\\', '\\\\', $text));		}		return $text;	}	/**	* Format language array for storage	*/	function format_lang_array($key, $value, $tabs = "\t")	{		$entry = '';		if (!is_array($value))		{			$entry .= "{$tabs}'{$key}'\t=> '" . $this->prepare_lang_entry($value) . "',\n";		}		else		{			$_tabs = $tabs . "\t";			$entry .= "\n{$tabs}'{$key}'\t=> array(\n";			foreach ($value as $_key => $_value)			{				$entry .= $this->format_lang_array($_key, $_value, $_tabs);			}			$entry .= "{$tabs}),\n\n";		}		return $entry;	}}?>

⌨️ 快捷键说明

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