Translations of this page?:

dailymotion plugin

dailymotion plugin by Christophe Benz
Plugin that creates a link or an embed object of Dailymotion movie.

Last updated on 2008-01-17. Provides Syntax.
No compatibility info given!

Conflicts with vshare!
Similar to flashplayer, flowplay, google_video, video, vshare, youtube, youtubev2.

Tagged with dailymotion, embed, flash, movie, video.

The following security issue was reported for this plugin:

XSS vulnerability allows arbitrary JavaScript insertion. Author informed on 2008-02-25.

It is not recommended to use this plugin until this issue was fixed. Plugin authors should read the plugin security guidelines.

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:

<?php
/**
 * Plugin Dailymotion: Create Dailymotion link and object from ID.
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Christophe Benz
 *
 * Based on the Youtube plugin written by Ikuo Obataya.
 */
 
if(!defined('DOKU_INC')) die();
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'syntax.php');
 
class syntax_plugin_dailymotion extends DokuWiki_Syntax_Plugin {
  function getInfo(){
    return array(
      'author' => 'Christophe Benz',
      'email'  => 'christophe.benz@gmail.com',
      'date'   => '2008-01-17',
      'name'   => 'Dailymotion Plugin',
      'desc'   => 'Dailymotion link and object',
      'url'    => '',
    );
  }
 
  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(is_null($video_size)) {
        $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  = '<div>';
      $obj .= '<object width="' . $width . '" height="' . $height . '">';
      $obj .= '<param name="movie" value="' . $url . $dailymotion_id . '"></param>';
      $obj .= '<param name="allowFullScreen" value="true"></param>';
      $obj .= '<param name="allowScriptAccess" value="always"></param>';
      $obj .= '<embed src="' . $url . $dailymotion_id . '" type="application/x-shockwave-flash"'
        . ' width="' . $width . '" height="' . $height
        . '" allowFullScreen="true" allowScriptAccess="always"></embed>';
      $obj .= '<param name="movie" value="' . $url . $dailymotion_id . '"></param>';
      $obj .= '<param name="wmode" value="transparent"></param>';
      $obj .= '</object>';
      $obj .= '</div>';
 
      $renderer->doc .= $obj;
 
      return true;
    }
    return false;
  }
}
?>

Installation

Paste the source code in a file named syntax.php and put it the lib/plugins/dailymotion directory of your DokuWiki installation.

 
plugin/dailymotion.txt · Last modified: 2008/03/11 22:36 by andi
 
Imprint Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
WikiForumIRCBugsTranslate