Yaron Koren has uploaded a new change for review.
https://gerrit.wikimedia.org/r/177257
Change subject: Added #formredlink parser function, restored #formlink to
previous behavior
......................................................................
Added #formredlink parser function, restored #formlink to previous behavior
Change-Id: I48ad424432a65fb1d42493fe828f9e56cc04ecf4
---
M includes/SF_ParserFunctions.php
M includes/SF_Utils.php
M languages/SF_Magic.php
3 files changed, 30 insertions(+), 10 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticForms
refs/changes/57/177257/1
diff --git a/includes/SF_ParserFunctions.php b/includes/SF_ParserFunctions.php
index 49e8768..f39db8b 100644
--- a/includes/SF_ParserFunctions.php
+++ b/includes/SF_ParserFunctions.php
@@ -153,6 +153,7 @@
$parser->setFunctionHook( 'default_form', array(
'SFParserFunctions', 'renderDefaultForm' ) );
$parser->setFunctionHook( 'forminput', array(
'SFParserFunctions', 'renderFormInput' ) );
$parser->setFunctionHook( 'formlink', array(
'SFParserFunctions', 'renderFormLink' ) );
+ $parser->setFunctionHook( 'formredlink', array(
'SFParserFunctions', 'renderFormRedLink' ) );
$parser->setFunctionHook( 'queryformlink', array(
'SFParserFunctions', 'renderQueryFormLink' ) );
if ( defined( get_class( $parser ) . '::SFH_OBJECT_ARGS' ) ) {
$parser->setFunctionHook( 'arraymap', array(
'SFParserFunctions', 'renderArrayMapObj' ), SFH_OBJECT_ARGS );
@@ -204,7 +205,16 @@
// hack to remove newline from beginning of output, thanks to
//
http://jimbojw.com/wiki/index.php?title=Raw_HTML_Output_from_a_MediaWiki_Parser_Function
- return $parser->insertStripItem( SFUtils::createFormLink(
$parser, 'FormEdit', $params ), $parser->mStripState );
+ return $parser->insertStripItem( SFUtils::createFormLink(
$parser, $params, 'formlink' ), $parser->mStripState );
+ }
+
+ static function renderFormRedLink ( &$parser ) {
+ $params = func_get_args();
+ array_shift( $params ); // We don't need the parser.
+
+ // hack to remove newline from beginning of output, thanks to
+ //
http://jimbojw.com/wiki/index.php?title=Raw_HTML_Output_from_a_MediaWiki_Parser_Function
+ return $parser->insertStripItem( SFUtils::createFormLink(
$parser, $params, 'formredlink' ), $parser->mStripState );
}
static function renderQueryFormLink ( &$parser ) {
@@ -213,7 +223,7 @@
// hack to remove newline from beginning of output, thanks to
//
http://jimbojw.com/wiki/index.php?title=Raw_HTML_Output_from_a_MediaWiki_Parser_Function
- return $parser->insertStripItem( SFUtils::createFormLink(
$parser, 'RunQuery', $params ), $parser->mStripState );
+ return $parser->insertStripItem( SFUtils::createFormLink(
$parser, $params, 'queryformlink' ), $parser->mStripState );
}
static function renderFormInput ( &$parser ) {
@@ -542,7 +552,7 @@
}
- static function renderAutoEdit( Parser &$parser ) {
+ static function renderAutoEdit( &$parser ) {
// set defaults
$formcontent = '';
$linkString = null;
diff --git a/includes/SF_Utils.php b/includes/SF_Utils.php
index 02e30d4..ee82f18 100644
--- a/includes/SF_Utils.php
+++ b/includes/SF_Utils.php
@@ -924,12 +924,11 @@
return true;
}
- static function createFormLink ( &$parser, $specialPageName, $params ) {
+ static function createFormLink ( &$parser, $params, $parserFunctionName
) {
// Set defaults.
$inFormName = $inLinkStr = $inLinkType = $inTooltip =
$inQueryStr = $inTargetName = '';
- $inEditExistingTarget = false;
- if ( $specialPageName == 'RunQuery' ) {
+ if ( $parserFunctionName == 'queryformlink' ) {
$inLinkStr = wfMessage( 'runquery' )->text();
}
$classStr = '';
@@ -981,8 +980,6 @@
$classStr = 'popupformlink';
} elseif ( $param_name == null && $value == 'new
window' ) {
$targetWindow = '_blank';
- } elseif ( $param_name == null && $value == 'edit
existing target' ) {
- $inEditExistingTarget = true;
} elseif ( $param_name !== null &&
!$positionalParameters ) {
$value = urlencode( $value );
parse_str( "$param_name=$value", $arr );
@@ -1005,6 +1002,13 @@
}
}
+ // Not the most graceful way to do this, but it is the
+ // easiest - if this is the #formredlink function, just
+ // ignore whatever values were passed in for these params.
+ if ( $parserFunctionName == 'formredlink' ) {
+ $inLinkStr = $inLinkType = $inTooltip = null;
+ }
+
// If "red link only" was specified, and a target page was
// specified, and it exists, just link to the page.
if ( $inTargetName != '' ) {
@@ -1014,11 +1018,16 @@
$targetPageExists = false;
}
- if ( !$inEditExistingTarget && $targetPageExists ) {
+ if ( $parserFunctionName == 'formredlink' && $targetPageExists
) {
return Linker::link( $targetTitle );
}
- $formSpecialPage = SpecialPageFactory::getPage(
$specialPageName );
+ if ( $parserFunctionName == 'queryformlink' ) {
+ $formSpecialPage = SpecialPageFactory::getPage(
'RunQuery' );
+ } else {
+ $formSpecialPage = SpecialPageFactory::getPage(
'FormEdit' );
+ }
+
if ( strpos( $inFormName, '/' ) == true ) {
$query = array( 'form' => $inFormName, 'target' =>
$inTargetName );
$link_url = $formSpecialPage->getTitle()->getLocalURL(
$query );
diff --git a/languages/SF_Magic.php b/languages/SF_Magic.php
index 56b41d6..01f1bdf 100644
--- a/languages/SF_Magic.php
+++ b/languages/SF_Magic.php
@@ -11,6 +11,7 @@
'default_form' => array( 0, 'default_form' ),
'forminput' => array( 0, 'forminput' ),
'formlink' => array( 0, 'formlink' ),
+ 'formredlink' => array( 0, 'formredlink' ),
'queryformlink' => array( 0, 'queryformlink' ),
'arraymap' => array( 0, 'arraymap' ),
'arraymaptemplate' => array( 0, 'arraymaptemplate' ),
--
To view, visit https://gerrit.wikimedia.org/r/177257
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I48ad424432a65fb1d42493fe828f9e56cc04ecf4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticForms
Gerrit-Branch: master
Gerrit-Owner: Yaron Koren <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits