====== YouTube Plugin ====== このプラグインは、DokuWiki のページに [[http://www.youtube.com/|YouTube]] の動画を埋め込みます。 ===== Syntax ===== {{youtube>videoID [width, height]}} ==== 各項目の説明 ==== ^ 項目 ^ 説明 ^ 必須 ^ デフォルト値 ^ ^ videoID | YouTube VideoのID。| 必須 | PaOWJxEr3U0 | ^ width | YouTube Videoの表示エリアの幅 | 任意 | 425 | ^ height | YouTube Videoの表示エリアの高さ | 任意 | 350 | ===== Installation ===== ==== Sources ==== * **Current version :** {{dokuwiki:plugin:plugin-youtube.zip|plugin-youtube.zip}} == [[doku>plugin:plugin_manager|plugin manager]] を利用する場合は、プラグインアーカイブの URL を使用して、**プラグイン管理**よりダウンロードして下さい。 プラグインを手動でインストールする場合は、ソースをダウンロードして ''lib/plugins'' に解凍して下さい。ただしくインストールできていれば、''lib/plugins/youtube'' ディレクトリが作成されています。 ===== Demo ===== {{youtube>b-Nw_14nuiw}} {{youtube>b-Nw_14nuiw}} ===== Details ===== ==== syntax.php ==== */ if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'syntax.php'); /** * All DokuWiki plugins to extend the parser/rendering mechanism * need to inherit from this class */ class syntax_plugin_youtube extends DokuWiki_Syntax_Plugin { function getInfo(){ return array( 'author' => 'Shinsuke Kamada', 'email' => 'okoze7@gmail.com', 'date' => '2007-02-15', 'name' => 'YouTube Plugin', 'desc' => 'syntax: {{youtube>VIDEOIDXXX [width, height]}}', 'url' => 'http://www.okoze-esca.net/dokuwiki/plugin/youtube', ); } function getType() { return 'substition'; } // must return a number lower than returned by native 'media' mode (320) function getSort() { return 319; } function connectTo($mode) { $this->Lexer->addSpecialPattern('\{\{youtube>.*?\}\}',$mode,'plugin_youtube'); } function handle($match, $state, $pos, &$handler) { $params = trim(substr($match, 10, -2)); $matches=array(); if (preg_match('/(.*)\[(.*)\]$/',$params,$matches)) { $v = $matches[1]; if (strpos($matches[2],',') !== false) { @list($w, $h) = explode(',',$matches[2],2); } else { $w = $matches[2]; $h = '350'; } } else { $v = ($params != '') ? $params : 'PaOWJxEr3U0'; $w = '425'; $h = '350'; } return array(hsc(trim($v)), hsc(trim($w)), hsc(trim($h))); } function render($mode, &$renderer, $data) { list($v,$w,$h) = $data; if($mode == 'xhtml'){ $renderer->doc .= ''; $renderer->doc .= ''; $renderer->doc .= ''; $renderer->doc .= ''; return true; } return false; } } ?> ===== Revision History ===== * **2007-02-15** --- リリース ===== ToDo ===== ===== Bugs ===== == {{tag>dokuwiki plugin}}