## Class MessageSource_MySQL

Description

MessageSource_MySQL class.

Retrive the message translation from a MySQL database.

See the MessageSource::factory() method to instantiate this class.

- version: v1.0, last update on Fri Dec 24 16:58:58 EST 2004
- author: Xiang Wei Zhuo <weizhuo[at]gmail[dot]com>

Located in /I18N/core/MessageSource_MySQL.php (line 41)

    MessageSource
       |
       --MessageSource_MySQL

Variable Summary
db $db
array $dns
string $source
Method Summary
MessageSource_MySQL __construct (string $source)
void __destruct ()
array catalogues ()
resource connect ()
db connection ()
boolean delete (string $message, [string $catalogue = 'messages'])
array getCatalogueList (string $catalogue)
int getLastModified (string $source)
boolean isValidSource (string $variant)
array &loadData (string $variant)
boolean save ([string $catalogue = 'messages'])
boolean update (string $text, string $target, string $comments, [string $catalogue = 'messages'])
Variables
db $db (line 59)

A resource link to the database

- access: protected

array $dns (line 53)

The DSN array property, parsed by PEAR's DB DSN parser.

- access: protected

string $source (line 47)

The datasource string, full DSN to the database.

- access: protected

Redefinition of:

MessageSource::$source
  The source of message translations.

#### Inherited Variables

Inherited from MessageSource

> MessageSource::$cache
> MessageSource::$culture
> MessageSource::$messages
> MessageSource::$untranslated

Methods
Constructor __construct (line 66)

Constructor.

Create a new message source using MySQL.

- see: MessageSource::factory();

MessageSource_MySQL __construct (string $source)

- string $source: MySQL datasource, in PEAR's DB DSN format.

Destructor __destruct (line 76)

Destructor, close the database connection.

void __destruct ()
catalogues (line 401)

Returns a list of catalogue as key and all it variants as value.

- return: list of catalogues

array catalogues ()
connect (line 86)

Connect to the MySQL datasource

- return: MySQL connection.
- access: protected
- throws: Exception, connection and database errors.

resource connect ()
connection (line 138)

Get the database connection.

- return: database connection.
- access: public

db connection ()
delete (line 336)

Delete a particular message from the specified catalogue.

- return: true if deleted, false otherwise.

boolean delete (string $message, [string $catalogue = 'messages'])

- string $message: the source message to delete.
- string $catalogue: the catalogue to delete from.

getCatalogueList (line 220)

Get all the variants of a particular catalogue.

- return: list of all variants for this catalogue.
- access: protected

array getCatalogueList (string $catalogue)

- string $catalogue: catalogue name

Redefinition of:

MessageSource::getCatalogueList()
  Get all the variants of a particular catalogue.

getLastModified (line 181)

Get the last modified unix-time for this particular catalogue+variant.

We need to query the database to get the date_modified.

- return: last modified in unix-time format.
- access: protected

int getLastModified (string $source)

- string $source: catalogue+variant

Redefinition of:

MessageSource::getLastModified()
  Get the last modified unix-time for this particular catalogue+variant.

isValidSource (line 200)

Check if a particular catalogue+variant exists in the database.

- return: true if the catalogue+variant is in the database, false otherwise.
- access: protected

boolean isValidSource (string $variant)

- string $variant: catalogue+variant

Redefinition of:

MessageSource::isValidSource()
  Determine if the source is valid.

loadData (line 149)

Get an array of messages for a particular catalogue and cultural variant.

- return: translation messages.
- access: protected

array &loadData (string $variant)

- string $variant: the catalogue name + variant

Redefinition of:

MessageSource::loadData()
  Load the message for a particular catalogue+variant.

save (line 297)

Save the list of untranslated blocks to the translation source.

If the translation was not found, you should add those strings to the translation source via the append() method.

- return: true if saved successfuly, false otherwise.

boolean save ([string $catalogue = 'messages'])

- string $catalogue: the catalogue to add to

update (line 367)

Update the translation.

- return: true if translation was updated, false otherwise.

boolean update (string $text, string $target, string $comments, [string $catalogue = 'messages'])

- string $text: the source string.
- string $target: the new translation string.
- string $comments: comments
- string $catalogue: the catalogue of the translation.

#### Inherited Methods

Inherited From MessageSource

> MessageSource::append()
> MessageSource::factory()
> MessageSource::getCache()
> MessageSource::getCatalogueList()
> MessageSource::getCulture()
> MessageSource::getLastModified()
> MessageSource::getSource()
> MessageSource::isValidSource()
> MessageSource::load()
> MessageSource::loadData()
> MessageSource::read()
> MessageSource::setCache()
> MessageSource::setCulture()

Documentation generated on Sun, 04 Jun 2006 18:58:29 -0400 by phpDocumentor 1.3.0RC4