Changeset 2470

Show
Ignore:
Timestamp:
06/30/2008 12:04:42 PM (3 months ago)
Author:
mikl
Message:

Implemented MessageSource?_Database

Location:
trunk
Files:
1 added
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/HISTORY

    r2468 r2470  
    1111BUG: Ticket#872 - use PATH_SEPARATOR in phpunit.php (fragmaster b) 
    1212ENH: Added Prado.Validation.validateControl(id) on client side to validate a specific control (Michael) 
     13ENH: Added MessageSource_Database to I18N (uses TDbConnection) (Michael) 
    1314 
    1415Version 3.1.2 April 21, 2008 
  • trunk/UPGRADE

    r2449 r2470  
    1212Upgrading from v3.1.2 
    1313--------------------- 
     14- The Translation configuration now also accepts type 'Database' to 
     15  ease the setup of DB base translation. A valid ConnectionID has to  
     16  be supplied in the source parameter: 
     17  <translation type="Database" source="db1" autosave="true" cache="false" /> 
     18  Type 'MySQL' can still be used but is deprecated and might be removed 
     19  in a later release. 
    1420 
    1521 
  • trunk/framework/Exceptions/messages/messages.txt

    r2445 r2470  
    350350globalization_cache_path_failed                 = Unable to create translation message cache path '{0}'. Make sure the parent directory exists and is writable by the Web process. 
    351351globalization_source_path_failed                = Unable to create translation message path '{0}'. Make sure the parent directory exists and is writable by the Web process. 
     352messagesource_connectionid_invalid      = MessageSource_Database.source '{0}' does not point to a valid TDataSourceConfig module. 
     353messagesource_connectionid_required     = ConnectionID in MessageSource_Database.source is required. 
     354 
    352355callback_not_support_no_priority_state_update   = Callback request does not support unprioritized pagestate update. 
    353356callback_invalid_callback_options               = '{1}' is not a valid TCallbackOptions control for Callback control '{0}'. 
  • trunk/framework/I18N/TGlobalization.php

    r2112 r2470  
    156156         * Sets the translation configuration. Example configuration: 
    157157         * <code> 
    158          * $config['type'] = 'XLIFF'; //XLIFF, gettext, mysql or sqlite 
    159          * $config['source'] = 'Path.to.directory'; //or database connection string 
     158         * $config['type'] = 'XLIFF'; //XLIFF, gettext, Database or MySQL (deprecated) 
     159         * $config['source'] = 'Path.to.directory'; // for types XLIFF and gettext 
     160         * $config['source'] = 'connectionId'; // for type Database 
     161         * $config['source'] = 'mysql://user:pw@host/db'; // for type MySQL (deprecated) 
    160162         * $config['catalogue'] = 'messages'; //default catalog 
    161163         * $config['autosave'] = 'true'; //save untranslated message 
  • trunk/framework/I18N/core/MessageSource.php

    r1398 r2470  
    109109        /** 
    110110         * Factory method to instantiate a new MessageSource depending on the 
    111          * source type. The allowed source types are 'XLIFF', 'SQLite',  
    112          * 'MySQL', and 'gettext'. The source parameter is dependent on the  
    113          * source type. For 'gettext' and 'XLIFF', it should point to the directory 
    114          * where the messages are stored. For database types, e.g. 'SQLite' and  
    115          * 'MySQL', it should be a PEAR DB style DSN string.  
     111         * source type. The allowed source types are 'XLIFF', 'gettext' and 
     112     * 'Database'. The source parameter depends on the source type.  
     113     * For 'gettext' and 'XLIFF', 'source' should point to the directory  
     114     * where the messages are stored.  
     115     * For 'Database', 'source' should be a valid connection id. 
     116     * If (deprecated) 'MySQL' is used, 'source' must contain a valid  
     117     * DSN. 
    116118         * 
    117119         * Custom message source are possible by supplying the a filename parameter 
     
    119121         *  
    120122         * @param string the message source type. 
    121          * @param string the location of the resource. 
     123         * @param string the location of the resource or the ConnectionID. 
    122124         * @param string the filename of the custom message source. 
    123125         * @return MessageSource a new message source of the specified type.  
     
    126128        static function &factory($type, $source='.', $filename='') 
    127129        { 
    128                 $types = array('XLIFF', 'SQLite', 'MySQL', 'gettext'); 
    129                  
    130                 if(empty($filename) && in_array($type, $types) == false) 
     130                $types = array('XLIFF', 'MySQL', 'Database', 'gettext'); 
     131                 
     132                if(empty($filename) && !in_array($type, $types)) 
    131133                        throw new Exception('Invalid type "'.$type.'", valid types are '. 
    132134                                implode(', ', $types));