r112470 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112469‎ | r112470 | r112471 >
Date:05:08, 27 February 2012
Author:santhosh
Status:resolved (Comments)
Tags:i18nreview, scaptrap 
Comment:
Backend logic and storage of language restriction Data (i18n #614)
Generic Table and read/store code for metadata of a group.
Modified paths:
  • /trunk/extensions/Translate/TranslateHooks.php (modified) (history)
  • /trunk/extensions/Translate/sql/translate_metadata.sql (added) (history)
  • /trunk/extensions/Translate/utils/TranslateMetadata.php (added) (history)

Diff [purge]

Index: trunk/extensions/Translate/TranslateHooks.php
@@ -183,7 +183,7 @@
184184 $updater->addExtensionUpdate( array( 'addTable', 'translate_reviews', "$dir/translate_reviews.sql", true ) );
185185 $updater->addExtensionUpdate( array( 'addTable', 'translate_groupreviews', "$dir/translate_groupreviews.sql", true ) );
186186 $updater->addExtensionUpdate( array( 'addTable', 'translate_tms', "$dir/translate_tm.sql", true ) );
187 -
 187+ $updater->addExtensionUpdate( array( 'addTable', 'translate_metadata', "$dir/translate_metadata.sql", true ) );
188188 return true;
189189 }
190190
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
110 + 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
140 + native

Sign-offs

UserFlagDate
Amire80inspected18:30, 29 February 2012

Follow-up revisions

RevisionCommit summaryAuthorDate
r112473Entry in _autoload.php. Follow up r111629santhosh06:29, 27 February 2012

Comments

#Comment by Nikerabbit (talk | contribs)   06:27, 27 February 2012

Forgot autoload?

#Comment by Santhosh.thottingal (talk | contribs)   06:32, 27 February 2012

Yes, fixed in r112473

#Comment by Siebrand (talk | contribs)   18:19, 6 March 2012

Metadata should be updated on page move and page delete events for translatable pages.

Status & tagging log