Extension:LastFm
This extension stores its source code on a wiki page. Please be aware that this code may be unreviewed or maliciously altered. They may contain security holes, outdated interfaces that are no longer compatible etc. Note: No localisation updates are provided for this extension by translatewiki.net . |
This extension is currently not actively maintained! Although it may still work, any bug reports or feature requests will more than likely be ignored. |
![]() 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 |
<lastfm> |
|
The LastFm extension enables embedding the Last.fm player in a page with the <lastfm>
tag.
Usage edit
Now you can use the extension with <lastfm>Last.fm-Username</lastfm>
in the wiki
Installation edit
- 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 file:
require_once "$IP/extensions/LastFm/LastFm.php";
- Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Code edit
- 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;
}