r24791 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24790‎ | r24791 | r24792 >
Date:15:57, 14 August 2007
Author:proes
Status:old
Tags:
Comment:
Fixed SpecialNeedsTranslation
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/NeedsTranslationTo.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/SpecialNeedsTranslation.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/SpecialNeedsTranslation.php
@@ -6,14 +6,23 @@
77 require_once("Wikidata.php");
88
99 function wfSpecialNeedsTranslation() {
10 - global $wgMessageCache;
11 - $wgMessageCache->addMessages(array('needstranslation'=>'Wikidata: Expressions needing translation'),'en');
 10+ global
 11+ $wgMessageCache;
 12+
 13+ $wgMessageCache->addMessages(array('needstranslation'=>'Wikidata: Expressions needing translation'),'en');
1214
1315 class SpecialNeedsTranslation extends SpecialPage {
1416 function SpecialNeedsTranslation() {
1517 SpecialPage::SpecialPage('NeedsTranslation');
1618 }
17 -
 19+
 20+ function getParameterWithDefault($parameterName, $default = 0) {
 21+ if (isset($_GET[$parameterName]))
 22+ return $_GET[$parameterName];
 23+ else
 24+ return $default;
 25+ }
 26+
1827 function execute($par) {
1928 global $wgOut, $wgRequest;
2029
@@ -25,9 +34,9 @@
2635 initializeOmegaWikiAttributes(new ViewInformation());
2736 $wgOut->setPageTitle('Expressions needing translation');
2837
29 - $sourceLanguageId = $_GET['from-lang'];
30 - $destinationLanguageId = $_GET['to-lang'];
31 - $collectionId = $_GET['collection'];
 38+ $sourceLanguageId = $this->getParameterWithDefault('from-lang');
 39+ $destinationLanguageId = $this->getParameterWithDefault('to-lang');
 40+ $collectionId = $this->getParameterWithDefault('collection');
3241
3342 $wgOut->addHTML(getOptionPanel(
3443 array(
@@ -46,9 +55,10 @@
4756 protected function showExpressionsNeedingTranslation($sourceLanguageId, $destinationLanguageId,$collectionId) {
4857 global
4958 $definedMeaningIdAttribute, $expressionIdAttribute, $expressionAttribute, $expressionStructure;
50 - $o=OmegaWikiAttributes::getInstance();
 59+
 60+ $attributeSet = new OmegaWikiAttributes(new ViewInformation());
 61+ $dc = wdGetDataSetContext();
5162
52 - $dc=wdGetDataSetContext();
5363 require_once("Transaction.php");
5464 require_once("OmegaWikiAttributes.php");
5565 require_once("RecordSet.php");
@@ -60,14 +70,14 @@
6171 $sql = 'SELECT source_expression.expression_id AS source_expression_id, source_expression.language_id AS source_language_id, source_expression.spelling AS source_spelling, source_syntrans.defined_meaning_id AS source_defined_meaning_id' .
6272 " FROM ({$dc}_syntrans source_syntrans, {$dc}_expression_ns source_expression)";
6373
64 - if ($collectionId != '')
 74+ if ($collectionId != 0)
6575 $sql .= " JOIN {$dc}_collection_contents ON source_syntrans.defined_meaning_id = member_mid";
6676
6777 $sql .= ' WHERE source_syntrans.expression_id = source_expression.expression_id';
6878
6979 if ($sourceLanguageId != '')
7080 $sql .= ' AND source_expression.language_id = ' . $sourceLanguageId;
71 - if ($collectionId != '')
 81+ if ($collectionId != 0)
7282 $sql .= " AND {$dc}_collection_contents.collection_id = " . $collectionId .
7383 ' AND ' . getLatestTransactionRestriction("{$dc}_collection_contents");
7484
@@ -95,8 +105,8 @@
96106 }
97107
98108 $expressionEditor = new RecordTableCellEditor($expressionAttribute);
99 - $expressionEditor->addEditor(new LanguageEditor($o->language, new SimplePermissionController(false), false));
100 - $expressionEditor->addEditor(new SpellingEditor($o->spelling, new SimplePermissionController(false), false));
 109+ $expressionEditor->addEditor(new LanguageEditor($attributeSet->language, new SimplePermissionController(false), false));
 110+ $expressionEditor->addEditor(new SpellingEditor($attributeSet->spelling, new SimplePermissionController(false), false));
101111
102112 $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), new ShowEditFieldChecker(true), new AllowAddController(false), false, false, null);
103113 $editor->addEditor($expressionEditor);
Index: trunk/extensions/Wikidata/OmegaWiki/NeedsTranslationTo.php
@@ -51,22 +51,25 @@
5252 $definedMeaningIdAttribute, $expressionIdAttribute, $expressionAttribute, $expressionStructure;
5353
5454 $dc=wdGetDataSetContext();
55 - $o=OmegaWikiAttributes::getInstance();
 55+ $attributeSet = new OmegaWikiAttributes(new ViewInformation());
5656
5757 $dbr = &wfGetDB(DB_SLAVE);
58 - $queryResult = $dbr->query("SELECT source_expression.expression_id AS source_expression_id, source_expression.language_id AS source_language_id, source_expression.spelling AS source_spelling, source_syntrans.defined_meaning_id AS source_defined_meaning_id" .
59 - " FROM {$dc}_syntrans source_syntrans, {$dc}_expression_ns source_expression" .
60 - " WHERE source_syntrans.expression_id=source_expression.expression_id AND source_expression.language_id=$sourceLanguageId" .
61 - " AND ". getLatestTransactionRestriction('source_syntrans').
62 - " AND ". getLatestTransactionRestriction('source_expression').
63 - " AND NOT EXISTS (" .
64 - " SELECT * FROM {$dc}_syntrans destination_syntrans, {$dc}_expression_ns destination_expression" .
65 - " WHERE destination_syntrans.expression_id=destination_expression.expression_id AND destination_expression.language_id=$destinationLanguageId" .
66 - " AND source_syntrans.defined_meaning_id=destination_syntrans.defined_meaning_id".
67 - " AND ". getLatestTransactionRestriction('destination_syntrans').
68 - " AND ". getLatestTransactionRestriction('destination_expression').
69 - " )" .
70 - " LIMIT 100");
 58+ $queryResult = $dbr->query(
 59+ "SELECT source_expression.expression_id AS source_expression_id, source_expression.language_id AS source_language_id, source_expression.spelling AS source_spelling, source_syntrans.defined_meaning_id AS source_defined_meaning_id" .
 60+ " FROM {$dc}_syntrans source_syntrans, {$dc}_expression_ns source_expression" .
 61+ " WHERE source_syntrans.expression_id=source_expression.expression_id AND source_expression.language_id=$sourceLanguageId" .
 62+ " AND ". getLatestTransactionRestriction('source_syntrans').
 63+ " AND ". getLatestTransactionRestriction('source_expression').
 64+ " AND NOT EXISTS (" .
 65+ " SELECT * FROM {$dc}_syntrans destination_syntrans, {$dc}_expression_ns destination_expression" .
 66+ " WHERE destination_syntrans.expression_id=destination_expression.expression_id " .
 67+ " AND destination_expression.language_id=$destinationLanguageId " .
 68+ " AND source_syntrans.defined_meaning_id=destination_syntrans.defined_meaning_id".
 69+ " AND ". getLatestTransactionRestriction('destination_syntrans').
 70+ " AND ". getLatestTransactionRestriction('destination_expression').
 71+ " )" .
 72+ " LIMIT 100"
 73+ );
7174
7275 $definitionAttribute = new Attribute("definition", "Definition", "definition");
7376 $recordSet = new ArrayRecordSet(new Structure($definedMeaningIdAttribute, $expressionIdAttribute, $expressionAttribute, $definitionAttribute), new Structure($definedMeaningIdAttribute, $expressionIdAttribute));
@@ -80,8 +83,8 @@
8184 }
8285
8386 $expressionEditor = new RecordTableCellEditor($expressionAttribute);
84 - $expressionEditor->addEditor(new LanguageEditor($o->language, new SimplePermissionController(false), false));
85 - $expressionEditor->addEditor(new SpellingEditor($spellingAttribute, new SimplePermissionController(false), false));
 87+ $expressionEditor->addEditor(new LanguageEditor($attributeSet->language, new SimplePermissionController(false), false));
 88+ $expressionEditor->addEditor(new SpellingEditor($attributeSet->spelling, new SimplePermissionController(false), false));
8689
8790 $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), new AllowAddController(false), false, false, null);
8891 $editor->addEditor($expressionEditor);

Status & tagging log