From: Michael M Slusarz Date: Thu, 9 Jul 2009 07:52:36 +0000 (-0600) Subject: Import Nls package from CVS HEAD X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=8d38a43880bfd2f005b63d098c51bb904cdaacfd;p=horde.git Import Nls package from CVS HEAD --- diff --git a/framework/Auth/lib/Horde/Auth.php b/framework/Auth/lib/Horde/Auth.php index 4e4edce17..8a5695a14 100644 --- a/framework/Auth/lib/Horde/Auth.php +++ b/framework/Auth/lib/Horde/Auth.php @@ -548,7 +548,7 @@ class Horde_Auth /* Reload preferences for the new user. */ $GLOBALS['registry']->loadPrefs(); - NLS::setLang($GLOBALS['prefs']->getValue('language')); + Horde_Nls::setLang($GLOBALS['prefs']->getValue('language')); /* Fetch the user's last login time. */ $old_login = @unserialize($GLOBALS['prefs']->getValue('last_login')); diff --git a/framework/Auth/lib/Horde/Auth/Cyrsql.php b/framework/Auth/lib/Horde/Auth/Cyrsql.php index a44d7f015..87874f136 100644 --- a/framework/Auth/lib/Horde/Auth/Cyrsql.php +++ b/framework/Auth/lib/Horde/Auth/Cyrsql.php @@ -266,7 +266,7 @@ class Horde_Auth_Cyrsql extends Horde_Auth_Sql } try { - $mailbox = Horde_String::convertCharset($this->_params['userhierarchy'] . $userId, NLS::getCharset(), 'utf7-imap'); + $mailbox = Horde_String::convertCharset($this->_params['userhierarchy'] . $userId, Horde_Nls::getCharset(), 'utf7-imap'); $ob->createMailbox($mailbox); $ob->setACL($mailbox, $this->_params['cyradm'], 'lrswipcda'); } catch (Horde_Imap_Client_Exception $e) { @@ -278,12 +278,12 @@ class Horde_Auth_Cyrsql extends Horde_Auth_Sql ($this->_params['domain_field'] != 'none')) { list($userName, $domain) = explode('@', $userName); $tmp = $userName . $this->_separator . $value . '@' . $domain; -Horde_String::convertCharset($userName . $this->_separator . $value . '@' . $domain, NLS::getCharset(), 'utf7-imap'); +Horde_String::convertCharset($userName . $this->_separator . $value . '@' . $domain, Horde_Nls::getCharset(), 'utf7-imap'); } else { $tmp = $userName . $this->_separator . $value; } - $tmp = Horde_String::convertCharset($tmp, NLS::getCharset(), 'utf7-imap'); + $tmp = Horde_String::convertCharset($tmp, Horde_Nls::getCharset(), 'utf7-imap'); $ob->createMailbox($tmp); $ob->setACL($tmp, $this->_params['cyradm'], 'lrswipcda'); } diff --git a/framework/Auth/lib/Horde/Auth/Cyrus.php b/framework/Auth/lib/Horde/Auth/Cyrus.php index ad6e76772..ec34da4db 100644 --- a/framework/Auth/lib/Horde/Auth/Cyrus.php +++ b/framework/Auth/lib/Horde/Auth/Cyrus.php @@ -158,7 +158,7 @@ class Horde_Auth_Cyrus extends Horde_Auth_Driver $this->_backend->addUser($userId, $credentials); - $mailbox = Horde_String::convertCharset('user' . $this->_params['separator'] . $userId, NLS::getCharset(), 'utf7-imap'); + $mailbox = Horde_String::convertCharset('user' . $this->_params['separator'] . $userId, Horde_Nls::getCharset(), 'utf7-imap'); try { $this->_ob->createMailbox($mailbox); @@ -170,7 +170,7 @@ class Horde_Auth_Cyrus extends Horde_Auth_Driver is_array($this->_params['folders'])) { foreach ($this->_params['folders'] as $folder) { try { - $this->_ob->createMailbox($mailbox . Horde_String::convertCharset($this->_params['separator'] . $folder, NLS::getCharset(), 'utf7-imap')); + $this->_ob->createMailbox($mailbox . Horde_String::convertCharset($this->_params['separator'] . $folder, Horde_Nls::getCharset(), 'utf7-imap')); } catch (Horde_Imap_Client_Exception $e) {} } } @@ -198,7 +198,7 @@ class Horde_Auth_Cyrus extends Horde_Auth_Driver $this->_backend->removeUser($userId); - $mailbox = Horde_String::convertCharset('user' . $this->_params['separator'] . $userId, NLS::getCharset(), 'utf7-imap'); + $mailbox = Horde_String::convertCharset('user' . $this->_params['separator'] . $userId, Horde_Nls::getCharset(), 'utf7-imap'); /* Set ACL for mailbox deletion. */ list($admin) = explode('@', $this->_params['cyradmin']); diff --git a/framework/Auth/lib/Horde/Auth/Imap.php b/framework/Auth/lib/Horde/Auth/Imap.php index e8e7d9f4f..b20db106f 100644 --- a/framework/Auth/lib/Horde/Auth/Imap.php +++ b/framework/Auth/lib/Horde/Auth/Imap.php @@ -96,7 +96,7 @@ class Horde_Auth_Imap extends Horde_Auth_Driver { try { $ob->_getOb($this->_params['admin_user'], $this->_params['admin_password']); - $mailbox = Horde_String::convertCharset($this->_params['userhierarchy'] . $userId, NLS::getCharset(), 'utf7-imap'); + $mailbox = Horde_String::convertCharset($this->_params['userhierarchy'] . $userId, Horde_Nls::getCharset(), 'utf7-imap'); $ob->createMailbox($mailbox); $ob->setACL($mailbox, $this->_params['admin_user'], 'lrswipcda'); } catch (Horde_Imap_Client_Exception $e) { @@ -116,7 +116,7 @@ class Horde_Auth_Imap extends Horde_Auth_Driver try { $ob->_getOb($this->_params['admin_user'], $this->_params['admin_password']); $ob->setACL($mailbox, $this->_params['admin_user'], 'lrswipcda'); - $ob->deleteMailbox(Horde_String::convertCharset($this->_params['userhierarchy'] . $userId, NLS::getCharset(), 'utf7-imap')); + $ob->deleteMailbox(Horde_String::convertCharset($this->_params['userhierarchy'] . $userId, Horde_Nls::getCharset(), 'utf7-imap')); } catch (Horde_Imap_Client_Exception $e) { throw new Horde_Exception($e); } diff --git a/framework/Auth/lib/Horde/Auth/Signup.php b/framework/Auth/lib/Horde/Auth/Signup.php index 2abdf6202..7656cd4bd 100644 --- a/framework/Auth/lib/Horde/Auth/Signup.php +++ b/framework/Auth/lib/Horde/Auth/Signup.php @@ -168,7 +168,7 @@ class Horde_Auth_Signup $message, $conf['signup']['email'], $conf['signup']['email'], - NLS::getCharset()); + Horde_Nls::getCharset()); $mail->send($conf['mailer']['type'], $conf['mailer']['params']); } } diff --git a/framework/Core/lib/Horde/Horde.php b/framework/Core/lib/Horde/Horde.php index ff1f3ac3c..88139cfea 100644 --- a/framework/Core/lib/Horde/Horde.php +++ b/framework/Core/lib/Horde/Horde.php @@ -494,7 +494,7 @@ HTML; */ static public function sendHTTPResponse($data, $ct) { - $charset = NLS::getCharset(); + $charset = Horde_Nls::getCharset(); // Output headers and encoded response. switch ($ct) { @@ -1134,7 +1134,7 @@ HTML; } if (!empty($title)) { if ($escape) { - $charset = NLS::getCharset(); + $charset = Horde_Nls::getCharset(); $old_error = error_reporting(0); $title = str_replace( array("\r", "\n"), '', @@ -1179,7 +1179,7 @@ HTML; $attributes = array()) { if (!empty($title)) { - $charset = NLS::getCharset(); + $charset = Horde_Nls::getCharset(); $old_error = error_reporting(0); $title = '<pre>' . preg_replace(array('/\n/', '/((?))/em', '/

/', '/
/'), array('', 'str_repeat(" ", strlen("$1"))', '<br /> <br />', '<br />'), nl2br(htmlspecialchars(htmlspecialchars($title, ENT_QUOTES, $charset), ENT_QUOTES, $charset))) . '</pre>'; error_reporting($old_error); @@ -1273,7 +1273,7 @@ HTML; */ static public function img($src, $alt = '', $attr = '', $dir = null) { - $charset = NLS::getCharset(); + $charset = Horde_Nls::getCharset(); /* If browser does not support images, simply return the ALT text. */ if (!$GLOBALS['browser']->hasFeature('images')) { @@ -1327,7 +1327,7 @@ HTML; */ static public function fullSrcImg($src, $options = array()) { - $charset = NLS::getCharset(); + $charset = Horde_Nls::getCharset(); /* If browser does not support images, simply return the ALT text. */ if (!$GLOBALS['browser']->hasFeature('images')) { @@ -1745,7 +1745,7 @@ HTML; if (!isset($GLOBALS['nls'])) { self::loadConfiguration('nls.php', null, 'horde'); } - $multibyte = isset($GLOBALS['nls']['multibyte'][NLS::getCharset(true)]); + $multibyte = isset($GLOBALS['nls']['multibyte'][Horde_Nls::getCharset(true)]); return preg_replace('/_([A-Za-z])/', $multibyte && preg_match('/[\x80-\xff]/', $label) ? '' : '\1', @@ -1769,10 +1769,10 @@ HTML; return $stripped_label; } - if (isset($GLOBALS['nls']['multibyte'][NLS::getCharset(true)])) { + if (isset($GLOBALS['nls']['multibyte'][Horde_Nls::getCharset(true)])) { /* Prefix parenthesis with the UTF-8 representation of the LRO * (Left-to-Right-Override) Unicode codepoint U+202D. */ - $prefix = NLS::getCharset() == 'UTF-8' ? "\xe2\x80\xad" : ''; + $prefix = Horde_Nls::getCharset() == 'UTF-8' ? "\xe2\x80\xad" : ''; return $stripped_label . $prefix . '(' . strtoupper($accessKey) . '' . ')'; } else { diff --git a/framework/Core/lib/Horde/Horde/Config.php b/framework/Core/lib/Horde/Horde/Config.php index 14b5ba253..d35b819eb 100644 --- a/framework/Core/lib/Horde/Horde/Config.php +++ b/framework/Core/lib/Horde/Horde/Config.php @@ -1356,7 +1356,7 @@ class Horde_Config return $apps; case 'list-horde-languages': - return array_map(create_function('$val', 'return preg_replace(array("/&#x([0-9a-f]{4});/ie", "/(&[^;]+;)/e"), array("Horde_String::convertCharset(pack(\"H*\", \"$1\"), \"ucs-2\", \"' . NLS::getCharset() . '\")", "Horde_String::convertCharset(html_entity_decode(\"$1\", ENT_COMPAT, \"iso-8859-1\"), \"iso-8859-1\", \"' . NLS::getCharset() . '\")"), $val);'), $GLOBALS['nls']['languages']); + return array_map(create_function('$val', 'return preg_replace(array("/&#x([0-9a-f]{4});/ie", "/(&[^;]+;)/e"), array("Horde_String::convertCharset(pack(\"H*\", \"$1\"), \"ucs-2\", \"' . Horde_Nls::getCharset() . '\")", "Horde_String::convertCharset(html_entity_decode(\"$1\", ENT_COMPAT, \"iso-8859-1\"), \"iso-8859-1\", \"' . Horde_Nls::getCharset() . '\")"), $val);'), $GLOBALS['nls']['languages']); case 'list-blocks': $collection = Horde_Block_Collection::singleton('portal'); diff --git a/framework/Core/lib/Horde/Horde/Registry.php b/framework/Core/lib/Horde/Horde/Registry.php index b2d81d6d0..d3d4779ce 100644 --- a/framework/Core/lib/Horde/Horde/Registry.php +++ b/framework/Core/lib/Horde/Horde/Registry.php @@ -150,11 +150,11 @@ class Horde_Registry } /* Initialize the localization routines and variables. We can't use - * NLS::setLanguageEnvironment() here because that depends on the + * Horde_Nls::setLanguageEnvironment() here because that depends on the * registry to be already initialized. */ - NLS::setLang(); - NLS::setTextdomain('horde', HORDE_BASE . '/locale', NLS::getCharset()); - Horde_String::setDefaultCharset(NLS::getCharset()); + Horde_Nls::setLang(); + Horde_Nls::setTextdomain('horde', HORDE_BASE . '/locale', Horde_Nls::getCharset()); + Horde_String::setDefaultCharset(Horde_Nls::getCharset()); /* Check for caching availability. Using cache while not authenticated * isn't possible because, although storage is possible, retrieval @@ -808,7 +808,7 @@ class Horde_Registry * language for this app, the have to be loaded after the * configuration, because they rely on configuration settings. So try * with the current language, and reset the language later. */ - NLS::setLanguageEnvironment($GLOBALS['language'], $app); + Horde_Nls::setLanguageEnvironment($GLOBALS['language'], $app); /* Import this application's configuration values. */ $success = $this->importConfig($app); @@ -826,7 +826,7 @@ class Horde_Registry if (isset($GLOBALS['prefs'])) { $language = $GLOBALS['prefs']->getValue('language'); if ($language != $GLOBALS['language']) { - NLS::setLanguageEnvironment($language, $app); + Horde_Nls::setLanguageEnvironment($language, $app); } } @@ -858,7 +858,7 @@ class Horde_Registry $this->importConfig($app); $this->loadPrefs($app); $language = $GLOBALS['prefs']->getValue('language'); - NLS::setLanguageEnvironment($language, $app); + Horde_Nls::setLanguageEnvironment($language, $app); } return $previous; diff --git a/framework/Crypt/lib/Horde/Crypt/Pgp.php b/framework/Crypt/lib/Horde/Crypt/Pgp.php index 2b061786c..7c394a742 100644 --- a/framework/Crypt/lib/Horde/Crypt/Pgp.php +++ b/framework/Crypt/lib/Horde/Crypt/Pgp.php @@ -926,7 +926,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt if ($errno == 0) { throw new Horde_Exception(_("Connection refused to the public keyserver."), 'horde.error'); } else { - throw new Horde_Exception(sprintf(_("Connection refused to the public keyserver. Reason: %s (%s)"), Horde_String::convertCharset($errstr, NLS::getExternalCharset()), $errno), 'horde.error'); + throw new Horde_Exception(sprintf(_("Connection refused to the public keyserver. Reason: %s (%s)"), Horde_String::convertCharset($errstr, Horde_Nls::getExternalCharset()), $errno), 'horde.error'); } } @@ -1306,7 +1306,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt '--armor', '--always-trust', '--batch', - '--charset ' . NLS::getCharset(), + '--charset ' . Horde_Nls::getCharset(), $keyring, '--verify' ); @@ -1378,12 +1378,12 @@ class Horde_Crypt_Pgp extends Horde_Crypt $msg_sign = $this->encrypt($mime_part->toString(array('headers' => true, 'canonical' => true, 'encode' => Horde_Mime_Part::ENCODE_7BIT)), $params); /* Add the PGP signature. */ - $charset = NLS::getEmailCharset(); + $charset = Horde_Nls::getEmailCharset(); $pgp_sign = new Horde_Mime_Part(); $pgp_sign->setType('application/pgp-signature'); $pgp_sign->setCharset($charset); $pgp_sign->setDisposition('inline'); - $pgp_sign->setDescription(Horde_String::convertCharset(_("PGP Digital Signature"), NLS::getCharset(), $charset)); + $pgp_sign->setDescription(Horde_String::convertCharset(_("PGP Digital Signature"), Horde_Nls::getCharset(), $charset)); $pgp_sign->setContents($msg_sign); /* Get the algorithim information from the signature. Since we are @@ -1423,12 +1423,12 @@ class Horde_Crypt_Pgp extends Horde_Crypt $message_encrypt = $this->encrypt($signenc_body, $params); /* Set up MIME Structure according to RFC 3156. */ - $charset = NLS::getEmailCharset(); + $charset = Horde_Nls::getEmailCharset(); $part = new Horde_Mime_Part(); $part->setType('multipart/encrypted'); $part->setCharset($charset); $part->setContentTypeParameter('protocol', 'application/pgp-encrypted'); - $part->setDescription(Horde_String::convertCharset(_("PGP Encrypted Data"), NLS::getCharset(), $charset)); + $part->setDescription(Horde_String::convertCharset(_("PGP Encrypted Data"), Horde_Nls::getCharset(), $charset)); $part->setContents('This message is in MIME format and has been PGP encrypted.' . "\n"); $part1 = new Horde_Mime_Part(); @@ -1470,9 +1470,9 @@ class Horde_Crypt_Pgp extends Horde_Crypt $part = $this->encryptMIMEPart($part, $encrypt_params); $part->setContents('This message is in MIME format and has been PGP signed and encrypted.' . "\n"); - $charset = NLS::getEmailCharset(); + $charset = Horde_Nls::getEmailCharset(); $part->setCharset($charset); - $part->setDescription(Horde_String::convertCharset(_("PGP Signed/Encrypted Data"), NLS::getCharset(), $charset)); + $part->setDescription(Horde_String::convertCharset(_("PGP Signed/Encrypted Data"), Horde_Nls::getCharset(), $charset)); return $part; } @@ -1487,11 +1487,11 @@ class Horde_Crypt_Pgp extends Horde_Crypt */ public function publicKeyMIMEPart($key) { - $charset = NLS::getEmailCharset(); + $charset = Horde_Nls::getEmailCharset(); $part = new Horde_Mime_Part(); $part->setType('application/pgp-keys'); $part->setCharset($charset); - $part->setDescription(Horde_String::convertCharset(_("PGP Public Key"), NLS::getCharset(), $charset)); + $part->setDescription(Horde_String::convertCharset(_("PGP Public Key"), Horde_Nls::getCharset(), $charset)); $part->setContents($key); return $part; diff --git a/framework/Crypt/lib/Horde/Crypt/Smime.php b/framework/Crypt/lib/Horde/Crypt/Smime.php index c3d5c9261..8eceaa51d 100644 --- a/framework/Crypt/lib/Horde/Crypt/Smime.php +++ b/framework/Crypt/lib/Horde/Crypt/Smime.php @@ -287,11 +287,11 @@ class Horde_Crypt_Smime extends Horde_Crypt $message = $this->encrypt($mime_part->toString(array('headers' => true, 'canonical' => true)), $params); /* Get charset for mime part description. */ - $charset = NLS::getEmailCharset(); + $charset = Horde_Nls::getEmailCharset(); $msg = new Horde_Mime_Part(); $msg->setCharset($charset); - $msg->setDescription(Horde_String::convertCharset(_("S/MIME Encrypted Message"), NLS::getCharset(), $charset)); + $msg->setDescription(Horde_String::convertCharset(_("S/MIME Encrypted Message"), Horde_Nls::getCharset(), $charset)); $msg->setDisposition('inline'); $msg->setType('application/pkcs7-mime'); $msg->setContentTypeParameter('smime-type', 'enveloped-data'); diff --git a/framework/Crypt/test/Horde/Crypt/bug_6601.phpt b/framework/Crypt/test/Horde/Crypt/bug_6601.phpt index e5caba078..f1ef6edc1 100644 --- a/framework/Crypt/test/Horde/Crypt/bug_6601.phpt +++ b/framework/Crypt/test/Horde/Crypt/bug_6601.phpt @@ -14,8 +14,8 @@ class mock_prefs { } $GLOBALS['prefs'] = new mock_prefs(); -require_once 'Horde/NLS.php'; -NLS::setTimezone(); +require_once 'Horde/Nls.php'; +Horde_Nls::setTimezone(); require 'pgp.inc'; echo $pgp->pgpPrettyKey(file_get_contents(dirname(__FILE__) . '/fixtures/bug_6601.asc')); diff --git a/framework/Crypt/test/Horde/Crypt/pgp_publicKeyMIMEPart.phpt b/framework/Crypt/test/Horde/Crypt/pgp_publicKeyMIMEPart.phpt index 886a6561b..0362b6186 100644 --- a/framework/Crypt/test/Horde/Crypt/pgp_publicKeyMIMEPart.phpt +++ b/framework/Crypt/test/Horde/Crypt/pgp_publicKeyMIMEPart.phpt @@ -15,7 +15,7 @@ class PrefsStub { } } -require_once 'Horde/NLS.php'; +require_once 'Horde/Nls.php'; require 'pgp.inc'; $prefs = new PrefsStub; diff --git a/framework/Crypt/test/Horde/Crypt/pgp_verify.phpt b/framework/Crypt/test/Horde/Crypt/pgp_verify.phpt index 0d4f9607a..a2e6af7f7 100644 --- a/framework/Crypt/test/Horde/Crypt/pgp_verify.phpt +++ b/framework/Crypt/test/Horde/Crypt/pgp_verify.phpt @@ -14,8 +14,8 @@ class mock_prefs { } $GLOBALS['prefs'] = new mock_prefs(); -require_once 'Horde/NLS.php'; -NLS::setTimezone(); +require_once 'Horde/Nls.php'; +Horde_Nls::setTimezone(); require 'pgp.inc'; echo $pgp->decrypt(file_get_contents(dirname(__FILE__) . '/fixtures/clear.txt'), @@ -38,4 +38,4 @@ gpg: Good signature from "My Name (My Comment) " gpg: Signature made Fri Aug 11 14:25:36 2006 GMT using DSA key ID BADEABD7 gpg: Good signature from "My Name (My Comment) " gpg: Signature made Fri Aug 11 14:28:48 2006 GMT using DSA key ID BADEABD7 -gpg: Good signature from "My Name (My Comment) " \ No newline at end of file +gpg: Good signature from "My Name (My Comment) " diff --git a/framework/Date/lib/Horde/Date.php b/framework/Date/lib/Horde/Date.php index bb011e421..5bec3a8ba 100644 --- a/framework/Date/lib/Horde/Date.php +++ b/framework/Date/lib/Horde/Date.php @@ -844,10 +844,6 @@ class Horde_Date */ protected function _strftime($format) { - if (preg_match('/%[bBpxX]/', $format)) { - require_once 'Horde/NLS.php'; - } - return preg_replace( array('/%b/e', '/%B/e', @@ -870,8 +866,8 @@ class Horde_Date '/%y/e', '/%Y/', '/%%/'), - array('$this->_strftime(NLS::getLangInfo(constant(\'ABMON_\' . (int)$this->_month)))', - '$this->_strftime(NLS::getLangInfo(constant(\'MON_\' . (int)$this->_month)))', + array('$this->_strftime(Horde_Nls::getLangInfo(constant(\'ABMON_\' . (int)$this->_month)))', + '$this->_strftime(Horde_Nls::getLangInfo(constant(\'MON_\' . (int)$this->_month)))', '(int)($this->_year / 100)', 'sprintf(\'%02d\', $this->_mday)', '$this->_strftime(\'%m/%d/%y\')', @@ -881,13 +877,13 @@ class Horde_Date 'sprintf(\'%02d\', $this->_month)', 'sprintf(\'%02d\', $this->_min)', "\n", - '$this->_strftime(NLS::getLangInfo($this->_hour < 12 ? AM_STR : PM_STR))', + '$this->_strftime(Horde_Nls::getLangInfo($this->_hour < 12 ? AM_STR : PM_STR))', '$this->_strftime(\'%H:%M\')', 'sprintf(\'%02d\', $this->_sec)', "\t", '$this->_strftime(\'%H:%M:%S\')', - '$this->_strftime(NLS::getLangInfo(D_FMT))', - '$this->_strftime(NLS::getLangInfo(T_FMT))', + '$this->_strftime(Horde_Nls::getLangInfo(D_FMT))', + '$this->_strftime(Horde_Nls::getLangInfo(T_FMT))', 'substr(sprintf(\'%04d\', $this->_year), -2)', (int)$this->_year, '%'), diff --git a/framework/Kolab_Format/lib/Horde/Kolab/Format/XML.php b/framework/Kolab_Format/lib/Horde/Kolab/Format/XML.php index 5297eae82..354ec9b42 100644 --- a/framework/Kolab_Format/lib/Horde/Kolab/Format/XML.php +++ b/framework/Kolab_Format/lib/Horde/Kolab/Format/XML.php @@ -15,9 +15,6 @@ /** We need the DOM library for XML access. */ require_once 'Horde/DOM.php'; -/** We need the NLS library for language support. */ -require_once 'Horde/NLS.php'; - /** * Kolab XML to array hash converter. * @@ -790,7 +787,7 @@ class Horde_Kolab_Format_XML */ protected function _createTextNode($parent, $name, $value) { - $value = Horde_String::convertCharset($value, NLS::getCharset(), 'utf-8'); + $value = Horde_String::convertCharset($value, Horde_Nls::getCharset(), 'utf-8'); $node = $this->_xmldoc->create_element($name); diff --git a/framework/Kolab_Format/test/Horde/Kolab/Format/ContactTest.php b/framework/Kolab_Format/test/Horde/Kolab/Format/ContactTest.php index 3ebde17bd..3648013bb 100644 --- a/framework/Kolab_Format/test/Horde/Kolab/Format/ContactTest.php +++ b/framework/Kolab_Format/test/Horde/Kolab/Format/ContactTest.php @@ -12,7 +12,7 @@ */ require_once 'PHPUnit/Framework.php'; -require_once 'Horde/NLS.php'; +require_once 'Horde/Nls.php'; require_once 'Horde/Kolab/Format.php'; require_once 'Horde/Kolab/Format/XML.php'; require_once 'Horde/Kolab/Format/XML/Contact.php'; @@ -69,7 +69,7 @@ class Horde_Kolab_Format_ContactTest extends PHPUnit_Framework_TestCase */ protected function setUp() { - NLS::setCharset('utf-8'); + Horde_Nls::setCharset('utf-8'); } /** diff --git a/framework/Kolab_Format/test/Horde/Kolab/Format/EventTest.php b/framework/Kolab_Format/test/Horde/Kolab/Format/EventTest.php index 019bd2425..a8fc5c4be 100644 --- a/framework/Kolab_Format/test/Horde/Kolab/Format/EventTest.php +++ b/framework/Kolab_Format/test/Horde/Kolab/Format/EventTest.php @@ -12,7 +12,7 @@ */ require_once 'PHPUnit/Framework.php'; -require_once 'Horde/NLS.php'; +require_once 'Horde/Nls.php'; require_once 'Horde/Kolab/Format.php'; /** @@ -36,7 +36,7 @@ class Horde_Kolab_Format_EventTest extends PHPUnit_Framework_TestCase */ protected function setUp() { - NLS::setCharset('utf-8'); + Horde_Nls::setCharset('utf-8'); } diff --git a/framework/Kolab_Format/test/Horde/Kolab/Format/MimeAttrTest.php b/framework/Kolab_Format/test/Horde/Kolab/Format/MimeAttrTest.php index 92bab6791..f2d5535b9 100644 --- a/framework/Kolab_Format/test/Horde/Kolab/Format/MimeAttrTest.php +++ b/framework/Kolab_Format/test/Horde/Kolab/Format/MimeAttrTest.php @@ -19,7 +19,7 @@ */ require_once 'PHPUnit/Framework.php'; -require_once 'Horde/NLS.php'; +require_once 'Horde/Nls.php'; require_once 'Horde/Kolab/Format.php'; /** @@ -49,7 +49,7 @@ class Horde_Kolab_Format_MimeAttrTest extends PHPUnit_Framework_TestCase */ protected function setUp() { - NLS::setCharset('utf-8'); + Horde_Nls::setCharset('utf-8'); } /** diff --git a/framework/Kolab_Format/test/Horde/Kolab/Format/PreferencesTest.php b/framework/Kolab_Format/test/Horde/Kolab/Format/PreferencesTest.php index 7884cb448..fc50a53e3 100644 --- a/framework/Kolab_Format/test/Horde/Kolab/Format/PreferencesTest.php +++ b/framework/Kolab_Format/test/Horde/Kolab/Format/PreferencesTest.php @@ -12,7 +12,7 @@ */ require_once 'PHPUnit/Framework.php'; -require_once 'Horde/NLS.php'; +require_once 'Horde/Nls.php'; require_once 'Horde/Kolab/Format.php'; require_once 'Horde/Kolab/Format/XML.php'; require_once 'Horde/Kolab/Format/XML/Hprefs.php'; @@ -63,7 +63,7 @@ class Horde_Kolab_Format_PreferencesTest extends PHPUnit_Framework_TestCase */ protected function setUp() { - NLS::setCharset('utf-8'); + Horde_Nls::setCharset('utf-8'); } /** diff --git a/framework/Kolab_Format/test/Horde/Kolab/Format/RecurrenceTest.php b/framework/Kolab_Format/test/Horde/Kolab/Format/RecurrenceTest.php index 54b49cc8d..0f81ba05a 100644 --- a/framework/Kolab_Format/test/Horde/Kolab/Format/RecurrenceTest.php +++ b/framework/Kolab_Format/test/Horde/Kolab/Format/RecurrenceTest.php @@ -12,7 +12,7 @@ */ require_once 'PHPUnit/Framework.php'; -require_once 'Horde/NLS.php'; +require_once 'Horde/Nls.php'; require_once 'Horde/Kolab/Format.php'; /** @@ -44,7 +44,7 @@ class Horde_Kolab_Format_RecurrenceTest extends PHPUnit_Framework_TestCase ); } - NLS::setCharset('utf-8'); + Horde_Nls::setCharset('utf-8'); } diff --git a/framework/Kolab_Format/test/Horde/Kolab/Format/XmlTest.php b/framework/Kolab_Format/test/Horde/Kolab/Format/XmlTest.php index 4c0ce729b..53c0d2462 100644 --- a/framework/Kolab_Format/test/Horde/Kolab/Format/XmlTest.php +++ b/framework/Kolab_Format/test/Horde/Kolab/Format/XmlTest.php @@ -12,7 +12,7 @@ */ require_once 'PHPUnit/Framework.php'; -require_once 'Horde/NLS.php'; +require_once 'Horde/Nls.php'; require_once 'Horde/Kolab/Format.php'; require_once 'Horde/Kolab/Format/XML.php'; @@ -37,7 +37,7 @@ class Horde_Kolab_Format_XmlTest extends PHPUnit_Framework_TestCase */ protected function setUp() { - NLS::setCharset('utf-8'); + Horde_Nls::setCharset('utf-8'); } @@ -315,4 +315,4 @@ class Horde_Kolab_Format_XML_dummy extends Horde_Kolab_Format_XML $result, array('type' => self::TYPE_STRING)); } -} \ No newline at end of file +} diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap.php index 45e43fe22..f9b753fe3 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap.php @@ -590,8 +590,8 @@ class Horde_Kolab_Server_Ldap extends Horde_Kolab_Server if (isset($criteria['field'])) { $rhs = isset($criteria['test']) ? $criteria['test'] : ''; /* Keep this in for reference as we did not really test servers with different encoding yet */ - // require_once 'Horde/NLS.php'; - //$rhs = Horde_String::convertCharset($criteria['test'], NLS::getCharset(), $this->params['charset']); + // require_once 'Horde/Nls.php'; + //$rhs = Horde_String::convertCharset($criteria['test'], Horde_Nls::getCharset(), $this->params['charset']); switch ($criteria['op']) { case '=': $op = 'equals'; diff --git a/framework/Mime/lib/Horde/Mime.php b/framework/Mime/lib/Horde/Mime.php index c3e2f7e47..16644238f 100644 --- a/framework/Mime/lib/Horde/Mime.php +++ b/framework/Mime/lib/Horde/Mime.php @@ -97,8 +97,7 @@ class Horde_Mime static public function encode($text, $charset = null) { if (is_null($charset)) { - require_once 'Horde/NLS.php'; - $charset = NLS::getCharset(); + $charset = Horde_Nls::getCharset(); } $charset = Horde_String::lower($charset); @@ -323,8 +322,7 @@ class Horde_Mime $rest = substr($string, (strlen($preceding . $charset . $encoding . $encoded_text) + 6)); if (is_null($to_charset)) { - require_once 'Horde/NLS.php'; - $to_charset = NLS::getCharset(); + $to_charset = Horde_Nls::getCharset(); } switch ($encoding) { diff --git a/framework/Mime/lib/Horde/Mime/Mdn.php b/framework/Mime/lib/Horde/Mime/Mdn.php index cd8306d7c..146146034 100644 --- a/framework/Mime/lib/Horde/Mime/Mdn.php +++ b/framework/Mime/lib/Horde/Mime/Mdn.php @@ -184,7 +184,7 @@ class Horde_Mime_Mdn $msg->setType('multipart/report'); $msg->setContentTypeParameter('report-type', 'disposition-notification'); - $charset = NLS::getCharset(); + $charset = Horde_Nls::getCharset(); /* The first part is a human readable message. */ $part_one = new Horde_Mime_Part('text/plain'); diff --git a/framework/Mime/lib/Horde/Mime/Part.php b/framework/Mime/lib/Horde/Mime/Part.php index 9fe8d64d9..a2033dd50 100644 --- a/framework/Mime/lib/Horde/Mime/Part.php +++ b/framework/Mime/lib/Horde/Mime/Part.php @@ -1211,7 +1211,7 @@ class Horde_Mime_Part return $bytes; } - $localeinfo = NLS::getLocaleInfo(); + $localeinfo = Horde_Nls::getLocaleInfo(); return number_format($bytes / 1024, 2, $localeinfo['decimal_point'], $localeinfo['thousands_sep']); } diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Css.php b/framework/Mime/lib/Horde/Mime/Viewer/Css.php index 3c487b955..c4fa8b77a 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Css.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Css.php @@ -94,7 +94,7 @@ class Horde_Mime_Viewer_Css extends Horde_Mime_Viewer_Source $this->_mimepart->getMimeId() => array( 'data' => $this->_lineNumber(trim($css)), 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() + 'type' => 'text/html; charset=' . Horde_Nls::getCharset() ) ); } diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Deb.php b/framework/Mime/lib/Horde/Mime/Viewer/Deb.php index 59b61d72b..38cfbe70f 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Deb.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Deb.php @@ -68,7 +68,7 @@ class Horde_Mime_Viewer_Deb extends Horde_Mime_Viewer_Driver $this->_mimepart->getMimeId() => array( 'data' => '
' . htmlspecialchars($data) . '
', 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() + 'type' => 'text/html; charset=' . Horde_Nls::getCharset() ) ); } diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Enriched.php b/framework/Mime/lib/Horde/Mime/Viewer/Enriched.php index e033235c5..4145dafdc 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Enriched.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Enriched.php @@ -65,7 +65,7 @@ class Horde_Mime_Viewer_Enriched extends Horde_Mime_Viewer_Driver $this->_mimepart->getMimeId() => array( 'data' => Horde_String::convertCharset($this->_toHTML(), $this->_mimepart->getCharset()), 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() + 'type' => 'text/html; charset=' . Horde_Nls::getCharset() ) ); } diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Enscript.php b/framework/Mime/lib/Horde/Mime/Viewer/Enscript.php index 3437a9f59..1cad8b246 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Enscript.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Enscript.php @@ -37,7 +37,7 @@ class Horde_Mime_Viewer_Enscript extends Horde_Mime_Viewer_Source $this->_mimepart->getMimeId() => array( 'data' => $this->_toHTML(false), 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() + 'type' => 'text/html; charset=' . Horde_Nls::getCharset() ) ); } @@ -53,7 +53,7 @@ class Horde_Mime_Viewer_Enscript extends Horde_Mime_Viewer_Source $this->_mimepart->getMimeId() => array( 'data' => $this->_toHTML(true), 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() + 'type' => 'text/html; charset=' . Horde_Nls::getCharset() ) ); } diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Html.php b/framework/Mime/lib/Horde/Mime/Viewer/Html.php index 1da54afac..b32ff7555 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Html.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Html.php @@ -59,7 +59,7 @@ class Horde_Mime_Viewer_html extends Horde_Mime_Viewer_Driver $this->_mimepart->getMimeId() => array( 'data' => Horde_String::convertCharset($html['data'], $this->_mimepart->getCharset()), 'status' => $html['status'], - 'type' => 'text/html; charset=' . NLS::getCharset() + 'type' => 'text/html; charset=' . Horde_Nls::getCharset() ) ); } @@ -177,7 +177,7 @@ class Horde_Mime_Viewer_html extends Horde_Mime_Viewer_Driver if (!$inline) { $temp = array(); foreach ($phish_warning as $val) { - $temp[] = Horde_String::convertCharset($val, NLS::getCharset(), $this->_mimepart->getCharset()); + $temp[] = Horde_String::convertCharset($val, Horde_Nls::getCharset(), $this->_mimepart->getCharset()); } $warning = $temp; } diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Msexcel.php b/framework/Mime/lib/Horde/Mime/Viewer/Msexcel.php index 6aab1e76b..e26e28c76 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Msexcel.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Msexcel.php @@ -51,7 +51,7 @@ class Horde_Mime_Viewer_Msexcel extends Horde_Mime_Viewer_Driver $this->_mimepart->getMimeId() => array( 'data' => file_get_contents($tmp_out), 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() + 'type' => 'text/html; charset=' . Horde_Nls::getCharset() ) ); } diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Mspowerpoint.php b/framework/Mime/lib/Horde/Mime/Viewer/Mspowerpoint.php index 31144b621..3a2c38196 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Mspowerpoint.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Mspowerpoint.php @@ -54,7 +54,7 @@ class Horde_Mime_Viewer_Mspowerpoint extends Horde_Mime_Viewer_Driver $this->_mimepart->getMimeId() => array( 'data' => $data, 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() + 'type' => 'text/html; charset=' . Horde_Nls::getCharset() ) ); } diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Msword.php b/framework/Mime/lib/Horde/Mime/Viewer/Msword.php index 5a17a714f..f1ce494cc 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Msword.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Msword.php @@ -60,7 +60,7 @@ class Horde_Mime_Viewer_Msword extends Horde_Mime_Viewer_Driver $this->_mimepart->getMimeId() => array( 'data' => $data, 'status' => array(), - 'type' => $type . '; charset=' . NLS::getCharset() + 'type' => $type . '; charset=' . Horde_Nls::getCharset() ) ); } diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Php.php b/framework/Mime/lib/Horde/Mime/Viewer/Php.php index d807e8f07..39d52cd01 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Php.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Php.php @@ -66,7 +66,7 @@ class Horde_Mime_Viewer_Php extends Horde_Mime_Viewer_Source $this->_mimepart->getMimeId() => array( 'data' => $text, 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() + 'type' => 'text/html; charset=' . Horde_Nls::getCharset() ) ); } diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Plain.php b/framework/Mime/lib/Horde/Mime/Viewer/Plain.php index 7d767b31d..5e2d8b6fe 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Plain.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Plain.php @@ -69,7 +69,7 @@ class Horde_Mime_Viewer_Plain extends Horde_Mime_Viewer_Driver $this->_mimepart->getMimeId() => array( 'data' => $data, 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() + 'type' => 'text/html; charset=' . Horde_Nls::getCharset() ) ); } diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Rar.php b/framework/Mime/lib/Horde/Mime/Viewer/Rar.php index 024d6f643..d98cb8a64 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Rar.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Rar.php @@ -58,7 +58,7 @@ class Horde_Mime_Viewer_Rar extends Horde_Mime_Viewer_Driver return array(); } - $charset = NLS::getCharset(); + $charset = Horde_Nls::getCharset(); $fileCount = count($rarData); $name = $this->_mimepart->getName(true); diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Rfc822.php b/framework/Mime/lib/Horde/Mime/Viewer/Rfc822.php index f17008f24..2333d0c1e 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Rfc822.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Rfc822.php @@ -37,7 +37,7 @@ class Horde_Mime_Viewer_Rfc822 extends Horde_Mime_Viewer_Driver $this->_mimepart->getMimeId() => array( 'data' => $this->_mimepart->getContents(), 'status' => array(), - 'type' => 'text/plain; charset=' . NLS::getCharset() + 'type' => 'text/plain; charset=' . Horde_Nls::getCharset() ) ); } @@ -86,7 +86,7 @@ class Horde_Mime_Viewer_Rfc822 extends Horde_Mime_Viewer_Driver $this->_mimepart->getMimeId() => array( 'data' => empty($header_output) ? '' : ('
' . Horde_Text_Filter::filter(implode("
\n", $header_output), 'emails') . '
'), 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() + 'type' => 'text/html; charset=' . Horde_Nls::getCharset() ) ); } diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Richtext.php b/framework/Mime/lib/Horde/Mime/Viewer/Richtext.php index 7f05964a0..77964b29c 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Richtext.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Richtext.php @@ -74,7 +74,7 @@ class Horde_Mime_Viewer_Richtext extends Horde_Mime_Viewer_Driver $this->_mimepart->getMimeId() => array( 'data' => Horde_String::convertCharset($this->_toHTML(), $this->_mimepart->getCharset()), 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() + 'type' => 'text/html; charset=' . Horde_Nls::getCharset() ) ); } diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Rpm.php b/framework/Mime/lib/Horde/Mime/Viewer/Rpm.php index 698cde66b..68432dffc 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Rpm.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Rpm.php @@ -54,7 +54,7 @@ class Horde_Mime_Viewer_Rpm extends Horde_Mime_Viewer_Driver $this->_mimepart->getMimeId() => array( 'data' => '
' . htmlentities($data) . '
', 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() + 'type' => 'text/html; charset=' . Horde_Nls::getCharset() ) ); } diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Rtf.php b/framework/Mime/lib/Horde/Mime/Viewer/Rtf.php index c4573da6a..6337babfc 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Rtf.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Rtf.php @@ -58,7 +58,7 @@ class Horde_Mime_Viewer_Rtf extends Horde_Mime_Viewer_Driver $this->_mimepart->getMimeId() => array( 'data' => $data, 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() + 'type' => 'text/html; charset=' . Horde_Nls::getCharset() ) ); } diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Smil.php b/framework/Mime/lib/Horde/Mime/Viewer/Smil.php index 327059745..187d4c178 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Smil.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Smil.php @@ -60,7 +60,7 @@ class Horde_Mime_Viewer_Smil extends Horde_Mime_Viewer_Driver $this->_mimepart->getMimeId() => array( 'data' => $this->_content, 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() + 'type' => 'text/html; charset=' . Horde_Nls::getCharset() ) ); } diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Srchighlite.php b/framework/Mime/lib/Horde/Mime/Viewer/Srchighlite.php index 6250bc2c3..5beff68ce 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Srchighlite.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Srchighlite.php @@ -78,7 +78,7 @@ class Horde_Mime_Viewer_Srchighlite extends Horde_Mime_Viewer_Source $this->_mimepart->getMimeId() => array( 'data' => $this->_lineNumber($results), 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() + 'type' => 'text/html; charset=' . Horde_Nls::getCharset() ) ); } diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Tgz.php b/framework/Mime/lib/Horde/Mime/Viewer/Tgz.php index f195ca7ea..139284b50 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Tgz.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Tgz.php @@ -66,7 +66,7 @@ class Horde_Mime_Viewer_Tgz extends Horde_Mime_Viewer_Driver return array(); } - $charset = NLS::getCharset(); + $charset = Horde_Nls::getCharset(); $fileCount = count($tarData); $name = $this->_mimepart->getName(true); diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Tnef.php b/framework/Mime/lib/Horde/Mime/Viewer/Tnef.php index 373ee9157..ad768e1f9 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Tnef.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Tnef.php @@ -67,7 +67,7 @@ class Horde_Mime_Viewer_Tnef extends Horde_Mime_Viewer_Driver $this->_mimepart->getMimeId() => array( 'data' => $data, 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() + 'type' => 'text/html; charset=' . Horde_Nls::getCharset() ) ); } diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Vcard.php b/framework/Mime/lib/Horde/Mime/Viewer/Vcard.php index dbeeb838f..1881b0aec 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Vcard.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Vcard.php @@ -389,7 +389,7 @@ class Horde_Mime_Viewer_Vcard extends Horde_Mime_Viewer_Driver $this->_mimepart->getMimeId() => array( 'data' => Horde_Util::bufferOutput(array($notification, 'notify'), array('listeners' => 'status')) . $html, 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() + 'type' => 'text/html; charset=' . Horde_Nls::getCharset() ) ); } diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Webcpp.php b/framework/Mime/lib/Horde/Mime/Viewer/Webcpp.php index b59e6bb1d..81386b5aa 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Webcpp.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Webcpp.php @@ -103,7 +103,7 @@ class Horde_Mime_Viewer_Webcpp extends Horde_Mime_Viewer_Driver $this->_mimepart->getMimeId() => array( 'data' => $results, 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() + 'type' => 'text/html; charset=' . Horde_Nls::getCharset() ) ); } diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Wordperfect.php b/framework/Mime/lib/Horde/Mime/Viewer/Wordperfect.php index 8027e23a4..80e5ce89b 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Wordperfect.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Wordperfect.php @@ -58,7 +58,7 @@ class Horde_Mime_Viewer_Wordperfect extends Horde_Mime_Viewer_Driver $this->_mimepart->getMimeId() => array( 'data' => $data, 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() + 'type' => 'text/html; charset=' . Horde_Nls::getCharset() ) ); } diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Zip.php b/framework/Mime/lib/Horde/Mime/Viewer/Zip.php index ffe13a65b..426f1b49f 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Zip.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Zip.php @@ -110,7 +110,7 @@ class Horde_Mime_Viewer_Zip extends Horde_Mime_Viewer_Driver Horde_String::pad(_("Ratio"), 10, ' ', STR_PAD_LEFT) . "\n", 'space2html', - array('charset' => NLS::getCharset(), 'encode' => true, 'encode_all' => true) + array('charset' => Horde_Nls::getCharset(), 'encode' => true, 'encode_all' => true) ) . str_repeat('-', 69 + $maxlen) . "\n"; foreach ($zipInfo as $key => $val) { @@ -140,7 +140,7 @@ class Horde_Mime_Viewer_Zip extends Horde_Mime_Viewer_Driver $this->_mimepart->getMimeId() => array( 'data' => nl2br($text . str_repeat('-', 69 + $maxlen) . "\n" . ''), 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() + 'type' => 'text/html; charset=' . Horde_Nls::getCharset() ) ); } diff --git a/framework/Mime/test/Horde/Mime/mail_003.phpt b/framework/Mime/test/Horde/Mime/mail_003.phpt index 2e55fb788..3ede3ed7e 100644 --- a/framework/Mime/test/Horde/Mime/mail_003.phpt +++ b/framework/Mime/test/Horde/Mime/mail_003.phpt @@ -5,7 +5,7 @@ Horde_Mime_Mail encoding test require dirname(__FILE__) . '/mail_dummy.inc'; require_once 'Horde/String.php'; -require 'Horde/NLS.php'; +require 'Horde/Nls.php'; require_once 'Horde/Util.php'; $mail = new Horde_Mime_Mail('Schöner Betreff', "Hübsche Umlaute \n und Leerzeichen.", diff --git a/framework/Nls/lib/Horde/Nls.php b/framework/Nls/lib/Horde/Nls.php new file mode 100644 index 000000000..e0ad66068 --- /dev/null +++ b/framework/Nls/lib/Horde/Nls.php @@ -0,0 +1,592 @@ +country lookups. + * + * Copyright 1999-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @author Jon Parise + * @author Chuck Hagenbuch + * @author Jan Schneider + * @author Michael Slusarz + * @package Nls + */ +class Horde_Nls +{ + /** + * Config values. + * + * @var array + */ + static public $config = array(); + + /** + * Cached values. + * + * @var array + */ + static protected $_cache = array(); + + /** + * Selects the most preferred language for the current client session. + * + * @return string The selected language abbreviation. + */ + static public function select() + { + $lang = Horde_Util::getFormData('new_lang'); + + /* First, check if language pref is locked and, if so, set it to its + * value */ + if (isset($GLOBALS['prefs']) && + $GLOBALS['prefs']->isLocked('language')) { + $language = $GLOBALS['prefs']->getValue('language'); + /* Check if the user selected a language from the login screen */ + } elseif (!empty($lang) && self::isValid($lang)) { + $language = $lang; + /* Check if we have a language set in the session */ + } elseif (isset($_SESSION['horde_language'])) { + $language = $_SESSION['horde_language']; + /* Use site-wide default, if one is defined */ + } elseif (!empty(self::$config['defaults']['language'])) { + $language = self::$config['defaults']['language']; + /* Try browser-accepted languages. */ + } elseif (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { + /* The browser supplies a list, so return the first valid one. */ + $browser_langs = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); + foreach ($browser_langs as $lang) { + /* Strip quality value for language */ + if (($pos = strpos($lang, ';')) !== false) { + $lang = substr($lang, 0, $pos); + } + $lang = self::_map(trim($lang)); + if (self::isValid($lang)) { + $language = $lang; + break; + } + + /* In case there's no full match, save our best guess. Try + * ll_LL, followed by just ll. */ + if (!isset($partial_lang)) { + $ll_LL = Horde_String::lower(substr($lang, 0, 2)) . '_' . Horde_String::upper(substr($lang, 0, 2)); + if (self::isValid($ll_LL)) { + $partial_lan = $ll_LL; + } else { + $ll = self::_map(substr($lang, 0, 2)); + if (self::isValid($ll)) { + $partial_lang = $ll; + } + } + } + } + } + + if (!isset($language)) { + $language = isset($partial_lang) + ? $partial_lang + /* No dice auto-detecting, default to US English. */ + : 'en_US'; + } + + return basename($language); + } + + /** + * Sets the language. + * + * @param string $lang The language abbreviation. + */ + static public function setLang($lang = null) + { + Horde::loadConfiguration('nls.php', null, 'horde'); + + if (empty($lang) || !self::isValid($lang)) { + $lang = self::select(); + } + + $_SESSION['horde_language'] = $lang; + + if (isset($GLOBALS['language'])) { + if ($GLOBALS['language'] == $lang) { + return; + } else { + $GLOBALS['registry']->clearCache(); + } + } + $GLOBALS['language'] = $lang; + + /* First try language with the current charset. */ + $lang_charset = $lang . '.' . self::getCharset(); + if ($lang_charset != setlocale(LC_ALL, $lang_charset)) { + /* Next try language with its default charset. */ + $charset = empty($GLOBALS['nls']['charsets'][$lang]) + ? 'ISO-8859-1' + : $GLOBALS['nls']['charsets'][$lang]; + $lang_charset = $lang . '.' . $charset; + self::_cachedCharset(0, $charset); + if ($lang_charset != setlocale(LC_ALL, $lang_charset)) { + /* At last try language solely. */ + $lang_charset = $lang; + setlocale(LC_ALL, $lang_charset); + } + } + + @putenv('LC_ALL=' . $lang_charset); + @putenv('LANG=' . $lang_charset); + @putenv('LANGUAGE=' . $lang_charset); + } + + /** + * Sets the gettext domain. + * + * @param string $app The application name. + * @param string $directory The directory where the application's + * LC_MESSAGES directory resides. + * @param string $charset The charset. + */ + static public function setTextdomain($app, $directory, $charset) + { + bindtextdomain($app, $directory); + textdomain($app); + + /* The existence of this function depends on the platform. */ + if (function_exists('bind_textdomain_codeset')) { + self::_cachedCharset(0, bind_textdomain_codeset($app, $charset)); + } + + if (!headers_sent()) { + header('Content-Type: text/html; charset=' . $charset); + } + } + + /** + * Sets the language and reloads the whole NLS environment. + * + * When setting the language, the gettext catalogs have to be reloaded + * too, charsets have to be updated etc. This method takes care of all + * this. + * + * @param string $language The new language. + * @param string $app The application for reloading the gettext + * catalog. The current application if empty. + */ + static public function setLanguageEnvironment($language = null, $app = null) + { + if (empty($app)) { + $app = $GLOBALS['registry']->getApp(); + } + self::setLang($language); + self::setTextdomain( + $app, + $GLOBALS['registry']->get('fileroot', $app) . '/locale', + self::getCharset() + ); + Horde_String::setDefaultCharset(self::getCharset()); + } + + /** + * Determines whether the supplied language is valid. + * + * @param string $language The abbreviated name of the language. + * + * @return boolean True if the language is valid, false if it's not + * valid or unknown. + */ + static public function isValid($language) + { + return !empty($GLOBALS['nls']['languages'][$language]); + } + + /** + * Maps languages with common two-letter codes (such as nl) to the + * full gettext code (in this case, nl_NL). Returns the language + * unmodified if it isn't an alias. + * + * @param string $language The language code to map. + * + * @return string The mapped language code. + */ + static protected function _map($language) + { + $aliases = &$GLOBALS['nls']['aliases']; + + // Translate the $language to get broader matches. + // (eg. de-DE should match de_DE) + $trans_lang = str_replace('-', '_', $language); + $lang_parts = explode('_', $trans_lang); + $trans_lang = Horde_String::lower($lang_parts[0]); + if (isset($lang_parts[1])) { + $trans_lang .= '_' . Horde_String::upper($lang_parts[1]); + } + + // See if we get a match for this + if (!empty($aliases[$trans_lang])) { + return $aliases[$trans_lang]; + } + + // If we get that far down, the language cannot be found. + // Return $trans_lang. + return $trans_lang; + } + + /** + * Returns the charset for the current language. + * + * @param boolean $original If true returns the original charset of the + * translation, the actually used one otherwise. + * + * @return string The character set that should be used with the current + * locale settings. + */ + static public function getCharset($original = false) + { + /* Get cached results. */ + $cacheKey = intval($original); + $charset = self::_cachedCharset($cacheKey); + if (!is_null($charset)) { + return $charset; + } + + if ($original) { + $charset = empty($GLOBALS['nls']['charsets'][$GLOBALS['language']]) + ? 'ISO-8859-1' + : $GLOBALS['nls']['charsets'][$GLOBALS['language']]; + } else { + $browser = Horde_Browser::singleton(); + if ($browser->hasFeature('utf') && + (Horde_Util::extensionExists('iconv') || + Horde_Util::extensionExists('mbstring'))) { + $charset = 'UTF-8'; + } + } + + if (is_null($charset)) { + $charset = self::getExternalCharset(); + } + + self::_cachedCharset($cacheKey, $charset); + + return $charset; + } + + /** + * Returns the current charset of the environment + * + * @return string The character set that should be used with the current + * locale settings. + */ + static public function getExternalCharset() + { + /* Get cached results. */ + $charset = self::_cachedCharset(2); + if (!is_null($charset)) { + return $charset; + } + + $lang_charset = setlocale(LC_ALL, 0); + if (strpos($lang_charset, ';') === false && + strpos($lang_charset, '/') === false) { + $lang_charset = explode('.', $lang_charset); + if ((count($lang_charset) == 2) && !empty($lang_charset[1])) { + self::_cachedCharset(2, $lang_charset[1]); + return $lang_charset[1]; + } + } + + return empty($GLOBALS['nls']['charsets'][$GLOBALS['language']]) + ? 'ISO-8859-1' + : $GLOBALS['nls']['charsets'][$GLOBALS['language']]; + } + + /** + * Sets or returns the charset used under certain conditions. + * + * @param integer $index The ID of a cache slot. 0 for the UI charset, 1 + * for the translation charset and 2 for the + * external charset. + * @param string $charset If specified, this charset will be stored in the + * given cache slot. Otherwise the content of the + * specified cache slot will be returned. + */ + static public function _cachedCharset($index, $charset = null) + { + if ($charset == null) { + return isset(self::$_cache['charset'][$index]) + ? self::$_cache['charset'][$index] + : null; + } else { + $cache[$index] = $charset; + } + } + + /** + * Returns the charset to use for outgoing emails. + * + * @return string The preferred charset for outgoing mails based on + * the user's preferences and the current language. + */ + static public function getEmailCharset() + { + $charset = $GLOBALS['prefs']->getValue('sending_charset'); + if (!empty($charset)) { + return $charset; + } + + return isset(self::$config['emails'][$GLOBALS['language']]) + ? self::$config['emails'][$GLOBALS['language']] + : (isset(self::$config['charsets'][$GLOBALS['language']]) ? self::$config['charsets'][$GLOBALS['language']] : 'ISO-8859-1'); + } + + /** + * Check to see if character set is valid for htmlspecialchars() calls. + * + * @param string $charset The character set to check. + * + * @return boolean Is charset valid for the current system? + */ + static public function checkCharset($charset) + { + if (is_null($charset) || empty($charset)) { + return false; + } + + if (isset(self::$_cache['check'][$charset])) { + return self::$_cache['check'][$charset]; + } elseif (!isset($check)) { + $check = array(); + } + + $valid = true; + + ini_set('track_errors', 1); + @htmlspecialchars('', ENT_COMPAT, $charset); + if (isset($php_errormsg)) { + $valid = false; + } + ini_restore('track_errors'); + + self::$_cache['check'][$charset] = $valid; + + return $valid; + } + + /** + * Sets the charset. + * + * In general, the applied charset is automatically determined by browser + * language and browser capabilities and there's no need to manually call + * setCharset. However for headless (RPC) operations the charset may be + * set manually to ensure correct character conversion in the backend. + * + * @param string $charset If specified, this charset will be stored in the + * given cache slot. + * @param integer $index The ID of a cache slot. 0 for the UI charset, 1 + * for the translation charset and 2 for the + * external charset. Defaults to 0: this is the + * charset returned by getCharset and used for + * conversion. + */ + static public function setCharset($charset, $index = 0) + { + self::_cachedCharset($index, $charset); + } + + /** + * Sets the charset and reloads the whole NLS environment. + * + * When setting the charset, the gettext catalogs have to be reloaded too, + * to match the new charset, among other things. This method takes care of + * all this. + * + * @param string $charset The new charset. + */ + static public function setCharsetEnvironment($charset) + { + unset($GLOBALS['language']); + self::setCharset($charset); + self::setLanguageEnvironment(); + } + + /** + * Returns a list of available timezones. + * + * @return array List of timezones. + */ + static public function getTimezones() + { + $timezones = DateTimeZone::listIdentifiers(); + return array_combine($timezones, $timezones); + } + + /** + * Sets the current timezone, if available. + */ + static public function setTimeZone() + { + $tz = $GLOBALS['prefs']->getValue('timezone'); + if (!empty($tz)) { + @date_default_timezone_set($tz); + } + } + + /** + * Get the locale info returned by localeconv(), but cache it, to + * avoid repeated calls. + * + * @return array The results of localeconv(). + */ + static public function getLocaleInfo() + { + if (!isset(self::$_cache['lc_info'])) { + self::$_cache['lc_info'] = localeconv(); + } + + return self::$_cache['lc_info']; + } + + /** + * Get the language info returned by nl_langinfo(), but cache it, to + * avoid repeated calls. + * + * @param const $item The langinfo item to return. + * + * @return array The results of nl_langinfo(). + */ + static public function getLangInfo($item) + { + if (!function_exists('nl_langinfo')) { + return false; + } + + if (!isset(self::$_cache['nl_info'])) { + self::$_cache['nl_info'] = nl_langinfo($item); + } + + return self::$_cache['nl_info']; + } + + /** + * Get country information from a hostname or IP address. + * + * @param string $host The hostname or IP address. + * + * @return mixed On success, return an array with the following entries: + * 'code' => Country Code + * 'name' => Country Name + * On failure, return false. + */ + static public function getCountryByHost($host) + { + /* List of generic domains that we know is not in the country TLD + list. See: http://www.iana.org/gtld/gtld.htm */ + $generic = array( + 'aero', 'biz', 'com', 'coop', 'edu', 'gov', 'info', 'int', 'mil', + 'museum', 'name', 'net', 'org', 'pro' + ); + + $checkHost = $host; + if (preg_match('/^\d+\.\d+\.\d+\.\d+$/', $host)) { + if (class_exists('Net_DNS')) { + $resolver = new Net_DNS_Resolver(); + $resolver->retry = isset($GLOBALS['conf']['dns']['retry']) ? $GLOBALS['conf']['dns']['retry'] : 1; + $resolver->retrans = isset($GLOBALS['conf']['dns']['retrans']) ? $GLOBALS['conf']['dns']['retrans'] : 1; + $response = $resolver->query($host, 'PTR'); + $checkHost = $response ? $response->answer[0]->ptrdname : $host; + } else { + $checkHost = @gethostbyaddr($host); + } + } + + /* Get the TLD of the hostname. */ + $pos = strrpos($checkHost, '.'); + if ($pos === false) { + return false; + } + $domain = Horde_String::lower(substr($checkHost, $pos + 1)); + + /* Try lookup via TLD first. */ + if (!in_array($domain, $generic)) { + $name = self::tldLookup($domain); + if ($name) { + return array( + 'code' => $domain, + 'name' => $name + ); + } + } + + /* Try GeoIP lookup next. */ + $geoip = Horde_Nls_Geoip::singleton(!empty($GLOBALS['conf']['geoip']['datafile']) ? $GLOBALS['conf']['geoip']['datafile'] : null); + + return $geoip->getCountryInfo($checkHost); + } + + /** + * Do a top level domain (TLD) lookup. + * + * @param string $code A 2-letter country code. + * + * @return mixed The localized country name, or null if not found. + */ + static public function tldLookup($code) + { + if (!isset(self::$_cache['tld'])) { + include dirname(__FILE__) . '/Nls/Tld.php'; + self::$_cache['tld'] = $tld; + } + + $code = Horde_String::lower($code); + + return isset(self::$_cache['tld'][$code]) + ? self::$_cache['tld'][$code] + : null; + } + + /** + * Returns a Horde image link to the country flag. + * + * @param string $host The hostname or IP address. + * + * @return string The image URL, or the empty string on error. + */ + static public function generateFlagImageByHost($host) + { + $data = self::getCountryByHost($host); + if ($data === false) { + return ''; + } + + $img = $data['code'] . '.png'; + return file_exists($GLOBALS['registry']->get('themesfs', 'horde') . '/graphics/flags/' . $img) + ? Horde::img($img, $data['name'], array('title' => $data['name']), $GLOBALS['registry']->getImageDir('horde') . '/flags') + : '[' . $data['name'] . ']'; + } + + /** + * Returns either a specific or all ISO-3166 country names. + * + * @param string $code The ISO 3166 country code. + * + * @return mixed If a country code has been requested will return the + * corresponding country name. If empty will return an + * array of all the country codes and their names. + */ + static public function getCountryISO($code = null) + { + if (!isset(self::$_cache['iso'])) { + include dirname(__FILE__) . '/Nls/Countries.php'; + self::$_cache['iso'] = $countries; + } + + $code = Horde_String::upper($code); + + return isset(self::$_cache['iso'][$code]) + ? self::$_cache['iso'][$code] + : null; + } + +} diff --git a/framework/Nls/lib/Horde/Nls/Carsigns.php b/framework/Nls/lib/Horde/Nls/Carsigns.php new file mode 100644 index 000000000..fb1a5931d --- /dev/null +++ b/framework/Nls/lib/Horde/Nls/Carsigns.php @@ -0,0 +1,205 @@ + 'A', + 'af' => 'AFG', + 'ag' => 'AG', + 'al' => 'AL', + 'ad' => 'AND', + 'ao' => 'ANG', + 'am' => 'ARM', + 'au' => 'AUS', + 'az' => 'AZ', + 'be' => 'B', + 'bd' => 'BD', + 'bb' => 'BDS', + 'bf' => 'BF', + 'bg' => 'BG', + 'bz' => 'BH', + 'bt' => 'BHT', + 'ba' => 'BIH', + 'bo' => 'BOL', + 'br' => 'BR', + 'bh' => 'BRN', + 'bn' => 'BRU', + 'bs' => 'BS', + 'bi' => 'BU', + 'vg' => 'BVI', + 'by' => 'BY', + 'bz' => 'BZ', + 'cu' => 'C', + 'cm' => 'CAM', + 'cd' => 'CD', + 'ca' => 'CDN', + 'ch' => 'CH', + 'ci' => 'CI', + 'lk' => 'CL', + 'co' => 'CO', + 'km' => 'COM', + 'cr' => 'CR', + 'cv' => 'CV', + 'cy' => 'CY', + 'cz' => 'CZ', + 'de' => 'D', + 'dj' => 'DJI', + 'dk' => 'DK', + 'do' => 'DOM', + 'kp' => 'DVRK', + 'bj' => 'DY', + 'dz' => 'DZ', + 'es' => 'E', + 'ke' => 'EAK', + 'tz' => 'EAT', + 'ug' => 'EAU', + 'ec' => 'EC', + 'er' => 'ER', + 'sv' => 'ES', + 'ee' => 'EST', + 'eg' => 'ET', + 'et' => 'ETH', + 'fr' => 'F', + 'fi' => 'FIN', + 'fj' => 'FJI', + 'li' => 'FL', + 'fo' => 'FO', + 'fm' => 'FSM', + 'ga' => 'G', + 'gb' => 'GB', + 'gi' => 'GBZ', + 'gt' => 'GCA', + 'ge' => 'GE', + 'gh' => 'GH', + 'gq' => 'GQ', + 'gr' => 'GR', + 'gy' => 'GUY', + 'hu' => 'H', + 'hk' => 'HK', + 'hn' => 'HN', + 'hr' => 'HR', + 'it' => 'I', + 'il' => 'IL', + 'in' => 'IND', + 'ir' => 'IR', + 'ie' => 'IRL', + 'iq' => 'IRQ', + 'is' => 'IS', + 'jp' => 'J', + 'jm' => 'JA', + 'jo' => 'JOR', + 'kh' => 'K', + 'ki' => 'KIR', + 'gl' => 'KN', + 'kg' => 'KS', + 'sa' => 'KSA', + 'kw' => 'KWT', + 'kz' => 'KZ', + 'lu' => 'L', + 'la' => 'LAO', + 'ly' => 'LAR', + 'lr' => 'LB', + 'ls' => 'LS', + 'lt' => 'LT', + 'lv' => 'LV', + 'mt' => 'M', + 'ma' => 'MA', + 'my' => 'MAL', + 'mc' => 'MC', + 'md' => 'MD', + 'mx' => 'MEX', + 'mn' => 'MGL', + 'mh' => 'MH', + 'mk' => 'MK', + 'mz' => 'MOC', + 'mu' => 'MS', + 'mv' => 'MV', + 'mw' => 'MW', + 'mm' => 'MYA', + 'no' => 'N', + 'an' => 'NA', + 'nl' => 'NL', + 'nz' => 'NZ', + 'om' => 'OM', + 'pt' => 'P', + 'pa' => 'PA', + 'pw' => 'PAL', + 'pe' => 'PE', + 'pk' => 'PK', + 'pl' => 'PL', + 'pg' => 'PNG', + 'cn' => 'PRC', + 'ps' => 'PS', + 'py' => 'PY', + 'qa' => 'Q', + 'ar' => 'RA', + 'bw' => 'RB', + 'tw' => 'RC', + 'cf' => 'RCA', + 'cd' => 'RCB', + 'cl' => 'RCH', + 're' => 'RE', + 'gn' => 'RG', + 'ht' => 'RH', + 'id' => 'RI', + 'mr' => 'RIM', + 'lb' => 'RL', + 'mg' => 'RM', + 'ml' => 'RMM', + 'ne' => 'RN', + 'ro' => 'RO', + 'kr' => 'ROK', + 'uy' => 'ROU', + 'ph' => 'RP', + 'sm' => 'RSM', + 'tg' => 'RT', + 'ru' => 'RUS', + 'rw' => 'RWA', + 'se' => 'S', + 'cs' => 'SCG', + 'kn' => 'SCN', + 'sz' => 'SD', + 'sg' => 'SGP', + 'sk' => 'SK', + 'si' => 'SLO', + 'sr' => 'SME', + 'sn' => 'SN', + 'sb' => 'SOL', + 'so' => 'SP', + 'st' => 'STP', + 'sd' => 'SUD', + 'sc' => 'SY', + 'sy' => 'SYR', + 'td' => 'TCH', + 'th' => 'THA', + 'tj' => 'TJ', + 'tl' => 'TL', + 'tm' => 'TM', + 'tn' => 'TN', + 'to' => 'TO', + 'tr' => 'TR', + 'tt' => 'TT', + 'tv' => 'TUV', + 'ua' => 'UA', + 'ae' => 'UAE', + 'us' => 'USA', + 'uz' => 'UZ', + 'va' => 'V', + 'vn' => 'VN', + 'vu' => 'VU', + 'GM' => 'WAG', + 'sl' => 'WAL', + 'ng' => 'WAN', + 'dm' => 'WD', + 'gd' => 'WG', + 'lc' => 'WL', + 'ws' => 'WS', + 'vc' => 'WV', + 'ye' => 'YAR', + 've' => 'YV', + 'zm' => 'Z', + 'za' => 'ZA', + 'zw' => 'ZW' +); diff --git a/framework/Nls/lib/Horde/Nls/Coordinates.php b/framework/Nls/lib/Horde/Nls/Coordinates.php new file mode 100644 index 000000000..b2c62c50e --- /dev/null +++ b/framework/Nls/lib/Horde/Nls/Coordinates.php @@ -0,0 +1,3906 @@ + _("Afghanistan"), + 'AL' => _("Albania"), + 'DZ' => _("Algeria"), + 'AS' => _("American Samoa"), + 'AD' => _("Andorra"), + 'AO' => _("Angola"), + 'AI' => _("Anguilla"), + 'AQ' => _("Antarctica"), + 'AG' => _("Antigua and Barbuda"), + 'AR' => _("Argentina"), + 'AM' => _("Armenia"), + 'AW' => _("Aruba"), + 'AU' => _("Australia"), + 'AT' => _("Austria"), + 'AZ' => _("Azerbaijan"), + 'BS' => _("Bahamas"), + 'BH' => _("Bahrain"), + 'BD' => _("Bangladesh"), + 'BB' => _("Barbados"), + 'BY' => _("Belarus"), + 'BE' => _("Belgium"), + 'BZ' => _("Belize"), + 'BJ' => _("Benin"), + 'BM' => _("Bermuda"), + 'BT' => _("Bhutan"), + 'BO' => _("Bolivia"), + 'BA' => _("Bosnia and Herzegovina"), + 'BW' => _("Botswana"), + 'BV' => _("Bouvet Island"), + 'BR' => _("Brazil"), + 'IO' => _("British Indian Ocean Territory"), + 'BN' => _("Brunei Darussalam"), + 'BG' => _("Bulgaria"), + 'BF' => _("Burkina Faso"), + 'BI' => _("Burundi"), + 'KH' => _("Cambodia"), + 'CM' => _("Cameroon"), + 'CA' => _("Canada"), + 'CV' => _("Cape Verde"), + 'KY' => _("Cayman Islands"), + 'CF' => _("Central African Republic"), + 'TD' => _("Chad"), + 'CL' => _("Chile"), + 'CN' => _("China"), + 'CX' => _("Christmas Island"), + 'CC' => _("Cocos (Keeling) Islands"), + 'CO' => _("Colombia"), + 'KM' => _("Comoros"), + 'CG' => _("Congo"), + 'CD' => _("Congo, The Democratic Republic of the"), + 'CK' => _("Cook Islands"), + 'CR' => _("Costa Rica"), + 'CI' => _("Cote d'Ivoire"), + 'HR' => _("Croatia"), + 'CU' => _("Cuba"), + 'CY' => _("Cyprus"), + 'CZ' => _("Czech Republic"), + 'DK' => _("Denmark"), + 'DJ' => _("Djibouti"), + 'DM' => _("Dominica"), + 'DO' => _("Dominican Republic"), + 'EC' => _("Ecuador"), + 'EG' => _("Egypt"), + 'SV' => _("El Salvador"), + 'GQ' => _("Equatorial Guinea"), + 'ER' => _("Eritrea"), + 'EE' => _("Estonia"), + 'ET' => _("Ethiopia"), + 'FK' => _("Falkland Islands (Malvinas)"), + 'FO' => _("Faroe Islands"), + 'FJ' => _("Fiji"), + 'FI' => _("Finland"), + 'FR' => _("France"), + 'GF' => _("French Guiana"), + 'PF' => _("French Polynesia"), + 'TF' => _("French Southern Territories"), + 'GA' => _("Gabon"), + 'GM' => _("Gambia"), + 'GE' => _("Georgia"), + 'DE' => _("Germany"), + 'GH' => _("Ghana"), + 'GI' => _("Gibraltar"), + 'GR' => _("Greece"), + 'GL' => _("Greenland"), + 'GD' => _("Grenada"), + 'GP' => _("Guadeloupe"), + 'GU' => _("Guam"), + 'GT' => _("Guatemala"), + 'GN' => _("Guinea"), + 'GW' => _("Guinea-Bissau"), + 'GY' => _("Guyana"), + 'HT' => _("Haiti"), + 'HM' => _("Heard Island and McDonald Islands"), + 'VA' => _("Holy See (Vatican City State)"), + 'HN' => _("Honduras"), + 'HK' => _("Hong Kong"), + 'HU' => _("Hungary"), + 'IS' => _("Iceland"), + 'IN' => _("India"), + 'ID' => _("Indonesia"), + 'IR' => _("Iran, Islamic Republic of"), + 'IQ' => _("Iraq"), + 'IE' => _("Ireland"), + 'IL' => _("Israel"), + 'IT' => _("Italy"), + 'JM' => _("Jamaica"), + 'JP' => _("Japan"), + 'JO' => _("Jordan"), + 'KZ' => _("Kazakhstan"), + 'KE' => _("Kenya"), + 'KI' => _("Kiribati"), + 'KP' => _("Korea, Democratic People's Republic of"), + 'KR' => _("Korea, Republic of"), + 'KW' => _("Kuwait"), + 'KG' => _("Kyrgyzstan"), + 'LA' => _("Lao People's Democratic Republic"), + 'LV' => _("Latvia"), + 'LB' => _("Lebanon"), + 'LS' => _("Lesotho"), + 'LR' => _("Liberia"), + 'LY' => _("Libyan Arab Jamahiriya"), + 'LI' => _("Liechtenstein"), + 'LT' => _("Lithuania"), + 'LU' => _("Luxembourg"), + 'MO' => _("Macao"), + 'MK' => _("Macedonia, The Former Yugoslav Republic of"), + 'MG' => _("Madagascar"), + 'MW' => _("Malawi"), + 'MY' => _("Malaysia"), + 'MV' => _("Maldives"), + 'ML' => _("Mali"), + 'MT' => _("Malta"), + 'MH' => _("Marshall Islands"), + 'MQ' => _("Martinique"), + 'MR' => _("Mauritania"), + 'MU' => _("Mauritius"), + 'YT' => _("Mayotte"), + 'MX' => _("Mexico"), + 'FM' => _("Micronesia, Federated States of"), + 'MD' => _("Moldova, Republic of"), + 'MC' => _("Monaco"), + 'MN' => _("Mongolia"), + 'MS' => _("Montserrat"), + 'MA' => _("Morocco"), + 'MZ' => _("Mozambique"), + 'MM' => _("Myanmar"), + 'NA' => _("Namibia"), + 'NR' => _("Nauru"), + 'NP' => _("Nepal"), + 'NL' => _("Netherlands"), + 'AN' => _("Netherlands Antilles"), + 'NC' => _("New Caledonia"), + 'NZ' => _("New Zealand"), + 'NI' => _("Nicaragua"), + 'NE' => _("Niger"), + 'NG' => _("Nigeria"), + 'NU' => _("Niue"), + 'NF' => _("Norfolk Island"), + 'MP' => _("Northern Mariana Islands"), + 'NO' => _("Norway"), + 'OM' => _("Oman"), + 'PK' => _("Pakistan"), + 'PW' => _("Palau"), + 'PS' => _("Palestinian Territory, Occupied"), + 'PA' => _("Panama"), + 'PG' => _("Papua New Guinea"), + 'PY' => _("Paraguay"), + 'PE' => _("Peru"), + 'PH' => _("Philippines"), + 'PN' => _("Pitcairn"), + 'PL' => _("Poland"), + 'PT' => _("Portugal"), + 'PR' => _("Puerto Rico"), + 'QA' => _("Qatar"), + 'RE' => _("Reunion"), + 'RO' => _("Romania"), + 'RU' => _("Russian Federation"), + 'RW' => _("Rwanda"), + 'SH' => _("Saint Helena"), + 'KN' => _("Saint Kitts and Nevis"), + 'LC' => _("Saint Lucia"), + 'PM' => _("Saint Pierre and Miquelon"), + 'VC' => _("Saint Vincent and the Grenadines"), + 'WS' => _("Samoa"), + 'SM' => _("San Marino"), + 'ST' => _("Sao Tome and Principe"), + 'SA' => _("Saudi Arabia"), + 'SN' => _("Senegal"), + 'CS' => _("Serbia and Montenegro"), + 'SC' => _("Seychelles"), + 'SL' => _("Sierra Leone"), + 'SG' => _("Singapore"), + 'SK' => _("Slovakia"), + 'SI' => _("Slovenia"), + 'SB' => _("Solomon Islands"), + 'SO' => _("Somalia"), + 'ZA' => _("South Africa"), + 'GS' => _("South Georgia and the South Sandwich Islands"), + 'ES' => _("Spain"), + 'LK' => _("Sri Lanka"), + 'SD' => _("Sudan"), + 'SR' => _("Suriname"), + 'SJ' => _("Svalbard and Jan Mayen"), + 'SZ' => _("Swaziland"), + 'SE' => _("Sweden"), + 'CH' => _("Switzerland"), + 'SY' => _("Syrian Arab Republic"), + 'TW' => _("Taiwan, Province of China"), + 'TJ' => _("Tajikistan"), + 'TZ' => _("Tanzania, United Republic of"), + 'TH' => _("Thailand"), + 'TL' => _("Timor-Leste"), + 'TG' => _("Togo"), + 'TK' => _("Tokelau"), + 'TO' => _("Tonga"), + 'TT' => _("Trinidad and Tobago"), + 'TN' => _("Tunisia"), + 'TR' => _("Turkey"), + 'TM' => _("Turkmenistan"), + 'TC' => _("Turks and Caicos Islands"), + 'TV' => _("Tuvalu"), + 'UG' => _("Uganda"), + 'UA' => _("Ukraine"), + 'AE' => _("United Arab Emirates"), + 'GB' => _("United Kingdom"), + 'US' => _("United States"), + 'UM' => _("United States Minor Outlying Islands"), + 'UY' => _("Uruguay"), + 'UZ' => _("Uzbekistan"), + 'VU' => _("Vanuatu"), + 'VE' => _("Venezuela"), + 'VN' => _("Viet Nam"), + 'VG' => _("Virgin Islands, British"), + 'VI' => _("Virgin Islands, U.S."), + 'WF' => _("Wallis and Futuna"), + 'EH' => _("Western Sahara"), + 'YE' => _("Yemen"), + 'ZM' => _("Zambia"), + 'ZW' => _("Zimbabwe") +); + +asort($countries, SORT_LOCALE_STRING); diff --git a/framework/Nls/lib/Horde/Nls/Geoip.php b/framework/Nls/lib/Horde/Nls/Geoip.php new file mode 100644 index 000000000..3b19a0eab --- /dev/null +++ b/framework/Nls/lib/Horde/Nls/Geoip.php @@ -0,0 +1,362 @@ +Country listing. + * + * Based on PHP geoip.inc library by MaxMind LLC: + * http://www.maxmind.com/download/geoip/api/php/ + * + * Originally based on php version of the geoip library written in May + * 2002 by jim winstead + * + * Copyright 2003 MaxMind LLC + * Copyright 2003-2009 The Horde Project (http://www.horde.org/) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @author Michael Slusarz + * @package Horde_NLS + */ +class Horde_Nls_Geoip +{ + /* TODO */ + const GEOIP_COUNTRY_BEGIN = 16776960; + const STRUCTURE_INFO_MAX_SIZE = 20; + const STANDARD_RECORD_LENGTH = 3; + + /** + * The singleton instance. + * + * @var Horde_Nls_Geoip + */ + static protected $_instance; + + /** + * Country list. + * + * @var array + */ + protected $_countryCodes = array( + '', 'AP', 'EU', 'AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AN', 'AO', + 'AQ', 'AR', 'AS', 'AT', 'AU', 'AW', 'AZ', 'BA', 'BB', 'BD', 'BE', + 'BF', 'BG', 'BH', 'BI', 'BJ', 'BM', 'BN', 'BO', 'BR', 'BS', 'BT', + 'BV', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD', 'CF', 'CG', 'CH', 'CI', + 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CX', 'CY', 'CZ', + 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG', 'EH', 'ER', + 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'FX', 'GA', 'UK', + 'GD', 'GE', 'GF', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', + 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HM', 'HN', 'HR', 'HT', 'HU', + 'ID', 'IE', 'IL', 'IN', 'IO', 'IQ', 'IR', 'IS', 'IT', 'JM', 'JO', + 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KP', 'KR', 'KW', 'KY', + 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', + 'LY', 'MA', 'MC', 'MD', 'MG', 'MH', 'MK', 'ML', 'MM', 'MN', 'MO', + 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', + 'NA', 'NC', 'NE', 'NF', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', + 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PM', 'PN', + 'PR', 'PS', 'PT', 'PW', 'PY', 'QA', 'RE', 'RO', 'RU', 'RW', 'SA', + 'SB', 'SC', 'SD', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', + 'SN', 'SO', 'SR', 'ST', 'SV', 'SY', 'SZ', 'TC', 'TD', 'TF', 'TG', + 'TH', 'TJ', 'TK', 'TM', 'TN', 'TO', 'TP', 'TR', 'TT', 'TV', 'TW', + 'TZ', 'UA', 'UG', 'UM', 'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VG', + 'VI', 'VN', 'VU', 'WF', 'WS', 'YE', 'YT', 'YU', 'ZA', 'ZM', 'ZR', + 'ZW', 'A1', 'A2', 'O1' + ); + + /** + * The location of the GeoIP database. + * + * @var string + */ + protected $_datafile; + + /** + * The open filehandle to the GeoIP database. + * + * @var resource + */ + protected $_fh; + + /** + * Returns a reference to the global Horde_Nls_GeoIP object, only creating + * it if it doesn't already exist. + * + * This method must be invoked as: + * $geoip = Horde_Nls_Geoip::singleton($datafile); + * + * @param string $datafile The location of the GeoIP database. + * + * @return object Horde_Nls_Geoip The object instance. + */ + static public function singleton($datafile) + { + if (!isset(self::$_instance)) { + self::$_instance = new Horde_Nls_Geoip($datafile); + } + + return $instance; + } + + /** + * Constructor. + * + * @param string $datafile The location of the GeoIP database. + */ + public function __construct($datafile) + { + $this->_datafile = $datafile; + } + + /** + * Open the GeoIP database. + * + * @return boolean False on error. + */ + protected function _open() + { + /* Return if we already have an object. */ + if (!empty($this->_fh)) { + return true; + } + + /* Return if no datafile specified. */ + if (empty($this->_datafile)) { + return false; + } + + $this->_fh = fopen($this->_datafile, 'rb'); + if (!$this->_fh) { + return false; + } + + $filepos = ftell($this->_fh); + fseek($this->_fh, -3, SEEK_END); + for ($i = 0; $i < self::STRUCTURE_INFO_MAX_SIZE; ++$i) { + $delim = fread($this->_fh, 3); + if ($delim == (chr(255) . chr(255) . chr(255))) { + break; + } else { + fseek($this->_fh, -4, SEEK_CUR); + } + } + fseek($this->_fh, $filepos, SEEK_SET); + + return true; + } + + /** + * Returns the country ID and Name for a given hostname. + * + * @param string $name The hostname. + * + * @return mixed An array with 'code' as the country code and 'name' as + * the country name, or false if not found. + */ + public function getCountryInfo($name) + { + if (Horde_Util::extensionExists('geoip')) { + $id = @geoip_country_code_by_name($name); + $cname = @geoip_country_name_by_name($name); + return (!empty($id) && !empty($cname)) ? + array('code' => Horde_String::lower($id), 'name' => $cname): + false; + } + + $id = $this->countryIdByName($name); + if (!empty($id)) { + $code = $this->_countryCodes[$id]; + return array( + 'code' => Horde_String::lower($code), + 'name' => $this->_getName($code) + ); + } + + return false; + } + + /** + * Returns the country ID for a hostname. + * + * @param string $name The hostname. + * + * @return integer The GeoIP country ID. + */ + public function countryIdByName($name) + { + if (!$this->_open()) { + return false; + } + + $addr = gethostbyname($name); + if (!$addr || ($addr == $name)) { + return false; + } + + return $this->countryIdByAddr($addr); + } + + /** + * Returns the country abbreviation (2-letter) for a hostname. + * + * @param string $name The hostname. + * + * @return integer The country abbreviation. + */ + public function countryCodeByName($name) + { + if ($this->_open()) { + $country_id = $this->countryIdByName($name); + if ($country_id !== false) { + return $this->_countryCodes[$country_id]; + } + } + + return false; + } + + /** + * Returns the country name for a hostname. + * + * @param string $name The hostname. + * + * @return integer The country name. + */ + public function countryNameByName($name) + { + if ($this->_open()) { + $country_id = $this->countryCodeByName($name); + if ($country_id !== false) { + return $this->_getName($country_id); + } + } + + return false; + } + + /** + * Returns the country ID for an IP Address. + * + * @param string $addr The IP Address. + * + * @return integer The GeoIP country ID. + */ + public function countryIdByAddr($addr) + { + if (!$this->_open()) { + return false; + } + + $ipnum = ip2long($addr); + $country = $this->_seekCountry($ipnum); + + return ($country === false) + ? '' + : ($this->_seekCountry($ipnum) - self::GEOIP_COUNTRY_BEGIN); + } + + /** + * Returns the country abbreviation (2-letter) for an IP Address. + * + * @param string $addr The IP Address. + * + * @return integer The country abbreviation. + */ + public function countryCodeByAddr($addr) + { + if ($this->_open()) { + $country_id = $this->countryIdByAddr($addr); + if ($country_id !== false) { + return $this->_countryCodes[$country_id]; + } + } + + return false; + } + + /** + * Returns the country name for an IP address. + * + * @param string $addr The IP address. + * + * @return mixed The country name. + */ + public function countryNameByAddr($addr) + { + if ($this->_open()) { + $country_id = $this->countryCodeByAddr($addr); + if ($country_id !== false) { + return $this->_getName($country_id); + } + } + + return false; + } + + /** + * Finds a country by IP Address in the GeoIP database. + * + * @param string $ipnum The IP Address to search for. + * + * @return mixed The country ID or false if not found. + */ + protected function _seekCountry($ipnum) + { + $offset = 0; + + for ($depth = 31; $depth >= 0; --$depth) { + if (fseek($this->_fh, 2 * self::STANDARD_RECORD_LENGTH * $offset, SEEK_SET) != 0) { + return false; + } + $buf = fread($this->_fh, 2 * self::STANDARD_RECORD_LENGTH); + $x = array(0, 0); + + for ($i = 0; $i < 2; ++$i) { + for ($j = 0; $j < self::STANDARD_RECORD_LENGTH; ++$j) { + $x[$i] += ord($buf[self::STANDARD_RECORD_LENGTH * $i + $j]) << ($j * 8); + } + } + if ($ipnum & (1 << $depth)) { + if ($x[1] >= self::GEOIP_COUNTRY_BEGIN) { + return $x[1]; + } + $offset = $x[1]; + } else { + if ($x[0] >= self::GEOIP_COUNTRY_BEGIN) { + return $x[0]; + } + $offset = $x[0]; + } + } + + return false; + } + + /** + * Given a 2-letter country code, returns a country string. + * + * @param string $code The country code. + * + * @return string The country string. + */ + protected function _getName($code) + { + $code = Horde_String::upper($code); + + $geoip_codes = array( + 'AP' => _("Asia/Pacific Region"), + 'EU' => _("Europe"), + 'A1' => _("Anonymous Proxy"), + 'A2' => _("Satellite Provider"), + 'O1' => _("Other") + ); + + return isset($geoip_codes[$code]) + ? $geoip_codes[$code] + : strval(Horde_Nls::getCountryISO($code)); + } + +} diff --git a/framework/Nls/lib/Horde/Nls/Tld.php b/framework/Nls/lib/Horde/Nls/Tld.php new file mode 100644 index 000000000..5c60416d2 --- /dev/null +++ b/framework/Nls/lib/Horde/Nls/Tld.php @@ -0,0 +1,263 @@ + _("Ascension Island"), + 'ad' => _("Andorra"), + 'ae' => _("United Arab Emirates"), + 'af' => _("Afghanistan"), + 'ag' => _("Antigua and Barbuda"), + 'ai' => _("Anguilla"), + 'al' => _("Albania"), + 'am' => _("Armenia"), + 'an' => _("Netherlands Antilles"), + 'ao' => _("Angola"), + 'aq' => _("Antarctica"), + 'ar' => _("Argentina"), + 'as' => _("American Samoa"), + 'at' => _("Austria"), + 'au' => _("Australia"), + 'aw' => _("Aruba"), + 'ax' => _("Aland Islands"), + 'az' => _("Azerbaijan"), + 'ba' => _("Bosnia and Herzegovina"), + 'bb' => _("Barbados"), + 'bd' => _("Bangladesh"), + 'be' => _("Belgium"), + 'bf' => _("Burkina Faso"), + 'bg' => _("Bulgaria"), + 'bh' => _("Bahrain"), + 'bi' => _("Burundi"), + 'bj' => _("Benin"), + 'bm' => _("Bermuda"), + 'bn' => _("Brunei Darussalam"), + 'bo' => _("Bolivia"), + 'br' => _("Brazil"), + 'bs' => _("Bahamas"), + 'bt' => _("Bhutan"), + 'bv' => _("Bouvet Island"), + 'bw' => _("Botswana"), + 'by' => _("Belarus"), + 'bz' => _("Belize"), + 'ca' => _("Canada"), + 'cc' => _("Cocos (Keeling) Islands"), + 'cd' => _("Congo, The Democratic Republic of the"), + 'cf' => _("Central African Republic"), + 'cg' => _("Congo, Republic of"), + 'ch' => _("Switzerland"), + 'ci' => _("Cote d'Ivoire"), + 'ck' => _("Cook Islands"), + 'cl' => _("Chile"), + 'cm' => _("Cameroon"), + 'cn' => _("China"), + 'co' => _("Colombia"), + 'cr' => _("Costa Rica"), + 'cu' => _("Cuba"), + 'cv' => _("Cape Verde"), + 'cx' => _("Christmas Island"), + 'cy' => _("Cyprus"), + 'cz' => _("Czech Republic"), + 'de' => _("Germany"), + 'dj' => _("Djibouti"), + 'dk' => _("Denmark"), + 'dm' => _("Dominica"), + 'do' => _("Dominican Republic"), + 'dz' => _("Algeria"), + 'ec' => _("Ecuador"), + 'ee' => _("Estonia"), + 'eg' => _("Egypt"), + 'eh' => _("Western Sahara"), + 'er' => _("Eritrea"), + 'es' => _("Spain"), + 'et' => _("Ethiopia"), + 'eu' => _("European Union"), + 'fi' => _("Finland"), + 'fj' => _("Fiji"), + 'fk' => _("Falkland Islands (Malvinas)"), + 'fm' => _("Micronesia, Federated States of"), + 'fo' => _("Faroe Islands"), + 'fr' => _("France"), + 'ga' => _("Gabon"), + 'gb' => _("United Kingdom"), + 'gd' => _("Grenada"), + 'ge' => _("Georgia"), + 'gf' => _("French Guiana"), + 'gg' => _("Guernsey"), + 'gh' => _("Ghana"), + 'gi' => _("Gibraltar"), + 'gl' => _("Greenland"), + 'gm' => _("Gambia"), + 'gn' => _("Guinea"), + 'gp' => _("Guadeloupe"), + 'gq' => _("Equatorial Guinea"), + 'gr' => _("Greece"), + 'gs' => _("South Georgia and the South Sandwich Islands"), + 'gt' => _("Guatemala"), + 'gu' => _("Guam"), + 'gw' => _("Guinea-Bissau"), + 'gy' => _("Guyana"), + 'hk' => _("Hong Kong"), + 'hm' => _("Heard and McDonald Islands"), + 'hn' => _("Honduras"), + 'hr' => _("Croatia/Hrvatska"), + 'ht' => _("Haiti"), + 'hu' => _("Hungary"), + 'id' => _("Indonesia"), + 'ie' => _("Ireland"), + 'il' => _("Israel"), + 'im' => _("Isle of Man"), + 'in' => _("India"), + 'io' => _("British Indian Ocean Territory"), + 'iq' => _("Iraq"), + 'ir' => _("Iran, Islamic Republic of"), + 'is' => _("Iceland"), + 'it' => _("Italy"), + 'je' => _("Jersey"), + 'jm' => _("Jamaica"), + 'jo' => _("Jordan"), + 'jp' => _("Japan"), + 'ke' => _("Kenya"), + 'kg' => _("Kyrgyzstan"), + 'kh' => _("Cambodia"), + 'ki' => _("Kiribati"), + 'km' => _("Comoros"), + 'kn' => _("Saint Kitts and Nevis"), + 'kp' => _("Korea, Democratic People's Republic of"), + 'kr' => _("Korea, Republic of"), + 'kw' => _("Kuwait"), + 'ky' => _("Cayman Islands"), + 'kz' => _("Kazakhstan"), + 'la' => _("Lao People's Democratic Republic"), + 'lb' => _("Lebanon"), + 'lc' => _("Saint Lucia"), + 'li' => _("Liechtenstein"), + 'lk' => _("Sri Lanka"), + 'lr' => _("Liberia"), + 'ls' => _("Lesotho"), + 'lt' => _("Lithuania"), + 'lu' => _("Luxembourg"), + 'lv' => _("Latvia"), + 'ly' => _("Libyan Arab Jamahiriya"), + 'ma' => _("Morocco"), + 'mc' => _("Monaco"), + 'md' => _("Moldova, Republic of"), + 'me' => _("Montenegro"), + 'mg' => _("Madagascar"), + 'mh' => _("Marshall Islands"), + 'mk' => _("Macedonia, The Former Yugoslav Republic of"), + 'ml' => _("Mali"), + 'mm' => _("Myanmar"), + 'mn' => _("Mongolia"), + 'mo' => _("Macao"), + 'mp' => _("Northern Mariana Islands"), + 'mq' => _("Martinique"), + 'mr' => _("Mauritania"), + 'ms' => _("Montserrat"), + 'mt' => _("Malta"), + 'mu' => _("Mauritius"), + 'mv' => _("Maldives"), + 'mw' => _("Malawi"), + 'mx' => _("Mexico"), + 'my' => _("Malaysia"), + 'mz' => _("Mozambique"), + 'na' => _("Namibia"), + 'nc' => _("New Caledonia"), + 'ne' => _("Niger"), + 'nf' => _("Norfolk Island"), + 'ng' => _("Nigeria"), + 'ni' => _("Nicaragua"), + 'nl' => _("Netherlands"), + 'no' => _("Norway"), + 'np' => _("Nepal"), + 'nr' => _("Nauru"), + 'nu' => _("Niue"), + 'nz' => _("New Zealand"), + 'om' => _("Oman"), + 'pa' => _("Panama"), + 'pe' => _("Peru"), + 'pf' => _("French Polynesia"), + 'pg' => _("Papua New Guinea"), + 'ph' => _("Philippines"), + 'pk' => _("Pakistan"), + 'pl' => _("Poland"), + 'pm' => _("Saint Pierre and Miquelon"), + 'pn' => _("Pitcairn Island"), + 'pr' => _("Puerto Rico"), + 'ps' => _("Palestinian Territory, Occupied"), + 'pt' => _("Portugal"), + 'pw' => _("Palau"), + 'py' => _("Paraguay"), + 'qa' => _("Qatar"), + 're' => _("Reunion Island"), + 'ro' => _("Romania"), + 'rs' => _("Serbia"), + 'ru' => _("Russian Federation"), + 'rw' => _("Rwanda"), + 'sa' => _("Saudi Arabia"), + 'sb' => _("Solomon Islands"), + 'sc' => _("Seychelles"), + 'sd' => _("Sudan"), + 'se' => _("Sweden"), + 'sg' => _("Singapore"), + 'sh' => _("Saint Helena"), + 'si' => _("Slovenia"), + 'sj' => _("Svalbard and Jan Mayen Islands"), + 'sk' => _("Slovakia"), + 'sl' => _("Sierra Leone"), + 'sm' => _("San Marino"), + 'sn' => _("Senegal"), + 'so' => _("Somalia"), + 'sr' => _("Suriname"), + 'st' => _("Sao Tome and Principe"), + 'su' => _("Soviet Union"), + 'sv' => _("El Salvador"), + 'sy' => _("Syrian Arab Republic"), + 'sz' => _("Swaziland"), + 'tc' => _("Turks and Caicos Islands"), + 'td' => _("Chad"), + 'tf' => _("French Southern Territories"), + 'tg' => _("Togo"), + 'th' => _("Thailand"), + 'tj' => _("Tajikistan"), + 'tk' => _("Tokelau"), + 'tl' => _("Timor-Leste"), + 'tm' => _("Turkmenistan"), + 'tn' => _("Tunisia"), + 'to' => _("Tonga"), + 'tp' => _("East Timor"), + 'tr' => _("Turkey"), + 'tt' => _("Trinidad and Tobago"), + 'tv' => _("Tuvalu"), + 'tw' => _("Taiwan"), + 'tz' => _("Tanzania, United Republic of"), + 'ua' => _("Ukraine"), + 'ug' => _("Uganda"), + 'uk' => _("United Kingdom"), + 'um' => _("United States Minor Outlying Islands"), + 'us' => _("United States"), + 'uy' => _("Uruguay"), + 'uz' => _("Uzbekistan"), + 'va' => _("Holy See (Vatican City State)"), + 'vc' => _("Saint Vincent and the Grenadines"), + 've' => _("Venezuela"), + 'vg' => _("Virgin Islands, British"), + 'vi' => _("Virgin Islands, U.S."), + 'vn' => _("Viet Nam"), + 'vu' => _("Vanuatu"), + 'wf' => _("Wallis and Futuna Islands"), + 'ws' => _("Samoa"), + 'ye' => _("Yemen"), + 'yt' => _("Mayotte"), + 'yu' => _("Yugoslavia"), + 'za' => _("South Africa"), + 'zm' => _("Zambia"), + 'zw' => _("Zimbabwe") +); diff --git a/framework/Nls/package.xml b/framework/Nls/package.xml new file mode 100644 index 000000000..699b0edb1 --- /dev/null +++ b/framework/Nls/package.xml @@ -0,0 +1,115 @@ + + + Nls + pear.horde.org + Localization Package + TODO + + + Chuck Hagenbuch + chuck + chuck@horde.org + yes + + + Jan Schneider + jan + jan@horde.org + yes + + 2009-07-08 + + 0.1.0 + 0.1.0 + + + beta + beta + + LGPL + * Initial Horde 4 package. + + + + + + + + + + + + + + + + + + + + + 5.2.0 + + + 1.5.4 + + + Browser + pear.horde.org + + + Util + pear.horde.org + + + + + geoip + + + + + + + + + + + + + + + + 2006-05-08 + + + 0.0.2 + 0.0.2 + + + alpha + alpha + + LGPL + Converted to package.xml 2.0 for pear.horde.org + + + + + 0.0.1 + 0.0.1 + + + alpha + alpha + + 2004-02-11 + LGPL + Initial packaging + + + + diff --git a/framework/Notification/lib/Horde/Notification/Listener/Status.php b/framework/Notification/lib/Horde/Notification/Listener/Status.php index 39fecc52a..7332a5bfa 100644 --- a/framework/Notification/lib/Horde/Notification/Listener/Status.php +++ b/framework/Notification/lib/Horde/Notification/Listener/Status.php @@ -93,7 +93,7 @@ class Horde_Notification_Listener_Status extends Horde_Notification_Listener $text = $event->getMessage(); if (!in_array('content.raw', $this->getFlags($message))) { - $text = htmlspecialchars($text, ENT_COMPAT, NLS::getCharset()); + $text = htmlspecialchars($text, ENT_COMPAT, Horde_Nls::getCharset()); } return empty($options['data']) diff --git a/framework/Rpc/lib/Horde/Rpc/Soap.php b/framework/Rpc/lib/Horde/Rpc/Soap.php index 1d8733af1..17ccadab6 100644 --- a/framework/Rpc/lib/Horde/Rpc/Soap.php +++ b/framework/Rpc/lib/Horde/Rpc/Soap.php @@ -49,7 +49,7 @@ class Horde_Rpc_Soap extends Horde_Rpc */ public function __construct($params = array()) { - NLS::setCharset('UTF-8'); + Horde_Nls::setCharset('UTF-8'); parent::__construct($params); diff --git a/framework/Rpc/lib/Horde/Rpc/Webdav.php b/framework/Rpc/lib/Horde/Rpc/Webdav.php index 7b5dff509..3eb7fa495 100644 --- a/framework/Rpc/lib/Horde/Rpc/Webdav.php +++ b/framework/Rpc/lib/Horde/Rpc/Webdav.php @@ -619,7 +619,7 @@ Horde::logMessage(print_r($list, true), __FILE__, __LINE__, PEAR_LOG_ERR); // Handle certain standard properties specially if (in_array('displayname', $properties['DAV:'])) { - $props[] = $this->mkprop('displayname', Horde_String::convertCharset($item['name'], NLS::getCharset(), 'UTF-8')); + $props[] = $this->mkprop('displayname', Horde_String::convertCharset($item['name'], Horde_Nls::getCharset(), 'UTF-8')); unset($properties['DAV:']['displayname']); } if (in_array('getlastmodified', $properties['DAV:'])) { diff --git a/framework/SpellChecker/lib/Horde/SpellChecker/Aspell.php b/framework/SpellChecker/lib/Horde/SpellChecker/Aspell.php index ee5062ba8..e81419367 100644 --- a/framework/SpellChecker/lib/Horde/SpellChecker/Aspell.php +++ b/framework/SpellChecker/lib/Horde/SpellChecker/Aspell.php @@ -46,8 +46,7 @@ class Horde_SpellChecker_Aspell extends Horde_SpellChecker throw new Horde_Exception('Spellcheck failed. Command line: ', $this->_cmd()); } - require_once 'Horde/NLS.php'; - $charset = NLS::getCharset(); + $charset = Horde_Nls::getCharset(); // Write to stdin. if ($this->_encoding) {