r55133 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55132‎ | r55133 | r55134 >
Date:10:07, 16 August 2009
Author:siebrand
Status:deferred
Tags:
Comment:
* Commentbox: stylize, trailing whitespace removed, messages tweaked, svn:eol-style native, bumped version
* Configure: added support for Commentbox
* Translate: added support for Commontbox
Modified paths:
  • /trunk/extensions/Commentbox/Commentbox.i18n.php (modified) (history)
  • /trunk/extensions/Commentbox/Commentbox.php (modified) (history)
  • /trunk/extensions/Commentbox/SpecialAddComment_body.php (modified) (history)
  • /trunk/extensions/Configure/Configure.settings-ext.txt (modified) (history)
  • /trunk/extensions/Translate/groups/mediawiki-defines.txt (modified) (history)

Diff [purge]

Index: trunk/extensions/Configure/Configure.settings-ext.txt
@@ -284,6 +284,12 @@
285285 empty[] = wgCollectionMWServeCert: null, wgLicenseName: null, wgLicenseURL: null
286286 url = http://www.mediawiki.org/wiki/Extension:Collection
287287
 288+Commentbox
 289+settings[] = wgCommentboxNamespaces: array
 290+settings[] = wgCommentboxRows: int, wgCommentboxColumns: int
 291+array[] = wgCommentboxNamespaces: ns-simple
 292+url = http://www.mediawiki.org/wiki/Extension:Commentbox
 293+
288294 CommentPages
289295 settings[] = wgCommentPagesNS: int
290296 url = http://www.mediawiki.org/wiki/Extension:CommentPages
Index: trunk/extensions/Commentbox/Commentbox.i18n.php
@@ -5,8 +5,6 @@
66 * @addtogroup Extensions
77 */
88
9 -if (!defined('MEDIAWIKI')) die();
10 -
119 $messages = array();
1210
1311 $messages['en'] = array(
@@ -16,7 +14,7 @@
1715 You have a comment on this page? Add it here or <span class="plainlinks">[{{fullurl:{{FULLPAGENAME}}|action=edit}} edit the page directly]</span>.',
1816 'commentbox-savebutton' => 'Save comment',
1917 'commentbox-name' => 'Name:',
20 - 'commentbox-name-explanation' => '<small>(Tip: If you [[Special:Userlogin|log in]], you won\'t have to fill in your name here manually)</small>',
 18+ 'commentbox-name-explanation' => '<small>(Tip: If you [[Special:Userlogin|log in]], you will not have to fill in your name here manually)</small>',
2119 'commentbox-log' => 'New Comments',
2220 'commentbox-first-comment-heading' => '== Comments ==',
2321 'commentbox-regex' => '/\n==\s*Comments\s*==\s*\n/i', # should match the above heading
@@ -26,6 +24,10 @@
2725 'commentbox-error-empty-comment' => 'Empty comments are not allowed!',
2826 );
2927
 28+$messages['qqq'] = array(
 29+ 'commentbox-regex' => 'Regular expression that should match {{msg-mw|commentbox-first-comment-heading}}',
 30+);
 31+
3032 $messages['de'] = array(
3133 'commentbox-desc' => 'Fügt in bestimmte Seiten ein Kommentarfeld ein',
3234 'commentbox-prefill' => '',
@@ -42,4 +44,3 @@
4345 'commentbox-error-namespace' => 'Kommentare sind in diesem Namensraum nicht erlaubt!',
4446 'commentbox-error-empty-comment' => 'Leere Kommentare sind nicht erlaubt!',
4547 );
46 -
Property changes on: trunk/extensions/Commentbox/Commentbox.i18n.php
___________________________________________________________________
Name: svn:eol-style
4748 + native
Index: trunk/extensions/Commentbox/SpecialAddComment_body.php
@@ -5,7 +5,7 @@
66 * @addtogroup Extensions
77 */
88
9 -if (!defined('MEDIAWIKI')) die();
 9+if ( !defined( 'MEDIAWIKI' ) ) die();
1010
1111 class SpecialAddComment extends UnlistedSpecialPage {
1212 public function __construct() {
@@ -14,14 +14,14 @@
1515
1616 public function execute( $par ) {
1717 global $wgUser, $wgRequest, $wgOut, $wgCommentboxNamespaces;
18 - if( !$wgRequest->wasPosted() ) {
 18+ if ( !$wgRequest->wasPosted() ) {
1919 $wgOut->redirect( Title::newMainPage()->getFullURL() );
2020 return;
2121 }
2222 $this->setHeaders();
2323 wfLoadExtensionMessages( 'Commentbox' );
2424
25 - if( !$this->userCanExecute( $wgUser ) ){
 25+ if ( !$this->userCanExecute( $wgUser ) ) {
2626 $this->displayRestrictionError();
2727 return;
2828 }
@@ -29,23 +29,23 @@
3030 $Author = $wgRequest->getText( 'wpAuthor', '' );
3131 $Comment = $wgRequest->getText( 'wpComment', '' );
3232 $title = Title::newFromText( $Pagename );
33 - if( $title == NULL || !$title->exists() ) {
 33+ if ( $title == NULL || !$title->exists() ) {
3434 $this->fail( 'commentbox-error-page-nonexistent' );
3535 return;
3636 }
3737
38 - if( !array_key_exists( $title->getNamespace(), $wgCommentboxNamespaces )
 38+ if ( !array_key_exists( $title->getNamespace(), $wgCommentboxNamespaces )
3939 || !$wgCommentboxNamespaces[ $title->getNamespace() ] ) {
4040 $this->fail( 'commentbox-error-namespace', $title );
4141 return;
4242 }
4343
44 - if( $Comment == '' || $Comment == wfMsgNoTrans( 'commentbox-prefill' ) ) {
 44+ if ( $Comment == '' || $Comment == wfMsgNoTrans( 'commentbox-prefill' ) ) {
4545 $this->fail( 'commentbox-error-empty-comment', $title );
4646 return;
4747 }
4848
49 - if( !$title->userCan( 'edit' ) ) {
 49+ if ( !$title->userCan( 'edit' ) ) {
5050 $this->displayRestrictionError();
5151 return;
5252 }
@@ -53,7 +53,7 @@
5454 // TODO: Integrate with SpamBlacklist etc.
5555 // Currently, no http/https-links are allowed at all
5656 $matches = array();
57 - if( preg_match( '@https?://[-.\w]+@', $Comment, $matches ) ||
 57+ if ( preg_match( '@https?://[-.\w]+@', $Comment, $matches ) ||
5858 preg_match( '@https?://[-.\w]+@', $Author, $matches ) ) {
5959 $wgOut->setPageTitle( wfMsg( 'spamprotectiontitle' ) );
6060 $wgOut->setRobotPolicy( 'noindex,nofollow' );
@@ -68,37 +68,37 @@
6969 $article = new Article( $title );
7070 $text = $article->getContent();
7171 $subject = '';
72 - if( !preg_match( wfMsgForContentNoTrans( 'commentbox-regex' ), $text ) )
73 - $subject = wfMsgForContent( 'commentbox-first-comment-heading' )."\n";
 72+ if ( !preg_match( wfMsgForContentNoTrans( 'commentbox-regex' ), $text ) )
 73+ $subject = wfMsgForContent( 'commentbox-first-comment-heading' ) . "\n";
7474 $sig = $wgUser->isLoggedIn() ? "-- ~~~~" : "-- $Author ~~~~~";
7575 // Append <br/> after each newline, except if the user started a new paragraph
7676 $Comment = preg_replace( '/(?<!\n)\n(?!\n)/', "<br/>\n", $Comment );
77 - $text .= "\n\n".$subject.$Comment."\n<br/>".$sig;
 77+ $text .= "\n\n" . $subject . $Comment . "\n<br/>" . $sig;
7878 try {
79 - $req = new FauxRequest(array(
 79+ $req = new FauxRequest( array(
8080 'action' => 'edit',
8181 'title' => $title->getPrefixedText(),
8282 'text' => $text,
8383 'summary' => wfMsgForContent( 'commentbox-log' ),
8484 'token' => $wgUser->editToken(),
85 - ), true);
86 - $api = new ApiMain($req, true);
 85+ ), true );
 86+ $api = new ApiMain( $req, true );
8787 $api->execute();
88 - wfDebug("Completed API-Save\n");
 88+ wfDebug( "Completed API-Save\n" );
8989 // we only reach this point if Api doesn't throw an exception
9090 $data = $api->getResultData();
91 - if ($data['edit']['result'] == 'Failure') {
 91+ if ( $data['edit']['result'] == 'Failure' ) {
9292 $spamurl = $data['edit']['spamblacklist'];
93 - if ($spamurl != '')
94 - throw new Exception("Die Seite enthaelt die Spam-Url ``{$spamurl}''");
 93+ if ( $spamurl != '' )
 94+ throw new Exception( "Die Seite enthaelt die Spam-Url ``{$spamurl}''" );
9595 else
96 - throw new Exception("Unbekannter Fehler");
 96+ throw new Exception( "Unbekannter Fehler" );
9797 }
98 - } catch (Exception $e) {
 98+ } catch ( Exception $e ) {
9999 global $wgOut;
100100 $wgOut->setPageTitle( wfMsg( 'commentbox-errorpage-title' ) );
101 - $wgOut->addHTML("<div class='errorbox'>". htmlspecialchars($e->getMessage()). "</div><br clear='both' />" );
102 - if( $title != NULL )
 101+ $wgOut->addHTML( "<div class='errorbox'>" . htmlspecialchars( $e->getMessage() ) . "</div><br clear='both' />" );
 102+ if ( $title != NULL )
103103 $wgOut->returnToMain( false, $title );
104104 return;
105105 }
@@ -110,8 +110,8 @@
111111 function fail( $str, $title = NULL ) {
112112 global $wgOut;
113113 $wgOut->setPageTitle( wfMsg( 'commentbox-errorpage-title' ) );
114 - $wgOut->addWikiText("<div class='errorbox'>". wfMsg( $str ). "</div><br clear='both' />" );
115 - if( $title != NULL )
 114+ $wgOut->addWikiText( "<div class='errorbox'>" . wfMsg( $str ) . "</div><br clear='both' />" );
 115+ if ( $title != NULL )
116116 $wgOut->returnToMain( false, $title );
117117 return;
118118 }
Property changes on: trunk/extensions/Commentbox/SpecialAddComment_body.php
___________________________________________________________________
Name: svn:eol-style
119119 + native
Index: trunk/extensions/Commentbox/Commentbox.php
@@ -9,13 +9,13 @@
1010 * @author Thomas Bleher <ThomasBleher@gmx.de>
1111 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
1212 */
13 -if (!defined('MEDIAWIKI')) die();
 13+if ( !defined( 'MEDIAWIKI' ) ) die();
1414
1515 $wgExtensionCredits['other'][] = array(
1616 'name' => 'Commentbox',
1717 'path' => __FILE__,
1818 'author' => '[http://spiele.j-crew.de Thomas Bleher]',
19 - 'version' => '0.1',
 19+ 'version' => '0.2',
2020 'url' => 'http://www.mediawiki.org/wiki/Extension:Commentbox',
2121 'description' => 'Adds a commentbox to certain pages',
2222 'descriptionmsg' => 'commentbox-desc',
@@ -28,7 +28,7 @@
2929 $wgCommentboxRows = 5;
3030 $wgCommentboxColumns = 80;
3131
32 -$wgExtensionMessagesFiles['Commentbox'] = dirname(__FILE__) . '/Commentbox.i18n.php';
 32+$wgExtensionMessagesFiles['Commentbox'] = dirname( __FILE__ ) . '/Commentbox.i18n.php';
3333 $wgSpecialPages['AddComment'] = 'SpecialAddComment';
3434 $wgAutoloadClasses['SpecialAddComment'] = dirname( __FILE__ ) . '/SpecialAddComment_body.php';
3535 $wgHooks['OutputPageBeforeHTML'][] = 'wfExtensionCommentbox_Add';
@@ -38,23 +38,23 @@
3939 $wgCommentboxNamespaces, $wgCommentboxRows,
4040 $wgCommentboxColumns;
4141
42 - if( !$wgTitle->exists() )
 42+ if ( !$wgTitle->exists() )
4343 return true;
4444
45 - if( !$wgTitle->userCan('edit', true) )
 45+ if ( !$wgTitle->userCan( 'edit', true ) )
4646 return true;
47 - if( !array_key_exists( $wgTitle->getNamespace(), $wgCommentboxNamespaces )
 47+ if ( !array_key_exists( $wgTitle->getNamespace(), $wgCommentboxNamespaces )
4848 || !$wgCommentboxNamespaces[ $wgTitle->getNamespace() ] )
4949 return true;
50 - if( !( $action == 'view' || $action == 'purge' || $action == 'submit' ) )
 50+ if ( !( $action == 'view' || $action == 'purge' || $action == 'submit' ) )
5151 return true;
52 - if( $wgRequest->getCheck( 'wpPreview' )
 52+ if ( $wgRequest->getCheck( 'wpPreview' )
5353 || $wgRequest->getCheck( 'wpLivePreview' )
5454 || $wgRequest->getCheck( 'wpDiff' ) )
5555 return true;
56 - if( !is_null( $wgRequest->getVal( 'preview' ) ) )
 56+ if ( !is_null( $wgRequest->getVal( 'preview' ) ) )
5757 return true;
58 - if( !is_null( $wgRequest->getVal( 'diff' ) ) )
 58+ if ( !is_null( $wgRequest->getVal( 'diff' ) ) )
5959 return true;
6060
6161 $newaction = Title::newFromText( 'AddComment', NS_SPECIAL )->escapeFullURL();
Property changes on: trunk/extensions/Commentbox/Commentbox.php
___________________________________________________________________
Name: svn:eol-style
6262 + native
Index: trunk/extensions/Translate/groups/mediawiki-defines.txt
@@ -184,6 +184,9 @@
185185 descmsg = coll-desc
186186 ignored = coll-template_blacklist_title, coll-license_url
187187
 188+Commentbox
 189+ignored = commentbox-prefill
 190+
188191 Comment Pages
189192 ignored = commenttab-editintro, commenttab-preload
190193

Status & tagging log