Index: trunk/extensions/Wikidata/OmegaWiki/SpecialNeedsTranslation.php |
— | — | @@ -6,14 +6,23 @@ |
7 | 7 | require_once("Wikidata.php"); |
8 | 8 | |
9 | 9 | 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'); |
12 | 14 | |
13 | 15 | class SpecialNeedsTranslation extends SpecialPage { |
14 | 16 | function SpecialNeedsTranslation() { |
15 | 17 | SpecialPage::SpecialPage('NeedsTranslation'); |
16 | 18 | } |
17 | | - |
| 19 | + |
| 20 | + function getParameterWithDefault($parameterName, $default = 0) { |
| 21 | + if (isset($_GET[$parameterName])) |
| 22 | + return $_GET[$parameterName]; |
| 23 | + else |
| 24 | + return $default; |
| 25 | + } |
| 26 | + |
18 | 27 | function execute($par) { |
19 | 28 | global $wgOut, $wgRequest; |
20 | 29 | |
— | — | @@ -25,9 +34,9 @@ |
26 | 35 | initializeOmegaWikiAttributes(new ViewInformation()); |
27 | 36 | $wgOut->setPageTitle('Expressions needing translation'); |
28 | 37 | |
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'); |
32 | 41 | |
33 | 42 | $wgOut->addHTML(getOptionPanel( |
34 | 43 | array( |
— | — | @@ -46,9 +55,10 @@ |
47 | 56 | protected function showExpressionsNeedingTranslation($sourceLanguageId, $destinationLanguageId,$collectionId) { |
48 | 57 | global |
49 | 58 | $definedMeaningIdAttribute, $expressionIdAttribute, $expressionAttribute, $expressionStructure; |
50 | | - $o=OmegaWikiAttributes::getInstance(); |
| 59 | + |
| 60 | + $attributeSet = new OmegaWikiAttributes(new ViewInformation()); |
| 61 | + $dc = wdGetDataSetContext(); |
51 | 62 | |
52 | | - $dc=wdGetDataSetContext(); |
53 | 63 | require_once("Transaction.php"); |
54 | 64 | require_once("OmegaWikiAttributes.php"); |
55 | 65 | require_once("RecordSet.php"); |
— | — | @@ -60,14 +70,14 @@ |
61 | 71 | $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' . |
62 | 72 | " FROM ({$dc}_syntrans source_syntrans, {$dc}_expression_ns source_expression)"; |
63 | 73 | |
64 | | - if ($collectionId != '') |
| 74 | + if ($collectionId != 0) |
65 | 75 | $sql .= " JOIN {$dc}_collection_contents ON source_syntrans.defined_meaning_id = member_mid"; |
66 | 76 | |
67 | 77 | $sql .= ' WHERE source_syntrans.expression_id = source_expression.expression_id'; |
68 | 78 | |
69 | 79 | if ($sourceLanguageId != '') |
70 | 80 | $sql .= ' AND source_expression.language_id = ' . $sourceLanguageId; |
71 | | - if ($collectionId != '') |
| 81 | + if ($collectionId != 0) |
72 | 82 | $sql .= " AND {$dc}_collection_contents.collection_id = " . $collectionId . |
73 | 83 | ' AND ' . getLatestTransactionRestriction("{$dc}_collection_contents"); |
74 | 84 | |
— | — | @@ -95,8 +105,8 @@ |
96 | 106 | } |
97 | 107 | |
98 | 108 | $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)); |
101 | 111 | |
102 | 112 | $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), new ShowEditFieldChecker(true), new AllowAddController(false), false, false, null); |
103 | 113 | $editor->addEditor($expressionEditor); |
Index: trunk/extensions/Wikidata/OmegaWiki/NeedsTranslationTo.php |
— | — | @@ -51,22 +51,25 @@ |
52 | 52 | $definedMeaningIdAttribute, $expressionIdAttribute, $expressionAttribute, $expressionStructure; |
53 | 53 | |
54 | 54 | $dc=wdGetDataSetContext(); |
55 | | - $o=OmegaWikiAttributes::getInstance(); |
| 55 | + $attributeSet = new OmegaWikiAttributes(new ViewInformation()); |
56 | 56 | |
57 | 57 | $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 | + ); |
71 | 74 | |
72 | 75 | $definitionAttribute = new Attribute("definition", "Definition", "definition"); |
73 | 76 | $recordSet = new ArrayRecordSet(new Structure($definedMeaningIdAttribute, $expressionIdAttribute, $expressionAttribute, $definitionAttribute), new Structure($definedMeaningIdAttribute, $expressionIdAttribute)); |
— | — | @@ -80,8 +83,8 @@ |
81 | 84 | } |
82 | 85 | |
83 | 86 | $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)); |
86 | 89 | |
87 | 90 | $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), new AllowAddController(false), false, false, null); |
88 | 91 | $editor->addEditor($expressionEditor); |