summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authormikl <>2008-07-01 13:45:46 +0000
committermikl <>2008-07-01 13:45:46 +0000
commitfb561e971e02b77f1caa569fb13c35fb286bd1c9 (patch)
tree41d54658c4ac5db4461a1656f0e90f8c46f1a503 /framework
parent81514767330333fdcfac3dd347718d3a585ea91f (diff)
Minor fixes in I18N MessageSource
Diffstat (limited to 'framework')
-rw-r--r--framework/I18N/core/MessageSource.php23
-rw-r--r--framework/I18N/core/MessageSource_Database.php9
2 files changed, 17 insertions, 15 deletions
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.
* <code>
- * $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 @@
<?php
/**
- * MessageSource_MySQL class file.
+ * MessageSource_Database class file.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the BSD License.
@@ -20,9 +20,9 @@
require_once(dirname(__FILE__).'/MessageSource.php');
/**
- * MessageSource_MySQL class.
+ * MessageSource_Database class.
*
- * Retrive the message translation from a MySQL database.
+ * Retrive the message translation from a database.
*
* See the MessageSource::factory() method to instantiate this class.
*
@@ -194,7 +194,7 @@ class MessageSource_Database extends MessageSource
'UPDATE catalogue SET date_modified = :moddate WHERE cat_id = :catid');
$command->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();
}