Source : extensions/music.php

From CreativeWiki
Jump to: navigation, search
<?php

/*******************************************************************************
*                                                                              *
* Music Extension by nate larson				                          *
*                                                                              *
********************************************************************************/

$wgExtensionFunctions[] = 'wfMusic';
$wgExtensionCredits['parserhook'][] = array(
       'name' => 'Music',
       'description' => 'Music Flash Player from http://www.jeroenwijering.com',
       'author' => 'nate larson',
       'url' => 'http://www.creativityexchange.org'
);

function wfMusic() {
	global $wgParser;
	$wgParser->setHook('music', 'renderMusic');
}


# Takes input of the text tagged by this extension in the wiki and outputs HTML
function renderMusic($input, $args) {
	$input = htmlspecialchars($input); // converts special chars

	$params = explode ("|", $input);   // creates an array params of the text in input split up by "|"
	$artistName = $params[0];          // first param is expected to be an artist name
	$width = 640;                      // flash player's width
	$height = 372;                     // flash player's height

	$playlistLocation = '../music/'.$artistName.'/playlist_generator.php';  // where the flash player looks for a playlist


	// output is the HTML string to pass to user's browser
	$output= '<embed src="http://creativityexchange.org/media/mediaplayer.swf" 
		width="'.$width.'" 
		height="'.$height.'"
		allowscriptaccess="always" 
		allowfullscreen="true" 
		flashvars="file='.$playlistLocation.'&displayheight=0&displaywidth=640&autoscroll=true&showicons=false&showeq=false&showdownload=true&thumbsinplaylist=false&autostart=true&searchbar=false"
		/>';


	return $output;
}
?>