r17520 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r17519‎ | r17520 | r17521 >
Date:11:09, 10 November 2006
Author:proes
Status:old
Tags:
Comment:
Added filter options to Special:Transaction. User now can provide a transaction to start from, the number of transactions to show, and the user name to filter on.
Modified paths:
  • /trunk/extensions/Wikidata/WiktionaryZ/SpecialTransaction.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/WiktionaryZ/SpecialTransaction.php
@@ -26,9 +26,19 @@
2727 initializeAttributes();
2828
2929 $fromTransactionId = $wgRequest->getInt('from-transaction');
 30+ $transactionCount = $wgRequest->getInt('transaction-count');
 31+ $userName = $wgRequest->getText('user-name');
3032
31 -// $wgOut->addHTML(getFilterOptionsPanel($fromTransactionId));
32 - $wgOut->addHTML(getTransactionOverview());
 33+ if ($fromTransactionId == 0)
 34+ $fromTransactionId = getLatestTransactionId();
 35+
 36+ if ($transactionCount == 0)
 37+ $transactionCount = 10;
 38+ else
 39+ $transactionCount = min($transactionCount, 20);
 40+
 41+ $wgOut->addHTML(getFilterOptionsPanel($fromTransactionId, $transactionCount, $userName));
 42+ $wgOut->addHTML(getTransactionOverview($fromTransactionId, $transactionCount, $userName));
3343 $wgOut->addHTML(DefaultEditor::getExpansionCss());
3444 $wgOut->addHTML("<script language='javascript'><!--\nexpandEditors();\n--></script>");
3545 }
@@ -37,15 +47,28 @@
3848 SpecialPage::addPage(new SpecialTransaction());
3949 }
4050
41 -function getFilterOptionsPanel($fromTransactionId) {
 51+function getFilterOptionsPanel($fromTransactionId, $transactionCount, $userName) {
 52+ $countOptions = array();
 53+
 54+ for ($i = 1; $i <= 20; $i++)
 55+ $countOptions[$i] = $i;
 56+
4257 return getOptionPanel(array(
43 - "From transaction" => getSuggest(
44 - 'from-transaction',
45 - 'transaction',
46 - $fromTransactionId,
47 - getTransactionLabel($fromTransactionId),
48 - array(0, 2, 3)
49 - )
 58+ "From transaction" =>
 59+ getSuggest(
 60+ 'from-transaction',
 61+ 'transaction',
 62+ $fromTransactionId,
 63+ getTransactionLabel($fromTransactionId),
 64+ array(0, 2, 3)
 65+ ),
 66+ "Count" =>
 67+ getSelect('transaction-count',
 68+ $countOptions,
 69+ $transactionCount
 70+ ),
 71+ "User name" =>
 72+ getTextBox('user-name', $userName)
5073 ));
5174 }
5275
@@ -145,7 +168,7 @@
146169 $updatesInTransactionAttribute = new Attribute('updates-in-transaction', 'Updates in transaction', new RecordType($updatesInTransactionStructure));
147170 }
148171
149 -function getTransactionOverview() {
 172+function getTransactionOverview($fromTransactionId, $transactionCount, $userName) {
150173 global
151174 $transactionsTable, $transactionAttribute, $transactionIdAttribute, $userAttribute, $userIPAttribute,
152175 $timestampAttribute, $summaryAttribute, $updatesInTransactionAttribute, $updatedDefinitionAttribute,
@@ -154,6 +177,11 @@
155178
156179 $queryTransactionInformation = new QueryLatestTransactionInformation();
157180
 181+ $restrictions = array("transaction_id <= $fromTransactionId");
 182+
 183+ if ($userName != "")
 184+ $restrictions[] = "EXISTS (SELECT user_name FROM user WHERE user.user_id=transactions.user_id)";
 185+
158186 $recordSet = queryRecordSet(
159187 $queryTransactionInformation,
160188 $transactionIdAttribute,
@@ -161,9 +189,9 @@
162190 'transaction_id' => $transactionIdAttribute
163191 ),
164192 $transactionsTable,
165 - array(),
 193+ $restrictions,
166194 array('transaction_id DESC'),
167 - 10
 195+ $transactionCount
168196 );
169197
170198 $recordSet->getStructure()->attributes[] = $transactionIdAttribute;