Index: trunk/extensions/Wikidata/WiktionaryZ/WiktionaryZ.php |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | * @package MediaWiki |
20 | 20 | */ |
21 | 21 | class WiktionaryZ extends DefaultWikidataApplication { |
22 | | - function view() { |
| 22 | + public function view() { |
23 | 23 | global |
24 | 24 | $wgOut, $wgTitle; |
25 | 25 | |
— | — | @@ -33,7 +33,7 @@ |
34 | 34 | # $wgOut->setPageTitleArray($this->mTitle->getTitleArray()); |
35 | 35 | } |
36 | 36 | |
37 | | - function history() { |
| 37 | + public function history() { |
38 | 38 | global |
39 | 39 | $wgOut, $wgTitle; |
40 | 40 | |
— | — | @@ -49,30 +49,18 @@ |
50 | 50 | $wgOut->setPageTitleArray($titleArray); |
51 | 51 | } |
52 | 52 | |
53 | | - function saveForm() { |
| 53 | + protected function save($referenceTransaction) { |
54 | 54 | global |
55 | | - $wgTitle, $wgUser, $wgRequest; |
| 55 | + $wgTitle; |
56 | 56 | |
57 | | - $summary = $wgRequest->getText('summary'); |
58 | | - |
59 | | - startNewTransaction($wgUser->getID(), wfGetIP(), $summary); |
60 | | - |
61 | 57 | $spelling = $wgTitle->getText(); |
62 | | - getExpressionsEditor($spelling, false)->save(new IdStack("expression"), getExpressionsRecordSet($spelling, new QueryLatestTransactionInformation())); |
63 | | - |
64 | | - Title::touchArray(array($wgTitle)); |
65 | | - $now = wfTimestampNow(); |
66 | | - RecentChange::notifyEdit($now, $wgTitle, false, $wgUser, $summary, |
67 | | - 0, $now, false, '', 0, 0, 0); |
| 58 | + getExpressionsEditor($spelling, false)->save(new IdStack("expression"), getExpressionsRecordSet($spelling, $referenceTransaction)); |
68 | 59 | } |
69 | 60 | |
70 | | - function edit() { |
| 61 | + public function edit() { |
71 | 62 | global |
72 | | - $wgOut, $wgTitle, $wgUser, $wgRequest; |
| 63 | + $wgOut, $wgTitle, $wgUser; |
73 | 64 | |
74 | | - if ($wgRequest->getText('save') != '') |
75 | | - $this->saveForm(); |
76 | | - |
77 | 65 | parent::edit(); |
78 | 66 | |
79 | 67 | $spelling = $wgTitle->getText(); |
— | — | @@ -80,13 +68,6 @@ |
81 | 69 | $this->outputEditHeader(); |
82 | 70 | $wgOut->addHTML(getExpressionsEditor($spelling, false)->edit(new IdStack("expression"), getExpressionsRecordSet($spelling, new QueryLatestTransactionInformation()))); |
83 | 71 | $this->outputEditFooter(); |
84 | | - |
85 | | - $wgOut->addHTML(DefaultEditor::getExpansionCss()); |
86 | | - $wgOut->addHTML("<script language='javascript'><!--\nexpandEditors();\n--></script>"); |
87 | | - |
88 | | - $titleArray = $wgTitle->getTitleArray(); |
89 | | - $titleArray["actionprefix"] = wfMsg('editing'); |
90 | | - $wgOut->setPageTitleArray($titleArray); |
91 | 72 | } |
92 | 73 | } |
93 | 74 | |
Index: trunk/extensions/Wikidata/WiktionaryZ/Wikidata.php |
— | — | @@ -1,6 +1,7 @@ |
2 | 2 | <?php
|
3 | 3 |
|
4 | 4 | require_once("forms.php");
|
| 5 | +require_once("Transaction.php");
|
5 | 6 |
|
6 | 7 | interface WikidataApplication {
|
7 | 8 | public function view();
|
— | — | @@ -45,10 +46,31 @@ |
46 | 47 | $wgOut->addHTML($this->getLanguageSelector());
|
47 | 48 | }
|
48 | 49 |
|
| 50 | + protected function save($referenceTransaction) {
|
| 51 | + }
|
| 52 | +
|
| 53 | + public function saveWithinTransaction() {
|
| 54 | + global
|
| 55 | + $wgTitle, $wgUser, $wgRequest;
|
| 56 | +
|
| 57 | + $summary = $wgRequest->getText('summary');
|
| 58 | +
|
| 59 | + startNewTransaction($wgUser->getID(), wfGetIP(), $summary);
|
| 60 | + $this->save(new QueryAtTransactionInformation($wgRequest->getInt('transaction')));
|
| 61 | +
|
| 62 | +
|
| 63 | + Title::touchArray(array($wgTitle));
|
| 64 | + $now = wfTimestampNow();
|
| 65 | + RecentChange::notifyEdit($now, $wgTitle, false, $wgUser, $summary, 0, $now, false, '', 0, 0, 0);
|
| 66 | + }
|
| 67 | +
|
49 | 68 | public function edit() {
|
50 | 69 | global
|
51 | | - $wgOut;
|
| 70 | + $wgOut, $wgRequest;
|
52 | 71 |
|
| 72 | + if ($wgRequest->getText('save') != '')
|
| 73 | + $this->saveWithinTransaction();
|
| 74 | +
|
53 | 75 | $wgOut->addHTML($this->getLanguageSelector());
|
54 | 76 | }
|
55 | 77 |
|
— | — | @@ -91,17 +113,26 @@ |
92 | 114 | global
|
93 | 115 | $wgOut;
|
94 | 116 |
|
95 | | - $wgOut->addHTML('<form method="post" action="">');
|
| 117 | + $wgOut->addHTML(
|
| 118 | + '<form method="post" action="">' .
|
| 119 | + '<input type="hidden" name="transaction" value="'. getLatestTransactionId() .'"/>'
|
| 120 | + );
|
96 | 121 | }
|
97 | 122 |
|
98 | 123 | protected function outputEditFooter() {
|
99 | 124 | global
|
100 | 125 | $wgOut, $wgTitle;
|
101 | 126 |
|
102 | | - $wgOut->addHTML('<div class="option-panel">');
|
103 | | - $wgOut->addHTML('<table cellpadding="0" cellspacing="0"><tr><th>' . wfMsg('summary') . ': </th><td class="option-field">' . getTextBox("summary") .'</td></tr></table>');
|
104 | | - $wgOut->addHTML(getSubmitButton("save", wfMsg('wz_save')));
|
105 | | - $wgOut->addHTML('</div>');
|
| 127 | + $wgOut->addHTML(
|
| 128 | + '<div class="option-panel">'.
|
| 129 | + '<table cellpadding="0" cellspacing="0"><tr>' .
|
| 130 | + '<th>' . wfMsg('summary') . ': </th>' .
|
| 131 | + '<td class="option-field">' . getTextBox("summary") .'</td>' .
|
| 132 | + '</tr></table>' .
|
| 133 | + getSubmitButton("save", wfMsg('wz_save')).
|
| 134 | + '</div>'
|
| 135 | + );
|
| 136 | +
|
106 | 137 | $wgOut->addHTML('</form>');
|
107 | 138 | $wgOut->addHTML(DefaultEditor::getExpansionCss());
|
108 | 139 | $wgOut->addHTML("<script language='javascript'><!--\nexpandEditors();\n--></script>");
|
Index: trunk/extensions/Wikidata/WiktionaryZ/DefinedMeaning.php |
— | — | @@ -20,11 +20,8 @@ |
21 | 21 | |
22 | 22 | public function edit() { |
23 | 23 | global |
24 | | - $wgOut, $wgTitle, $wgRequest; |
| 24 | + $wgOut, $wgTitle; |
25 | 25 | |
26 | | - if ($wgRequest->getText('save') != '') |
27 | | - $this->save(); |
28 | | - |
29 | 26 | parent::edit(); |
30 | 27 | |
31 | 28 | // $definedMeaningId = $wgTitle->getText(); |
— | — | @@ -33,12 +30,9 @@ |
34 | 31 | $this->outputEditHeader(); |
35 | 32 | $wgOut->addHTML(getDefinedMeaningEditor(false)->edit($this->getIdStack($definedMeaningId), getDefinedMeaningRecord($definedMeaningId, new QueryLatestTransactionInformation()))); |
36 | 33 | $this->outputEditFooter(); |
37 | | - |
38 | | - $wgOut->addHTML(DefaultEditor::getExpansionCss()); |
39 | | - $wgOut->addHTML("<script language='javascript'><!--\nexpandEditors();\n--></script>"); |
40 | 34 | } |
41 | 35 | |
42 | | - function history() { |
| 36 | + public function history() { |
43 | 37 | global |
44 | 38 | $wgOut, $wgTitle; |
45 | 39 | |
— | — | @@ -59,21 +53,13 @@ |
60 | 54 | $wgOut->setPageTitleArray($titleArray); |
61 | 55 | } |
62 | 56 | |
63 | | - protected function save() { |
| 57 | + protected function save($referenceTransaction) { |
64 | 58 | global |
65 | | - $wgTitle, $wgUser, $wgRequest; |
| 59 | + $wgTitle; |
66 | 60 | |
67 | | - $summary = $wgRequest->getText('summary'); |
68 | | - |
69 | | - startNewTransaction($wgUser->getID(), wfGetIP(), $summary); |
70 | | - |
71 | 61 | // $definedMeaningId = $wgTitle->getText(); |
72 | 62 | $definedMeaningId = $this->getDefinedMeaningIdFromTitle($wgTitle->getText()); |
73 | | - getDefinedMeaningEditor(false)->save($this->getIdStack($definedMeaningId), getDefinedMeaningRecord($definedMeaningId, new QueryLatestTransactionInformation())); |
74 | | - |
75 | | - Title::touchArray(array($wgTitle)); |
76 | | - $now = wfTimestampNow(); |
77 | | - RecentChange::notifyEdit($now, $wgTitle, false, $wgUser, $summary, 0, $now, false, '', 0, 0, 0); |
| 63 | + getDefinedMeaningEditor(false)->save($this->getIdStack($definedMeaningId), getDefinedMeaningRecord($definedMeaningId, $referenceTransaction)); |
78 | 64 | } |
79 | 65 | |
80 | 66 | protected function getIdStack($definedMeaningId) { |
— | — | @@ -95,9 +81,7 @@ |
96 | 82 | $bracketPosition = strrpos($title, "("); |
97 | 83 | $definedMeaningId = substr($title, $bracketPosition + 1, strlen($title) - $bracketPosition - 2); |
98 | 84 | return $definedMeaningId; |
99 | | - } |
100 | | - |
| 85 | + } |
101 | 86 | } |
102 | 87 | |
103 | | - |
104 | 88 | ?> |
Index: trunk/extensions/Wikidata/WiktionaryZ/Transaction.php |
— | — | @@ -116,6 +116,16 @@ |
117 | 117 | return $updateTransactionId;
|
118 | 118 | }
|
119 | 119 |
|
| 120 | +function getLatestTransactionId() {
|
| 121 | + $dbr =& wfGetDB(DB_SLAVE);
|
| 122 | + $queryResult = $dbr->query("SELECT max(transaction_id) AS transaction_id FROM transactions");
|
| 123 | +
|
| 124 | + if ($transaction = $dbr->fetchObject($queryResult))
|
| 125 | + return $transaction->transaction_id;
|
| 126 | + else
|
| 127 | + return 0;
|
| 128 | +}
|
| 129 | +
|
120 | 130 | function getLatestTransactionRestriction($table) {
|
121 | 131 | return ' '. $table . '.remove_transaction_id IS NULL ';
|
122 | 132 | }
|