1<?php 2/** 3 * Syntax Plugin Prototype 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Andreas Gohr <andi@splitbrain.org> 7 */ 8// must be run within Dokuwiki 9if(!defined('DOKU_INC')) die(); 10if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 11require_once(DOKU_PLUGIN.'syntax.php'); 12 13 14/** 15* All DokuWiki plugins to extend the parser/rendering mechanism 16* need to inherit from this class 17*/ 18class syntax_plugin_google_video extends DokuWiki_Syntax_Plugin { 19 /** 20 * return some info 21 */ 22 function getInfo(){ 23 return array( 24 'author' => 'François Laperruque', 25 'email' => 'francois.laperruque@toulouse.inra.fr', 26 'date' => '2007-08-02', 27 'name' => 'Google Video Plugin', 28 'desc' => 'Google Video link and object 29 syntax: {{googlevideo>type:ID}}', 30 'url' => 'http://flap.mynetmemo.com/?p=15', 31 ); 32 } 33 function getType(){ return 'substition'; } 34 function getSort(){ return 159; } 35 function connectTo($mode) 36 { 37 $this->Lexer->addSpecialPattern('\{\{googlevideo>[^}]*\}\}',$mode,'plugin_google_video'); 38 } 39 /** 40 * Handle the match 41 */ 42 function handle($match, $state, $pos, Doku_Handler $handler){ 43 $match = substr($match,14,-2); // Strip markup 44 return array($state,explode(':',$match)); 45 } 46 /** 47 * Create output 48 */ 49 function render($mode, Doku_Renderer $renderer, $data) { 50 if($mode == 'xhtml') 51 { 52 list($state, $match) = $data; 53 list($disptype,$id) = $match; 54 55 $href_start = '<a href="//video.google.com/googleplayer.swf?docId='.$id.'">'; 56 57 $LOGO_URL = '/_media/icon/googlevideo.png'; 58 if ($disptype=='link'){ 59 $renderer->doc .= $href_start; 60 $renderer->doc .= '<img src="'.$LOGO_URL.'" alt="movie-'.$id.'"/></a>'; 61 } 62 elseif ($disptype=='large') 63 { 64 $obj = '<object width="425" height="350" type="application/x-shockwave-flash"'; 65 $obj .= ' data="//video.google.com/googleplayer.swf?docId='.$id.'">'; 66 $obj .= '<param name="movie" value="http://video.google.com/googleplayer.swf?docId='.$id.'"></object>'; 67 $renderer->doc .= $obj; 68 } 69 elseif($disptype=='small'){ 70 $obj = '<object width="255" height="210" type="application/x-shockwave-flash"'; 71 $obj .= ' data="//video.google.com/googleplayer.swf?docId='.$id.'">'; 72 $obj .= '<param name="movie" value="http://video.google.com/googleplayer.swf?docId='.$id.'"></object>'; 73 $renderer->doc .= $obj; 74 } 75 else 76 { 77 $renderer->doc .="??"; 78 } 79 return true; 80 } 81 return false; 82 } 83} 84 85?> 86