forked from chimeric/dokuwiki-plugin-mp3play
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
darcs-hash:20080815175253-23886-f8f729883e14fa69a57662ddf0a08be26a967059.gz
- Loading branch information
Michael Klier
committed
Aug 15, 2008
0 parents
commit fe28c82
Showing
8 changed files
with
567 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Mp3Play Plugin for DokuWiki | ||
|
||
This plugin is a DokuWiki port of the well known Audio Player Wordpress Plugin | ||
http://www.1pixelout.net/code/audio-player-wordpress-plugin/ | ||
|
||
All documentation for the Mp3Play Plugin is available online at: | ||
http://dokuwiki.org/plugin:mp3play | ||
|
||
(c) 2008 by Michael Klier <chi@chimeric.de> | ||
See COPYING for license info. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2008-08-15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Color configuration for DokuWiki Plugin Mp3Play | ||
# IMPORTANT: Colors have to be in hex notation!!! | ||
bg = f8f8f8 | ||
leftbg = eeeeee | ||
lefticon = 666666 | ||
rightbg = cccccc | ||
rightbghover = 999999 | ||
righticon = 666666 | ||
righticonhover = ffffff | ||
text = 666666 | ||
slider = 666666 | ||
track = ffffff | ||
border = 666666 | ||
loader = cccccc |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Javascript for DokuWiki Plugin Mp3play | ||
* | ||
* Slightly modified for DokuWiki | ||
* | ||
* Michael Klier <chi@chimeric.de> | ||
*/ | ||
|
||
var ap_instances = new Array(); | ||
|
||
function ap_stopAll(playerID) { | ||
for(var i = 0; i<ap_instances.length; i++) { | ||
try { | ||
if(ap_instances[i] != playerID) { | ||
$("audioplayer" + ap_instances[i].toString()).SetVariable("closePlayer", 1); | ||
} else { | ||
$("audioplayer" + ap_instances[i].toString()).SetVariable("closePlayer", 0); | ||
} | ||
} catch( errorObject ) { | ||
// stop any errors | ||
} | ||
} | ||
} | ||
|
||
addInitEvent(function() { | ||
var objectID; | ||
var objectTags = document.getElementsByTagName("object"); | ||
for(var i=0; i<objectTags.length; i++) { | ||
objectID = objectTags[i].id; | ||
if(objectID.indexOf("audioplayer") == 0) { | ||
ap_instances[i] = objectID.substring(11, objectID.length); | ||
} | ||
} | ||
}); | ||
|
||
// vim:ts=4:sw=4:et:enc=utf-8: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* CSS for DokuWiki Plugin MP3 | ||
* | ||
* Michael Klier <chi@chimeric.de> | ||
*/ | ||
|
||
div.dokuwiki div.plugin_mp3play { | ||
display: block; | ||
margin: 1em; | ||
} | ||
|
||
/** | ||
* vim:ts=2:sw=2:et:enc=utf-8: | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
<?php | ||
/** | ||
* DokuWiki Syntax Plugin Mp3Play | ||
* | ||
* Shows an arrow image which links to the top of the page. | ||
* The image can be defined via the configuration manager. | ||
* | ||
* Syntax: {{mp3play>soundfile.mp3}} | ||
* | ||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html) | ||
* @author Michael Klier <chi@chimeric.de> | ||
*/ | ||
|
||
// must be run within DokuWiki | ||
if(!defined('DOKU_INC')) die(); | ||
|
||
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); | ||
require_once(DOKU_PLUGIN.'syntax.php'); | ||
|
||
if(!defined('DOKU_LF')) define('DOKU_LF',"\n"); | ||
|
||
/** | ||
* All DokuWiki plugins to extend the parser/rendering mechanism | ||
* need to inherit from this class | ||
*/ | ||
class syntax_plugin_mp3play extends DokuWiki_Syntax_Plugin { | ||
|
||
/** | ||
* return some info | ||
*/ | ||
function getInfo(){ | ||
return array( | ||
'author' => 'Michael Klier', | ||
'email' => 'chi@chimeric.de', | ||
'date' => '2008-08-15', | ||
'name' => 'Mp3play', | ||
'desc' => 'Embeds a flash mp3 player.', | ||
'url' => 'http://dokuwiki.org/plugin:mp3play', | ||
); | ||
} | ||
|
||
/** | ||
* Syntax Type | ||
* | ||
* Needs to return one of the mode types defined in $PARSER_MODES in parser.php | ||
*/ | ||
function getType() { return 'substition'; } | ||
function getPType() { return 'block'; } | ||
function getSort() { return 309; } | ||
|
||
/** | ||
* Connect pattern to lexer | ||
*/ | ||
function connectTo($mode) { $this->Lexer->addSpecialPattern('\{\{mp3play>.*?\}\}',$mode,'plugin_mp3play'); } | ||
|
||
/** | ||
* Handle the match | ||
*/ | ||
function handle($match, $state, $pos, &$handler){ | ||
$match = substr($match, 10, -2); | ||
$data = array(); | ||
if(file_exists(mediaFN($mp3))) { | ||
$data = array(); | ||
$data['loop'] = 0; | ||
$data['autostart'] = 0; | ||
|
||
list($mp3, $params) = explode('?', $match); | ||
$data['mp3'] = $mp3; | ||
|
||
$params = explode('&', $params); | ||
if($params) { | ||
foreach($params as $param) { | ||
switch($param) { | ||
case 'loop': | ||
$data['loop'] = 1; | ||
break; | ||
case 'autostart': | ||
$data['autostart'] = 1; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
return $data; | ||
|
||
} else { | ||
return array(); | ||
} | ||
} | ||
|
||
/** | ||
* Create output | ||
*/ | ||
function render($mode, &$renderer, $data) { | ||
global $ID; | ||
|
||
if(empty($data['mp3'])) return; | ||
|
||
if($mode == 'xhtml') { | ||
$renderer->info['cache'] = false; | ||
|
||
$players = p_get_metadata($ID, 'plugin_mp3play players'); | ||
$instance = $players[$data['mp3']]; | ||
|
||
$params = ''; | ||
$color_cfg = DOKU_PLUGIN . 'mp3play/colors.conf'; | ||
|
||
if(@file_exists($color_cfg)) { | ||
|
||
$colors = array(); | ||
$lines = @file($color_cfg); | ||
|
||
foreach($lines as $line) { | ||
$line = preg_replace("/\ *#.*$/", '', $line); | ||
$line = trim($line); | ||
if(empty($line)) continue; | ||
list($key, $color) = explode('=', $line); | ||
$colors[trim($key)] = trim($color); | ||
} | ||
|
||
if(!empty($colors)) { | ||
foreach($colors as $key => $color) { | ||
$params .= $key . '=0x' . $color . '&'; | ||
} | ||
} | ||
} | ||
|
||
$params .= ($data['loop']) ? 'loop=yes&' : 'loop=no&'; | ||
$params .= ($data['autostart']) ? 'autostart=yes&' : 'autostart=no&'; | ||
|
||
$renderer->doc .= '<div class="plugin_mp3play">' . DOKU_LF; | ||
$renderer->doc .= ' <object type="application/x-shockwave-flash" data="' . DOKU_URL . 'lib/plugins/mp3play/player.swf" id="audioplayer' . $instance . '" height="24" width="290">' . DOKU_LF; | ||
$renderer->doc .= ' <param name="movie" value="' . DOKU_URL . 'lib/plugins/mp3play/player.swf" />' . DOKU_LF; | ||
$renderer->doc .= ' <param name="FlashVars" value="playerID=' . $instance . '&' . $params . 'soundFile=' . DOKU_URL . '/lib/exe/fetch.php?media=' . $data['mp3'] . '" />' . DOKU_LF; | ||
$renderer->doc .= ' <param name="quality" value="high" />' . DOKU_LF; | ||
$renderer->doc .= ' <param name="menu" value="false" />' . DOKU_LF; | ||
$renderer->doc .= ' <param name="wmode" value="transparent" />' . DOKU_LF; | ||
$renderer->doc .= ' </object>' . DOKU_LF; | ||
$renderer->doc .= '</div>' . DOKU_LF; | ||
|
||
} elseif ($mode == 'metadata') { | ||
|
||
if($renderer->meta['plugin_mp3play']['instances']) { | ||
$renderer->meta['plugin_mp3play']['instances']++; | ||
} else { | ||
$renderer->meta['plugin_mp3play']['instances'] = 1; | ||
} | ||
$renderer->meta['plugin_mp3play']['players'][$data['mp3']] = $renderer->meta['plugin_mp3play']['instances']; | ||
} | ||
} | ||
} | ||
// vim:ts=4:sw=4:et:enc=utf-8: |