r111426 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111425‎ | r111426 | r111427 >
Date:22:13, 13 February 2012
Author:bsitu
Status:ok (Comments)
Tags:
Comment:
alter "create page" link behavior in search result page
Modified paths:
  • /trunk/extensions/ArticleCreationWorkflow/ArticleCreationWorkflow.hooks.php (modified) (history)
  • /trunk/extensions/ArticleCreationWorkflow/ArticleCreationWorkflow.php (modified) (history)
  • /trunk/extensions/ArticleCreationWorkflow/modules/ext.articleCreation.searchResult (added) (history)
  • /trunk/extensions/ArticleCreationWorkflow/modules/ext.articleCreation.searchResult/ext.articleCreation.searchResult.js (added) (history)

Diff [purge]

Index: trunk/extensions/ArticleCreationWorkflow/modules/ext.articleCreation.searchResult/ext.articleCreation.searchResult.js
@@ -0,0 +1,9 @@
 2+(function($,mw) {
 3+ var newTitle = 'Special:ArticleCreationLanding' + '/' +
 4+ encodeURIComponent(mw.config.get('acSearch'));
 5+ var landingURL = mw.config.get('wgArticlePath').replace( '$1', newTitle );
 6+ // change the link to point to the new special page
 7+ $("div.searchresults")
 8+ .find('a[href*="action=edit"]')
 9+ .attr( 'href', landingURL );
 10+})( jQuery, window.mediaWiki );
Property changes on: trunk/extensions/ArticleCreationWorkflow/modules/ext.articleCreation.searchResult/ext.articleCreation.searchResult.js
___________________________________________________________________
Added: svn:eol-style
111 + native
Index: trunk/extensions/ArticleCreationWorkflow/ArticleCreationWorkflow.php
@@ -28,6 +28,7 @@
2929 $wgHooks['BeforeDisplayNoArticleText'][] = 'ArticleCreationHooks::BeforeDisplayNoArticleText';
3030 $wgHooks['BeforeWelcomeCreation'][] = 'ArticleCreationHooks::BeforeWelcomeCreation';
3131 $wgHooks['AlternateEdit'][] = 'ArticleCreationHooks::AlternateEdit';
 32+$wgHooks['SpecialSearchCreateLink'][] = 'ArticleCreationHooks::SpecialSearchCreateLink';
3233
3334 $wgHooks['ResourceLoaderGetConfigVars'][] = 'ArticleCreationHooks::resourceLoaderGetConfigVars';
3435
@@ -44,6 +45,10 @@
4546 'scripts' => 'ext.articleCreation.init/ext.articleCreation.init.js',
4647 );
4748
 49+$wgResourceModules['ext.articleCreation.searchResult'] = $acResourceTemplate + array(
 50+ 'scripts' => 'ext.articleCreation.searchResult/ext.articleCreation.searchResult.js',
 51+);
 52+
4853 $wgResourceModules['ext.articleCreation.core'] = $acResourceTemplate + array (
4954 'styles' => 'ext.articleCreation.core/ext.articleCreation.core.css',
5055 'scripts' => 'ext.articleCreation.core/ext.articleCreation.core.js',
Index: trunk/extensions/ArticleCreationWorkflow/ArticleCreationWorkflow.hooks.php
@@ -78,4 +78,26 @@
7979 return true;
8080 }
8181
 82+ public static function configSearchTitle( &$vars ) {
 83+ global $wgRequest;
 84+
 85+ $vars['acSearch'] = $wgRequest->getVal( 'search' );
 86+
 87+ return true;
 88+ }
 89+
 90+ /**
 91+ * Alter 'Create' Link behavior in search result page
 92+ */
 93+ public static function SpecialSearchCreateLink( $title, &$params ) {
 94+ global $wgOut, $wgHooks;
 95+
 96+ if ( ArticleCreationUtil::isEnabled() ) {
 97+ $wgHooks['MakeGlobalVariablesScript'][] = 'ArticleCreationHooks::configSearchTitle';
 98+ $wgOut->addModules( array( 'ext.articleCreation.searchResult' ) );
 99+ }
 100+
 101+ return true;
 102+ }
 103+
82104 }

Comments

#Comment by Raindrift (talk | contribs)   18:41, 17 February 2012

Does the JS code here need to check the user's bucket, or do users outside the test bucket get redirected when they hit the Special page?

#Comment by Bsitu (talk | contribs)   19:33, 17 February 2012

ArticleCreationUtil::isEnabled() is checking the users's bucket, if it's off, then redlink behavior won't be altered

#Comment by Raindrift (talk | contribs)   19:39, 17 February 2012

Oh, I see. Totally. Thanks for clarifying.  :)

Status & tagging log