r17821 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r17820‎ | r17821 | r17822 >
Date:10:11, 21 November 2006
Author:proes
Status:old
Tags:
Comment:
Several changes, mostly to allow for rolling back a definition later on:
* Added several shorthand functions to create viewers like createTableViewer(), createShortTextViewer() et cetera
* Introduced createSuggestionsTableViewer() to integrate the suggestions table more closely with the generic editor structure
* Introduced a static suggestion control that does not refresh its options from the server but contains a static table of options
* Solved bug on Special:Datasearch page
* Added control to allow the user to select a specific previous version of a definition
Modified paths:
  • /trunk/extensions/Wikidata/WiktionaryZ/Editor.php (modified) (history)
  • /trunk/extensions/Wikidata/WiktionaryZ/HTMLtable.php (modified) (history)
  • /trunk/extensions/Wikidata/WiktionaryZ/Search.php (modified) (history)
  • /trunk/extensions/Wikidata/WiktionaryZ/SpecialDatasearch.php (modified) (history)
  • /trunk/extensions/Wikidata/WiktionaryZ/SpecialSuggest.php (modified) (history)
  • /trunk/extensions/Wikidata/WiktionaryZ/SpecialTransaction.php (modified) (history)
  • /trunk/extensions/Wikidata/WiktionaryZ/WiktionaryZEditors.php (modified) (history)
  • /trunk/extensions/Wikidata/WiktionaryZ/forms.php (modified) (history)
  • /trunk/extensions/Wikidata/WiktionaryZ/suggest.js (modified) (history)
  • /trunk/extensions/Wikidata/WiktionaryZ/tmp/suggest.css (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/WiktionaryZ/SpecialDatasearch.php
@@ -69,7 +69,7 @@
7070 " ORDER BY position ASC, uw_expression_ns.spelling ASC limit 100";
7171
7272 $queryResult = $dbr->query($sql);
73 - list($relation, $editor) = getDefinedMeaningAsRelation($queryResult);
 73+ list($relation, $editor) = getSearchResultAsRecordSet($queryResult);
7474 return $editor->view(new IdStack("expression"), $relation);
7575 }
7676 }
Index: trunk/extensions/Wikidata/WiktionaryZ/Search.php
@@ -7,6 +7,7 @@
88 require_once("Expression.php");
99 require_once("WiktionaryZAttributes.php");
1010 require_once("WiktionaryZRecordSets.php");
 11+require_once("WiktionaryZEditors.php");
1112
1213 class Search extends DefaultWikidataApplication {
1314 function view() {
@@ -33,13 +34,13 @@
3435 " ORDER BY position ASC, uw_expression_ns.spelling ASC limit 100";
3536
3637 $queryResult = $dbr->query($sql);
37 - list($relation, $editor) = getDefinedMeaningAsRelation($queryResult);
 38+ list($recordSet, $editor) = getSearchResultAsRecordSet($queryResult);
3839 // return $sql;
39 - return $editor->view(new IdStack("expression"), $relation);
 40+ return $editor->view(new IdStack("expression"), $recordSet);
4041 }
4142 }
4243
43 -function getDefinedMeaningAsRelation($queryResult) {
 44+function getSearchResultAsRecordSet($queryResult) {
4445 global
4546 $idAttribute, $definedMeaningReferenceType;
4647
@@ -78,7 +79,7 @@
7980 $meaningEditor->addEditor(new DefinedMeaningReferenceEditor($definedMeaningAttribute, new SimplePermissionController(false), false));
8081 $meaningEditor->addEditor(new TextEditor($definitionAttribute, new SimplePermissionController(false), false, true, 75));
8182
82 - $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), new AllowAddController(false), false, false, null);
 83+ $editor = createTableViewer(null);
8384 $editor->addEditor($expressionEditor);
8485 $editor->addEditor($meaningEditor);
8586
Index: trunk/extensions/Wikidata/WiktionaryZ/suggest.js
@@ -71,6 +71,14 @@
7272 scheduleUpdateSuggestions(getSuggestPrefix(suggestText, "text"));
7373 }
7474
 75+function mouseOverRow(row) {
 76+ row.className = "suggestion-row active";
 77+}
 78+
 79+function mouseOutRow(row) {
 80+ row.className = "suggestion-row inactive";
 81+}
 82+
7583 function stopEventHandling(event) {
7684 event.cancelBubble = true;
7785
@@ -90,9 +98,12 @@
9199 var suggestDiv = document.getElementById(suggestPrefix + "div");
92100 var suggestField = document.getElementById(suggestPrefix + "text");
93101 suggestDiv.style.display = 'block';
94 - suggestField.focus();
95102
96 - updateSuggestions(suggestPrefix);
 103+ if (suggestField != null) {
 104+ suggestField.focus();
 105+ updateSuggestions(suggestPrefix);
 106+ }
 107+
97108 stopEventHandling(event);
98109 }
99110
@@ -123,6 +134,7 @@
124135
125136 function suggestRowClicked(event, suggestRow) {
126137 var suggestPrefix = getSuggestPrefix(suggestRow.parentNode.parentNode.parentNode.parentNode, "div");
 138+ var idColumnsField = document.getElementById(suggestPrefix + "id-columns");
127139 var displayLabelField = document.getElementById(suggestPrefix + "label-columns");
128140 var displayLabelColumnIndices = displayLabelField.value.split(", ");
129141 var labels = new Array();
@@ -134,18 +146,21 @@
135147 labels.push(columnValue);
136148 }
137149
138 - updateSuggestValue(suggestPrefix, suggestRow.id, labels.join(', '));
 150+ var idColumns = 1;
 151+
 152+ if (idColumnsField != null)
 153+ idColumns = idColumnsField.value;
 154+
 155+ var values = suggestRow.id.split('-');
 156+ var ids = new Array();
 157+
 158+ for (var i = idColumns - 1; i >= 0; i--)
 159+ ids.push(values[values.length - i - 1]);
 160+
 161+ updateSuggestValue(suggestPrefix, ids.join('-'), labels.join(', '));
139162 stopEventHandling(event);
140163 }
141164
142 -function mouseOverRow(row) {
143 - row.className = "suggestion-row active";
144 -}
145 -
146 -function mouseOutRow(row) {
147 - row.className = "suggestion-row inactive";
148 -}
149 -
150165 function enableChildNodes(node, enabled) {
151166 if (enabled)
152167 var disabled = "";
Index: trunk/extensions/Wikidata/WiktionaryZ/tmp/suggest.css
@@ -54,6 +54,10 @@
5555 white-space: nowrap;
5656 }
5757
 58+td .suggest-link, td .suggest-link:hover, td .suggest-link:active, td .suggest-link:visited {
 59+ white-space: normal;
 60+}
 61+
5862 .suggestion-row {
5963 padding: 0px;
6064 margin: 0px;
@@ -65,10 +69,6 @@
6670 cursor: pointer;
6771 }
6872
69 -/*.suggestion-row.inactive {
70 - background-color: #FFFFFF;
71 -}*/
72 -
7373 .suggestion-row td {
7474 padding-top: 0px;
7575 padding-bottom: 0px;
Index: trunk/extensions/Wikidata/WiktionaryZ/HTMLtable.php
@@ -149,29 +149,6 @@
150150 return $result;
151151 }
152152
153 -function getRelationAsSuggestionTable($editor, $idPath, $relation) {
154 - $result = '<table id="' . $idPath->getId() .'" class="wiki-data-table">';
155 - $structure = $editor->getStructure();
156 - $key = $relation->getKey();
157 -
158 - foreach(getStructureAsTableHeaderRows($structure, 0) as $headerRow)
159 - $result .= '<tr>' . $headerRow . '</tr>';
160 -
161 - $recordCount = $relation->getRecordCount();
162 -
163 - for($i = 0; $i < $recordCount; $i++) {
164 - $record = $relation->getRecord($i);
165 - $idPath->pushKey(project($record, $key));
166 - $id = getRecordKeyName($relation->getRecord($i), $key);
167 - $result .= '<tr id="'. $id .'" class="suggestion-row inactive" onclick="suggestRowClicked(event, this)" onmouseover="mouseOverRow(this)" onmouseout="mouseOutRow(this)">' . getRecordAsTableCells($idPath, $editor, $record) .'</tr>';
168 - $idPath->popKey();
169 - }
170 -
171 - $result .= '</table>';
172 -
173 - return $result;
174 -}
175 -
176153 function getStructureAsAddCells($idPath, $editor, &$startColumn = 0) {
177154 $result = '';
178155
Index: trunk/extensions/Wikidata/WiktionaryZ/SpecialSuggest.php
@@ -22,7 +22,9 @@
2323 require_once("Editor.php");
2424 require_once("HTMLtable.php");
2525 require_once("Expression.php");
26 - require_once("Transaction.php");
 26+ require_once("Transaction.php");
 27+ require_once("WiktionaryZEditors.php");
 28+
2729 echo getSuggestions();
2830 }
2931 }
@@ -135,7 +137,7 @@
136138 break;
137139 }
138140
139 - return getRelationAsSuggestionTable($editor, new IdStack($prefix .'table'), $recordSet);
 141+ return $editor->view(new IdStack($prefix . 'table'), $recordSet);
140142 }
141143
142144 function getSQLForCollectionOfType($collectionType) {
@@ -182,9 +184,9 @@
183185 while ($row = $dbr->fetchObject($queryResult))
184186 $recordSet->addRecord(array($row->member_mid, $row->spelling, definedMeaningExpression($row->collection_mid)));
185187
186 - $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), new ShowEditFieldChecker(true), new AllowAddController(false), false, false, null);
187 - $editor->addEditor(new ShortTextEditor($relationTypeAttribute, new SimplePermissionController(false), false));
188 - $editor->addEditor(new ShortTextEditor($collectionAttribute, new SimplePermissionController(false), false));
 188+ $editor = createSuggestionsTableViewer(null);
 189+ $editor->addEditor(createShortTextViewer($relationTypeAttribute));
 190+ $editor->addEditor(createShortTextViewer($collectionAttribute));
189191
190192 return array($recordSet, $editor);
191193 }
@@ -202,9 +204,9 @@
203205 while ($row = $dbr->fetchObject($queryResult))
204206 $recordSet->addRecord(array($row->member_mid, $row->spelling, definedMeaningExpression($row->collection_mid)));
205207
206 - $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), false, false, false, null);
207 - $editor->addEditor(new ShortTextEditor($classAttribute, new SimplePermissionController(false), false));
208 - $editor->addEditor(new ShortTextEditor($collectionAttribute, new SimplePermissionController(false), false));
 208+ $editor = createSuggestionsTableViewer(null);
 209+ $editor->addEditor(createShortTextViewer($classAttribute));
 210+ $editor->addEditor(createShortTextViewer($collectionAttribute));
209211
210212 return array($recordSet, $editor);
211213 }
@@ -220,9 +222,9 @@
221223 while ($row = $dbr->fetchObject($queryResult))
222224 $recordSet->addRecord(array($row->member_mid, $row->spelling, definedMeaningExpression($row->collection_mid)));
223225
224 - $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), new ShowEditFieldChecker(true), new AllowAddController(false), false, false, null);
225 - $editor->addEditor(new ShortTextEditor($textAttributeAttribute, new SimplePermissionController(false), false));
226 - $editor->addEditor(new ShortTextEditor($collectionAttribute, new SimplePermissionController(false), false));
 226+ $editor = createSuggestionsTableViewer(null);
 227+ $editor->addEditor(createShortTextViewer($textAttributeAttribute));
 228+ $editor->addEditor(createShortTextViewer($collectionAttribute));
227229
228230 return array($recordSet, $editor);
229231 }
@@ -240,9 +242,9 @@
241243 while ($row = $dbr->fetchObject($queryResult))
242244 $recordSet->addRecord(array($row->member_mid, $row->spelling, definedMeaningExpression($row->collection_mid)));
243245
244 - $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), new ShowEditFieldChecker(true), new AllowAddController(false), false, false, null);
245 - $editor->addEditor(new ShortTextEditor($translatedTextAttributeAttribute, new SimplePermissionController(false), false));
246 - $editor->addEditor(new ShortTextEditor($collectionAttribute, new SimplePermissionController(false), false));
 246+ $editor = createSuggestionsTableViewer(null);
 247+ $editor->addEditor(createShortTextViewer($translatedTextAttributeAttribute));
 248+ $editor->addEditor(createShortTextViewer($collectionAttribute));
247249
248250 return array($recordSet, $editor);
249251 }
@@ -270,10 +272,10 @@
271273 }
272274
273275 $expressionEditor = new RecordTableCellEditor($definedMeaningAttribute);
274 - $expressionEditor->addEditor(new ShortTextEditor($spellingAttribute, new SimplePermissionController(false), false));
275 - $expressionEditor->addEditor(new LanguageEditor($languageAttribute, new SimplePermissionController(false), false));
 276+ $expressionEditor->addEditor(createShortTextViewer($spellingAttribute));
 277+ $expressionEditor->addEditor(createLanguageViewer($languageAttribute));
276278
277 - $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), new ShowEditFieldChecker(true), new AllowAddController(false), false, false, null);
 279+ $editor = createSuggestionsTableViewer(null);
278280 $editor->addEditor($expressionEditor);
279281 $editor->addEditor(new TextEditor($definitionAttribute, new SimplePermissionController(false), false, true, 75));
280282
@@ -294,9 +296,9 @@
295297 while ($row = $dbr->fetchObject($queryResult))
296298 $recordSet->addRecord(array($row->member_mid, $row->spelling, definedMeaningExpression($row->collection_mid)));
297299
298 - $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), new ShowEditFieldChecker(true), new AllowAddController(false), false, false, null);
299 - $editor->addEditor(new ShortTextEditor($classAttributeLevelAttribute, new SimplePermissionController(false), false));
300 - $editor->addEditor(new ShortTextEditor($collectionAttribute, new SimplePermissionController(false), false));
 300+ $editor = createSuggestionsTableViewer(null);
 301+ $editor->addEditor(createShortTextViewer($classAttributeLevelAttribute));
 302+ $editor->addEditor(createShortTextViewer($collectionAttribute));
301303
302304 return array($recordSet, $editor);
303305 }
@@ -313,8 +315,8 @@
314316 while ($row = $dbr->fetchObject($queryResult))
315317 $recordSet->addRecord(array($row->collection_id, $row->spelling));
316318
317 - $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), new ShowEditFieldChecker(true), new AllowAddController(false), false, false, null);
318 - $editor->addEditor(new ShortTextEditor($collectionAttribute, new SimplePermissionController(false), false));
 319+ $editor = createSuggestionsTableViewer(null);
 320+ $editor->addEditor(createShortTextViewer($collectionAttribute));
319321
320322 return array($recordSet, $editor);
321323 }
@@ -331,8 +333,8 @@
332334 while ($row = $dbr->fetchObject($queryResult))
333335 $recordSet->addRecord(array($row->row_id, $row->language_name));
334336
335 - $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), new ShowEditFieldChecker(true), new AllowAddController(false), false, false, null);
336 - $editor->addEditor(new ShortTextEditor($languageAttribute, new SimplePermissionController(false), false));
 337+ $editor = createSuggestionsTableViewer(null);
 338+ $editor->addEditor(createShortTextViewer($languageAttribute));
337339
338340 return array($recordSet, $editor);
339341 }
@@ -351,11 +353,11 @@
352354 while ($row = $dbr->fetchObject($queryResult))
353355 $recordSet->addRecord(array($row->transaction_id, getUserLabel($row->user_id, $row->user_ip), $row->time, $row->comment));
354356
355 - $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), new ShowEditFieldChecker(true), new AllowAddController(false), false, false, null);
356 - $editor->addEditor(new ShortTextEditor($timestampAttribute, new SimplePermissionController(false), false));
357 - $editor->addEditor(new ShortTextEditor($idAttribute, new SimplePermissionController(false), false));
358 - $editor->addEditor(new ShortTextEditor($userAttribute, new SimplePermissionController(false), false));
359 - $editor->addEditor(new ShortTextEditor($summaryAttribute, new SimplePermissionController(false), false));
 357+ $editor = createSuggestionsTableViewer(null);
 358+ $editor->addEditor(createShortTextViewer($timestampAttribute));
 359+ $editor->addEditor(createShortTextViewer($idAttribute));
 360+ $editor->addEditor(createShortTextViewer($userAttribute));
 361+ $editor->addEditor(createShortTextViewer($summaryAttribute));
360362
361363 return array($recordSet, $editor);
362364 }
Index: trunk/extensions/Wikidata/WiktionaryZ/WiktionaryZEditors.php
@@ -40,17 +40,23 @@
4141 return $transactionEditor;
4242 }
4343
 44+function createTableLifeSpanEditor($attribute) {
 45+ global
 46+ $addTransactionAttribute, $removeTransactionAttribute;
 47+
 48+ $result = new RecordTableCellEditor($attribute);
 49+ $result->addEditor(getTransactionEditor($addTransactionAttribute));
 50+ $result->addEditor(getTransactionEditor($removeTransactionAttribute));
 51+
 52+ return $result;
 53+}
 54+
4455 function addTableLifeSpanEditor($editor, $showRecordLifeSpan) {
4556 global
4657 $recordLifeSpanAttribute, $addTransactionAttribute, $removeTransactionAttribute, $wgRequest;
4758
48 - if ($wgRequest->getText('action') == 'history' && $showRecordLifeSpan) {
49 - $lifeSpanEditor = new RecordTableCellEditor($recordLifeSpanAttribute);
50 - $lifeSpanEditor->addEditor(getTransactionEditor($addTransactionAttribute));
51 - $lifeSpanEditor->addEditor(getTransactionEditor($removeTransactionAttribute));
52 -
53 - $editor->addEditor($lifeSpanEditor);
54 - }
 59+ if ($wgRequest->getText('action') == 'history' && $showRecordLifeSpan)
 60+ $editor->addEditor(createTableLifeSpanEditor($recordLifeSpanAttribute));
5561 }
5662
5763 function getDefinitionEditor($attribute, $controller, $showRecordLifeSpan) {
@@ -299,7 +305,9 @@
300306 }
301307
302308 function createLongTextViewer($attribute) {
303 - return new TextEditor($attribute, new SimplePermissionController(false), false);
 309+ $result = new TextEditor($attribute, new SimplePermissionController(false), false);
 310+
 311+ return $result;
304312 }
305313
306314 function createShortTextViewer($attribute) {
@@ -314,4 +322,16 @@
315323 return new DefinedMeaningReferenceEditor($attribute, new SimplePermissionController(false), false);
316324 }
317325
 326+function createSuggestionsTableViewer($attribute) {
 327+ $result = createTableViewer($attribute);
 328+ $result->setRowHTMLAttributes(array(
 329+ "class" => "suggestion-row",
 330+ "onclick" => "suggestRowClicked(event, this)",
 331+ "onmouseover" => "mouseOverRow(this)",
 332+ "onmouseout" => "mouseOutRow(this)"
 333+ ));
 334+
 335+ return $result;
 336+}
 337+
318338 ?>
Index: trunk/extensions/Wikidata/WiktionaryZ/SpecialTransaction.php
@@ -34,6 +34,7 @@
3535 $recordSet = getTransactionRecordSet($fromTransactionId, $transactionCount, $userName);
3636 rollBackTransactions($recordSet);
3737 $fromTransactionId = 0;
 38+// print_r($_POST);
3839 }
3940
4041 if ($fromTransactionId == 0)
@@ -115,14 +116,32 @@
116117 $rollbackAttribute = new Attribute('roll-back', 'Roll back', 'boolean');
117118
118119 global
 120+ $translatedContentHistoryStructure, $translatedContentHistoryKeyStructure, $translatedContentHistoryAttribute, $recordLifeSpanAttribute,
 121+ $addTransactionIdAttribute;
 122+
 123+ $addTransactionIdAttribute = new Attribute('add-transaction-id', 'Add transaction ID', 'identifier');
 124+
 125+ $translatedContentHistoryStructure = new Structure($addTransactionIdAttribute, $textAttribute, $recordLifeSpanAttribute);
 126+ $translatedContentHistoryKeyStructure = new Structure($addTransactionIdAttribute);
 127+ $translatedContentHistoryAttribute = new Attribute('translated-content-history', 'History', new RecordSetType($translatedContentHistoryStructure));
 128+
 129+ global
 130+ $updatedTextStructure, $updatedTextAttribute;
 131+
 132+ $updatedTextStructure = new Structure($textAttribute, $translatedContentHistoryAttribute);
 133+ $updatedTextAttribute = new Attribute('updated-text', 'Text', new RecordType($updatedTextStructure));
 134+
 135+ global
119136 $updatedDefinitionStructure, $updatedDefinitionAttribute;
120137
121138 $updatedDefinitionStructure = new Structure(
 139+ $rollbackAttribute,
122140 $definedMeaningIdAttribute,
123141 $definedMeaningReferenceAttribute,
124142 $languageAttribute,
125 - $textAttribute,
126 - $operationAttribute
 143+ $updatedTextAttribute,
 144+ $operationAttribute,
 145+ $isLatestAttribute
127146 );
128147
129148 $updatedDefinitionAttribute = new Attribute('updated-definition', 'Definition', new RecordSetType($updatedDefinitionStructure));
@@ -251,7 +270,7 @@
252271 $captionEditor->addEditor(new TextEditor($summaryAttribute, new SimplePermissionController(false), false));
253272
254273 $valueEditor = new RecordUnorderedListEditor($updatesInTransactionAttribute, 5);
255 - $valueEditor->addEditor(getUpdatedDefinedMeaningDefinitionEditor($updatedDefinitionAttribute));
 274+ $valueEditor->addEditor(getUpdatedDefinedMeaningDefinitionEditor($updatedDefinitionAttribute, $showRollBackOptions));
256275 $valueEditor->addEditor(getUpdatedSyntransesEditor($updatedSyntransesAttribute));
257276 $valueEditor->addEditor(getUpdatedRelationsEditor($updatedRelationsAttribute, $showRollBackOptions));
258277 $valueEditor->addEditor(getUpdatedClassMembershipEditor($updatedClassMembershipAttribute, $showRollBackOptions));
@@ -292,14 +311,59 @@
293312 return $record;
294313 }
295314
 315+function getTranslatedContentHistory($translatedContentId, $languageId, $isLatest) {
 316+ global
 317+ $translatedContentHistoryStructure, $translatedContentHistoryKeyStructure,
 318+ $textAttribute, $addTransactionIdAttribute, $recordLifeSpanAttribute;
 319+
 320+ $recordSet = new ArrayRecordSet($translatedContentHistoryStructure, $translatedContentHistoryKeyStructure);
 321+
 322+ if ($isLatest) {
 323+ $dbr = &wfGetDB(DB_SLAVE);
 324+ $queryResult = $dbr->query(
 325+ "SELECT old_text, add_transaction_id, remove_transaction_id " .
 326+ " FROM translated_content, text" .
 327+ " WHERE translated_content.translated_content_id=$translatedContentId" .
 328+ " AND translated_content.language_id=$languageId " .
 329+ " AND translated_content.text_id=text.old_id " .
 330+ " ORDER BY add_transaction_id DESC"
 331+ );
 332+
 333+ while ($row = $dbr->fetchObject($queryResult)) {
 334+ $record = new ArrayRecord($translatedContentHistoryStructure);
 335+ $record->setAttributeValue($textAttribute, $row->old_text);
 336+ $record->setAttributeValue($addTransactionIdAttribute, (int) $row->add_transaction_id);
 337+ $record->setAttributeValue($recordLifeSpanAttribute, getRecordLifeSpanTuple((int) $row->add_transaction_id, (int) $row->remove_transaction_id));
 338+
 339+ $recordSet->add($record);
 340+ }
 341+ }
 342+
 343+ return $recordSet;
 344+}
 345+
 346+function getUpdatedTextRecord($text, $history) {
 347+ global
 348+ $updatedTextStructure, $textAttribute, $translatedContentHistoryAttribute;
 349+
 350+ $result = new ArrayRecord($updatedTextStructure);
 351+ $result->setAttributeValue($textAttribute, $text);
 352+ $result->setAttributeValue($translatedContentHistoryAttribute, $history);
 353+
 354+ return $result;
 355+}
 356+
296357 function getUpdatedDefinedMeaningDefinitionRecordSet($transactionId) {
297358 global
298 - $languageAttribute, $textAttribute, $definedMeaningIdAttribute,
299 - $definedMeaningReferenceAttribute, $updatedDefinitionStructure, $operationAttribute;
 359+ $languageAttribute, $updatedTextAttribute, $definedMeaningIdAttribute,
 360+ $definedMeaningReferenceAttribute, $updatedDefinitionStructure,
 361+ $operationAttribute, $isLatestAttribute, $rollbackAttribute;
300362
301363 $dbr = &wfGetDB(DB_SLAVE);
302364 $queryResult = $dbr->query(
303 - "SELECT defined_meaning_id, language_id, old_text, " . getOperationSelectColumn('translated_content', $transactionId) .
 365+ "SELECT defined_meaning_id, translated_content_id, language_id, old_text, " .
 366+ getOperationSelectColumn('translated_content', $transactionId) . ', ' .
 367+ getIsLatestSelectColumn('translated_content', array('translated_content_id', 'language_id'), $transactionId) .
304368 " FROM uw_defined_meaning, translated_content, text " .
305369 " WHERE uw_defined_meaning.meaning_text_tcid=translated_content.translated_content_id ".
306370 " AND translated_content.text_id=text.old_id " .
@@ -307,15 +371,17 @@
308372 " AND " . getAtTransactionRestriction('uw_defined_meaning', $transactionId)
309373 );
310374
311 - $recordSet = new ArrayRecordSet($updatedDefinitionStructure, new Structure($definedMeaningIdAttribute));
 375+ $recordSet = new ArrayRecordSet($updatedDefinitionStructure, new Structure($definedMeaningIdAttribute, $languageAttribute));
312376
313 - while ($definition = $dbr->fetchObject($queryResult)) {
 377+ while ($row = $dbr->fetchObject($queryResult)) {
314378 $record = new ArrayRecord($updatedDefinitionStructure);
315 - $record->setAttributeValue($definedMeaningIdAttribute, $definition->defined_meaning_id);
316 - $record->setAttributeValue($definedMeaningReferenceAttribute, getDefinedMeaningReferenceRecord($definition->defined_meaning_id));
317 - $record->setAttributeValue($languageAttribute, $definition->language_id);
318 - $record->setAttributeValue($textAttribute, $definition->old_text);
319 - $record->setAttributeValue($operationAttribute, $definition->operation);
 379+ $record->setAttributeValue($definedMeaningIdAttribute, $row->defined_meaning_id);
 380+ $record->setAttributeValue($definedMeaningReferenceAttribute, getDefinedMeaningReferenceRecord($row->defined_meaning_id));
 381+ $record->setAttributeValue($languageAttribute, $row->language_id);
 382+ $record->setAttributeValue($updatedTextAttribute, getUpdatedTextRecord($row->old_text, getTranslatedContentHistory($row->translated_content_id, $row->language_id, $row->is_latest)));
 383+ $record->setAttributeValue($operationAttribute, $row->operation);
 384+ $record->setAttributeValue($isLatestAttribute, $row->is_latest);
 385+ $record->setAttributeValue($rollbackAttribute, $row->is_latest);
320386
321387 $recordSet->add($record);
322388 }
@@ -358,13 +424,21 @@
359425 return $recordSet;
360426 }
361427
362 -function getIsLatestSelectColumn($table, $idField, $transactionId) {
 428+function getIsLatestSelectColumn($table, $idFields, $transactionId) {
 429+ $idSelectColumns = array();
 430+ $idRestrictions = array();
 431+
 432+ foreach ($idFields as $idField) {
 433+ $idSelectColumns[] = "latest_$table.$idField";
 434+ $idRestrictions[] = "$table.$idField=latest_$table.$idField";
 435+ }
 436+
363437 return
364 - "($table.add_transaction_id=$transactionId AND $table.remove_transaction_id IS NULL) OR (remove_transaction_id=$transactionId AND NOT EXISTS(" .
365 - "SELECT latest_$table.$idField " .
 438+ "($table.add_transaction_id=$transactionId AND $table.remove_transaction_id IS NULL) OR ($table.remove_transaction_id=$transactionId AND NOT EXISTS(" .
 439+ "SELECT " . implode(', ', $idSelectColumns) .
366440 " FROM $table AS latest_$table" .
367 - " WHERE $table.$idField=latest_$table.$idField" .
368 - " AND (latest_$table.add_transaction_id > $transactionId) " .
 441+ " WHERE " . implode(' AND ', $idRestrictions) .
 442+ " AND (latest_$table.add_transaction_id >= $transactionId) " .
369443 ")) AS is_latest ";
370444 }
371445
@@ -377,7 +451,7 @@
378452 $queryResult = $dbr->query(
379453 "SELECT relation_id, meaning1_mid, meaning2_mid, relationtype_mid, " .
380454 getOperationSelectColumn('uw_meaning_relations', $transactionId) . ', ' .
381 - getIsLatestSelectColumn('uw_meaning_relations', 'relation_id', $transactionId) .
 455+ getIsLatestSelectColumn('uw_meaning_relations', array('relation_id'), $transactionId) .
382456 " FROM uw_meaning_relations " .
383457 " WHERE " . getInTransactionRestriction('uw_meaning_relations', $transactionId)
384458 );
@@ -409,7 +483,7 @@
410484 $queryResult = $dbr->query(
411485 "SELECT class_membership_id, class_mid, class_member_mid, " .
412486 getOperationSelectColumn('uw_class_membership', $transactionId) . ', ' .
413 - getIsLatestSelectColumn('uw_class_membership', 'class_membership_id', $transactionId) .
 487+ getIsLatestSelectColumn('uw_class_membership', array('class_membership_id'), $transactionId) .
414488 " FROM uw_class_membership " .
415489 " WHERE " . getInTransactionRestriction('uw_class_membership', $transactionId)
416490 );
@@ -462,15 +536,45 @@
463537 return $recordSet;
464538 }
465539
466 -function getUpdatedDefinedMeaningDefinitionEditor($attribute) {
 540+function getTranslatedContentHistorySelector($attribute) {
467541 global
468 - $definedMeaningReferenceAttribute, $languageAttribute, $textAttribute, $operationAttribute;
 542+ $textAttribute, $recordLifeSpanAttribute;
469543
 544+ $result = createSuggestionsTableViewer($attribute);
 545+ $result->addEditor(createLongTextViewer($textAttribute));
 546+ $result->addEditor(createTableLifeSpanEditor($recordLifeSpanAttribute));
 547+
 548+ $result = new RecordSetRecordSelector($result);
 549+
 550+ return $result;
 551+}
 552+
 553+function createUpdatedTextViewer($attribute) {
 554+ global
 555+ $textAttribute, $translatedContentHistoryAttribute;
 556+
 557+ $result = new RecordDivListEditor($attribute);
 558+ $result->addEditor(createLongTextViewer($textAttribute));
 559+// $result->addEditor(getTranslatedContentHistorySelector($translatedContentHistoryAttribute));
 560+
 561+ return $result;
 562+}
 563+
 564+function getUpdatedDefinedMeaningDefinitionEditor($attribute, $showRollBackOptions) {
 565+ global
 566+ $definedMeaningReferenceAttribute, $languageAttribute, $updatedTextAttribute,
 567+ $operationAttribute, $isLatestAttribute, $rollbackAttribute, $translatedContentHistoryAttribute;
 568+
470569 $editor = createTableViewer($attribute);
 570+
 571+// if ($showRollBackOptions)
 572+// $editor->addEditor(new RollbackEditor($rollbackAttribute));
 573+
471574 $editor->addEditor(createDefinedMeaningReferenceViewer($definedMeaningReferenceAttribute));
472575 $editor->addEditor(createLanguageViewer($languageAttribute));
473 - $editor->addEditor(createLongTextViewer($textAttribute));
 576+ $editor->addEditor(createUpdatedTextViewer($updatedTextAttribute));
474577 $editor->addEditor(createShortTextViewer($operationAttribute));
 578+ $editor->addEditor(createBooleanViewer($isLatestAttribute));
475579
476580 return $editor;
477581 }
Index: trunk/extensions/Wikidata/WiktionaryZ/Editor.php
@@ -386,10 +386,26 @@
387387 }
388388
389389 class RecordSetTableEditor extends RecordSetEditor {
 390+ protected $rowHTMLAttributes = array();
 391+
 392+ protected function getRowAttributesText() {
 393+ $result = array();
 394+
 395+ foreach ($this->rowHTMLAttributes as $name => $value)
 396+ $result[] = $name . '="' . $value . '"';
 397+
 398+ return implode(' ', $result);
 399+ }
 400+
 401+ public function setRowHTMLAttributes($rowHTMLAttributes) {
 402+ $this->rowHTMLAttributes = $rowHTMLAttributes;
 403+ }
 404+
390405 public function view($idPath, $value) {
391406 $result = '<table id="'. $idPath->getId() .'" class="wiki-data-table">';
392407 $structure = $value->getStructure();
393408 $key = $value->getKey();
 409+ $rowAttributes = $this->getRowAttributesText();
394410
395411 foreach(getStructureAsTableHeaderRows($this->getTableStructure($this), 0) as $headerRow)
396412 $result .= '<tr>' . $headerRow . '</tr>';
@@ -399,7 +415,7 @@
400416 for($i = 0; $i < $recordCount; $i++) {
401417 $record = $value->getRecord($i);
402418 $idPath->pushKey(project($record, $key));
403 - $result .= '<tr id="'. $idPath->getId() .'">' . getRecordAsTableCells($idPath, $this, $record) .'</tr>';
 419+ $result .= '<tr id="'. $idPath->getId() .'" '. $rowAttributes . '>' . getRecordAsTableCells($idPath, $this, $record) .'</tr>';
404420 $idPath->popKey();
405421 }
406422
@@ -414,6 +430,7 @@
415431
416432 $result = '<table id="'. $idPath->getId() .'" class="wiki-data-table">';
417433 $key = $value->getKey();
 434+ $rowAttributes = $this->getRowAttributesText();
418435
419436 if ($this->allowRemove)
420437 $columnOffset = 1;
@@ -429,7 +446,7 @@
430447 $headerRows[0] .= '<th class="add" rowspan="' . count($headerRows) . '">Input rows</th>';
431448
432449 foreach ($headerRows as $headerRow)
433 - $result .= '<tr>' . $headerRow . '</tr>';
 450+ $result .= '<tr id="'. $idPath->getId() .'" '. $rowAttributes . '>' . $headerRow . '</tr>';
434451
435452 $recordCount = $value->getRecordCount();
436453
@@ -809,7 +826,7 @@
810827 }
811828
812829 public function getEditHTML($idPath, $value) {
813 - return getTextArea($this->updateId($idPath->getId()), $value, 3);
 830+ return getTextArea($this->updateId($idPath->getId()), $value, 3);
814831 }
815832
816833 public function add($idPath) {
@@ -1219,7 +1236,7 @@
12201237
12211238 protected function startToggleCode($attributeId) {
12221239 return
1223 - '<a id="popup-' . $attributeId . '-link" style="cursor: pointer; font-weight: bolder; font-size: 90%;" onclick="togglePopup(this, event);">'. $this->linkCaption .' &raquo;</a>' .
 1240+ '<a id="popup-' . $attributeId . '-link" style="cursor: pointer; font-weight: bolder; font-size: 90%; white-space: nowrap" onclick="togglePopup(this, event);">'. $this->linkCaption .' &raquo;</a>' .
12241241 '<div style="absolute"><div id="popup-' . $attributeId . '-toggleable" style="position: absolute; border: 1px solid #000000; display: none; background-color: white; padding: 4px;">';
12251242 }
12261243
@@ -1565,4 +1582,10 @@
15661583 }
15671584 }
15681585
 1586+class RecordSetRecordSelector extends WrappingEditor {
 1587+ public function view($idPath, $value) {
 1588+ return getStaticSuggest($idPath->getId(), $this->wrappedEditor->view($idPath, $value), count($value->getKey()->attributes));
 1589+ }
 1590+}
 1591+
15691592 ?>
Index: trunk/extensions/Wikidata/WiktionaryZ/forms.php
@@ -66,6 +66,34 @@
6767 return $result;
6868 }
6969
 70+function getStaticSuggest($name, $suggestions, $idColumns = 1, $value=0, $label='', $displayLabelColumns = array(0)) {
 71+ if ($label == "")
 72+ $label = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
 73+
 74+ $result =
 75+ '<span class="suggest">' .
 76+// '<input type="hidden" id="'. $name .'-suggest-query" value="'. $query .'"/>' .
 77+ '<input type="hidden" id="'. $name .'-suggest-label-columns" value="'. implode(', ', $displayLabelColumns) .'"/>' .
 78+ '<input type="hidden" id="'. $name .'" name="'. $name .'" value="'. $value .'"/>';
 79+
 80+ if ($idColumns > 1)
 81+ $result .= '<input type="hidden" id="'. $name .'-suggest-id-columns" value="' . $idColumns. '"/>';
 82+
 83+ $result .=
 84+ '<a id="'. $name .'-suggest-link" class="suggest-link" onclick="suggestLinkClicked(event, this);" title="Click to change selection">' . $label . '</a>' .
 85+ '</span>'.
 86+ '<div class="suggest-drop-down" style="position: relative"><div id="'. $name .'-suggest-div" style="position: absolute; left: 0px; top: 0px; border: 1px solid #000000; display: none; background-color: white; padding: 4px">' .
 87+ '<div><table><tr><td>' .
 88+// '<input type="text" id="'. $name .'-suggest-text" autocomplete="off" onkeyup="suggestTextChanged(this)" style="width: 300px"></input>' .
 89+ '</td><td><a id="'. $name .'-suggest-clear" href="#'. $name . '-suggest-link" onclick="suggestClearClicked(event, this)">Clear</a></td><td><a id="'. $name .'-suggest-close" href="#'. $name . '-suggest-link" onclick="suggestCloseClicked(event, this)">[X]</a></td></tr></table></div>' .
 90+ '<div>' . $suggestions .
 91+ //<table id="'. $name .'-suggest-table"><tr><td></td></tr></table>
 92+ '</div>'.
 93+ '</div></div>';
 94+
 95+ return $result;
 96+}
 97+
7098 function getLanguageOptions($languageIdsToExclude = array()) {
7199 global
72100 $wgUser;