X-Git-Url: https://git.mxchange.org/?p=hub.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Flanguage%2Fclass_LanguageSystem.php;fp=inc%2Fclasses%2Fmain%2Flanguage%2Fclass_LanguageSystem.php;h=0000000000000000000000000000000000000000;hp=befccdb1414a132c9a7dbc30dc3a8efef6617cb6;hb=7150c6d1a1e3c91d3cfd2e732b26bbe9f0dc4f57;hpb=12dbc1af8f0bc2981711b17c7c955f270c440b35 diff --git a/inc/classes/main/language/class_LanguageSystem.php b/inc/classes/main/language/class_LanguageSystem.php deleted file mode 100644 index befccdb14..000000000 --- a/inc/classes/main/language/class_LanguageSystem.php +++ /dev/null @@ -1,183 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.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 3 of the License, or - * (at your option) any later version. - * - * 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, see . - */ -class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage { - /** - * The full-qualified base path for the language include files - */ - private $basePath = ""; - - /** - * The 2-char language code - */ - private $langCode = "xx"; // This will later be overwritten! - - /** - * The array-object for all language strings - */ - private $langStrings = null; - - /** - * An instance of this class - */ - private static $thisInstance = null; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Clean up a little - $this->removeNumberFormaters(); - $this->removeSystemArray(); - } - - /** - * Creates an instance of the class LanguageSystem and prepares it for usage - * - * @param $basePath The local base path for all language strings - * @return $langInstance An instance of LanguageSystem - * @throws LanguagePathIsEmptyException If the provided $basePath is empty - * @throws InvalidLanguagePathStringException If $basePath is no string - * @throws LanguagePathIsNoDirectoryException If $basePath is no - * directory or not found - * @throws LanguagePathReadProtectedException If $basePath is - * read-protected - */ - public final static function createLanguageSystem ($basePath) { - // Get a new instance - $langInstance = new LanguageSystem(); - - // Is the base path valid? - if (empty($basePath)) { - // Language path is empty - throw new LanguagePathIsEmptyException($langInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif (!is_string($basePath)) { - // Is not a string - throw new InvalidLanguagePathStringException(array($langInstance, $basePath), self::EXCEPTION_INVALID_STRING); - } elseif (!is_dir($basePath)) { - // Is not a path - throw new LanguagePathIsNoDirectoryException(array($langInstance, $basePath), self::EXCEPTION_INVALID_PATH_NAME); - } elseif (!is_readable($basePath)) { - // Is not readable - throw new LanguagePathReadProtectedException(array($langInstance, $basePath), self::EXCEPTION_READ_PROTECED_PATH); - } - - // Set the base path - $langInstance->setBasePath($basePath); - - // Initialize the variable stack - $langInstance->initLanguageStrings(); - - // Set language code from default config - $langInstance->setLanguageCode(FrameworkConfiguration::getInstance()->readConfig('default_lang')); - - // Remember this instance - self::$thisInstance = $langInstance; - - // Return the prepared instance - return $langInstance; - } - - /** - * Singleton getter for this instance - * - * @return $thisInstance An instance of this class - */ - public final static function getInstance () { - return self::$thisInstance; - } - - /** - * Setter for base path - * - * @param $basePath The local base path for all templates - * @return void - */ - protected final function setBasePath ($basePath) { - // And set it - $this->basePath = (string) $basePath; - } - - /** - * Setter for language code - * - * @param $langCode The language code for the current application - * @return void - */ - protected final function setLanguageCode ($langCode) { - // Cast it - $langCode = (string) $langCode; - - // And set it (only 2 chars) - $this->langCode = substr($langCode, 0, 2); - } - - /** - * Initialize the array-object for all later language strings - * - * @return void - */ - public function initLanguageStrings () { - $this->langStrings = new FrameworkArrayObject("FakedLanguageStrings"); - } - - /** - * Getter for language code - * - * @return $langCode The language code for the current application - */ - public final function getLanguageCode () { - return $this->langCode; - } - - /** - * Get the plain message from the cache variable for the given message id - * - * @param $messageId The message id we shall find in the cache variable - * @return $messageText The plain message text - */ - public function getMessage ($messageId) { - // Default is missing message text - $messageText = sprintf("!%s!", - $messageId - ); - - // Try to look it up in the cache variable - if ($this->langStrings->offsetExists($messageId)) { - // Return the message string - $messageText = $this->langStrings->offsetGet($messageId); - } - - // Return the text - return $messageText; - } -} - -// [EOF] -?>