r101580 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101579‎ | r101580 | r101581 >
Date:03:13, 2 November 2011
Author:yaron
Status:ok
Tags:
Comment:
Added handling for new 'title=' parameter for #formlink, based on a patch from Van de Bugger; also removed hardcoded HTML from link-display code
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_ParserFunctions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_ParserFunctions.php
@@ -41,7 +41,7 @@
4242 *
4343 * 'formlink' is called as:
4444 *
45 - * {{#formlink:form=|link text=|link type=|query string=}}
 45+ * {{#formlink:form=|link text=|link type=|title=|query string=|target=}}
4646 *
4747 * This function returns HTML representing a link to a form; given that
4848 * no page name is entered by the the user, the form must be one that
@@ -53,9 +53,12 @@
5454 * the link: if set to 'button', the link will be a button; if set to
5555 * 'post button', the link will be a button that uses the 'POST' method to
5656 * send other values to the form; if set to anything else or not called, it
57 - * will be a standard hyperlink. 'query string' is the text to be added to
58 - * the generated URL's query string (or, in the case of 'post button' to
59 - * be sent as hidden inputs).
 57+ * will be a standard hyperlink. 'title' sets the 'title' HTML attribute
 58+ * for the link, if it's an actual link; i.e., the hovering tooltip text.
 59+ * 'query string' is the text to be added to the generated URL's query
 60+ * string (or, in the case of 'post button' to be sent as hidden inputs).
 61+ * 'target' is an optional value, setting the name of the page to be
 62+ * edited by the form.
6063 *
6164 * Example: to create a link to add data with a form called
6265 * 'User' within a namespace also called 'User', and to have the form
@@ -155,9 +158,10 @@
156159 global $wgVersion;
157160
158161 $params = func_get_args();
159 - array_shift( $params ); // don't need the parser
160 - // set defaults
161 - $inFormName = $inLinkStr = $inLinkType = $inQueryStr = $inTargetName = '';
 162+ array_shift( $params ); // We don't need the parser.
 163+ // Set defaults.
 164+ $inFormName = $inLinkStr = $inLinkType = $inTitle =
 165+ $inQueryStr = $inTargetName = '';
162166 $classStr = "";
163167 // assign params - support unlabelled params, for backwards compatibility
164168 foreach ( $params as $i => $param ) {
@@ -176,6 +180,8 @@
177181 $inLinkType = $value;
178182 } elseif ( $param_name == 'query string' ) {
179183 $inQueryStr = $value;
 184+ } elseif ( $param_name == 'title' ) {
 185+ $inTitle = $value;
180186 } elseif ( $param_name == 'target' ) {
181187 $inTargetName = $value;
182188 } elseif ( $param_name == null && $value == 'popup'
@@ -245,7 +251,7 @@
246252 $classStr .= " new";
247253 }
248254 }
249 - $str = "<a href=\"$link_url\" class=\"$classStr\">$inLinkStr</a>";
 255+ $str = Xml::element( 'a', array( 'href' => $link_url, 'class' => $classStr, 'title' => $inTitle ), $inLinkStr );
250256 }
251257 // hack to remove newline from beginning of output, thanks to
252258 // http://jimbojw.com/wiki/index.php?title=Raw_HTML_Output_from_a_MediaWiki_Parser_Function

Follow-up revisions

RevisionCommit summaryAuthorDate
r101674Follow-up to r101580 - added decodeCharReferences() call from patchyaron20:31, 2 November 2011

Status & tagging log