Index: trunk/extensions/Wikidata/WiktionaryZ/SpecialDatasearch.php |
— | — | @@ -69,7 +69,7 @@ |
70 | 70 | " ORDER BY position ASC, uw_expression_ns.spelling ASC limit 100";
|
71 | 71 |
|
72 | 72 | $queryResult = $dbr->query($sql);
|
73 | | - list($relation, $editor) = getDefinedMeaningAsRelation($queryResult);
|
| 73 | + list($relation, $editor) = getSearchResultAsRecordSet($queryResult);
|
74 | 74 | return $editor->view(new IdStack("expression"), $relation);
|
75 | 75 | }
|
76 | 76 | }
|
Index: trunk/extensions/Wikidata/WiktionaryZ/Search.php |
— | — | @@ -7,6 +7,7 @@ |
8 | 8 | require_once("Expression.php"); |
9 | 9 | require_once("WiktionaryZAttributes.php"); |
10 | 10 | require_once("WiktionaryZRecordSets.php"); |
| 11 | +require_once("WiktionaryZEditors.php"); |
11 | 12 | |
12 | 13 | class Search extends DefaultWikidataApplication { |
13 | 14 | function view() { |
— | — | @@ -33,13 +34,13 @@ |
34 | 35 | " ORDER BY position ASC, uw_expression_ns.spelling ASC limit 100"; |
35 | 36 | |
36 | 37 | $queryResult = $dbr->query($sql); |
37 | | - list($relation, $editor) = getDefinedMeaningAsRelation($queryResult); |
| 38 | + list($recordSet, $editor) = getSearchResultAsRecordSet($queryResult); |
38 | 39 | // return $sql; |
39 | | - return $editor->view(new IdStack("expression"), $relation); |
| 40 | + return $editor->view(new IdStack("expression"), $recordSet); |
40 | 41 | } |
41 | 42 | } |
42 | 43 | |
43 | | -function getDefinedMeaningAsRelation($queryResult) { |
| 44 | +function getSearchResultAsRecordSet($queryResult) { |
44 | 45 | global |
45 | 46 | $idAttribute, $definedMeaningReferenceType; |
46 | 47 | |
— | — | @@ -78,7 +79,7 @@ |
79 | 80 | $meaningEditor->addEditor(new DefinedMeaningReferenceEditor($definedMeaningAttribute, new SimplePermissionController(false), false)); |
80 | 81 | $meaningEditor->addEditor(new TextEditor($definitionAttribute, new SimplePermissionController(false), false, true, 75)); |
81 | 82 | |
82 | | - $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), new AllowAddController(false), false, false, null); |
| 83 | + $editor = createTableViewer(null); |
83 | 84 | $editor->addEditor($expressionEditor); |
84 | 85 | $editor->addEditor($meaningEditor); |
85 | 86 | |
Index: trunk/extensions/Wikidata/WiktionaryZ/suggest.js |
— | — | @@ -71,6 +71,14 @@ |
72 | 72 | scheduleUpdateSuggestions(getSuggestPrefix(suggestText, "text")); |
73 | 73 | } |
74 | 74 | |
| 75 | +function mouseOverRow(row) { |
| 76 | + row.className = "suggestion-row active"; |
| 77 | +} |
| 78 | + |
| 79 | +function mouseOutRow(row) { |
| 80 | + row.className = "suggestion-row inactive"; |
| 81 | +} |
| 82 | + |
75 | 83 | function stopEventHandling(event) { |
76 | 84 | event.cancelBubble = true; |
77 | 85 | |
— | — | @@ -90,9 +98,12 @@ |
91 | 99 | var suggestDiv = document.getElementById(suggestPrefix + "div"); |
92 | 100 | var suggestField = document.getElementById(suggestPrefix + "text"); |
93 | 101 | suggestDiv.style.display = 'block'; |
94 | | - suggestField.focus(); |
95 | 102 | |
96 | | - updateSuggestions(suggestPrefix); |
| 103 | + if (suggestField != null) { |
| 104 | + suggestField.focus(); |
| 105 | + updateSuggestions(suggestPrefix); |
| 106 | + } |
| 107 | + |
97 | 108 | stopEventHandling(event); |
98 | 109 | } |
99 | 110 | |
— | — | @@ -123,6 +134,7 @@ |
124 | 135 | |
125 | 136 | function suggestRowClicked(event, suggestRow) { |
126 | 137 | var suggestPrefix = getSuggestPrefix(suggestRow.parentNode.parentNode.parentNode.parentNode, "div"); |
| 138 | + var idColumnsField = document.getElementById(suggestPrefix + "id-columns"); |
127 | 139 | var displayLabelField = document.getElementById(suggestPrefix + "label-columns"); |
128 | 140 | var displayLabelColumnIndices = displayLabelField.value.split(", "); |
129 | 141 | var labels = new Array(); |
— | — | @@ -134,18 +146,21 @@ |
135 | 147 | labels.push(columnValue); |
136 | 148 | } |
137 | 149 | |
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(', ')); |
139 | 162 | stopEventHandling(event); |
140 | 163 | } |
141 | 164 | |
142 | | -function mouseOverRow(row) { |
143 | | - row.className = "suggestion-row active"; |
144 | | -} |
145 | | - |
146 | | -function mouseOutRow(row) { |
147 | | - row.className = "suggestion-row inactive"; |
148 | | -} |
149 | | - |
150 | 165 | function enableChildNodes(node, enabled) { |
151 | 166 | if (enabled) |
152 | 167 | var disabled = ""; |
Index: trunk/extensions/Wikidata/WiktionaryZ/tmp/suggest.css |
— | — | @@ -54,6 +54,10 @@ |
55 | 55 | white-space: nowrap; |
56 | 56 | } |
57 | 57 | |
| 58 | +td .suggest-link, td .suggest-link:hover, td .suggest-link:active, td .suggest-link:visited { |
| 59 | + white-space: normal; |
| 60 | +} |
| 61 | + |
58 | 62 | .suggestion-row { |
59 | 63 | padding: 0px; |
60 | 64 | margin: 0px; |
— | — | @@ -65,10 +69,6 @@ |
66 | 70 | cursor: pointer; |
67 | 71 | } |
68 | 72 | |
69 | | -/*.suggestion-row.inactive { |
70 | | - background-color: #FFFFFF; |
71 | | -}*/ |
72 | | - |
73 | 73 | .suggestion-row td { |
74 | 74 | padding-top: 0px; |
75 | 75 | padding-bottom: 0px; |
Index: trunk/extensions/Wikidata/WiktionaryZ/HTMLtable.php |
— | — | @@ -149,29 +149,6 @@ |
150 | 150 | return $result; |
151 | 151 | } |
152 | 152 | |
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 | | - |
176 | 153 | function getStructureAsAddCells($idPath, $editor, &$startColumn = 0) { |
177 | 154 | $result = ''; |
178 | 155 | |
Index: trunk/extensions/Wikidata/WiktionaryZ/SpecialSuggest.php |
— | — | @@ -22,7 +22,9 @@ |
23 | 23 | require_once("Editor.php");
|
24 | 24 | require_once("HTMLtable.php");
|
25 | 25 | require_once("Expression.php");
|
26 | | - require_once("Transaction.php");
|
| 26 | + require_once("Transaction.php");
|
| 27 | + require_once("WiktionaryZEditors.php");
|
| 28 | +
|
27 | 29 | echo getSuggestions();
|
28 | 30 | }
|
29 | 31 | }
|
— | — | @@ -135,7 +137,7 @@ |
136 | 138 | break;
|
137 | 139 | }
|
138 | 140 |
|
139 | | - return getRelationAsSuggestionTable($editor, new IdStack($prefix .'table'), $recordSet);
|
| 141 | + return $editor->view(new IdStack($prefix . 'table'), $recordSet);
|
140 | 142 | }
|
141 | 143 |
|
142 | 144 | function getSQLForCollectionOfType($collectionType) {
|
— | — | @@ -182,9 +184,9 @@ |
183 | 185 | while ($row = $dbr->fetchObject($queryResult))
|
184 | 186 | $recordSet->addRecord(array($row->member_mid, $row->spelling, definedMeaningExpression($row->collection_mid)));
|
185 | 187 |
|
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));
|
189 | 191 |
|
190 | 192 | return array($recordSet, $editor);
|
191 | 193 | }
|
— | — | @@ -202,9 +204,9 @@ |
203 | 205 | while ($row = $dbr->fetchObject($queryResult))
|
204 | 206 | $recordSet->addRecord(array($row->member_mid, $row->spelling, definedMeaningExpression($row->collection_mid)));
|
205 | 207 |
|
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));
|
209 | 211 |
|
210 | 212 | return array($recordSet, $editor);
|
211 | 213 | }
|
— | — | @@ -220,9 +222,9 @@ |
221 | 223 | while ($row = $dbr->fetchObject($queryResult))
|
222 | 224 | $recordSet->addRecord(array($row->member_mid, $row->spelling, definedMeaningExpression($row->collection_mid)));
|
223 | 225 |
|
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));
|
227 | 229 |
|
228 | 230 | return array($recordSet, $editor);
|
229 | 231 | }
|
— | — | @@ -240,9 +242,9 @@ |
241 | 243 | while ($row = $dbr->fetchObject($queryResult))
|
242 | 244 | $recordSet->addRecord(array($row->member_mid, $row->spelling, definedMeaningExpression($row->collection_mid)));
|
243 | 245 |
|
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));
|
247 | 249 |
|
248 | 250 | return array($recordSet, $editor);
|
249 | 251 | }
|
— | — | @@ -270,10 +272,10 @@ |
271 | 273 | }
|
272 | 274 |
|
273 | 275 | $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));
|
276 | 278 |
|
277 | | - $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), new ShowEditFieldChecker(true), new AllowAddController(false), false, false, null);
|
| 279 | + $editor = createSuggestionsTableViewer(null);
|
278 | 280 | $editor->addEditor($expressionEditor);
|
279 | 281 | $editor->addEditor(new TextEditor($definitionAttribute, new SimplePermissionController(false), false, true, 75));
|
280 | 282 |
|
— | — | @@ -294,9 +296,9 @@ |
295 | 297 | while ($row = $dbr->fetchObject($queryResult))
|
296 | 298 | $recordSet->addRecord(array($row->member_mid, $row->spelling, definedMeaningExpression($row->collection_mid)));
|
297 | 299 |
|
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));
|
301 | 303 |
|
302 | 304 | return array($recordSet, $editor);
|
303 | 305 | }
|
— | — | @@ -313,8 +315,8 @@ |
314 | 316 | while ($row = $dbr->fetchObject($queryResult))
|
315 | 317 | $recordSet->addRecord(array($row->collection_id, $row->spelling));
|
316 | 318 |
|
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));
|
319 | 321 |
|
320 | 322 | return array($recordSet, $editor);
|
321 | 323 | }
|
— | — | @@ -331,8 +333,8 @@ |
332 | 334 | while ($row = $dbr->fetchObject($queryResult))
|
333 | 335 | $recordSet->addRecord(array($row->row_id, $row->language_name));
|
334 | 336 |
|
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));
|
337 | 339 |
|
338 | 340 | return array($recordSet, $editor);
|
339 | 341 | }
|
— | — | @@ -351,11 +353,11 @@ |
352 | 354 | while ($row = $dbr->fetchObject($queryResult))
|
353 | 355 | $recordSet->addRecord(array($row->transaction_id, getUserLabel($row->user_id, $row->user_ip), $row->time, $row->comment));
|
354 | 356 |
|
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));
|
360 | 362 |
|
361 | 363 | return array($recordSet, $editor);
|
362 | 364 | }
|
Index: trunk/extensions/Wikidata/WiktionaryZ/WiktionaryZEditors.php |
— | — | @@ -40,17 +40,23 @@ |
41 | 41 | return $transactionEditor; |
42 | 42 | } |
43 | 43 | |
| 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 | + |
44 | 55 | function addTableLifeSpanEditor($editor, $showRecordLifeSpan) { |
45 | 56 | global |
46 | 57 | $recordLifeSpanAttribute, $addTransactionAttribute, $removeTransactionAttribute, $wgRequest; |
47 | 58 | |
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)); |
55 | 61 | } |
56 | 62 | |
57 | 63 | function getDefinitionEditor($attribute, $controller, $showRecordLifeSpan) { |
— | — | @@ -299,7 +305,9 @@ |
300 | 306 | } |
301 | 307 | |
302 | 308 | 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; |
304 | 312 | } |
305 | 313 | |
306 | 314 | function createShortTextViewer($attribute) { |
— | — | @@ -314,4 +322,16 @@ |
315 | 323 | return new DefinedMeaningReferenceEditor($attribute, new SimplePermissionController(false), false); |
316 | 324 | } |
317 | 325 | |
| 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 | + |
318 | 338 | ?> |
Index: trunk/extensions/Wikidata/WiktionaryZ/SpecialTransaction.php |
— | — | @@ -34,6 +34,7 @@ |
35 | 35 | $recordSet = getTransactionRecordSet($fromTransactionId, $transactionCount, $userName);
|
36 | 36 | rollBackTransactions($recordSet);
|
37 | 37 | $fromTransactionId = 0;
|
| 38 | +// print_r($_POST);
|
38 | 39 | }
|
39 | 40 |
|
40 | 41 | if ($fromTransactionId == 0)
|
— | — | @@ -115,14 +116,32 @@ |
116 | 117 | $rollbackAttribute = new Attribute('roll-back', 'Roll back', 'boolean');
|
117 | 118 |
|
118 | 119 | 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
|
119 | 136 | $updatedDefinitionStructure, $updatedDefinitionAttribute;
|
120 | 137 |
|
121 | 138 | $updatedDefinitionStructure = new Structure(
|
| 139 | + $rollbackAttribute,
|
122 | 140 | $definedMeaningIdAttribute,
|
123 | 141 | $definedMeaningReferenceAttribute,
|
124 | 142 | $languageAttribute,
|
125 | | - $textAttribute,
|
126 | | - $operationAttribute
|
| 143 | + $updatedTextAttribute,
|
| 144 | + $operationAttribute,
|
| 145 | + $isLatestAttribute
|
127 | 146 | );
|
128 | 147 |
|
129 | 148 | $updatedDefinitionAttribute = new Attribute('updated-definition', 'Definition', new RecordSetType($updatedDefinitionStructure));
|
— | — | @@ -251,7 +270,7 @@ |
252 | 271 | $captionEditor->addEditor(new TextEditor($summaryAttribute, new SimplePermissionController(false), false));
|
253 | 272 |
|
254 | 273 | $valueEditor = new RecordUnorderedListEditor($updatesInTransactionAttribute, 5);
|
255 | | - $valueEditor->addEditor(getUpdatedDefinedMeaningDefinitionEditor($updatedDefinitionAttribute));
|
| 274 | + $valueEditor->addEditor(getUpdatedDefinedMeaningDefinitionEditor($updatedDefinitionAttribute, $showRollBackOptions));
|
256 | 275 | $valueEditor->addEditor(getUpdatedSyntransesEditor($updatedSyntransesAttribute));
|
257 | 276 | $valueEditor->addEditor(getUpdatedRelationsEditor($updatedRelationsAttribute, $showRollBackOptions));
|
258 | 277 | $valueEditor->addEditor(getUpdatedClassMembershipEditor($updatedClassMembershipAttribute, $showRollBackOptions));
|
— | — | @@ -292,14 +311,59 @@ |
293 | 312 | return $record;
|
294 | 313 | }
|
295 | 314 |
|
| 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 | +
|
296 | 357 | function getUpdatedDefinedMeaningDefinitionRecordSet($transactionId) {
|
297 | 358 | global
|
298 | | - $languageAttribute, $textAttribute, $definedMeaningIdAttribute,
|
299 | | - $definedMeaningReferenceAttribute, $updatedDefinitionStructure, $operationAttribute;
|
| 359 | + $languageAttribute, $updatedTextAttribute, $definedMeaningIdAttribute,
|
| 360 | + $definedMeaningReferenceAttribute, $updatedDefinitionStructure,
|
| 361 | + $operationAttribute, $isLatestAttribute, $rollbackAttribute;
|
300 | 362 |
|
301 | 363 | $dbr = &wfGetDB(DB_SLAVE);
|
302 | 364 | $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) .
|
304 | 368 | " FROM uw_defined_meaning, translated_content, text " .
|
305 | 369 | " WHERE uw_defined_meaning.meaning_text_tcid=translated_content.translated_content_id ".
|
306 | 370 | " AND translated_content.text_id=text.old_id " .
|
— | — | @@ -307,15 +371,17 @@ |
308 | 372 | " AND " . getAtTransactionRestriction('uw_defined_meaning', $transactionId)
|
309 | 373 | );
|
310 | 374 |
|
311 | | - $recordSet = new ArrayRecordSet($updatedDefinitionStructure, new Structure($definedMeaningIdAttribute));
|
| 375 | + $recordSet = new ArrayRecordSet($updatedDefinitionStructure, new Structure($definedMeaningIdAttribute, $languageAttribute));
|
312 | 376 |
|
313 | | - while ($definition = $dbr->fetchObject($queryResult)) {
|
| 377 | + while ($row = $dbr->fetchObject($queryResult)) {
|
314 | 378 | $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);
|
320 | 386 |
|
321 | 387 | $recordSet->add($record);
|
322 | 388 | }
|
— | — | @@ -358,13 +424,21 @@ |
359 | 425 | return $recordSet;
|
360 | 426 | }
|
361 | 427 |
|
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 | +
|
363 | 437 | 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) .
|
366 | 440 | " 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) " .
|
369 | 443 | ")) AS is_latest ";
|
370 | 444 | }
|
371 | 445 |
|
— | — | @@ -377,7 +451,7 @@ |
378 | 452 | $queryResult = $dbr->query(
|
379 | 453 | "SELECT relation_id, meaning1_mid, meaning2_mid, relationtype_mid, " .
|
380 | 454 | getOperationSelectColumn('uw_meaning_relations', $transactionId) . ', ' .
|
381 | | - getIsLatestSelectColumn('uw_meaning_relations', 'relation_id', $transactionId) .
|
| 455 | + getIsLatestSelectColumn('uw_meaning_relations', array('relation_id'), $transactionId) .
|
382 | 456 | " FROM uw_meaning_relations " .
|
383 | 457 | " WHERE " . getInTransactionRestriction('uw_meaning_relations', $transactionId)
|
384 | 458 | );
|
— | — | @@ -409,7 +483,7 @@ |
410 | 484 | $queryResult = $dbr->query(
|
411 | 485 | "SELECT class_membership_id, class_mid, class_member_mid, " .
|
412 | 486 | getOperationSelectColumn('uw_class_membership', $transactionId) . ', ' .
|
413 | | - getIsLatestSelectColumn('uw_class_membership', 'class_membership_id', $transactionId) .
|
| 487 | + getIsLatestSelectColumn('uw_class_membership', array('class_membership_id'), $transactionId) .
|
414 | 488 | " FROM uw_class_membership " .
|
415 | 489 | " WHERE " . getInTransactionRestriction('uw_class_membership', $transactionId)
|
416 | 490 | );
|
— | — | @@ -462,15 +536,45 @@ |
463 | 537 | return $recordSet;
|
464 | 538 | }
|
465 | 539 |
|
466 | | -function getUpdatedDefinedMeaningDefinitionEditor($attribute) {
|
| 540 | +function getTranslatedContentHistorySelector($attribute) {
|
467 | 541 | global
|
468 | | - $definedMeaningReferenceAttribute, $languageAttribute, $textAttribute, $operationAttribute;
|
| 542 | + $textAttribute, $recordLifeSpanAttribute;
|
469 | 543 |
|
| 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 | +
|
470 | 569 | $editor = createTableViewer($attribute);
|
| 570 | +
|
| 571 | +// if ($showRollBackOptions)
|
| 572 | +// $editor->addEditor(new RollbackEditor($rollbackAttribute));
|
| 573 | +
|
471 | 574 | $editor->addEditor(createDefinedMeaningReferenceViewer($definedMeaningReferenceAttribute));
|
472 | 575 | $editor->addEditor(createLanguageViewer($languageAttribute));
|
473 | | - $editor->addEditor(createLongTextViewer($textAttribute));
|
| 576 | + $editor->addEditor(createUpdatedTextViewer($updatedTextAttribute));
|
474 | 577 | $editor->addEditor(createShortTextViewer($operationAttribute));
|
| 578 | + $editor->addEditor(createBooleanViewer($isLatestAttribute));
|
475 | 579 |
|
476 | 580 | return $editor;
|
477 | 581 | }
|
Index: trunk/extensions/Wikidata/WiktionaryZ/Editor.php |
— | — | @@ -386,10 +386,26 @@ |
387 | 387 | } |
388 | 388 | |
389 | 389 | 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 | + |
390 | 405 | public function view($idPath, $value) { |
391 | 406 | $result = '<table id="'. $idPath->getId() .'" class="wiki-data-table">'; |
392 | 407 | $structure = $value->getStructure(); |
393 | 408 | $key = $value->getKey(); |
| 409 | + $rowAttributes = $this->getRowAttributesText(); |
394 | 410 | |
395 | 411 | foreach(getStructureAsTableHeaderRows($this->getTableStructure($this), 0) as $headerRow) |
396 | 412 | $result .= '<tr>' . $headerRow . '</tr>'; |
— | — | @@ -399,7 +415,7 @@ |
400 | 416 | for($i = 0; $i < $recordCount; $i++) { |
401 | 417 | $record = $value->getRecord($i); |
402 | 418 | $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>'; |
404 | 420 | $idPath->popKey(); |
405 | 421 | } |
406 | 422 | |
— | — | @@ -414,6 +430,7 @@ |
415 | 431 | |
416 | 432 | $result = '<table id="'. $idPath->getId() .'" class="wiki-data-table">'; |
417 | 433 | $key = $value->getKey(); |
| 434 | + $rowAttributes = $this->getRowAttributesText(); |
418 | 435 | |
419 | 436 | if ($this->allowRemove) |
420 | 437 | $columnOffset = 1; |
— | — | @@ -429,7 +446,7 @@ |
430 | 447 | $headerRows[0] .= '<th class="add" rowspan="' . count($headerRows) . '">Input rows</th>'; |
431 | 448 | |
432 | 449 | foreach ($headerRows as $headerRow) |
433 | | - $result .= '<tr>' . $headerRow . '</tr>'; |
| 450 | + $result .= '<tr id="'. $idPath->getId() .'" '. $rowAttributes . '>' . $headerRow . '</tr>'; |
434 | 451 | |
435 | 452 | $recordCount = $value->getRecordCount(); |
436 | 453 | |
— | — | @@ -809,7 +826,7 @@ |
810 | 827 | } |
811 | 828 | |
812 | 829 | public function getEditHTML($idPath, $value) { |
813 | | - return getTextArea($this->updateId($idPath->getId()), $value, 3); |
| 830 | + return getTextArea($this->updateId($idPath->getId()), $value, 3); |
814 | 831 | } |
815 | 832 | |
816 | 833 | public function add($idPath) { |
— | — | @@ -1219,7 +1236,7 @@ |
1220 | 1237 | |
1221 | 1238 | protected function startToggleCode($attributeId) { |
1222 | 1239 | return |
1223 | | - '<a id="popup-' . $attributeId . '-link" style="cursor: pointer; font-weight: bolder; font-size: 90%;" onclick="togglePopup(this, event);">'. $this->linkCaption .' »</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 .' »</a>' . |
1224 | 1241 | '<div style="absolute"><div id="popup-' . $attributeId . '-toggleable" style="position: absolute; border: 1px solid #000000; display: none; background-color: white; padding: 4px;">'; |
1225 | 1242 | } |
1226 | 1243 | |
— | — | @@ -1565,4 +1582,10 @@ |
1566 | 1583 | } |
1567 | 1584 | } |
1568 | 1585 | |
| 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 | + |
1569 | 1592 | ?> |
Index: trunk/extensions/Wikidata/WiktionaryZ/forms.php |
— | — | @@ -66,6 +66,34 @@ |
67 | 67 | return $result;
|
68 | 68 | }
|
69 | 69 |
|
| 70 | +function getStaticSuggest($name, $suggestions, $idColumns = 1, $value=0, $label='', $displayLabelColumns = array(0)) {
|
| 71 | + if ($label == "")
|
| 72 | + $label = ' ';
|
| 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 | +
|
70 | 98 | function getLanguageOptions($languageIdsToExclude = array()) {
|
71 | 99 | global
|
72 | 100 | $wgUser;
|