Last modified: 2013-01-21 21:24:05 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T45220, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 43220 - mw:extension:Listings needs to be able to override defaults for listing format and parameters
mw:extension:Listings needs to be able to override defaults for listing forma...
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
Listings (Other open bugs)
master
All All
: High normal with 1 vote (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks: 41184
  Show dependency treegraph
 
Reported: 2012-12-18 03:53 UTC by Carl Austin Bennett
Modified: 2013-01-21 21:24 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
patch to allow template to override default Wikivoyage listing format (706 bytes, patch)
2012-12-18 03:53 UTC, Carl Austin Bennett
Details
Listings.body.php with patch applied to allow template to override listing format (8.99 KB, application/x-php)
2012-12-18 03:59 UTC, Carl Austin Bennett
Details

Description Carl Austin Bennett 2012-12-18 03:53:12 UTC
Created attachment 11533 [details]
patch to allow template to override default Wikivoyage listing format

The format of a Wikivoyage listing tag, as generated by [[mw:extension:listings]], is hard-coded and rather inflexible. A mechanism is needed to allow the parameters or presentation style to be changed without editing the PHP code each time.

The listings are tags (eat, drink, see, do, buy, sleep) for historical reasons. All behave identically; the parameters are fed into Listings.body.php where private static function listingsTag( $aType, $input, $args, $parser ) is effectively a template written in hard-coded PHP.

There has already been at least one request on [[voy:Wikivoyage_talk:Listings]] to change this hard-coded format but that can't be done if there's no way to override the listingsTag() function.

I propose, simply, to change listingsTag() to look for a plain, standard template. If one exists, call it and let it deal with formatting the listing; if not, proceed as before.

The change requires inserting the following code into Listings.body.php at the start of the listingsTag() function:

	private static function listingsTag( $aType, $input, $args, $parser ) {

		/*
		 * if a {{listings}} template exists, feed tag name and parameter list to template verbatim and exit
		 */
		$ltemplate='';
		if ( !wfMessage( 'listings-template' )->inContentLanguage()->isDisabled() )
			$ltemplate = wfMessage( 'listings-template' )->inContentLanguage()->text();
		if ( $ltemplate != '' ) {
			$inputtext = '{{' . $ltemplate . '|type=' . $aType;
			foreach ($args as $key => $value)
				$inputtext .= '|' . $key . '=' . $value;
			$inputtext .= '|' . $input . '}}';
			$out .= $parser->internalParse( $inputtext );
			return $out;
		}

		/*
		 * if no pre-defined template exists, generate listing from parameters normally
		 */
Comment 1 Carl Austin Bennett 2012-12-18 03:59:29 UTC
Created attachment 11534 [details]
Listings.body.php with patch applied to allow template to override listing format

When the patch is initially applied, the extension continues to operate as it always has... until [[mediawiki:listings-template]] is created and set to the name of a template (ie: "listing" for [[voy:template:listing]], which would work well with this code were the leading "* " removed from the template).

Once the listings template is defined, listingsTag() generates {{ listings-template | type= (eat, drink, sleep) | name=...and any other parameters, passed through as-is| listing $input text... }}, feeds it to the parser to expand the template to output text and then exits without doing much of anything else - effectively shutting down the hard-coded output formatting built into the extension.
Comment 2 Andre Klapper 2012-12-18 10:53:59 UTC
Hi! Thanks for your patch!

You are welcome to use Developer access
  https://www.mediawiki.org/wiki/Developer_access
to submit this as a Git branch directly into Gerrit:
  https://www.mediawiki.org/wiki/Git/Tutorial

Putting your branch in Git makes it easier for us to review it quickly.
Thanks again! We appreciate your contribution.
Comment 3 Carl Austin Bennett 2012-12-19 17:10:41 UTC
https://gerrit.wikimedia.org/r/#/c/39394/
Comment 4 Carl Austin Bennett 2013-01-04 15:52:56 UTC
How do I get this fix verified and code reviewed for deployment? 

It has been sitting in 'git' untouched since Dec 22, 2012 7:27 PM and it *is* needed if Wikivoyage is to add wp="" (to link from an individual listing to a Wikipedia article on a landmark) or any other new fields using the template.

See http://en.wikivoyage.org/wiki/Wikivoyage_talk:Listings
Comment 5 Alex Monk 2013-01-17 17:03:37 UTC
Someone with access must approve it. It seems that Matthias Mullie should really be the person to ask, though technically others (https://gerrit.wikimedia.org/r/#/admin/groups/11,members) are capable of it.
Comment 6 Alex Monk 2013-01-21 19:13:25 UTC
Matthias Mullie approved that change - is this bug fixed now?
Comment 7 Carl Austin Bennett 2013-01-21 19:20:44 UTC
If by "approved" this means "currently waiting for deployment", that would remove patch-needs-review and add a shell request to deploy this to Wikivoyage?
Comment 8 Alex Monk 2013-01-21 21:23:48 UTC
By approved it means currently in the master version of the code, so marking this bug as RESOLVED FIXED.

As for when Wikimedia updates their copy of the extension... Well, this seems like an enhancement to me so I doubt it'll be deployed before 1.21wmf9 phase 2.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links