http://www.mediawiki.org/wiki/Special:Code/MediaWiki/55133
Revision: 55133 Author: siebrand Date: 2009-08-16 10:07:06 +0000 (Sun, 16 Aug 2009) Log Message: ----------- * 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 trunk/extensions/Commentbox/Commentbox.php trunk/extensions/Commentbox/SpecialAddComment_body.php trunk/extensions/Configure/Configure.settings-ext.txt trunk/extensions/Translate/groups/mediawiki-defines.txt Property Changed: ---------------- trunk/extensions/Commentbox/Commentbox.i18n.php trunk/extensions/Commentbox/Commentbox.php trunk/extensions/Commentbox/SpecialAddComment_body.php Modified: trunk/extensions/Commentbox/Commentbox.i18n.php =================================================================== --- trunk/extensions/Commentbox/Commentbox.i18n.php 2009-08-16 09:52:10 UTC (rev 55132) +++ trunk/extensions/Commentbox/Commentbox.i18n.php 2009-08-16 10:07:06 UTC (rev 55133) @@ -5,8 +5,6 @@ * @addtogroup Extensions */ -if (!defined('MEDIAWIKI')) die(); - $messages = array(); $messages['en'] = array( @@ -16,7 +14,7 @@ You have a comment on this page? Add it here or <span class="plainlinks">[{{fullurl:{{FULLPAGENAME}}|action=edit}} edit the page directly]</span>.', 'commentbox-savebutton' => 'Save comment', 'commentbox-name' => 'Name:', - 'commentbox-name-explanation' => '<small>(Tip: If you [[Special:Userlogin|log in]], you won\'t have to fill in your name here manually)</small>', + 'commentbox-name-explanation' => '<small>(Tip: If you [[Special:Userlogin|log in]], you will not have to fill in your name here manually)</small>', 'commentbox-log' => 'New Comments', 'commentbox-first-comment-heading' => '== Comments ==', 'commentbox-regex' => '/\n==\s*Comments\s*==\s*\n/i', # should match the above heading @@ -26,6 +24,10 @@ 'commentbox-error-empty-comment' => 'Empty comments are not allowed!', ); +$messages['qqq'] = array( + 'commentbox-regex' => 'Regular expression that should match {{msg-mw|commentbox-first-comment-heading}}', +); + $messages['de'] = array( 'commentbox-desc' => 'Fügt in bestimmte Seiten ein Kommentarfeld ein', 'commentbox-prefill' => '', @@ -42,4 +44,3 @@ 'commentbox-error-namespace' => 'Kommentare sind in diesem Namensraum nicht erlaubt!', 'commentbox-error-empty-comment' => 'Leere Kommentare sind nicht erlaubt!', ); - Property changes on: trunk/extensions/Commentbox/Commentbox.i18n.php ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/extensions/Commentbox/Commentbox.php =================================================================== --- trunk/extensions/Commentbox/Commentbox.php 2009-08-16 09:52:10 UTC (rev 55132) +++ trunk/extensions/Commentbox/Commentbox.php 2009-08-16 10:07:06 UTC (rev 55133) @@ -9,13 +9,13 @@ * @author Thomas Bleher <thomasble...@gmx.de> * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later */ -if (!defined('MEDIAWIKI')) die(); +if ( !defined( 'MEDIAWIKI' ) ) die(); $wgExtensionCredits['other'][] = array( 'name' => 'Commentbox', 'path' => __FILE__, 'author' => '[http://spiele.j-crew.de Thomas Bleher]', - 'version' => '0.1', + 'version' => '0.2', 'url' => 'http://www.mediawiki.org/wiki/Extension:Commentbox', 'description' => 'Adds a commentbox to certain pages', 'descriptionmsg' => 'commentbox-desc', @@ -28,7 +28,7 @@ $wgCommentboxRows = 5; $wgCommentboxColumns = 80; -$wgExtensionMessagesFiles['Commentbox'] = dirname(__FILE__) . '/Commentbox.i18n.php'; +$wgExtensionMessagesFiles['Commentbox'] = dirname( __FILE__ ) . '/Commentbox.i18n.php'; $wgSpecialPages['AddComment'] = 'SpecialAddComment'; $wgAutoloadClasses['SpecialAddComment'] = dirname( __FILE__ ) . '/SpecialAddComment_body.php'; $wgHooks['OutputPageBeforeHTML'][] = 'wfExtensionCommentbox_Add'; @@ -38,23 +38,23 @@ $wgCommentboxNamespaces, $wgCommentboxRows, $wgCommentboxColumns; - if( !$wgTitle->exists() ) + if ( !$wgTitle->exists() ) return true; - if( !$wgTitle->userCan('edit', true) ) + if ( !$wgTitle->userCan( 'edit', true ) ) return true; - if( !array_key_exists( $wgTitle->getNamespace(), $wgCommentboxNamespaces ) + if ( !array_key_exists( $wgTitle->getNamespace(), $wgCommentboxNamespaces ) || !$wgCommentboxNamespaces[ $wgTitle->getNamespace() ] ) return true; - if( !( $action == 'view' || $action == 'purge' || $action == 'submit' ) ) + if ( !( $action == 'view' || $action == 'purge' || $action == 'submit' ) ) return true; - if( $wgRequest->getCheck( 'wpPreview' ) + if ( $wgRequest->getCheck( 'wpPreview' ) || $wgRequest->getCheck( 'wpLivePreview' ) || $wgRequest->getCheck( 'wpDiff' ) ) return true; - if( !is_null( $wgRequest->getVal( 'preview' ) ) ) + if ( !is_null( $wgRequest->getVal( 'preview' ) ) ) return true; - if( !is_null( $wgRequest->getVal( 'diff' ) ) ) + if ( !is_null( $wgRequest->getVal( 'diff' ) ) ) return true; $newaction = Title::newFromText( 'AddComment', NS_SPECIAL )->escapeFullURL(); Property changes on: trunk/extensions/Commentbox/Commentbox.php ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/extensions/Commentbox/SpecialAddComment_body.php =================================================================== --- trunk/extensions/Commentbox/SpecialAddComment_body.php 2009-08-16 09:52:10 UTC (rev 55132) +++ trunk/extensions/Commentbox/SpecialAddComment_body.php 2009-08-16 10:07:06 UTC (rev 55133) @@ -5,7 +5,7 @@ * @addtogroup Extensions */ -if (!defined('MEDIAWIKI')) die(); +if ( !defined( 'MEDIAWIKI' ) ) die(); class SpecialAddComment extends UnlistedSpecialPage { public function __construct() { @@ -14,14 +14,14 @@ public function execute( $par ) { global $wgUser, $wgRequest, $wgOut, $wgCommentboxNamespaces; - if( !$wgRequest->wasPosted() ) { + if ( !$wgRequest->wasPosted() ) { $wgOut->redirect( Title::newMainPage()->getFullURL() ); return; } $this->setHeaders(); wfLoadExtensionMessages( 'Commentbox' ); - if( !$this->userCanExecute( $wgUser ) ){ + if ( !$this->userCanExecute( $wgUser ) ) { $this->displayRestrictionError(); return; } @@ -29,23 +29,23 @@ $Author = $wgRequest->getText( 'wpAuthor', '' ); $Comment = $wgRequest->getText( 'wpComment', '' ); $title = Title::newFromText( $Pagename ); - if( $title == NULL || !$title->exists() ) { + if ( $title == NULL || !$title->exists() ) { $this->fail( 'commentbox-error-page-nonexistent' ); return; } - if( !array_key_exists( $title->getNamespace(), $wgCommentboxNamespaces ) + if ( !array_key_exists( $title->getNamespace(), $wgCommentboxNamespaces ) || !$wgCommentboxNamespaces[ $title->getNamespace() ] ) { $this->fail( 'commentbox-error-namespace', $title ); return; } - if( $Comment == '' || $Comment == wfMsgNoTrans( 'commentbox-prefill' ) ) { + if ( $Comment == '' || $Comment == wfMsgNoTrans( 'commentbox-prefill' ) ) { $this->fail( 'commentbox-error-empty-comment', $title ); return; } - if( !$title->userCan( 'edit' ) ) { + if ( !$title->userCan( 'edit' ) ) { $this->displayRestrictionError(); return; } @@ -53,7 +53,7 @@ // TODO: Integrate with SpamBlacklist etc. // Currently, no http/https-links are allowed at all $matches = array(); - if( preg_match( '@https?://[-.\w]+@', $Comment, $matches ) || + if ( preg_match( '@https?://[-.\w]+@', $Comment, $matches ) || preg_match( '@https?://[-.\w]+@', $Author, $matches ) ) { $wgOut->setPageTitle( wfMsg( 'spamprotectiontitle' ) ); $wgOut->setRobotPolicy( 'noindex,nofollow' ); @@ -68,37 +68,37 @@ $article = new Article( $title ); $text = $article->getContent(); $subject = ''; - if( !preg_match( wfMsgForContentNoTrans( 'commentbox-regex' ), $text ) ) - $subject = wfMsgForContent( 'commentbox-first-comment-heading' )."\n"; + if ( !preg_match( wfMsgForContentNoTrans( 'commentbox-regex' ), $text ) ) + $subject = wfMsgForContent( 'commentbox-first-comment-heading' ) . "\n"; $sig = $wgUser->isLoggedIn() ? "-- ~~~~" : "-- $Author ~~~~~"; // Append <br/> after each newline, except if the user started a new paragraph $Comment = preg_replace( '/(?<!\n)\n(?!\n)/', "<br/>\n", $Comment ); - $text .= "\n\n".$subject.$Comment."\n<br/>".$sig; + $text .= "\n\n" . $subject . $Comment . "\n<br/>" . $sig; try { - $req = new FauxRequest(array( + $req = new FauxRequest( array( 'action' => 'edit', 'title' => $title->getPrefixedText(), 'text' => $text, 'summary' => wfMsgForContent( 'commentbox-log' ), 'token' => $wgUser->editToken(), - ), true); - $api = new ApiMain($req, true); + ), true ); + $api = new ApiMain( $req, true ); $api->execute(); - wfDebug("Completed API-Save\n"); + wfDebug( "Completed API-Save\n" ); // we only reach this point if Api doesn't throw an exception $data = $api->getResultData(); - if ($data['edit']['result'] == 'Failure') { + if ( $data['edit']['result'] == 'Failure' ) { $spamurl = $data['edit']['spamblacklist']; - if ($spamurl != '') - throw new Exception("Die Seite enthaelt die Spam-Url ``{$spamurl}''"); + if ( $spamurl != '' ) + throw new Exception( "Die Seite enthaelt die Spam-Url ``{$spamurl}''" ); else - throw new Exception("Unbekannter Fehler"); + throw new Exception( "Unbekannter Fehler" ); } - } catch (Exception $e) { + } catch ( Exception $e ) { global $wgOut; $wgOut->setPageTitle( wfMsg( 'commentbox-errorpage-title' ) ); - $wgOut->addHTML("<div class='errorbox'>". htmlspecialchars($e->getMessage()). "</div><br clear='both' />" ); - if( $title != NULL ) + $wgOut->addHTML( "<div class='errorbox'>" . htmlspecialchars( $e->getMessage() ) . "</div><br clear='both' />" ); + if ( $title != NULL ) $wgOut->returnToMain( false, $title ); return; } @@ -110,8 +110,8 @@ function fail( $str, $title = NULL ) { global $wgOut; $wgOut->setPageTitle( wfMsg( 'commentbox-errorpage-title' ) ); - $wgOut->addWikiText("<div class='errorbox'>". wfMsg( $str ). "</div><br clear='both' />" ); - if( $title != NULL ) + $wgOut->addWikiText( "<div class='errorbox'>" . wfMsg( $str ) . "</div><br clear='both' />" ); + if ( $title != NULL ) $wgOut->returnToMain( false, $title ); return; } Property changes on: trunk/extensions/Commentbox/SpecialAddComment_body.php ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/extensions/Configure/Configure.settings-ext.txt =================================================================== --- trunk/extensions/Configure/Configure.settings-ext.txt 2009-08-16 09:52:10 UTC (rev 55132) +++ trunk/extensions/Configure/Configure.settings-ext.txt 2009-08-16 10:07:06 UTC (rev 55133) @@ -284,6 +284,12 @@ empty[] = wgCollectionMWServeCert: null, wgLicenseName: null, wgLicenseURL: null url = http://www.mediawiki.org/wiki/Extension:Collection +Commentbox +settings[] = wgCommentboxNamespaces: array +settings[] = wgCommentboxRows: int, wgCommentboxColumns: int +array[] = wgCommentboxNamespaces: ns-simple +url = http://www.mediawiki.org/wiki/Extension:Commentbox + CommentPages settings[] = wgCommentPagesNS: int url = http://www.mediawiki.org/wiki/Extension:CommentPages Modified: trunk/extensions/Translate/groups/mediawiki-defines.txt =================================================================== --- trunk/extensions/Translate/groups/mediawiki-defines.txt 2009-08-16 09:52:10 UTC (rev 55132) +++ trunk/extensions/Translate/groups/mediawiki-defines.txt 2009-08-16 10:07:06 UTC (rev 55133) @@ -184,6 +184,9 @@ descmsg = coll-desc ignored = coll-template_blacklist_title, coll-license_url +Commentbox +ignored = commentbox-prefill + Comment Pages ignored = commenttab-editintro, commenttab-preload _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs