dailymotion plugin

dailymotion plugin by Christophe Benz
Create Dailymotion embedded video object from ID.

Last updated on 2008-12-08. Provides Syntax.
No compatibility info given!

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

Tagged with embed, flash, media, video.

    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 embedded video object from ID.
     *
     * @license    GPL v3 (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'  => '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  = '<div>';
          $obj .= '<object width="' . $width . '" height="' . $height . '">';
          $obj .= '<param name="movie" value="' . $url . htmlentities($dailymotion_id) . '"></param>';
          $obj .= '<param name="allowFullScreen" value="true"></param>';
          $obj .= '<param name="allowScriptAccess" value="always"></param>';
          $obj .= '<embed src="' . $url . htmlentities($dailymotion_id) . '" type="application/x-shockwave-flash"'
            . ' width="' . $width . '" height="' . $height
            . '" allowFullScreen="true" allowScriptAccess="always"></embed>';
          $obj .= '<param name="movie" value="' . $url . htmlentities($dailymotion_id) . '"></param>';
          $obj .= '<param name="wmode" value="transparent"></param>';
          $obj .= '</object>';
          $obj .= '</div>';
     
          $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.

     
    plugin/dailymotion.txt · Last modified: 2009/10/07 17:53 by laynee
     
    Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
    Imprint Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
    WikiForumIRCBugsGitXRefTranslate