r93402 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93401‎ | r93402 | r93403 >
Date:17:43, 28 July 2011
Author:kipcool
Status:deferred
Tags:
Comment:
Removed NeedsTranslationTo.php : unused, it seems to be an older version of SpecialNeedsTranslation.php
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/NeedsTranslationTo.php (deleted) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/NeedsTranslationTo.php
@@ -1,97 +0,0 @@
2 -<?php
3 -
4 -require_once( "Wikidata.php" );
5 -require_once( "languages.php" );
6 -require_once( "Transaction.php" );
7 -require_once( "OmegaWikiAttributes.php" );
8 -require_once( "RecordSet.php" );
9 -require_once( "Editor.php" );
10 -require_once( "WikiDataAPI.php" );
11 -require_once( "Wikidata.php" );
12 -
13 -class NeedsTranslationTo extends DefaultWikidataApplication {
14 - public function view() {
15 - global
16 - $wgOut, $wgTitle, $wgRequest;
17 -
18 - parent::view();
19 -
20 - $destinationLanguageName = $wgTitle->getText();
21 - $sourceLanguageName = $wgRequest->getText( 'source-language' );
22 -
23 - $sourceLanguageId = getLanguageIdForName( $sourceLanguageName );
24 - $destinationLanguageId = getLanguageIdForName( $destinationLanguageName );
25 -
26 - if ( $sourceLanguageId > 0 && $destinationLanguageId > 0 ) {
27 - $wgOut->addHTML( "<h1>Expressions needing translation from <i>$sourceLanguageName</i> to <i>$destinationLanguageName</i></h1>" );
28 - $wgOut->addHTML( '<p>Showing only a maximum of 100 expressions.</p>' );
29 - $this->showExpressionsNeedingTranslation( $sourceLanguageId, $destinationLanguageId );
30 - }
31 - else {
32 - $wgOut->addHTML( "<h1>Error in input</h1>" );
33 -
34 - if ( $sourceLanguageId == 0 ) {
35 - if ( $sourceLanguageName == '' )
36 - $wgOut->addHTML( "<p>Please specify source language.</p>" );
37 - else
38 - $wgOut->addHTML( "<p>Unknown source language: $sourceLanguageName</p>" );
39 - }
40 -
41 - if ( $destinationLanguageId == 0 ) {
42 - if ( $destinationLanguageName == '' )
43 - $wgOut->addHTML( "<p>Please specify destination language.</p>" );
44 - else
45 - $wgOut->addHTML( "<p>Unknown destination language: $destinationLanguageName</p>" );
46 - }
47 - }
48 - }
49 -
50 - protected function showExpressionsNeedingTranslation( $sourceLanguageId, $destinationLanguageId ) {
51 -
52 - $o = OmegaWikiAttributes::getInstance();
53 -
54 - $dc = wdGetDataSetContext();
55 - $o = OmegaWikiAttributes::getInstance();
56 -
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 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 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" );
71 -
72 - $definitionAttribute = new Attribute( "definition", wfMsgSc( "Definition" ), "definition" );
73 - $recordSet = new ArrayRecordSet( new Structure( $o->definedMeaningId, $o->expressionId, $o->expression, $definitionAttribute ), new Structure( $o->definedMeaningId, $o->expressionId ) );
74 -
75 - while ( $row = $dbr->fetchObject( $queryResult ) ) {
76 - $expressionRecord = new ArrayRecord( $o->expressionStructure );
77 - $expressionRecord->language = $row->source_language_id;
78 - $expressionRecord->spelling = $row->source_spelling;
79 -
80 - $recordSet->addRecord( array( $row->source_defined_meaning_id, $row->source_expression_id, $expressionRecord, getDefinedMeaningDefinition( $row->source_defined_meaning_id ) ) );
81 - }
82 -
83 - $expressionEditor = new RecordTableCellEditor( $o->expression );
84 - $expressionEditor->addEditor( new LanguageEditor( $o->language, new SimplePermissionController( false ), false ) );
85 - $expressionEditor->addEditor( new SpellingEditor( $spellingAttribute, new SimplePermissionController( false ), false ) );
86 -
87 - $editor = new RecordSetTableEditor( null, new SimplePermissionController( false ), new AllowAddController( false ), false, false, null );
88 - $editor->addEditor( $expressionEditor );
89 - $editor->addEditor( new TextEditor( $definitionAttribute, new SimplePermissionController( false ), false, true, 75 ) );
90 -
91 - global
92 - $wgOut;
93 -
94 - $wgOut->addHTML( $editor->view( new IdStack( "expression" ), $recordSet ) );
95 - }
96 -}
97 -
98 -

Status & tagging log