![]() Release status: unmaintained |
|
---|---|
Implementation | Tag |
Description | Enables embedding the Last.fm player in a page with the <lastfm> tag. |
Author(s) | Guy Taylor (TheBigGuytalk) |
Latest version | 0.2 (2008-05-20) |
MediaWiki | |
Database changes | No |
License | No license specified |
Download | See the code section |
Tags
<lastfm> |
|
The LastFm extension enables embedding the Last.fm player in a page with the <lastfm>
tag.
Usage
Now you can use the extension with <lastfm>Last.fm-Username</lastfm>
in the wiki
Installation
- Copy the code into a file and place the file(s) in a directory called
LastFm
in yourextensions/
folder. - Add the following code at the bottom of your LocalSettings.php
require_once "$IP/extensions/LastFm/LastFm.php";
file: Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Code
- LastFm.php
<?php
/**
* LastFm extension for MediaWiki
*
* @author Guy Taylor
* @copyright © Guy Taylor
* @version 0.2
* @link https://www.mediawiki.org/wiki/Extension:LastFm
*/
if ( !defined( 'MEDIAWIKI' ) ) {
die( 'This is not a valid entry point.' );
}
// Extension credits that show up on Special:Version
$wgExtensionCredits['parserhook'][] = array(
'name' => 'LastFm',
'author' => 'Guy Taylor',
'version' => '0.2',
'url' => 'https://www.mediawiki.org/wiki/Extension:LastFm',
'description' => 'Allows to adds the Last.fm player to a page with the <tt><lastfm></tt> tag'
);
$wgExtensionFunctions[] = 'wfLastFm';
function wfLastFm() {
global $wgParser;
$wgParser->setHook( 'lastfm', 'renderLastFm' );
}
# The callback function for converting the input text to HTML output
function renderLastFm( $input ) {
$output = "<!-- Last.fm http://www.last.fm/ -->";
$output = "<a href=\"http://www.last.fm/user/";
$output .= htmlspecialchars($input);
$output .= "/?chartstyle=tracks\">";
$output .= "<img src=\"http://imagegen.last.fm/tracks/artists/";
$output .= htmlspecialchars($input);
$output .= ".gif\" border=\"0\" alt=\"";
$output .= htmlspecialchars($input);
$output .= "'s Last.fm Weekly Artists Chart\" /></a>";
return $output;
}
This article is issued from Mediawiki. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.