| Index: trunk/extensions/BlogPage/SpecialCreateBlogPost.php |
| — | — | @@ -5,7 +5,7 @@ |
| 6 | 6 | * |
| 7 | 7 | * @file |
| 8 | 8 | * @ingroup Extensions |
| 9 | | - * @date 16 July 2011 |
| | 9 | + * @date 4 January 2012 |
| 10 | 10 | */ |
| 11 | 11 | class SpecialCreateBlogPost extends SpecialPage { |
| 12 | 12 | |
| — | — | @@ -24,7 +24,7 @@ |
| 25 | 25 | * @param $par Mixed: parameter passed to the special page or null |
| 26 | 26 | */ |
| 27 | 27 | public function execute( $par ) { |
| 28 | | - global $wgOut, $wgUser, $wgRequest, $wgContLang, $wgScriptPath, $wgHooks; |
| | 28 | + global $wgOut, $wgUser, $wgRequest, $wgContLang; |
| 29 | 29 | |
| 30 | 30 | // If the user can't create blog posts, display an error |
| 31 | 31 | if( !$wgUser->isAllowed( 'createblogpost' ) ) { |
| — | — | @@ -47,19 +47,8 @@ |
| 48 | 48 | // Set page title, robot policies, etc. |
| 49 | 49 | $this->setHeaders(); |
| 50 | 50 | |
| 51 | | - // i18n for JS |
| 52 | | - $wgHooks['MakeGlobalVariablesScript'][] = 'SpecialCreateBlogPost::addJSGlobals'; |
| 53 | | - |
| 54 | 51 | // Add CSS & JS |
| 55 | | - if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) ) { |
| 56 | | - $wgOut->addModules( array( |
| 57 | | - 'mediawiki.legacy.edit', 'ext.blogPage.create' |
| 58 | | - ) ); |
| 59 | | - } else { |
| 60 | | - $wgOut->addExtensionStyle( $wgScriptPath . '/extensions/BlogPage/CreateBlogPost.css' ); |
| 61 | | - $wgOut->addScriptFile( $wgScriptPath . '/extensions/BlogPage/CreateBlogPost.js' ); |
| 62 | | - $wgOut->addScriptFile( 'edit.js' ); // for the edit toolbar |
| 63 | | - } |
| | 52 | + $wgOut->addModules( 'ext.blogPage.create' ); |
| 64 | 53 | |
| 65 | 54 | // If the request was POSTed, we haven't submitted a request yet AND |
| 66 | 55 | // we have a title, create the page...otherwise just display the |
| — | — | @@ -225,7 +214,11 @@ |
| 226 | 215 | '</span><br />'; |
| 227 | 216 | // The EditPage toolbar wasn't originally present here but I figured |
| 228 | 217 | // that adding it might be more helpful than anything else. |
| 229 | | - $output .= EditPage::getEditToolbar(); |
| | 218 | + // Guess what...turns out that resources/mediawiki.action/mediawiki.action.edit.js |
| | 219 | + // assumes way too many things and no longer is suitable for different |
| | 220 | + // editing interfaces, such as this special page. |
| | 221 | + // I miss the old edit.js... |
| | 222 | + //$output .= EditPage::getEditToolbar(); |
| 230 | 223 | $output .= '<textarea class="createbox" tabindex="' . |
| 231 | 224 | $this->tabCounter . '" accesskey="," name="pageBody" id="pageBody" rows="10" cols="80"></textarea><br /><br />'; |
| 232 | 225 | $this->tabCounter++; |
| — | — | @@ -253,7 +246,7 @@ |
| 254 | 247 | $slashedTag = str_replace( "'", "\'", $tag ); |
| 255 | 248 | } |
| 256 | 249 | $tagcloud .= " <span id=\"tag-{$tagnumber}\" style=\"font-size:{$cloud->tags[$tag]['size']}{$cloud->tags_size_type}\"> |
| 257 | | - <a class=\"tag-cloud-entry\" onclick=\"javascript:CreateBlogPost.insertTag('" . $slashedTag . "',{$tagnumber});\">{$tag}</a> |
| | 250 | + <a class=\"tag-cloud-entry\" data-blog-slashed-tag=\"" . $slashedTag . "\" data-blog-tag-number=\"{$tagnumber}\">{$tag}</a> |
| 258 | 251 | </span>"; |
| 259 | 252 | $tagnumber++; |
| 260 | 253 | } |
| — | — | @@ -313,8 +306,8 @@ |
| 314 | 307 | |
| 315 | 308 | $output .= "\n" . $this->displayFormPageCategories() . "\n"; |
| 316 | 309 | $output .= "\n" . $this->displayCopyrightWarning() . "\n"; |
| 317 | | - $output .= '<input type="button" onclick="CreateBlogPost.performChecks()" value="' . |
| 318 | | - wfMsg( 'blog-create-button' ) . '" name="wpSave" class="createsubmit site-button" accesskey="s" title="' . |
| | 310 | + $output .= '<input type="button" value="' . wfMsg( 'blog-create-button' ) . |
| | 311 | + '" name="wpSave" class="createsubmit site-button" accesskey="s" title="' . |
| 319 | 312 | wfMsg( 'tooltip-save' ) . ' [alt-s]" /> |
| 320 | 313 | <input type="hidden" value="" name="wpSection" /> |
| 321 | 314 | <input type="hidden" value="" name="wpEdittime" /> |
| — | — | @@ -352,17 +345,4 @@ |
| 353 | 346 | return 'OK'; |
| 354 | 347 | } |
| 355 | 348 | } |
| 356 | | - |
| 357 | | - /** |
| 358 | | - * Add i18n messages for the JS file. |
| 359 | | - * |
| 360 | | - * @param $vars Array: array of pre-existing JavaScript globals |
| 361 | | - * @return Boolean: true |
| 362 | | - */ |
| 363 | | - public static function addJSGlobals( $vars ) { |
| 364 | | - $vars['_BLOG_NEEDS_CONTENT'] = wfMsg( 'blog-js-create-error-need-content' ); |
| 365 | | - $vars['_BLOG_NEEDS_TITLE'] = wfMsg( 'blog-js-create-error-need-title' ); |
| 366 | | - $vars['_BLOG_PAGE_EXISTS'] = wfMsg( 'blog-js-create-error-page-exists' ); |
| 367 | | - return true; |
| 368 | | - } |
| 369 | 349 | } |
| \ No newline at end of file |
| Index: trunk/extensions/BlogPage/SpecialArticlesHome.php |
| — | — | @@ -30,11 +30,7 @@ |
| 31 | 31 | $wgSupressPageTitle = true; |
| 32 | 32 | |
| 33 | 33 | // Add CSS |
| 34 | | - if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) ) { |
| 35 | | - $wgOut->addModules( 'ext.blogPage.articlesHome' ); |
| 36 | | - } else { |
| 37 | | - $wgOut->addExtensionStyle( $wgScriptPath . '/extensions/BlogPage/ArticlesHome.css' ); |
| 38 | | - } |
| | 34 | + $wgOut->addModules( 'ext.blogPage.articlesHome' ); |
| 39 | 35 | |
| 40 | 36 | if( !$type ) { |
| 41 | 37 | $type = 'popular'; |
| Index: trunk/extensions/BlogPage/CreateBlogPost.js |
| — | — | @@ -27,12 +27,12 @@ |
| 28 | 28 | // name |
| 29 | 29 | var title = document.getElementById( 'title' ).value; |
| 30 | 30 | if ( !title || title == '' ) { |
| 31 | | - alert( _BLOG_NEEDS_TITLE ); |
| | 31 | + alert( mw.msg( 'blog-js-create-error-need-title' ) ); |
| 32 | 32 | return ''; |
| 33 | 33 | } |
| 34 | 34 | var pageBody = document.getElementById( 'pageBody' ).value; |
| 35 | 35 | if ( !pageBody || pageBody == '' ) { |
| 36 | | - alert( _BLOG_NEEDS_CONTENT ); |
| | 36 | + alert( mw.msg( 'blog-js-create-error-need-content' ) ); |
| 37 | 37 | return ''; |
| 38 | 38 | } |
| 39 | 39 | |
| — | — | @@ -41,8 +41,26 @@ |
| 42 | 42 | if( r.responseText.indexOf( 'OK' ) >= 0 ) { |
| 43 | 43 | document.editform.submit(); |
| 44 | 44 | } else { |
| 45 | | - alert( _BLOG_PAGE_EXISTS ); |
| | 45 | + alert( mw.msg( 'blog-js-create-error-page-exists' ) ); |
| 46 | 46 | } |
| 47 | 47 | }); |
| 48 | 48 | } |
| 49 | | -}; |
| \ No newline at end of file |
| | 49 | +}; |
| | 50 | + |
| | 51 | +jQuery( document ).ready( function() { |
| | 52 | + // Tag cloud |
| | 53 | + jQuery( 'a.tag-cloud-entry' ).each( function( index ) { |
| | 54 | + var that = jQuery( this ); |
| | 55 | + that.click( function() { |
| | 56 | + CreateBlogPost.insertTag( |
| | 57 | + that.data( 'blog-slashed-tag' ), |
| | 58 | + that.data( 'blog-tag-number' ) |
| | 59 | + ); |
| | 60 | + } ); |
| | 61 | + } ); |
| | 62 | + |
| | 63 | + // Save button |
| | 64 | + jQuery( 'input[name="wpSave"]' ).click( function() { |
| | 65 | + CreateBlogPost.performChecks(); |
| | 66 | + } ); |
| | 67 | +} ); |
| \ No newline at end of file |
| Index: trunk/extensions/BlogPage/Blog.php |
| — | — | @@ -5,7 +5,7 @@ |
| 6 | 6 | * |
| 7 | 7 | * @file |
| 8 | 8 | * @ingroup Extensions |
| 9 | | - * @version 2.0 |
| | 9 | + * @version 2.1 |
| 10 | 10 | * @author David Pean <david.pean@gmail.com> |
| 11 | 11 | * @author Jack Phoenix <jack@countervandalism.net> |
| 12 | 12 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
| — | — | @@ -18,7 +18,7 @@ |
| 19 | 19 | // Extension credits that will show up on Special:Version |
| 20 | 20 | $wgExtensionCredits['other'][] = array( |
| 21 | 21 | 'name' => 'BlogPage', |
| 22 | | - 'version' => '2.0', |
| | 22 | + 'version' => '2.1', |
| 23 | 23 | 'author' => array( 'David Pean', 'Jack Phoenix' ), |
| 24 | 24 | 'description' => 'Blogging system with commenting and voting features, ' . |
| 25 | 25 | '[[Special:CreateBlogPost|a special page to create blog posts]] and ' . |
| — | — | @@ -50,11 +50,11 @@ |
| 51 | 51 | $wgResourceModules['ext.blogPage.create'] = $blogResourceTemplate + array( |
| 52 | 52 | 'styles' => 'CreateBlogPost.css', |
| 53 | 53 | 'scripts' => 'CreateBlogPost.js', |
| | 54 | + //'dependencies' => 'mediawiki.action.edit', |
| 54 | 55 | 'messages' => array( |
| 55 | 56 | 'blog-js-create-error-need-content', 'blog-js-create-error-need-title', |
| 56 | 57 | 'blog-js-create-error-page-exists' |
| 57 | | - ), |
| 58 | | - 'position' => 'top' // available since r85616 |
| | 58 | + ) |
| 59 | 59 | ); |
| 60 | 60 | |
| 61 | 61 | // Default setup for displaying sections |
| Index: trunk/extensions/BlogPage/SpecialArticleLists.php |
| — | — | @@ -34,11 +34,7 @@ |
| 35 | 35 | // @todo FIXME: this should be loaded when including the special page, |
| 36 | 36 | // too, but if ( $this->including() ) does nothing, prolly because of |
| 37 | 37 | // the parser cache |
| 38 | | - if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) ) { |
| 39 | | - $wgOut->addModules( 'ext.blogPage.articlesHome' ); |
| 40 | | - } else { |
| 41 | | - $wgOut->addExtensionStyle( $wgScriptPath . '/extensions/BlogPage/ArticlesHome.css' ); |
| 42 | | - } |
| | 38 | + $wgOut->addModules( 'ext.blogPage.articlesHome' ); |
| 43 | 39 | |
| 44 | 40 | $imgPath = $wgScriptPath . '/extensions/BlogPage/images/'; |
| 45 | 41 | |
| Index: trunk/extensions/BlogPage/BlogHooks.php |
| — | — | @@ -36,11 +36,7 @@ |
| 37 | 37 | $wgOut->enableClientCache( false ); |
| 38 | 38 | |
| 39 | 39 | // Add CSS |
| 40 | | - if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) ) { |
| 41 | | - $wgOut->addModules( 'ext.blogPage' ); |
| 42 | | - } else { |
| 43 | | - $wgOut->addExtensionStyle( $wgScriptPath . '/extensions/BlogPage/BlogPage.css' ); |
| 44 | | - } |
| | 40 | + $wgOut->addModules( 'ext.blogPage' ); |
| 45 | 41 | |
| 46 | 42 | // This originally used $wgTitle but I saw no point in that, so I |
| 47 | 43 | // changed that as per Chad et al. |
| — | — | @@ -59,6 +55,7 @@ |
| 60 | 56 | */ |
| 61 | 57 | public static function allowShowEditBlogPage( $editPage ) { |
| 62 | 58 | global $wgOut, $wgUser; |
| | 59 | + |
| 63 | 60 | if( $editPage->mTitle->getNamespace() == NS_BLOG ) { |
| 64 | 61 | if( $wgUser->isAnon() ) { // anons can't edit blog pages |
| 65 | 62 | if( !$editPage->mTitle->exists() ) { |
| — | — | @@ -74,6 +71,7 @@ |
| 75 | 72 | return false; |
| 76 | 73 | } |
| 77 | 74 | } |
| | 75 | + |
| 78 | 76 | return true; |
| 79 | 77 | } |
| 80 | 78 | |