r17067 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r17066‎ | r17067 | r17068 >
Date:09:03, 17 October 2006
Author:proes
Status:old
Tags:
Comment:
Language drop down now shows language names in user preference language only using English as a fall back.
Modified paths:
  • /trunk/extensions/Wikidata/WiktionaryZ/SpecialSuggest.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/WiktionaryZ/SpecialSuggest.php
@@ -1,293 +1,311 @@
2 -<?php
3 -
4 -if (!defined('MEDIAWIKI')) die();
5 -
6 -$wgExtensionFunctions[] = 'wfSpecialSuggest';
7 -
8 -function wfSpecialSuggest() {
9 - class SpecialSuggest extends SpecialPage {
10 - function SpecialSuggest() {
11 - SpecialPage::SpecialPage('Suggest');
12 - }
13 -
14 - function execute( $par ) {
15 - global
16 - $wgOut, $IP;
17 -
18 - $wgOut->disable();
19 -
20 - require_once("$IP/includes/Setup.php");
21 - require_once("Attribute.php");
22 - require_once("RecordSet.php");
23 - require_once("Editor.php");
24 - require_once("HTMLtable.php");
25 - require_once("Expression.php");
26 - require_once("Transaction.php");
27 - echo getSuggestions();
28 - }
29 - }
30 -
31 - SpecialPage::addPage(new SpecialSuggest());
32 -}
33 -
34 -function getSuggestions() {
35 - global
36 - $idAttribute;
37 -
38 - $search = ltrim($_GET['search-text']);
39 - $prefix = $_GET['prefix'];
40 - $query = $_GET['query'];
41 -
42 - $dbr =& wfGetDB( DB_SLAVE );
43 - $rowText = 'spelling';
44 -
45 - switch ($query) {
46 - case 'relation-type':
47 - $sql = getSQLForCollectionOfType('RELT');
48 - break;
49 - case 'class':
50 - $sql = getSQLForCollectionOfType('CLAS');
51 - break;
52 - case 'text-attribute':
53 - $sql = getSQLForCollectionOfType('TATT');
54 - break;
55 - case 'language':
56 - $sql = "SELECT language_id AS row_id, language_name " .
57 - "FROM language_names " .
58 - "WHERE 1 ";
59 - $rowText = 'language_name';
60 - break;
61 - case 'defined-meaning':
62 - $sql = "SELECT syntrans.defined_meaning_id AS defined_meaning_id, expression.spelling AS spelling, expression.language_id AS language_id ".
63 - "FROM uw_expression_ns expression, uw_syntrans syntrans ".
64 - "WHERE expression.expression_id=syntrans.expression_id AND syntrans.identical_meaning=1 " .
65 - " AND " . getLatestTransactionRestriction('syntrans');
66 - break;
67 - case 'collection':
68 - $sql = "SELECT collection_id, spelling ".
69 - "FROM uw_expression_ns expression, uw_collection_ns collection, uw_syntrans syntrans ".
70 - "WHERE expression.expression_id=syntrans.expression_id AND syntrans.defined_meaning_id=collection.collection_mid ".
71 - "AND syntrans.identical_meaning=1" .
72 - " AND " . getLatestTransactionRestriction('syntrans') .
73 - " AND " . getLatestTransactionRestriction('collection');
74 - break;
75 - case 'transaction':
76 - $sql = "SELECT transaction_id, user_id, user_ip, " .
77 - " CONCAT(SUBSTRING(timestamp, 1, 4), '-', SUBSTRING(timestamp, 5, 2), '-', SUBSTRING(timestamp, 7, 2), ' '," .
78 - " SUBSTRING(timestamp, 9, 2), ':', SUBSTRING(timestamp, 11, 2), ':', SUBSTRING(timestamp, 13, 2)) AS time, comment" .
79 - " FROM transactions WHERE 1";
80 - $rowText = "CONCAT(SUBSTRING(timestamp, 1, 4), '-', SUBSTRING(timestamp, 5, 2), '-', SUBSTRING(timestamp, 7, 2), ' '," .
81 - " SUBSTRING(timestamp, 9, 2), ':', SUBSTRING(timestamp, 11, 2), ':', SUBSTRING(timestamp, 13, 2))";
82 - break;
83 - }
84 -
85 - if ($search != '') {
86 - if ($query == 'transaction')
87 - $searchCondition = " AND $rowText LIKE " . $dbr->addQuotes("%$search%");
88 - else
89 - $searchCondition = " AND $rowText LIKE " . $dbr->addQuotes("$search%");
90 - }
91 - else
92 - $searchCondition = "";
93 -
94 - if ($query == 'transaction')
95 - $orderBy = 'transaction_id DESC';
96 - else
97 - $orderBy = $rowText;
98 -
99 - $sql .= $searchCondition . " ORDER BY $orderBy LIMIT 10";
100 - $queryResult = $dbr->query($sql);
101 - $idAttribute = new Attribute("id", "ID", "id");
102 -
103 - switch($query) {
104 - case 'relation-type':
105 - list($recordSet, $editor) = getRelationTypeAsRecordSet($queryResult);
106 - break;
107 - case 'class':
108 - list($recordSet, $editor) = getClassAsRecordSet($queryResult);
109 - break;
110 - case 'text-attribute':
111 - list($recordSet, $editor) = getTextAttributeAsRecordSet($queryResult);
112 - break;
113 - case 'defined-meaning':
114 - list($recordSet, $editor) = getDefinedMeaningAsRecordSet($queryResult);
115 - break;
116 - case 'collection':
117 - list($recordSet, $editor) = getCollectionAsRecordSet($queryResult);
118 - break;
119 - case 'language':
120 - list($recordSet, $editor) = getLanguageAsRecordSet($queryResult);
121 - break;
122 - case 'transaction':
123 - list($recordSet, $editor) = getTransactionAsRecordSet($queryResult);
124 - break;
125 - }
126 -
127 - return getRelationAsSuggestionTable($editor, new IdStack($prefix .'table'), $recordSet);
128 -}
129 -
130 -function getSQLForCollectionOfType($collectionType) {
131 - return "SELECT member_mid, spelling, collection_mid " .
132 - "FROM uw_collection_contents, uw_collection_ns, uw_syntrans syntrans, uw_expression_ns expression " .
133 - "WHERE uw_collection_contents.collection_id=uw_collection_ns.collection_id and uw_collection_ns.collection_type='$collectionType' " .
134 -
135 - "AND syntrans.defined_meaning_id=uw_collection_contents.member_mid " .
136 - "AND expression.expression_id=syntrans.expression_id AND syntrans.identical_meaning=1 ".
137 - "AND " . getLatestTransactionRestriction('syntrans') .
138 - "AND " . getLatestTransactionRestriction('uw_collection_contents');
139 -}
140 -
141 -function getRelationTypeAsRecordSet($queryResult) {
142 - global
143 - $idAttribute;
144 -
145 - $dbr =& wfGetDB(DB_SLAVE);
146 -
147 - $relationTypeAttribute = new Attribute("relation-type", "Relation type", "short-text");
148 - $collectionAttribute = new Attribute("collection", "Collection", "short-text");
149 -
150 - $recordSet = new ArrayRecordSet(new Structure($idAttribute, $relationTypeAttribute, $collectionAttribute), new Structure($idAttribute));
151 -
152 - while ($row = $dbr->fetchObject($queryResult))
153 - $recordSet->addRecord(array($row->member_mid, $row->spelling, definedMeaningExpression($row->collection_mid)));
154 -
155 - $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), false, false, false, null);
156 - $editor->addEditor(new ShortTextEditor($relationTypeAttribute, new SimplePermissionController(false), false));
157 - $editor->addEditor(new ShortTextEditor($collectionAttribute, new SimplePermissionController(false), false));
158 -
159 - return array($recordSet, $editor);
160 -}
161 -
162 -function getClassAsRecordSet($queryResult) {
163 - global
164 - $idAttribute;
165 -
166 - $dbr =& wfGetDB(DB_SLAVE);
167 - $classAttribute = new Attribute("class", "Class", "short-text");
168 - $collectionAttribute = new Attribute("collection", "Collection", "short-text");
169 -
170 - $recordSet = new ArrayRecordSet(new Structure($idAttribute, $classAttribute, $collectionAttribute), new Structure($idAttribute));
171 -
172 - while ($row = $dbr->fetchObject($queryResult))
173 - $recordSet->addRecord(array($row->member_mid, $row->spelling, definedMeaningExpression($row->collection_mid)));
174 -
175 - $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), false, false, false, null);
176 - $editor->addEditor(new ShortTextEditor($classAttribute, new SimplePermissionController(false), false));
177 - $editor->addEditor(new ShortTextEditor($collectionAttribute, new SimplePermissionController(false), false));
178 -
179 - return array($recordSet, $editor);
180 -}
181 -
182 -function getTextAttributeAsRecordSet($queryResult) {
183 - global
184 - $idAttribute;
185 -
186 - $dbr =& wfGetDB(DB_SLAVE);
187 - $textAttributeAttribute = new Attribute("text-attribute", "Text attribute", "short-text");
188 - $collectionAttribute = new Attribute("collection", "Collection", "short-text");
189 -
190 - $recordSet = new ArrayRecordSet(new Structure($idAttribute, $textAttributeAttribute, $collectionAttribute), new Structure($idAttribute));
191 -
192 - while ($row = $dbr->fetchObject($queryResult))
193 - $recordSet->addRecord(array($row->member_mid, $row->spelling, definedMeaningExpression($row->collection_mid)));
194 -
195 - $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), false, false, false, null);
196 - $editor->addEditor(new ShortTextEditor($textAttributeAttribute, new SimplePermissionController(false), false));
197 - $editor->addEditor(new ShortTextEditor($collectionAttribute, new SimplePermissionController(false), false));
198 -
199 - return array($recordSet, $editor);
200 -}
201 -
202 -function getDefinedMeaningAsRecordSet($queryResult) {
203 - global
204 - $idAttribute;
205 -
206 - $dbr =& wfGetDB(DB_SLAVE);
207 - $spellingAttribute = new Attribute("spelling", "Spelling", "short-text");
208 - $languageAttribute = new Attribute("language", "Language", "language");
209 -
210 - $expressionStructure = new Structure($spellingAttribute, $languageAttribute);
211 - $definedMeaningAttribute = new Attribute("defined-meaning", "Defined meaning", new RecordType($expressionStructure));
212 - $definitionAttribute = new Attribute("definition", "Definition", "definition");
213 -
214 - $recordSet = new ArrayRecordSet(new Structure($idAttribute, $definedMeaningAttribute, $definitionAttribute), new Structure($idAttribute));
215 -
216 - while ($row = $dbr->fetchObject($queryResult)) {
217 - $definedMeaningRecord = new ArrayRecord($expressionStructure);
218 - $definedMeaningRecord->setAttributeValue($spellingAttribute, $row->spelling);
219 - $definedMeaningRecord->setAttributeValue($languageAttribute, $row->language_id);
220 -
221 - $recordSet->addRecord(array($row->defined_meaning_id, $definedMeaningRecord, getDefinedMeaningDefinition($row->defined_meaning_id)));
222 - }
223 -
224 - $expressionEditor = new RecordTableCellEditor($definedMeaningAttribute);
225 - $expressionEditor->addEditor(new ShortTextEditor($spellingAttribute, new SimplePermissionController(false), false));
226 - $expressionEditor->addEditor(new LanguageEditor($languageAttribute, new SimplePermissionController(false), false));
227 -
228 - $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), false, false, false, null);
229 - $editor->addEditor($expressionEditor);
230 - $editor->addEditor(new TextEditor($definitionAttribute, new SimplePermissionController(false), false, true, 75));
231 -
232 - return array($recordSet, $editor);
233 -}
234 -
235 -function getCollectionAsRecordSet($queryResult) {
236 - global
237 - $idAttribute;
238 -
239 - $dbr =& wfGetDB(DB_SLAVE);
240 - $collectionAttribute = new Attribute("collection", "Collection", "short-text");
241 -
242 - $recordSet = new ArrayRecordSet(new Structure($idAttribute, $collectionAttribute), new Structure($idAttribute));
243 -
244 - while ($row = $dbr->fetchObject($queryResult))
245 - $recordSet->addRecord(array($row->collection_id, $row->spelling));
246 -
247 - $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), false, false, false, null);
248 - $editor->addEditor(new ShortTextEditor($collectionAttribute, new SimplePermissionController(false), false));
249 -
250 - return array($recordSet, $editor);
251 -}
252 -
253 -function getLanguageAsRecordSet($queryResult) {
254 - global
255 - $idAttribute;
256 -
257 - $dbr =& wfGetDB(DB_SLAVE);
258 - $languageAttribute = new Attribute("language", "Language", "short-text");
259 -
260 - $recordSet = new ArrayRecordSet(new Structure($idAttribute, $languageAttribute), new Structure($idAttribute));
261 -
262 - while ($row = $dbr->fetchObject($queryResult))
263 - $recordSet->addRecord(array($row->row_id, $row->language_name));
264 -
265 - $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), false, false, false, null);
266 - $editor->addEditor(new ShortTextEditor($languageAttribute, new SimplePermissionController(false), false));
267 -
268 - return array($recordSet, $editor);
269 -}
270 -
271 -function getTransactionAsRecordSet($queryResult) {
272 - global
273 - $idAttribute, $userAttribute;
274 -
275 - $dbr =& wfGetDB(DB_SLAVE);
276 -
277 - $timestampAttribute = new Attribute("timestamp", "Time", "timestamp");
278 - $summaryAttribute = new Attribute("summary", "Summary", "short-text");
279 -
280 - $recordSet = new ArrayRecordSet(new Structure($idAttribute, $userAttribute, $timestampAttribute, $summaryAttribute), new Structure($idAttribute));
281 -
282 - while ($row = $dbr->fetchObject($queryResult))
283 - $recordSet->addRecord(array($row->transaction_id, getUserLabel($row->user_id, $row->user_ip), $row->time, $row->comment));
284 -
285 - $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), false, false, false, null);
286 - $editor->addEditor(new ShortTextEditor($timestampAttribute, new SimplePermissionController(false), false));
287 - $editor->addEditor(new ShortTextEditor($idAttribute, new SimplePermissionController(false), false));
288 - $editor->addEditor(new ShortTextEditor($userAttribute, new SimplePermissionController(false), false));
289 - $editor->addEditor(new ShortTextEditor($summaryAttribute, new SimplePermissionController(false), false));
290 -
291 - return array($recordSet, $editor);
292 -}
293 -
 2+<?php
 3+
 4+if (!defined('MEDIAWIKI')) die();
 5+
 6+$wgExtensionFunctions[] = 'wfSpecialSuggest';
 7+
 8+function wfSpecialSuggest() {
 9+ class SpecialSuggest extends SpecialPage {
 10+ function SpecialSuggest() {
 11+ SpecialPage::SpecialPage('Suggest');
 12+ }
 13+
 14+ function execute( $par ) {
 15+ global
 16+ $wgOut, $IP;
 17+
 18+ $wgOut->disable();
 19+
 20+ require_once("$IP/includes/Setup.php");
 21+ require_once("Attribute.php");
 22+ require_once("RecordSet.php");
 23+ require_once("Editor.php");
 24+ require_once("HTMLtable.php");
 25+ require_once("Expression.php");
 26+ require_once("Transaction.php");
 27+ echo getSuggestions();
 28+ }
 29+ }
 30+
 31+ SpecialPage::addPage(new SpecialSuggest());
 32+}
 33+
 34+function getSuggestions() {
 35+ global
 36+ $idAttribute;
 37+
 38+ $search = ltrim($_GET['search-text']);
 39+ $prefix = $_GET['prefix'];
 40+ $query = $_GET['query'];
 41+
 42+ $dbr =& wfGetDB( DB_SLAVE );
 43+ $rowText = 'spelling';
 44+
 45+ switch ($query) {
 46+ case 'relation-type':
 47+ $sql = getSQLForCollectionOfType('RELT');
 48+ break;
 49+ case 'class':
 50+ $sql = getSQLForCollectionOfType('CLAS');
 51+ break;
 52+ case 'text-attribute':
 53+ $sql = getSQLForCollectionOfType('TATT');
 54+ break;
 55+ case 'language':
 56+ $sql = getSQLForLanguage();
 57+ $rowText = 'language_name';
 58+ break;
 59+ case 'defined-meaning':
 60+ $sql = "SELECT syntrans.defined_meaning_id AS defined_meaning_id, expression.spelling AS spelling, expression.language_id AS language_id ".
 61+ "FROM uw_expression_ns expression, uw_syntrans syntrans ".
 62+ "WHERE expression.expression_id=syntrans.expression_id AND syntrans.identical_meaning=1 " .
 63+ " AND " . getLatestTransactionRestriction('syntrans');
 64+ break;
 65+ case 'collection':
 66+ $sql = "SELECT collection_id, spelling ".
 67+ "FROM uw_expression_ns expression, uw_collection_ns collection, uw_syntrans syntrans ".
 68+ "WHERE expression.expression_id=syntrans.expression_id AND syntrans.defined_meaning_id=collection.collection_mid ".
 69+ "AND syntrans.identical_meaning=1" .
 70+ " AND " . getLatestTransactionRestriction('syntrans') .
 71+ " AND " . getLatestTransactionRestriction('collection');
 72+ break;
 73+ case 'transaction':
 74+ $sql = "SELECT transaction_id, user_id, user_ip, " .
 75+ " CONCAT(SUBSTRING(timestamp, 1, 4), '-', SUBSTRING(timestamp, 5, 2), '-', SUBSTRING(timestamp, 7, 2), ' '," .
 76+ " SUBSTRING(timestamp, 9, 2), ':', SUBSTRING(timestamp, 11, 2), ':', SUBSTRING(timestamp, 13, 2)) AS time, comment" .
 77+ " FROM transactions WHERE 1";
 78+ $rowText = "CONCAT(SUBSTRING(timestamp, 1, 4), '-', SUBSTRING(timestamp, 5, 2), '-', SUBSTRING(timestamp, 7, 2), ' '," .
 79+ " SUBSTRING(timestamp, 9, 2), ':', SUBSTRING(timestamp, 11, 2), ':', SUBSTRING(timestamp, 13, 2))";
 80+ break;
 81+ }
 82+
 83+ if ($search != '') {
 84+ if ($query == 'transaction')
 85+ $searchCondition = " AND $rowText LIKE " . $dbr->addQuotes("%$search%");
 86+ else if ($query == 'language')
 87+ $searchCondition = " HAVING $rowText LIKE " . $dbr->addQuotes("$search%");
 88+ else
 89+ $searchCondition = " AND $rowText LIKE " . $dbr->addQuotes("$search%");
 90+ }
 91+ else
 92+ $searchCondition = "";
 93+
 94+ if ($query == 'transaction')
 95+ $orderBy = 'transaction_id DESC';
 96+ else
 97+ $orderBy = $rowText;
 98+
 99+ $sql .= $searchCondition . " ORDER BY $orderBy LIMIT 10";
 100+ $queryResult = $dbr->query($sql);
 101+ $idAttribute = new Attribute("id", "ID", "id");
 102+
 103+ switch($query) {
 104+ case 'relation-type':
 105+ list($recordSet, $editor) = getRelationTypeAsRecordSet($queryResult);
 106+ break;
 107+ case 'class':
 108+ list($recordSet, $editor) = getClassAsRecordSet($queryResult);
 109+ break;
 110+ case 'text-attribute':
 111+ list($recordSet, $editor) = getTextAttributeAsRecordSet($queryResult);
 112+ break;
 113+ case 'defined-meaning':
 114+ list($recordSet, $editor) = getDefinedMeaningAsRecordSet($queryResult);
 115+ break;
 116+ case 'collection':
 117+ list($recordSet, $editor) = getCollectionAsRecordSet($queryResult);
 118+ break;
 119+ case 'language':
 120+ list($recordSet, $editor) = getLanguageAsRecordSet($queryResult);
 121+ break;
 122+ case 'transaction':
 123+ list($recordSet, $editor) = getTransactionAsRecordSet($queryResult);
 124+ break;
 125+ }
 126+
 127+ return getRelationAsSuggestionTable($editor, new IdStack($prefix .'table'), $recordSet);
 128+}
 129+
 130+function getSQLForCollectionOfType($collectionType) {
 131+ return "SELECT member_mid, spelling, collection_mid " .
 132+ "FROM uw_collection_contents, uw_collection_ns, uw_syntrans syntrans, uw_expression_ns expression " .
 133+ "WHERE uw_collection_contents.collection_id=uw_collection_ns.collection_id and uw_collection_ns.collection_type='$collectionType' " .
 134+
 135+ "AND syntrans.defined_meaning_id=uw_collection_contents.member_mid " .
 136+ "AND expression.expression_id=syntrans.expression_id AND syntrans.identical_meaning=1 ".
 137+ "AND " . getLatestTransactionRestriction('syntrans') .
 138+ "AND " . getLatestTransactionRestriction('uw_collection_contents');
 139+}
 140+
 141+function getSQLForLanguage() {
 142+ global
 143+ $wgUser;
 144+
 145+ $userLanguage = $wgUser->getOption('language');
 146+
 147+ if ($userLanguage == 'en')
 148+ return "SELECT language.language_id AS row_id,language_names.language_name " .
 149+ "FROM language " .
 150+ "JOIN language_names ON language.language_id = language_names.language_id " .
 151+ "WHERE language_names.name_language_id = " . getLanguageIdForCode('en');
 152+ else
 153+ return "SELECT language.language_id AS row_id,COALESCE(ln1.language_name,ln2.language_name) AS language_name " .
 154+ "FROM language " .
 155+ "LEFT JOIN language_names AS ln1 ON language.language_id = ln1.language_id AND ln1.name_language_id = " . getLanguageIdForCode($userLanguage) . " " .
 156+ "JOIN language_names AS ln2 ON language.language_id = ln2.language_id AND ln2.name_language_id = " . getLanguageIdForCode('en');
 157+}
 158+
 159+function getRelationTypeAsRecordSet($queryResult) {
 160+ global
 161+ $idAttribute;
 162+
 163+ $dbr =& wfGetDB(DB_SLAVE);
 164+
 165+ $relationTypeAttribute = new Attribute("relation-type", "Relation type", "short-text");
 166+ $collectionAttribute = new Attribute("collection", "Collection", "short-text");
 167+
 168+ $recordSet = new ArrayRecordSet(new Structure($idAttribute, $relationTypeAttribute, $collectionAttribute), new Structure($idAttribute));
 169+
 170+ while ($row = $dbr->fetchObject($queryResult))
 171+ $recordSet->addRecord(array($row->member_mid, $row->spelling, definedMeaningExpression($row->collection_mid)));
 172+
 173+ $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), false, false, false, null);
 174+ $editor->addEditor(new ShortTextEditor($relationTypeAttribute, new SimplePermissionController(false), false));
 175+ $editor->addEditor(new ShortTextEditor($collectionAttribute, new SimplePermissionController(false), false));
 176+
 177+ return array($recordSet, $editor);
 178+}
 179+
 180+function getClassAsRecordSet($queryResult) {
 181+ global
 182+ $idAttribute;
 183+
 184+ $dbr =& wfGetDB(DB_SLAVE);
 185+ $classAttribute = new Attribute("class", "Class", "short-text");
 186+ $collectionAttribute = new Attribute("collection", "Collection", "short-text");
 187+
 188+ $recordSet = new ArrayRecordSet(new Structure($idAttribute, $classAttribute, $collectionAttribute), new Structure($idAttribute));
 189+
 190+ while ($row = $dbr->fetchObject($queryResult))
 191+ $recordSet->addRecord(array($row->member_mid, $row->spelling, definedMeaningExpression($row->collection_mid)));
 192+
 193+ $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), false, false, false, null);
 194+ $editor->addEditor(new ShortTextEditor($classAttribute, new SimplePermissionController(false), false));
 195+ $editor->addEditor(new ShortTextEditor($collectionAttribute, new SimplePermissionController(false), false));
 196+
 197+ return array($recordSet, $editor);
 198+}
 199+
 200+function getTextAttributeAsRecordSet($queryResult) {
 201+ global
 202+ $idAttribute;
 203+
 204+ $dbr =& wfGetDB(DB_SLAVE);
 205+ $textAttributeAttribute = new Attribute("text-attribute", "Text attribute", "short-text");
 206+ $collectionAttribute = new Attribute("collection", "Collection", "short-text");
 207+
 208+ $recordSet = new ArrayRecordSet(new Structure($idAttribute, $textAttributeAttribute, $collectionAttribute), new Structure($idAttribute));
 209+
 210+ while ($row = $dbr->fetchObject($queryResult))
 211+ $recordSet->addRecord(array($row->member_mid, $row->spelling, definedMeaningExpression($row->collection_mid)));
 212+
 213+ $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), false, false, false, null);
 214+ $editor->addEditor(new ShortTextEditor($textAttributeAttribute, new SimplePermissionController(false), false));
 215+ $editor->addEditor(new ShortTextEditor($collectionAttribute, new SimplePermissionController(false), false));
 216+
 217+ return array($recordSet, $editor);
 218+}
 219+
 220+function getDefinedMeaningAsRecordSet($queryResult) {
 221+ global
 222+ $idAttribute;
 223+
 224+ $dbr =& wfGetDB(DB_SLAVE);
 225+ $spellingAttribute = new Attribute("spelling", "Spelling", "short-text");
 226+ $languageAttribute = new Attribute("language", "Language", "language");
 227+
 228+ $expressionStructure = new Structure($spellingAttribute, $languageAttribute);
 229+ $definedMeaningAttribute = new Attribute("defined-meaning", "Defined meaning", new RecordType($expressionStructure));
 230+ $definitionAttribute = new Attribute("definition", "Definition", "definition");
 231+
 232+ $recordSet = new ArrayRecordSet(new Structure($idAttribute, $definedMeaningAttribute, $definitionAttribute), new Structure($idAttribute));
 233+
 234+ while ($row = $dbr->fetchObject($queryResult)) {
 235+ $definedMeaningRecord = new ArrayRecord($expressionStructure);
 236+ $definedMeaningRecord->setAttributeValue($spellingAttribute, $row->spelling);
 237+ $definedMeaningRecord->setAttributeValue($languageAttribute, $row->language_id);
 238+
 239+ $recordSet->addRecord(array($row->defined_meaning_id, $definedMeaningRecord, getDefinedMeaningDefinition($row->defined_meaning_id)));
 240+ }
 241+
 242+ $expressionEditor = new RecordTableCellEditor($definedMeaningAttribute);
 243+ $expressionEditor->addEditor(new ShortTextEditor($spellingAttribute, new SimplePermissionController(false), false));
 244+ $expressionEditor->addEditor(new LanguageEditor($languageAttribute, new SimplePermissionController(false), false));
 245+
 246+ $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), false, false, false, null);
 247+ $editor->addEditor($expressionEditor);
 248+ $editor->addEditor(new TextEditor($definitionAttribute, new SimplePermissionController(false), false, true, 75));
 249+
 250+ return array($recordSet, $editor);
 251+}
 252+
 253+function getCollectionAsRecordSet($queryResult) {
 254+ global
 255+ $idAttribute;
 256+
 257+ $dbr =& wfGetDB(DB_SLAVE);
 258+ $collectionAttribute = new Attribute("collection", "Collection", "short-text");
 259+
 260+ $recordSet = new ArrayRecordSet(new Structure($idAttribute, $collectionAttribute), new Structure($idAttribute));
 261+
 262+ while ($row = $dbr->fetchObject($queryResult))
 263+ $recordSet->addRecord(array($row->collection_id, $row->spelling));
 264+
 265+ $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), false, false, false, null);
 266+ $editor->addEditor(new ShortTextEditor($collectionAttribute, new SimplePermissionController(false), false));
 267+
 268+ return array($recordSet, $editor);
 269+}
 270+
 271+function getLanguageAsRecordSet($queryResult) {
 272+ global
 273+ $idAttribute;
 274+
 275+ $dbr =& wfGetDB(DB_SLAVE);
 276+ $languageAttribute = new Attribute("language", "Language", "short-text");
 277+
 278+ $recordSet = new ArrayRecordSet(new Structure($idAttribute, $languageAttribute), new Structure($idAttribute));
 279+
 280+ while ($row = $dbr->fetchObject($queryResult))
 281+ $recordSet->addRecord(array($row->row_id, $row->language_name));
 282+
 283+ $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), false, false, false, null);
 284+ $editor->addEditor(new ShortTextEditor($languageAttribute, new SimplePermissionController(false), false));
 285+
 286+ return array($recordSet, $editor);
 287+}
 288+
 289+function getTransactionAsRecordSet($queryResult) {
 290+ global
 291+ $idAttribute, $userAttribute;
 292+
 293+ $dbr =& wfGetDB(DB_SLAVE);
 294+
 295+ $timestampAttribute = new Attribute("timestamp", "Time", "timestamp");
 296+ $summaryAttribute = new Attribute("summary", "Summary", "short-text");
 297+
 298+ $recordSet = new ArrayRecordSet(new Structure($idAttribute, $userAttribute, $timestampAttribute, $summaryAttribute), new Structure($idAttribute));
 299+
 300+ while ($row = $dbr->fetchObject($queryResult))
 301+ $recordSet->addRecord(array($row->transaction_id, getUserLabel($row->user_id, $row->user_ip), $row->time, $row->comment));
 302+
 303+ $editor = new RecordSetTableEditor(null, new SimplePermissionController(false), false, false, false, null);
 304+ $editor->addEditor(new ShortTextEditor($timestampAttribute, new SimplePermissionController(false), false));
 305+ $editor->addEditor(new ShortTextEditor($idAttribute, new SimplePermissionController(false), false));
 306+ $editor->addEditor(new ShortTextEditor($userAttribute, new SimplePermissionController(false), false));
 307+ $editor->addEditor(new ShortTextEditor($summaryAttribute, new SimplePermissionController(false), false));
 308+
 309+ return array($recordSet, $editor);
 310+}
 311+
294312 ?>
\ No newline at end of file