Index: trunk/extensions/Farmer/Farmer.i18n.php |
— | — | @@ -46,9 +46,10 @@ |
47 | 47 | 'farmer-wikiexists-text' => 'The wiki you are attempting to create, \'\'\'$1\'\'\', already exists. |
48 | 48 | Please go back and try another name.', |
49 | 49 | 'farmer-confirmsetting' => 'Confirm wiki settings', |
50 | | - 'farmer-confirmsetting-name' => 'Name: $1', |
51 | | - 'farmer-confirmsetting-title' => 'Title: $1', |
52 | | - 'farmer-confirmsetting-description' => 'Description: $1', |
| 50 | + 'farmer-confirmsetting-name' => 'Name', |
| 51 | + 'farmer-confirmsetting-title' => 'Title', |
| 52 | + 'farmer-confirmsetting-description' => 'Description', |
| 53 | + 'farmer-confirmsetting-reason' => 'Reason', |
53 | 54 | 'farmer-description' => 'Description', |
54 | 55 | 'farmer-confirmsetting-text' => 'Your wiki, \'\'\'$1\'\'\', will be accessible via http://$1.myfarm. |
55 | 56 | The project namespace will be \'\'\'$2\'\'\'. |
— | — | @@ -73,6 +74,7 @@ |
74 | 75 | 'farmer-createwiki-name' => 'Wiki name', |
75 | 76 | 'farmer-createwiki-title' => 'Wiki title', |
76 | 77 | 'farmer-createwiki-description' => 'Description', |
| 78 | + 'farmer-createwiki-reason' => 'Reason', |
77 | 79 | 'farmer-updatedlist' => 'Updated list', |
78 | 80 | 'farmer-notaccessible' => 'Not accessible', |
79 | 81 | 'farmer-notaccessible-test' => 'This feature is only available on the parent wiki in the farm', |
— | — | @@ -80,6 +82,9 @@ |
81 | 83 | 'farmer-permissiondenied-text' => 'You do not have permission to delete a wiki from the farm', |
82 | 84 | 'farmer-permissiondenied-text1' => 'You do not have permission to access this page', |
83 | 85 | 'farmer-deleting' => 'Deleting $1', |
| 86 | + 'farmer-delete-confirm' => 'I confirm that I want to delete this wiki', |
| 87 | + 'farmer-delete-confirm-wiki' => "Wiki to delete: '''$1'''.", |
| 88 | + 'farmer-delete-reason' => 'Reason for the deletion:', |
84 | 89 | 'farmer-delete-title' => 'Delete wiki', |
85 | 90 | 'farmer-delete-text' => 'Please select the wiki from the list below that you wish to delete', |
86 | 91 | 'farmer-delete-form' => 'Select a wiki', |
— | — | @@ -128,6 +133,10 @@ |
129 | 134 | 'farmer-extensions-register-includefile' => 'Include file', |
130 | 135 | 'farmer-error-exists' => 'Cannot create wiki. It already exists: $1', |
131 | 136 | 'farmer-error-noextwrite' => 'Unable to write out extension file:', |
| 137 | + 'farmer-log-name' => 'Wiki farm log', |
| 138 | + 'farmer-log-header' => 'This is a log of changes made to the wiki farm.', |
| 139 | + 'farmer-log-create' => 'created the wiki "$2"', |
| 140 | + 'farmer-log-delete' => 'deleted the wiki "$2"', |
132 | 141 | ); |
133 | 142 | |
134 | 143 | /** Message documentation (Message documentation) |
Index: trunk/extensions/Farmer/Farmer.php |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | 'url' => 'http://www.mediawiki.org/wiki/Extension:Farmer', |
20 | 20 | 'description' => 'Manage a MediaWiki farm', |
21 | 21 | 'descriptionmsg' => 'farmer-desc', |
22 | | - 'version' => '0.0.5', |
| 22 | + 'version' => '0.0.6', |
23 | 23 | ); |
24 | 24 | |
25 | 25 | /** |
— | — | @@ -95,3 +95,10 @@ |
96 | 96 | $wgGroupPermissions['sysop']['farmeradmin'] = true; |
97 | 97 | $wgGroupPermissions['*']['createwiki'] = false; |
98 | 98 | $wgGroupPermissions['sysop']['createwiki'] = true; |
| 99 | + |
| 100 | +# New log |
| 101 | +$wgLogTypes[] = 'farmer'; |
| 102 | +$wgLogNames['farmer'] = 'farmer-log-name'; |
| 103 | +$wgLogHeaders['farmer'] = 'farmer-log-header'; |
| 104 | +$wgLogActions['farmer/create'] = 'farmer-log-create'; |
| 105 | +$wgLogActions['farmer/delete'] = 'farmer-log-delete'; |
Index: trunk/extensions/Farmer/SpecialFarmer.php |
— | — | @@ -107,8 +107,6 @@ |
108 | 108 | protected function _executeCreate( $wgFarmer, $wiki ){ |
109 | 109 | global $wgOut, $wgUser, $wgRequest; |
110 | 110 | |
111 | | - $confirmaccount = wfMsg( 'farmer-button-confirm' ); |
112 | | - |
113 | 111 | if( !$wgFarmer->getActiveWiki()->isDefaultWiki() ) { |
114 | 112 | $wgOut->wrapWikiMsg( '== $1 ==', 'farmer-notavailable' ); |
115 | 113 | $wgOut->addWikiMsg( 'farmer-notavailable-text' ); |
— | — | @@ -120,18 +118,22 @@ |
121 | 119 | return; |
122 | 120 | } |
123 | 121 | |
124 | | - $name = MediaWikiFarmer_Wiki::sanitizeName( $wgRequest->getVal( 'name', $wiki ) ); |
125 | | - $title = MediaWikiFarmer_Wiki::sanitizeTitle( $wgRequest->getVal( 'wikititle' ) ); |
126 | | - $description = $wgRequest->getVal( 'description' ); |
| 122 | + $name = MediaWikiFarmer_Wiki::sanitizeName( $wgRequest->getVal( 'wpName', $wiki ) ); |
| 123 | + $title = MediaWikiFarmer_Wiki::sanitizeTitle( $wgRequest->getVal( 'wpTitle' ) ); |
| 124 | + $description = $wgRequest->getVal( 'wpDescription', '' ); |
| 125 | + $reason = $wgRequest->getVal( 'wpReason' ); |
127 | 126 | $action = $this->getTitle( 'create' )->escapeLocalURL(); |
128 | 127 | |
129 | 128 | //if something was POST'd |
130 | 129 | if( $wgRequest->wasPosted() ){ |
131 | 130 | //we create the wiki if the user pressed 'Confirm' |
132 | | - if( $wgRequest->getCheck( 'confirm' ) ) { |
| 131 | + if( $wgRequest->getCheck( 'wpConfirm' ) ) { |
133 | 132 | $wikiObj = MediaWikiFarmer_Wiki::newFromParams( $name, $title, $description, $wgUser->getName() ); |
134 | 133 | $wikiObj->create(); |
135 | 134 | |
| 135 | + $log = new LogPage( 'farmer' ); |
| 136 | + $log->addEntry( 'create', $this->getTitle(), $reason, array( $name ) ); |
| 137 | + |
136 | 138 | $wgOut->wrapWikiMsg( '== $1 ==', 'farmer-wikicreated' ); |
137 | 139 | $wgOut->addWikiMsg( 'farmer-wikicreated-text', $wikiObj->getUrl( wfUrlencode( wfMsgNoDB( 'mainpage' ) ) ) ); |
138 | 140 | $wgOut->addWikiMsg( 'farmer-default', '[['.$title.':Special:Farmer|Special:Farmer]]' ); |
— | — | @@ -147,25 +149,33 @@ |
148 | 150 | } |
149 | 151 | |
150 | 152 | $url = $wiki->getUrl( '' ); |
151 | | - $wgOut->wrapWikiMsg( |
152 | | - "== $1 ==\n; $2\n; $3\n; $4\n$5", |
153 | | - 'farmer-confirmsetting', |
154 | | - array( 'farmer-confirmsetting-name', $name ), |
155 | | - array( 'farmer-confirmsetting-title', $title ), |
156 | | - array( 'farmer-confirmsetting-description', $description ), |
157 | | - array( 'farmer-confirmsetting-text', $name, $title, $url ) |
| 153 | + $wgOut->wrapWikiMsg( '== $1 ==', 'farmer-confirmsetting' ); |
| 154 | + |
| 155 | + $wgOut->addHtml( Xml::openElement( 'table', array( 'class' => 'wikitable' ) ) . "\n" . |
| 156 | + Xml::tags( 'tr', array(), Xml::tags( 'th', array(), |
| 157 | + wfMsgExt( 'farmer-confirmsetting-name', 'parseinline' ) ) . Xml::element( 'td', array(), $name ) ) . "\n" . |
| 158 | + Xml::tags( 'tr', array(), Xml::tags( 'th', array(), |
| 159 | + wfMsgExt( 'farmer-confirmsetting-title', 'parseinline' ) ) . Xml::element( 'td', array(), $title ) ) . "\n" . |
| 160 | + Xml::tags( 'tr', array(), Xml::tags( 'th', array(), |
| 161 | + wfMsgExt( 'farmer-confirmsetting-description', 'parseinline' ) ) . Xml::element( 'td', array(), $description ) ) . "\n" . |
| 162 | + Xml::tags( 'tr', array(), Xml::tags( 'th', array(), |
| 163 | + wfMsgExt( 'farmer-confirmsetting-reason', 'parseinline' ) ) . Xml::element( 'td', array(), $reason ) ) . "\n" . |
| 164 | + Xml::closeElement( 'table' ) |
158 | 165 | ); |
| 166 | + $wgOut->addWikiMsg( 'farmer-confirmsetting-text', $name, $title, $url ); |
159 | 167 | |
160 | 168 | $nameaccount = htmlspecialchars( $name ); |
161 | 169 | $nametitle = htmlspecialchars( $title ); |
162 | 170 | $namedescript = htmlspecialchars( $description ); |
| 171 | + $confirmaccount = wfMsgHtml( 'farmer-button-confirm' ); |
163 | 172 | $wgOut->addHTML(" |
164 | 173 | |
165 | 174 | <form id=\"farmercreate2\" method=\"post\" action=\"$action\"> |
166 | | -<input type=\"hidden\" name=\"name\" value=\"{$nameaccount}\" /> |
167 | | -<input type=\"hidden\" name=\"wikititle\" value=\"{$nametitle}\" /> |
168 | | -<input type=\"hidden\" name=\"description\" value=\"{$namedescript}\" /> |
169 | | -<input type=\"submit\" name=\"confirm\" value=\"{$confirmaccount}\" /> |
| 175 | +<input type=\"hidden\" name=\"wpName\" value=\"{$nameaccount}\" /> |
| 176 | +<input type=\"hidden\" name=\"wpTitle\" value=\"{$nametitle}\" /> |
| 177 | +<input type=\"hidden\" name=\"wpDescription\" value=\"{$namedescript}\" /> |
| 178 | +<input type=\"hidden\" name=\"wpReason\" value=\"{$reason}\" /> |
| 179 | +<input type=\"submit\" name=\"wpConfirm\" value=\"{$confirmaccount}\" /> |
170 | 180 | </form>" |
171 | 181 | ); |
172 | 182 | |
— | — | @@ -194,33 +204,20 @@ |
195 | 205 | |
196 | 206 | $token = htmlspecialchars( $wgUser->editToken() ); |
197 | 207 | |
198 | | - $wgOut->addHTML( " |
199 | | -<form id='farmercreate1' method='post' action=\"$action\"> |
200 | | - <table> |
201 | | - <tr> |
202 | | - <td align=\"right\">". wfMsg( 'farmer-createwiki-user' ) . "</td> |
203 | | - <td align=\"left\"><b>{$wgUser->getName()}</b></td> |
204 | | - </tr> |
205 | | - <tr> |
206 | | - <td align='right'>". wfMsg( 'farmer-createwiki-name' ) . "</td> |
207 | | - <td align='left'><input tabindex='1' type='text' size='20' name='name' value=\"" . htmlspecialchars( $name ) . "\" /></td> |
208 | | - </tr> |
209 | | - <tr> |
210 | | - <td align='right'>". wfMsg( 'farmer-createwiki-title' ) ."</td> |
211 | | - <td align='left'><input tabindex='1' type='text' size='20' name='wikititle' value=\"" . htmlspecialchars( $title ) . "\"/></td> |
212 | | - </tr> |
213 | | - <tr> |
214 | | - <td align='right'>". wfMsg( 'farmer-createwiki-description' ) ."</td> |
215 | | - <td align='left'><textarea tabindex='1' cols=\"40\" rows=\"5\" name='description'>" . htmlspecialchars( $description ) . "</textarea></td> |
216 | | - </tr> |
217 | | - <tr> |
218 | | - <td> </td> |
219 | | - <td align='right'><input type='submit' name='submit' value=\"". wfMsgHtml( 'farmer-button-submit' ) . "\" /></td> |
220 | | - </tr> |
221 | | - </table> |
222 | | - <input type='hidden' name='token' value=\"$token\" /> |
223 | | -</form>"); |
224 | | - |
| 208 | + $wgOut->addHTML( |
| 209 | + Xml::openElement( 'form', array( 'method' => 'post', 'action' => $action ) ) . "\n" . |
| 210 | + Xml::buildForm( |
| 211 | + array( |
| 212 | + 'farmer-createwiki-user' => Xml::element( 'b', array(), $wgUser->getName() ), |
| 213 | + 'farmer-createwiki-name' => Xml::input( 'wpName', 20, $name ), |
| 214 | + 'farmer-createwiki-title' => Xml::input( 'wpTitle', 20, $title ), |
| 215 | + 'farmer-createwiki-description' => Xml::textarea( 'wpDescription', $description ), |
| 216 | + 'farmer-createwiki-reason' => Xml::input( 'wpReason', 20, $reason ), |
| 217 | + ), 'farmer-button-submit' |
| 218 | + ) . "\n" . |
| 219 | + Xml::hidden( 'token', $token ) . "\n" . |
| 220 | + Xml::closeElement( 'form' ) |
| 221 | + ); |
225 | 222 | } |
226 | 223 | |
227 | 224 | protected function _executeUpdateList( $wgFarmer ) { |
— | — | @@ -233,7 +230,7 @@ |
234 | 231 | |
235 | 232 | $wgFarmer->updateFarmList(); |
236 | 233 | $wgFarmer->updateInterwikiTable(); |
237 | | - $wgOut->wrapWikiMsg( '<div class="successbox">$1</div>', 'farmer-updatedlist' ); |
| 234 | + $wgOut->wrapWikiMsg( '<div class="successbox">$1</div><br clear="all" />', 'farmer-updatedlist' ); |
238 | 235 | $wgOut->returnToMain( null, $this->getTitle() ); |
239 | 236 | } |
240 | 237 | |
— | — | @@ -250,29 +247,50 @@ |
251 | 248 | return; |
252 | 249 | } |
253 | 250 | |
254 | | - if( ( $wiki = $wgRequest->getVal( 'wiki' ) ) && $wiki != '-1' ) { |
255 | | - $wgOut->wrapWikiMsg( "== $1 ==", array( 'farmer-deleting', $wiki ) ); |
| 251 | + if( $wgRequest->wasPosted() && ( $wiki = $wgRequest->getVal( 'wpWiki' ) ) && $wiki != '-1' ) { |
| 252 | + if( $wgRequest->getCheck( 'wpConfirm' ) ) { |
| 253 | + $wgOut->wrapWikiMsg( '== $1 ==', array( 'farmer-deleting', $wiki ) ); |
256 | 254 | |
257 | | - $deleteWiki = MediaWikiFarmer_Wiki::factory( $wiki ); |
| 255 | + $log = new LogPage( 'farmer' ); |
| 256 | + $log->addEntry( 'delete', $this->getTitle(), $wgRequest->getVal( 'wpReason' ), array( $wiki ) ); |
258 | 257 | |
259 | | - $deleteWiki->deleteWiki(); |
| 258 | + $deleteWiki = MediaWikiFarmer_Wiki::factory( $wiki ); |
| 259 | + $deleteWiki->deleteWiki(); |
| 260 | + } else { |
| 261 | + $wgOut->addWikiMsg( 'farmer-delete-confirm-wiki', $wiki ); |
| 262 | + $wgOut->addHTML( |
| 263 | + Xml::openElement( 'form', array( 'method' => 'post', 'name' => 'deleteWiki' ) ) . "\n" . |
| 264 | + Xml::buildForm( array( |
| 265 | + 'farmer-delete-reason' => Xml::input( 'wpReason', false, $wgRequest->getVal( 'wpReason' ) ), |
| 266 | + 'farmer-delete-confirm' => Xml::check( 'wpConfirm' ) |
| 267 | + ), 'farmer-delete-form-submit' ) . "\n" . |
| 268 | + Xml::hidden( 'wpWiki', $wiki ) . "\n" . |
| 269 | + Xml::closeElement( 'form' ) |
| 270 | + ); |
| 271 | + } |
| 272 | + return; |
260 | 273 | } |
261 | 274 | |
262 | 275 | $list = $wgFarmer->getFarmList(); |
263 | 276 | |
264 | 277 | $wgOut->wrapWikiMsg( "== $1 ==\n$2", 'farmer-delete-title', 'farmer-delete-text' ); |
265 | 278 | |
266 | | - $wgOut->addHTML('<form method="post" name="deleteWiki"><select name="wiki"><option value="-1">'.wfMsgExt( 'farmer-delete-form', 'parseinline' )."</option>\n" ); |
267 | | - |
| 279 | + $select = new XmlSelect( 'wpWiki', false, $wgRequest->getVal( 'wpWiki' ) ); |
| 280 | + $select->addOption( wfMsg( 'farmer-delete-form' ), '-1' ); |
268 | 281 | foreach ( $list as $wiki ) { |
269 | 282 | if( $wiki['name'] != $wgFarmer->getDefaultWiki() ) { |
270 | | - $name = htmlspecialchars( $wiki['name'] ); |
271 | | - $title = htmlspecialchars( $wiki['title'] ); |
272 | | - $wgOut->addHTML("<option value=\"$name\">$name - $title</option>\n" ); |
| 283 | + $name = $wiki['name']; |
| 284 | + $title = $wiki['title']; |
| 285 | + $select->addOption( "$name - $title", $name ); |
273 | 286 | } |
274 | 287 | } |
275 | 288 | |
276 | | - $wgOut->addHTML('</select><input type="submit" name="submit" value="'. wfMsgExt( 'farmer-delete-form-submit', 'parseinline' ).'" /></form>'); |
| 289 | + $wgOut->addHTML( |
| 290 | + Xml::openElement( 'form', array( 'method' => 'post', 'name' => 'deleteWiki' ) ) . "\n" . |
| 291 | + $select->getHTML() . "\n" . |
| 292 | + Xml::submitButton( wfMsg( 'farmer-delete-form-submit' ) ) . "\n" . |
| 293 | + Xml::closeElement( 'form' ) |
| 294 | + ); |
277 | 295 | |
278 | 296 | } |
279 | 297 | |