plugins:mcmediaplayer:mcmediaplayer_code

NP_MCMediaPlayer.php Source Code

<?php
/*
	Name:NP_MCMediaPlayer
	License:GPL
	History:
		0.1a:  (2008-03-29) First Release.
		0.2a:  (2008-04-15) Deleate Options.
		0.3a:  (2008-04-19) Bug Fixed.
		0.32a: (2008-08-22) Bug Fixed, Surport mp4 format.
		0.33a: (2008-09-20) Bug Fixed.
*/
 
class NP_MCMediaPlayer extends NucleusPlugin {
	function getName() { return 'NP_MCMediaPlayer'; }
	function getAuthor() { return 'floors'; }
	function getURL() { return 'http://japan.nucleuscms.org/wiki/plugins:mcmediaplayer'; }
	function getVersion() { return '0.33a'; }
	function getDescription() { return 'A single-file video player designed to be both easy to set up and extremely customisable. Supports FLV and H.264.'; }
	function supportsFeature($what) { switch($what) { case 'SqlTablePrefix': return 1; default: return 0; } }
 
 
 
	function install() {
		//MC Altair Option
		$this->createOption('playerURI','Flash Media Player URI','text','http://');
		$this->createOption('jsURI','Javascript URI','text','http://');
		$this->createOption('movieWidth','Default Movie Width','text','300','numerical=true');
		$this->createOption('movieHeight','Default Movie Height','text','225','numerical=true');
	}
 
	function getEventList() {return array('PreItem');}
	function event_PreItem($data) {
		$this->currentItem = &$data["item"]; 
		$this->currentItem->body = preg_replace_callback("/<\%media\((.*)\)%\>/Us", array(&$this, 'MCMediaPlayer'), $this->currentItem->body);
		$this->currentItem->more = preg_replace_callback("/<\%media\((.*)\)%\>/Us", array(&$this, 'MCMediaPlayer'), $this->currentItem->more);
	}
 
 
 
	function MCMediaPlayer($matches) {
		global $CONF;
 
		$mcarray = array();
		$mcarray = explode("|",htmlspecialchars($matches[1],ENT_QUOTES,_CHARSET));
 
		$filename = $mcarray[0];
		$explanation = $mcarray[1];
		$width = (int) $mcarray[2];
		$height = (int) $mcarray[3];
 
		$searchdot = strrpos($filename,".");
		$tail = substr($filename,$searchdot,strlen($filename)-$searchdot+1);
		$permit_ext = array(".flv", ".m4v", ".mov", ".mp4");
 
		if(in_array($tail,$permit_ext)) {
			if($width == 0) {$width = $this->getOption('movieWidth');}
			if($height == 0) {$height = $this->getOption('movieHeight');}
			if(!strstr($filename,'/')) {$media = $this->currentItem->authorid;}
 
			$media = $CONF['MediaURL']. $media;
			$swfuri = $this->getOption('playerURI');
			$jsuri = $this->getOption('jsURI');
 
			$text = '<div class="MCMediaPlayerArea">
			<script type="text/javascript">
			playerFile = "'.$swfuri.'";
			fpFileURL = "'.$media.'/'.$filename.'";
			playerSize = "'.$width.'x'.$height.'";
			</script>
			<script type="text/javascript" src="'.$jsuri.'"></script>
			<noscript><p class="noMCMediaPlayer"><em><a href="'.$media.'/'.$filename.'">Movie: '.$explanation.' (Direct Link)</a></em></p></noscript>
			</div>';
			} else {
			$text = <<<EOD
<%media($filename|$explanation|$width|$height)%>
EOD;
		}
		return $text;
 
 
 
	}
}
?>
 
plugins/mcmediaplayer/mcmediaplayer_code.txt · 最終更新: 2011/03/23 21:28 (外部編集)