System.I18N.core
[ class tree: System.I18N.core ] [ index: System.I18N.core ] [ all elements ]

Class: MessageSource_MySQL

Source Location: /I18N/core/MessageSource_MySQL.php

Class Overview

MessageSource
   |
   --MessageSource_MySQL

MessageSource_MySQL class.

Class Details

[line 41]
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>


[ Top ]

Variables

Methods


Inherited Variables

Inherited Methods

Class: MessageSource

MessageSource::append()
Add a untranslated message to the source. Need to call save() to save the messages to source.
MessageSource::factory()
Factory method to instantiate a new MessageSource depending on the
MessageSource::getCache()
Get the cache handler for this source.
MessageSource::getCatalogueList()
Get all the variants of a particular catalogue.
MessageSource::getCulture()
Get the culture identifier for the source.
MessageSource::getLastModified()
Get the last modified unix-time for this particular catalogue+variant.
MessageSource::getSource()
Get the source, this could be a filename or database ID.
MessageSource::isValidSource()
Determine if the source is valid.
MessageSource::load()
Load a particular message catalogue. Use read() to to get the array of messages. The catalogue loading sequence is as follows
MessageSource::loadData()
Load the message for a particular catalogue+variant.
MessageSource::read()
Get the array of messages.
MessageSource::setCache()
Set the cache handler for caching the messages.
MessageSource::setCulture()
Set the culture for this message source.

Class Variables

$db =

[line 59]

A resource link to the database



access:  protected

Type:   db


[ Top ]

$dns =

[line 53]

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



access:  protected

Type:   array


[ Top ]

$source =

[line 47]

The datasource string, full DSN to the database.



access:  protected

Type:   string
Overrides:   Array


[ Top ]



Class Methods


constructor __construct [line 66]

MessageSource_MySQL __construct( string $source)

Constructor.

Create a new message source using MySQL.




see:  MessageSource::factory();


Parameters:

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

[ Top ]

destructor __destruct [line 76]

void __destruct( )

Destructor, close the database connection.



[ Top ]

method catalogues [line 401]

array catalogues( )

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



return:  list of catalogues


[ Top ]

method connect [line 86]

resource connect( )

Connect to the MySQL datasource



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


[ Top ]

method connection [line 138]

db connection( )

Get the database connection.



return:  database connection.
access:  public


[ Top ]

method delete [line 336]

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

Delete a particular message from the specified catalogue.



return:  true if deleted, false otherwise.


Parameters:

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

[ Top ]

method getCatalogueList [line 220]

array getCatalogueList( string $catalogue)

Get all the variants of a particular catalogue.



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


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

Parameters:

string   $catalogue   catalogue name

[ Top ]

method getLastModified [line 181]

int getLastModified( string $source)

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


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

Parameters:

string   $source   catalogue+variant

[ Top ]

method isValidSource [line 200]

boolean isValidSource( string $variant)

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



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


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

Parameters:

string   $variant   catalogue+variant

[ Top ]

method loadData [line 149]

array &loadData( string $variant)

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



return:  translation messages.
access:  protected


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

Parameters:

string   $variant   the catalogue name + variant

[ Top ]

method save [line 297]

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

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.


Parameters:

string   $catalogue   the catalogue to add to

[ Top ]

method update [line 367]

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

Update the translation.



return:  true if translation was updated, false otherwise.


Parameters:

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

[ Top ]


© 2004-2005 PRADO Software Group. All Rights Reserved.