diff options
author | lisps <stummp@loewen.de> | 2014-02-17 23:15:36 +0100 |
---|---|---|
committer | lisps <stummp@loewen.de> | 2014-02-17 23:15:36 +0100 |
commit | d90a79c0ee1837353622e4b2abb0753ca09dffd2 (patch) | |
tree | 554da8dc13606efc2bc1ea7fe3697a5ff87d02e5 /inc/parser | |
parent | f2643d9ff318af1d2fbb6249e929212381959247 (diff) | |
parent | a83975113c7725a13144b3e65bfb58c8447d37d7 (diff) | |
download | rpg-d90a79c0ee1837353622e4b2abb0753ca09dffd2.tar.gz rpg-d90a79c0ee1837353622e4b2abb0753ca09dffd2.tar.bz2 |
Merge remote-tracking branch 'origin/diff_navigation' into revisions
Conflicts:
inc/parser/xhtml.php
Diffstat (limited to 'inc/parser')
-rw-r--r-- | inc/parser/parser.php | 84 | ||||
-rw-r--r-- | inc/parser/renderer.php | 12 | ||||
-rw-r--r-- | inc/parser/xhtml.php | 62 |
3 files changed, 130 insertions, 28 deletions
diff --git a/inc/parser/parser.php b/inc/parser/parser.php index e39a4daf5..252bd9170 100644 --- a/inc/parser/parser.php +++ b/inc/parser/parser.php @@ -125,43 +125,91 @@ class Doku_Parser { } //------------------------------------------------------------------- + /** - * This class and all the subclasses below are - * used to reduce the effort required to register - * modes with the Lexer. For performance these - * could all be eliminated later perhaps, or - * the Parser could be serialized to a file once - * all modes are registered + * Class Doku_Parser_Mode_Interface * - * @author Harry Fuecks <hfuecks@gmail.com> + * Defines a mode (syntax component) in the Parser */ -class Doku_Parser_Mode { +interface Doku_Parser_Mode_Interface { + /** + * returns a number used to determine in which order modes are added + */ + public function getSort(); + + /** + * Called before any calls to connectTo + */ + function preConnect(); + + /** + * Connects the mode + * + * @param string $mode + */ + function connectTo($mode); /** + * Called after all calls to connectTo + */ + function postConnect(); + + /** + * Check if given mode is accepted inside this mode + * + * @param string $mode + * @return bool + */ + function accepts($mode); +} + +/** + * This class and all the subclasses below are used to reduce the effort required to register + * modes with the Lexer. + * + * @author Harry Fuecks <hfuecks@gmail.com> + */ +class Doku_Parser_Mode implements Doku_Parser_Mode_Interface { + /** * @var Doku_Lexer $Lexer */ var $Lexer; - var $allowedModes = array(); - // returns a number used to determine in which order modes are added function getSort() { trigger_error('getSort() not implemented in '.get_class($this), E_USER_WARNING); } - // Called before any calls to connectTo function preConnect() {} - - // Connects the mode function connectTo($mode) {} - - // Called after all calls to connectTo function postConnect() {} - function accepts($mode) { return in_array($mode, (array) $this->allowedModes ); } +} + +/** + * Basically the same as Doku_Parser_Mode but extends from DokuWiki_Plugin + * + * Adds additional functions to syntax plugins + */ +class Doku_Parser_Mode_Plugin extends DokuWiki_Plugin implements Doku_Parser_Mode_Interface { + /** + * @var Doku_Lexer $Lexer + */ + var $Lexer; + var $allowedModes = array(); + + function getSort() { + trigger_error('getSort() not implemented in '.get_class($this), E_USER_WARNING); + } + function preConnect() {} + function connectTo($mode) {} + function postConnect() {} + function accepts($mode) { + return in_array($mode, (array) $this->allowedModes ); + } } //------------------------------------------------------------------- @@ -454,8 +502,8 @@ class Doku_Parser_Mode_table extends Doku_Parser_Mode { } function connectTo($mode) { - $this->Lexer->addEntryPattern('\s*\n\^',$mode,'table'); - $this->Lexer->addEntryPattern('\s*\n\|',$mode,'table'); + $this->Lexer->addEntryPattern('[\t ]*\n\^',$mode,'table'); + $this->Lexer->addEntryPattern('[\t ]*\n\|',$mode,'table'); } function postConnect() { diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index c697e990c..e3401fd48 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -59,9 +59,15 @@ class Doku_Renderer extends DokuWiki_Plugin { return false; } - - //handle plugin rendering - function plugin($name,$data){ + /** + * handle plugin rendering + * + * @param string $name Plugin name + * @param mixed $data custom data set by handler + * @param string $state matched state if any + * @param string $match raw matched syntax + */ + function plugin($name,$data,$state='',$match=''){ $plugin = plugin_load('syntax',$name); if($plugin != null){ $plugin->render($this->getFormat(),$this,$data); diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 2070c3af6..1cf1acc32 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -785,7 +785,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } function internalmedia ($src, $title=null, $align=null, $width=null, - $height=null, $cache=null, $linking=null) { + $height=null, $cache=null, $linking=null, $return=NULL) { global $ID; list($src,$hash) = explode('#',$src,2); resolve_mediaid(getNS($ID),$src, $exists); @@ -797,8 +797,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer { list($ext,$mime,$dl) = mimetype($src,false); if(substr($mime,0,5) == 'image' && $render){ $link['url'] = ml($src,array('id'=>$ID,'cache'=>$cache,'rev'=>$this->_getLastMediaRevisionAt($src)),($linking=='direct')); - }elseif($mime == 'application/x-shockwave-flash' && $render){ - // don't link flash movies + }elseif(($mime == 'application/x-shockwave-flash' || media_supportedav($mime)) && $render){ + // don't link movies $noLink = true; }else{ // add file icons @@ -816,8 +816,13 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } //output formatted - if ($linking == 'nolink' || $noLink) $this->doc .= $link['name']; - else $this->doc .= $this->_formatLink($link); + if ($return) { + if ($linking == 'nolink' || $noLink) return $link['name']; + else return $this->_formatLink($link); + } else { + if ($linking == 'nolink' || $noLink) $this->doc .= $link['name']; + else $this->doc .= $this->_formatLink($link); + } } function externalmedia ($src, $title=null, $align=null, $width=null, @@ -833,8 +838,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer { if(substr($mime,0,5) == 'image' && $render){ // link only jpeg images // if ($ext != 'jpg' && $ext != 'jpeg') $noLink = true; - }elseif($mime == 'application/x-shockwave-flash' && $render){ - // don't link flash movies + }elseif(($mime == 'application/x-shockwave-flash' || media_supportedav($mime)) && $render){ + // don't link movies $noLink = true; }else{ // add file icons @@ -1052,6 +1057,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $height=null, $cache=null, $render = true) { $ret = ''; + list($ext,$mime,$dl) = mimetype($src); if(substr($mime,0,5) == 'image'){ // first get the $title @@ -1094,6 +1100,48 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $ret .= ' />'; + }elseif(media_supportedav($mime, 'video')){ + // first get the $title + if (!is_null($title)) { + $title = $this->_xmlEntities($title); + } + if (!$title) { + // just show the sourcename + $title = $this->_xmlEntities(utf8_basename(noNS($src))); + } + if (!$render) { + // if the video is not supposed to be rendered + // return the title of the video + return $title; + } + + $att = array(); + $att['class'] = "media$align"; + + //add video(s) + $ret .= $this->_video($src, $width, $height, $att); + + }elseif(media_supportedav($mime, 'audio')){ + // first get the $title + if (!is_null($title)) { + $title = $this->_xmlEntities($title); + } + if (!$title) { + // just show the sourcename + $title = $this->_xmlEntities(utf8_basename(noNS($src))); + } + if (!$render) { + // if the video is not supposed to be rendered + // return the title of the video + return $title; + } + + $att = array(); + $att['class'] = "media$align"; + + //add audio + $ret .= $this->_audio($src, $att); + }elseif($mime == 'application/x-shockwave-flash'){ if (!$render) { // if the flash is not supposed to be rendered |