From fb561e971e02b77f1caa569fb13c35fb286bd1c9 Mon Sep 17 00:00:00 2001 From: mikl <> Date: Tue, 1 Jul 2008 13:45:46 +0000 Subject: Minor fixes in I18N MessageSource --- framework/I18N/core/MessageSource.php | 23 ++++++++++++----------- framework/I18N/core/MessageSource_Database.php | 9 +++++---- 2 files changed, 17 insertions(+), 15 deletions(-) (limited to 'framework/I18N') diff --git a/framework/I18N/core/MessageSource.php b/framework/I18N/core/MessageSource.php index 68fcd903..76d06e9d 100644 --- a/framework/I18N/core/MessageSource.php +++ b/framework/I18N/core/MessageSource.php @@ -34,9 +34,10 @@ require_once(dirname(__FILE__).'/MessageCache.php'); * using the factory method. The default valid sources are * * # XLIFF -- using XML XLIFF format to store the translation messages. - * # SQLite -- Store the translation messages in a SQLite database. - * # MySQL -- Using a MySQL database to store the messages. * # gettext -- Translated messages are stored in the gettext format. + * # Database -- Use an existing TDbConnection to store the messages. + * # SQLite -- (Deprecated) Store the translation messages in a SQLite database. + * # MySQL -- (Deprecated) Using a MySQL database to store the messages. * * A custom message source can be instantiated by specifying the filename * parameter to point to the custom class file. E.g. @@ -50,13 +51,13 @@ require_once(dirname(__FILE__).'/MessageCache.php'); * loadCatalogue method. It details how the resources are loaded and cached. * See also the existing message source types as examples. * - * The following example instantiates a MySQL message source, set the culture, + * The following example instantiates a Database message source, set the culture, * set the cache handler, and use the source in a message formatter. - * The messages are store in a database named "messages". The source parameter - * for the actory method is a PEAR DB style DSN. + * The messages are stored using an existing connection. The source parameter + * for the factory method must contain a valid ConnectionID. * - * $dsn = 'mysql://username:password@localhost/messages'; - * $source = MessageSource::factory('MySQL', $dsn); + * // db1 must be already configured + * $source = MessageSource::factory('Database', 'db1'); * * //set the culture and cache, store the cache in the /tmp directory. * $source->setCulture('en_AU')l @@ -112,9 +113,9 @@ abstract class MessageSource implements IMessageSource * 'Database'. The source parameter depends on the source type. * For 'gettext' and 'XLIFF', 'source' should point to the directory * where the messages are stored. - * For 'Database', 'source' should be a valid connection id. - * If (deprecated) 'MySQL' is used, 'source' must contain a valid - * DSN. + * For 'Database', 'source' must be a valid connection id. + * If one of the deprecated types 'MySQL' or 'SQLite' is used, + * 'source' must contain a valid DSN. * * Custom message source are possible by supplying the a filename parameter * in the factory method. @@ -127,7 +128,7 @@ abstract class MessageSource implements IMessageSource */ static function &factory($type, $source='.', $filename='') { - $types = array('XLIFF', 'MySQL', 'Database', 'gettext'); + $types = array('XLIFF','gettext','Database','MySQL','SQLite'); if(empty($filename) && !in_array($type, $types)) throw new Exception('Invalid type "'.$type.'", valid types are '. diff --git a/framework/I18N/core/MessageSource_Database.php b/framework/I18N/core/MessageSource_Database.php index 4d756820..3ccea61b 100644 --- a/framework/I18N/core/MessageSource_Database.php +++ b/framework/I18N/core/MessageSource_Database.php @@ -1,6 +1,6 @@ bindParameter(':moddate',$time,PDO::PARAM_INT); $command->bindParameter(':catid',$cat_id,PDO::PARAM_INT); - $command->execute(); + $result=$command->execute(); if(!empty($this->cache)) $this->cache->clean($variant, $this->culture); @@ -235,6 +235,7 @@ class MessageSource_Database extends MessageSource $command->bindParameter(':dateadded',$time,PDO::PARAM_INT); foreach($messages as $message) { + if (empty($message)) continue; $count++; $inserted++; $command->execute(); } -- cgit v1.2.3