Index: trunk/extensions/Translate/TranslateHooks.php |
— | — | @@ -183,7 +183,7 @@ |
184 | 184 | $updater->addExtensionUpdate( array( 'addTable', 'translate_reviews', "$dir/translate_reviews.sql", true ) ); |
185 | 185 | $updater->addExtensionUpdate( array( 'addTable', 'translate_groupreviews', "$dir/translate_groupreviews.sql", true ) ); |
186 | 186 | $updater->addExtensionUpdate( array( 'addTable', 'translate_tms', "$dir/translate_tm.sql", true ) ); |
187 | | - |
| 187 | + $updater->addExtensionUpdate( array( 'addTable', 'translate_metadata', "$dir/translate_metadata.sql", true ) ); |
188 | 188 | return true; |
189 | 189 | } |
190 | 190 | |
Index: trunk/extensions/Translate/sql/translate_metadata.sql |
— | — | @@ -0,0 +1,8 @@ |
| 2 | +-- Translate group metadata |
| 3 | +CREATE TABLE /*$wgDBprefix*/translate_metadata ( |
| 4 | + tmd_group varchar(200) binary NOT NULL, |
| 5 | + tmd_key varchar(20) binary NOT NULL, |
| 6 | + tmd_value mediumblob NOT NULL, |
| 7 | + |
| 8 | + PRIMARY KEY (tmd_group, tmd_key) |
| 9 | +) /*$wgDBTableOptions*/; |
Property changes on: trunk/extensions/Translate/sql/translate_metadata.sql |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 10 | + native |
Index: trunk/extensions/Translate/utils/TranslateMetadata.php |
— | — | @@ -0,0 +1,38 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Contains class which offers functionality for reading and updating Translate group |
| 5 | + * related metadata |
| 6 | + * |
| 7 | + * @file |
| 8 | + * @author Niklas Laxström |
| 9 | + * @author Santhosh Thottingal |
| 10 | + * @copyright Copyright © 2012, Niklas Laxström, Santhosh Thottingal |
| 11 | + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
| 12 | + */ |
| 13 | + |
| 14 | +class TranslateMetadata { |
| 15 | + /* |
| 16 | + * Get a metadata value for the given group and key. |
| 17 | + * @param $group The group name |
| 18 | + * @param $key Metadata key |
| 19 | + * @return String |
| 20 | + */ |
| 21 | + public static function get( $group , $key ) { |
| 22 | + $dbr = wfGetDB( DB_SLAVE ); |
| 23 | + $conds = array( 'tmd_group' => $group , 'tmd_key' => $key ); |
| 24 | + $result = $dbr->selectField( 'translate_metadata', 'tmd_value', $conds, __METHOD__ ); |
| 25 | + return $result; |
| 26 | + } |
| 27 | + /* |
| 28 | + * Set a metadata value for the given group and metadata key. Updates the value if already existing. |
| 29 | + * @param $group The group name |
| 30 | + * @param $key Metadata key |
| 31 | + * @param $value Metadata value |
| 32 | + */ |
| 33 | + public static function set( $group , $key, $value ) { |
| 34 | + $dbw = wfGetDB( DB_MASTER ); |
| 35 | + $data = array( 'tmd_group' => $group , 'tmd_key' => $key, 'tmd_value' => $value ); |
| 36 | + $dbw->replace( 'translate_metadata', array( array( 'tmd_group', 'tmd_key' ) ), $data, __METHOD__ ); |
| 37 | + } |
| 38 | + |
| 39 | +} |
Property changes on: trunk/extensions/Translate/utils/TranslateMetadata.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 40 | + native |