====== dailymotion plugin ====== ---- plugin ---- description: Create Dailymotion embedded video object from ID. author : Christophe Benz email : christophe[dot]benz[at]gmail[dot]com type : syntax lastupdate : 2008-12-08 compatible : depends : conflicts : similar : dailymotion_videozap, flowplay, flashplayer, video tags : !obsolete, media, video, embed, flash ---- Flash is not available anymore in browsers. Embedding videos from many video sites like Dailymotion can be done with [[vshare]] plugin. =====Summary===== This DokuWiki plugin creates a link and embed a Dailymotion movie in an Wiki page. User can embed movies just specifying the movie ID with simple syntax. This plugin is based on the [[Youtube]] plugin written by Ikuo Obataya. =====Syntax===== {{dailymotion>ID:SIZE}} ID is given by Dailymotion. SIZE is either small, medium or large. Default: medium. ====Example==== Wiki syntax {{dailymotion>x29kjo}} {{dailymotion>x29kjo:small}} {{dailymotion>x29kjo:medium}} {{dailymotion>x29kjo:large}} =====Source code===== Here is the source code: 'Christophe Benz', 'email' => 'cbenz _AT_ easter-eggs _DOT_ com', 'date' => '2008-12-08', 'name' => 'Dailymotion Plugin', 'desc' => 'Create Dailymotion embedded video object from ID.', 'url' => 'http://www.dokuwiki.org/plugin:dailymotion', ); } function getType() { return 'substition'; } function getSort() { return 159; } function connectTo($mode) { $this->Lexer->addSpecialPattern('\{\{dailymotion>[^}]*\}\}', $mode, 'plugin_dailymotion'); } /** * Handle the match */ function handle($match, $state, $pos, &$handler){ $params = substr($match, strlen('{{dailymotion>'), - strlen('}}') ); // Strip markup return array($state, explode(':', $params)); } /** * Create output */ function render($mode, &$renderer, $data) { if($mode == 'xhtml'){ list($state, $params) = $data; list($dailymotion_id, $video_size) = $params; if(preg_match('/^\w+$/', $dailymotion_id) == 0) { $renderer->doc .= 'Error: Dailymotion ID must be alphanumeric. Given value: ' . htmlentities($dailymotion_id); return false; } if(is_null($video_size) or ! in_array($video_size, array('small', 'medium', 'large'))) { $video_size = 'medium'; } $url = 'http://www.dailymotion.com/swf/'; $obj_dimensions['small'] = array('w' => 200, 'h' => 166); $obj_dimensions['medium'] = array('w' => 420, 'h' => 331); $obj_dimensions['large'] = array('w' => 520, 'h' => 406); $width = $obj_dimensions[$video_size]['w']; $height = $obj_dimensions[$video_size]['h']; $obj = '
'; $obj .= ''; $obj .= ''; $obj .= ''; $obj .= ''; $obj .= ''; $obj .= ''; $obj .= ''; $obj .= ''; $obj .= '
'; $renderer->doc .= $obj; return true; } return false; } } ?>
PS: do not add a newline at the end of file ====Installation==== Paste the source code in a file named ''syntax.php'' and put it the ''lib/plugins/dailymotion'' directory of your DokuWiki installation.