Minahito
minah****@users*****
2006年 7月 20日 (木) 17:15:41 JST
Index: xoops2jp/html/modules/base/kernel/Legacy_LanguageManager.class.php diff -u xoops2jp/html/modules/base/kernel/Legacy_LanguageManager.class.php:1.1.2.5 xoops2jp/html/modules/base/kernel/Legacy_LanguageManager.class.php:1.1.2.6 --- xoops2jp/html/modules/base/kernel/Legacy_LanguageManager.class.php:1.1.2.5 Tue Mar 28 22:30:15 2006 +++ xoops2jp/html/modules/base/kernel/Legacy_LanguageManager.class.php Thu Jul 20 17:15:40 2006 @@ -1,88 +1,107 @@ <?php -// $Id: Legacy_LanguageManager.class.php,v 1.1.2.5 2006/03/28 13:30:15 minahito Exp $ -// ------------------------------------------------------------------------ // -// XOOPS - PHP Content Management System // -// Copyright (c) 2000 XOOPS.org // -// <http://www.xoops.org/> // -// ------------------------------------------------------------------------ // -// This program 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. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program 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. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // +/** + * @package legacy + * @version $Id: Legacy_LanguageManager.class.php,v 1.1.2.6 2006/07/20 08:15:40 minahito Exp $ + */ if (!defined('XOOPS_ROOT_PATH')) exit(); -require_once XOOPS_ROOT_PATH . "/class/XCube_LanguageManager.class.php"; +require_once XOOPS_ROOT_PATH . "/kernel/XCube_LanguageManager.class.php"; class Legacy_LanguageManager extends XCube_LanguageManager { - var $mLanguageName; + function prepare() + { + parent::prepare(); + + // + // Load the additional file to control DB. + // + $filename = XOOPS_MODULE_PATH . '/base/language/' . $this->mLanguageName . '/charset_' . XOOPS_DB_TYPE . '.php'; + if (file_exists($filename)) { + require_once($filename); + } + } - function loadMainLanguage() + function loadGlobalMessageCatalog() { if (!$this->_loadFile(XOOPS_ROOT_PATH . "/modules/base/language/" . $this->mLanguageName . "/global.php")) { - $this->_loadFile(XOOPS_ROOT_PATH."/modules/base/language/english/global.php"); + $this->_loadFile(XOOPS_ROOT_PATH . "/modules/base/language/english/global.php"); } + // // Now, if XOOPS_USE_MULTIBYTES isn't defined, set zero to it. + // if (!defined("XOOPS_USE_MULTIBYTES")) { - define("XOOPS_USE_MULTIBYTES",0); + define("XOOPS_USE_MULTIBYTES", 0); } } - function loadSpecialTypeLanguage($type) + /** + * Load the special message catalog which is defined has been the XOOPS2 + * generation. + * + * @access public + * @param string $type + */ + function loadPageTypeMessageCatalog($type) { - if (strpos($type,'.') === false) { + if (strpos($type, '.') === false) { $filename = XOOPS_ROOT_PATH . "/language/" . $this->mLanguageName . "/" . $type . ".php"; if (!$this->_loadFile($filename)) { - $filename = XOOPS_ROOT_PATH . "/language/english/" . $type . ".php"; + $filename = XOOPS_ROOT_PATH . "/language/" . $this->getFallbackLanguage() . "/" . $type . ".php"; $this->_loadFile($filename); } } } /** - Load language for module controller. - @param $dirname module directory name + * Load the message catalog of the specified module. + * + * @access public + * @param $dirname A dirname of module. */ - function loadModuleLanguage($dirname) + function loadModuleMessageCatalog($moduleName) { - $this->_loadLanguage($dirname, "main"); + $this->_loadLanguage($moduleName, "main"); } - - function loadModuleAdminLanguage($dirname) + + /** + * Load the message catalog of the specified module for admin. + * + * @access public + * @param $dirname A dirname of module. + */ + function loadModuleAdminMessageCatalog($dirname) { $this->_loadLanguage($dirname, "admin"); } + /** + * Load the message catalog of the specified module for block. + * + * @access public + * @param $dirname A dirname of module. + */ function loadBlockLanguage($dirname) { $this->_loadLanguage($dirname, "blocks"); } - function loadManifestoLanguage($dirname) + /** + * Load the message catalog of the specified module for modinfo. + * + * @access public + * @param $dirname A dirname of module. + */ + function loadModinfoMessageCatalog($dirname) { $this->_loadLanguage($dirname, "modinfo"); } /** - * @access private - * @param $dirname module directory name + * @access protected + * @param $dirname module directory name * @param $fileBodyName language file body name */ function _loadLanguage($dirname, $fileBodyName) @@ -96,7 +115,7 @@ /** - * @access private + * @access protected */ function _loadFile($filename) { @@ -111,6 +130,76 @@ return false; } + + /** + * check the exstence of the specified file in the specified section. + * + * @access public + * @param string $section A name of section. + * @param string $filename A name of file + * @return bool + */ + function existFile($section, $filename) + { + if ($section != null) { + $filePath = XOOPS_ROOT_PATH . "/languages/" . $this->mLanguageName . "/${section}/${filename}"; + } + else { + $filePath = XOOPS_ROOT_PATH . "/languages/" . $this->mLanguageName . "/${filename}"; + } + + return file_exists($filePath); + } + + /** + * Return the file path by the specified section and the specified file. + * + * @access public + * @param string $section A name of section. + * @param string $filename A name of file + * @return string + */ + function getFilepath($section, $filename) + { + $filepath = null; + if ($section != null) { + $filepath = XOOPS_ROOT_PATH . "/languages/" . $this->mLanguageName . "/${section}/${filename}"; + } + else { + $filepath = XOOPS_ROOT_PATH . "/languages/" . $this->mLanguageName . "/${filename}"; + } + + if (file_exists($filepath)) { + return $filepath; + } + else { + if ($section != null) { + return XOOPS_ROOT_PATH . "/languages/" . $this->getFallbackLanguage() . "/${section}/${filename}"; + } + else { + return XOOPS_ROOT_PATH . "/languages/" . $this->getFallbackLanguage() . "/${filename}"; + } + } + } + + /** + * Get file contents and return it. + * + * @access public + * @param string $section A name of section. + * @param string $filename A name of file + * @return string + */ + function loadTextFile($section, $filename) + { + $filepath = $this->getFilepath($section, $filename); + return file_get_contents($filepath); + } + + function getFallbackLanguage() + { + return "english"; + } } ?> \ No newline at end of file