ChipPC - Xcalibur W Wiki

For Server 2.14.x & Agent 2.14.x

User Tools

Site Tools


advanced:xcalibur_w_tray

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

advanced:xcalibur_w_tray [2019/05/05 20:53]
dan
advanced:xcalibur_w_tray [2021/11/21 17:18] (current)
Line 1: Line 1:
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN+<?php 
-   ​"​http://​www.w3.org/TR/html4/frameset.dtd"> +/** 
-<​html>​ + * DokuWiki Plugin html5video (Syntax Component) 
-<​head>​ + * 
-<​title>​A simple frameset document</​title>​ + * @license GPL 2 http://www.gnu.org/licenses/​gpl-2.0.html 
-</head> + * @author ​ Jason van Gumster (Fweeb) <​[email protected]>​ 
-<​frameset cols="20%80%">​ + * 
-  ​<​frameset rows="100200"> + * Parts borrowed from the videogg plugin written by Ludovic Kiefer, 
-      <​frame src="contents_of_frame1.html"> + * which is based on Christophe Benz' Dailymotion plugin, which, in turn, 
-      <​frame src="contents_of_frame2.gif"> + * is based on Ikuo Obataya'​s Youtube plugin. Whew... 
-  </​frameset>​ + * 
-  <​frame src="contents_of_frame3.html"> + * Currently only supports webm videos 
-  <​noframes>​ + */ 
-      <p>This frameset document contains:</p+ 
-      <​ul>​ +// must be run within Dokuwiki 
-         <li><a href="contents_of_frame1.html">​Some neat contents</a></​li+if (!defined('​DOKU_INC'​)) die(); 
-         <li><img src="contents_of_frame2.gif" ​alt="A neat image"></​li+ 
-         ​<li><a href="contents_of_frame3.html">Some other neat contents</a></​li+if (!defined('​DOKU_LF'​)) define('​DOKU_LF', ​"\n"); 
-      </​ul>​ +if (!defined('​DOKU_TAB'​)) define('​DOKU_TAB', ​"\t"​);​ 
-  </​noframes>​ +if (!defined('​DOKU_PLUGIN'​)) define('​DOKU_PLUGIN',​DOKU_INC.'​lib/​plugins/'​);​ 
-</​frameset+ 
-</​html>​+require_once DOKU_PLUGIN.'​syntax.php';​ 
 + 
 +class syntax_plugin_html5video_video extends DokuWiki_Syntax_Plugin { 
 + 
 +    public function getType() { 
 +        return '​substition';​ 
 +    } 
 + 
 +    public function getPType() { 
 +        return '​block';​ 
 +    } 
 + 
 +    public function getSort() { 
 +        return 159; 
 +    } 
 + 
 +    public function connectTo($mode) { 
 +        // Kind of a nasty regex, but it allows us to avoid using a  
 +        //   ​plugin-specific prefix. We can use syntax directly from Media 
 +        //   ​Manager. 
 +        // http://gskinner.com/RegExr is a big help 
 +        $this->​Lexer->​addSpecialPattern('​\{\{[^}]*(?:​(?:​webm)|(?:​ogv)|(?:​mp4))(?:​\|(?:​\d{2,​4}x\d{2,​4})?​(?:​\|(?:​loop)?,?​(?:​autoplay)?​(?:,​loop)?​)?​)?​ ?​\}\}',​$mode,'​plugin_html5video_video'​);​ 
 +    } 
 + 
 +    public function handle($match,​ $state, $pos, &​$handler){ 
 +        $params = substr($match,​ strlen('​{{'​),​ - strlen('​}}'​));​ //Strip markup 
 +        if(strpos($params,​ ' ') === 0) { // Space as first character 
 +            if(substr_compare($params,​ ' ', -1, 1) === 0) { // Space a front and back = centered 
 +                $params = trim($params);​ 
 +                $params = '​center|' ​$params; 
 +            }  
 +            else { // Only space at front = right-aligned 
 +                $params = trim($params);​ 
 +                $params = '​right|'​ . $params; 
 +            } 
 +        } 
 +        elseif(substr_compare($params,​ ' ', -1, 1) === 0) { // Space only as last character = left-aligned 
 +            $params = trim($params);​ 
 +            $params = '​left|' ​$params; 
 +        } 
 +        else { // No space padding = inline 
 +            $params = '​inline|'​ . $params; 
 +        } 
 +        return array(state,​ explode('​|',​ $params));​ 
 +    } 
 + 
 +    public function render($mode,​ &​$renderer,​ $data) { 
 +        if($mode != '​xhtml'​) return false; 
 + 
 +        list($state,​ $params) = $data; 
 +        list($video_align,​ $video_url, $video_size,​ $video_attr) = $params; 
 + 
 +        if($video_align == "center"​) { 
 +            ​$align = "​margin:​ 0 auto;";​ 
 +        } 
 +        ​elseif($video_align == "​left"​) { 
 +            ​$align = "​float:​ left;";​ 
 +        } 
 +        elseif($video_align == "​right"​) { 
 +            $align = "​float:​ right;";​ 
 +        } 
 +        else { // Inline 
 +            ​$align ​= ""; 
 +        } 
 + 
 +        if(!substr_count($video_url'/'​)) { 
 +            $video_url = ml($video_url);​ 
 +        } 
 + 
 +        if(substr($video_url,​ -4) != '​webm'​ && substr($video_url,​ -3) != '​ogv'​ && substr($video_url,​ -3) != '​mp4'​) { 
 +            $renderer->​doc .= "Error: The video must be in webm, ogv, or mp4 format.<​br />" . $video_url; 
 +            ​return false; 
 +        } 
 + 
 +        if(is_null($video_size) or !substr_count($video_size,​ '​x'​)) { 
 +            $width ​ = 640; 
 +            $height = 360; 
 +        } 
 +        else { 
 +            $obj_dimensions = explode('​x',​ $video_size);​ 
 +            $width ​ = $obj_dimensions[0];​ 
 +            $height = $obj_dimensions[1];​ 
 +        } 
 + 
 +        if(is_null($video_attr)) { 
 +            $attr = ""; 
 +        } 
 +        else { 
 +            $arr_attr = explode('​,', $video_attr);​ 
 +            if(count($arr_attr) == 1) { 
 +                if($arr_attr[0] == "loop") { 
 +                    $attr = 'loop="loop"'; 
 +                } 
 +                elseif($arr_attr[0] == "autoplay") { 
 +                    $attr = '​autoplay="​autoplay"';​ 
 +                } 
 +            } 
 +            elseif(count($arr_attr) == 2) { 
 +                if($arr_attr[0] != $arr_attr[1]) { 
 +                    $attr = 'loop="loop" ​autoplay="​autoplay"';​ 
 +                } 
 +                else { 
 +                    $renderer->doc .= "ErrorDuplicate parameters.<br />"; 
 +                    ​return false; 
 +                } 
 +            } 
 +            else { 
 +                $renderer->doc .= "Error: Wrong number of parameters.<br />"; 
 +                ​return false; 
 +            } 
 +        } 
 + 
 +        $obj = '<video src="' ​$video_url . '" ​width="' . $width . '" ​height="'​ . $height . '"​ controls="​controls"​ ' . $attr . '></video>'; 
 +        ​if($align != ""​) { 
 +            $obj = '<div style="width: ' ​$width . 'px; ' . $align . '">' . $obj . '</div>'; 
 +        } 
 + 
 +        ​$renderer->doc .= $obj; 
 +        return true; 
 +    } 
 +    private function _getAlts($filename) { 
 +        return false; 
 +    } 
 +} 
advanced/xcalibur_w_tray.txt · Last modified: 2021/11/21 17:18 (external edit)