From f9528c0c7accd2da60f16864555b4982b940a1a0 Mon Sep 17 00:00:00 2001 From: Klap-in Date: Sun, 27 Jan 2013 22:02:47 +0100 Subject: Added diff navigation Navigation links to move to previous edit before revision in left column or next/last edit after revision in right column. --- inc/changelog.php | 213 +++++++++++++++++++++++++++++++++++++++++++++++++++ inc/html.php | 47 +++++++++++- inc/lang/en/lang.php | 4 + inc/lang/nl/lang.php | 4 + 4 files changed, 267 insertions(+), 1 deletion(-) (limited to 'inc') diff --git a/inc/changelog.php b/inc/changelog.php index 9768fea51..e25c3144e 100644 --- a/inc/changelog.php +++ b/inc/changelog.php @@ -543,4 +543,217 @@ function getRevisions($id, $first, $num, $chunk_size=8192, $media=false) { return $revs; } +/** + * Get the nth revision left or right handside for a specific page id + * and revision (timestamp). For large changelog files, only the chunk containing the + * reference revision $rev is read and sometimes a next chunck. + * + * Adjacent changelog lines are optimistically parsed and cached to speed up + * consecutive calls to getRevisionInfo. + * + * @author Gerrit Uitslag + * + * based on getRevisionInfo by + * @author Ben Coburn + * @author Kate Arzamastseva + * + * @param string $id pageid + * @param int $rev revision timestamp used as startdate (doesn't need to be revisionnumber) + * @param int $direction give position of returned revision with respect to $rev; positive=next, negative=prev + * @param int $chunk_size maximum block size + * @param bool $media + * @return bool|string + */ +function getRelativeRevision($id, $rev, $direction, $chunk_size = 8192, $media = false) { + global $cache_revinfo; + global $INFO; + $cache =& $cache_revinfo; + if(!isset($cache[$id])) { + $cache[$id] = array(); + } + $rev = max($rev, 0); + + //no direction given or last rev, so no follow-up + if(!$direction || ($direction > 0 && $rev == $INFO['meta']['last_change']['date'])) { + return false; + } + + if($media) { + $file = mediaMetaFN($id, '.changes'); + } else { + $file = metaFN($id, '.changes'); + } + if(!@file_exists($file)) { + return false; + } + + //get $lines from changelog + $lines = array(); + $fp = null; + $tail = 0; + $head = 0; + $eof = 0; + if(filesize($file) < $chunk_size || $chunk_size == 0) { + // read whole file + $uses_chuncks = false; + $lines = file($file); + if($lines === false) { + return false; + } + } else { + // read by chunk + $uses_chuncks = true; + $fp = fopen($file, 'rb'); // "file pointer" + if($fp === false) { + return false; + } //error + $head = 0; + fseek($fp, 0, SEEK_END); //set file position indicator 0 byte from end. + $tail = ftell($fp); //return current position of pointer as integer + $eof = $tail; + $finger = 0; + $finger_rev = 0; + + // find chunk + while($tail - $head > $chunk_size) { + $finger = $head + floor(($tail - $head) / 2.0); + $finger = getNewlinepointer($fp, $finger); + $tmp = fgets($fp); // then read at that location + $tmp = parseChangelogLine($tmp); + $finger_rev = $tmp['date']; + if($finger == $head || $finger == $tail) { + break; + } + if($finger_rev > $rev) { + $tail = $finger; + } else { + $head = $finger; + } + } + + if($tail - $head < 1) { + // cound not find chunk, assume requested rev is missing + fclose($fp); + return false; + } + + $lines = readChunk($fp, $head, $tail); + } + + // look for revisions later then $rev, when founded count till the wanted revision is reached + // also parse and cache changelog lines that pass + $revcounter = 0; + $relrev = false; + $tmp = array(); + $checkotherchunck = true; //always runs once + while(!$relrev && $checkotherchunck) { + + if($direction > 0) { + foreach($lines as $value) { + $tmp = parseChangelogLine($value); + if($tmp !== false) { + $cache[$id][$tmp['date']] = $tmp; + //look for revs older then reference $rev and select $direction-th one + if($tmp['date'] > $rev) { + $revcounter++; + if($revcounter == $direction) { + $relrev = $tmp['date']; + } + } + } + } + } else { + //parse in reverse order + for($i = count($lines) - 1; $i >= 0; $i--) { + $tmp = parseChangelogLine($lines[$i]); + if($tmp !== false) { + $cache[$id][$tmp['date']] = $tmp; + //look for revs older then reference $rev and select $direction-th one + if($tmp['date'] < $rev) { + $revcounter++; + if($revcounter == abs($direction)) { + $relrev = $tmp['date']; + } + } + } + } + } + + //true when $rev is found, but not the wanted follow-up. + $checkotherchunck = $uses_chuncks + && ($tmp['date'] == $rev || ($revcounter > 0 && !$relrev)) + && !feof($fp); + + if($checkotherchunck) { + if($direction > 0) { + //get interval of next chunck, smaller than $chunck_size + $head = $tail; + $lookpointer = true; + $tail = $head + floor($chunk_size * (2 / 3)); + while($lookpointer) { + $tail = min($tail, $eof); + $tail = getNewlinepointer($fp, $tail); + $lookpointer = $tail - $head > $chunk_size; + if($lookpointer) { + $tail = $head + floor(($tail - $head) / 2); + } + } + } else { + $tail = $head; + $head = max($tail - $chunk_size, 0); + $head = getNewlinepointer($fp, $head); + } + + //load next chunck + $lines = readChunk($fp, $head, $tail); + } + } + if($uses_chuncks) { + fclose($fp); + } + if($relrev == $INFO['meta']['last_change']['date']) { + return 'current'; + } + return $relrev; +} + +/** + * Read chunk and return array with lines of given chunck. + * Has no check if $head and $tail are really at a new line + * + * @param $fp resource filepointer + * @param $head int start point chunck + * @param $tail int end point chunck + * @return array lines read from chunck + */ +function readChunk($fp, $head, $tail) { + $chunk = ''; + $chunk_size = max($tail - $head, 0); // found chunk size + $got = 0; + fseek($fp, $head); + while($got < $chunk_size && !feof($fp)) { + $tmp = @fread($fp, max($chunk_size - $got, 0)); + if($tmp === false) { + break; + } //error state + $got += strlen($tmp); + $chunk .= $tmp; + } + $lines = explode("\n", $chunk); + array_pop($lines); // remove trailing newline + return $lines; +} + +/** + * Set pointer to first new line after $finger and return its position + * + * @param $fp resource filepointer + * @param $finger int a pointer + * @return int pointer + */ +function getNewlinepointer($fp, $finger) { + fseek($fp, $finger); + fgets($fp); // slip the finger forward to a new line + return ftell($fp); +} diff --git a/inc/html.php b/inc/html.php index 5c1c75cf6..9d344a05f 100644 --- a/inc/html.php +++ b/inc/html.php @@ -1151,6 +1151,18 @@ function html_diff($text='',$intro=true,$type=null){ } $r_text = rawWiki($ID,$r_rev); + //look for previous/next revision + if($r_rev) { + $next_rev = getRelativeRevision($ID, $r_rev, 1); + } else { + $next_rev = false; + } + if($l_rev) { + $prev_rev = getRelativeRevision($ID, $l_rev, -1); + } else { + $prev_rev = false; + } + list($l_head, $r_head, $l_minor, $r_minor) = html_diff_head($l_rev, $r_rev); } @@ -1191,7 +1203,40 @@ function html_diff($text='',$intro=true,$type=null){ 'rev2[1]' => $r_rev, 'difftype' => $type, )); - ptln('

'.$lang['difflink'].'

'); + ptln('

'.$lang['difflink'].'
'); + if($prev_rev){ + $diffurlprev = wl($ID, array( + 'do' => 'diff', + 'rev2[0]' => $prev_rev, + 'rev2[1]' => $l_rev, + 'difftype' => $type, + )); + ptln('← '.$lang['diffpreviousedit'].' - '); + } + $recenturl = wl($ID, array( + 'do' => 'revisions' + )); + ptln(''.$lang['overviewrevs'].''); + if($next_rev){ + if($next_rev=='current') { + $diffurlnextparam = array( + 'do' => 'diff', + 'rev' => $r_rev, + 'difftype' => $type, + ); + $navnexttitle = $lang['difflastedit']; + } else { + $diffurlnextparam = array( + 'do' => 'diff', + 'rev2[0]' => $r_rev, + 'rev2[1]' => $next_rev, + 'difftype' => $type, + ); + $navnexttitle = $lang['diffnextedit']; + } + ptln(' - '.$navnexttitle.' →'); + } + ptln('

'); ptln(''); } ?> diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index 144faf4e1..92d352097 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -184,6 +184,10 @@ $lang['difflink'] = 'Link to this comparison view'; $lang['diff_type'] = 'View differences:'; $lang['diff_inline'] = 'Inline'; $lang['diff_side'] = 'Side by Side'; +$lang['diffpreviousedit'] = 'Previous edit'; +$lang['diffnextedit'] = 'Next edit'; +$lang['difflastedit'] = 'Last edit'; +$lang['overviewrevs'] = 'Overview of revisions'; $lang['line'] = 'Line'; $lang['breadcrumb'] = 'Trace'; $lang['youarehere'] = 'You are here'; diff --git a/inc/lang/nl/lang.php b/inc/lang/nl/lang.php index 0241eab2f..2fe536f31 100644 --- a/inc/lang/nl/lang.php +++ b/inc/lang/nl/lang.php @@ -185,6 +185,10 @@ $lang['difflink'] = 'Link naar deze vergelijking'; $lang['diff_type'] = 'Bekijk verschillen:'; $lang['diff_inline'] = 'Inline'; $lang['diff_side'] = 'Zij aan zij'; +$lang['diffpreviousedit'] = 'Vorige bewerking'; +$lang['diffnextedit'] = 'Volgende bewerking'; +$lang['difflastedit'] = 'Laatste bewerking'; +$lang['overviewrevs'] = 'Overzicht van revisies'; $lang['line'] = 'Regel'; $lang['breadcrumb'] = 'Spoor'; $lang['youarehere'] = 'Je bent hier'; -- cgit v1.2.3 From ce2f604739dc66e32e05f7078ada1711fe387979 Mon Sep 17 00:00:00 2001 From: Klap-in Date: Mon, 28 Jan 2013 01:17:40 +0100 Subject: Add working EoF and BoF checks when chunck reading. Also isset on meta-last_change-date entry. --- inc/changelog.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'inc') diff --git a/inc/changelog.php b/inc/changelog.php index e25c3144e..d2be5b2db 100644 --- a/inc/changelog.php +++ b/inc/changelog.php @@ -574,7 +574,7 @@ function getRelativeRevision($id, $rev, $direction, $chunk_size = 8192, $media = $rev = max($rev, 0); //no direction given or last rev, so no follow-up - if(!$direction || ($direction > 0 && $rev == $INFO['meta']['last_change']['date'])) { + if(!$direction || ($direction > 0 && isset($INFO['meta']['last_change']['date']) && $rev == $INFO['meta']['last_change']['date'])) { return false; } @@ -682,7 +682,7 @@ function getRelativeRevision($id, $rev, $direction, $chunk_size = 8192, $media = //true when $rev is found, but not the wanted follow-up. $checkotherchunck = $uses_chuncks && ($tmp['date'] == $rev || ($revcounter > 0 && !$relrev)) - && !feof($fp); + && !(($tail == $eof && $direction > 0) || ($head == 0 && $direction < 0)); if($checkotherchunck) { if($direction > 0) { @@ -712,7 +712,7 @@ function getRelativeRevision($id, $rev, $direction, $chunk_size = 8192, $media = fclose($fp); } - if($relrev == $INFO['meta']['last_change']['date']) { + if(isset($INFO['meta']['last_change']) && $relrev == $INFO['meta']['last_change']['date']) { return 'current'; } return $relrev; -- cgit v1.2.3 From 9a01fb1de9ece0c4d37cb331e51e3b0b7dcf75a8 Mon Sep 17 00:00:00 2001 From: Klap-in Date: Mon, 28 Jan 2013 01:39:57 +0100 Subject: Add some breaks to while loops. --- inc/changelog.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'inc') diff --git a/inc/changelog.php b/inc/changelog.php index d2be5b2db..c5c1c8246 100644 --- a/inc/changelog.php +++ b/inc/changelog.php @@ -697,6 +697,7 @@ function getRelativeRevision($id, $rev, $direction, $chunk_size = 8192, $media = if($lookpointer) { $tail = $head + floor(($tail - $head) / 2); } + if($tail == $head) break; } } else { $tail = $head; @@ -706,6 +707,7 @@ function getRelativeRevision($id, $rev, $direction, $chunk_size = 8192, $media = //load next chunck $lines = readChunk($fp, $head, $tail); + if(empty($lines)) break; } } if($uses_chuncks) { -- cgit v1.2.3 From 040f0e135c37c5b544f16277ff69205369df5f1f Mon Sep 17 00:00:00 2001 From: Klap-in Date: Mon, 4 Feb 2013 15:45:59 +0100 Subject: some refactoring --- inc/changelog.php | 265 ++++++++++++++++++++++++------------------------------ 1 file changed, 117 insertions(+), 148 deletions(-) (limited to 'inc') diff --git a/inc/changelog.php b/inc/changelog.php index c5c1c8246..fc9dc9fd1 100644 --- a/inc/changelog.php +++ b/inc/changelog.php @@ -360,59 +360,13 @@ function getRevisionInfo($id, $rev, $chunk_size=8192, $media=false) { } else { $file = metaFN($id, '.changes'); } - if (!@file_exists($file)) { return false; } - if (filesize($file)<$chunk_size || $chunk_size==0) { - // read whole file - $lines = file($file); - if ($lines===false) { return false; } - } else { - // read by chunk - $fp = fopen($file, 'rb'); // "file pointer" - if ($fp===false) { return false; } - $head = 0; - fseek($fp, 0, SEEK_END); - $tail = ftell($fp); - $finger = 0; - $finger_rev = 0; - // find chunk - while ($tail-$head>$chunk_size) { - $finger = $head+floor(($tail-$head)/2.0); - fseek($fp, $finger); - fgets($fp); // slip the finger forward to a new line - $finger = ftell($fp); - $tmp = fgets($fp); // then read at that location - $tmp = parseChangelogLine($tmp); - $finger_rev = $tmp['date']; - if ($finger==$head || $finger==$tail) { break; } - if ($finger_rev>$rev) { - $tail = $finger; - } else { - $head = $finger; - } - } - - if ($tail-$head<1) { - // cound not find chunk, assume requested rev is missing - fclose($fp); - return false; - } - - // read chunk - $chunk = ''; - $chunk_size = max($tail-$head, 0); // found chunk size - $got = 0; - fseek($fp, $head); - while ($got<$chunk_size && !feof($fp)) { - $tmp = @fread($fp, max($chunk_size-$got, 0)); - if ($tmp===false) { break; } //error state - $got += strlen($tmp); - $chunk .= $tmp; - } - $lines = explode("\n", $chunk); - array_pop($lines); // remove trailing newline + //read lines from changelog + list($fp, $lines) = _readloglines($file, $rev, $chunk_size); + if($fp) { fclose($fp); } + if(empty($lines)) return false; // parse and cache changelog lines foreach ($lines as $value) { @@ -572,9 +526,13 @@ function getRelativeRevision($id, $rev, $direction, $chunk_size = 8192, $media = $cache[$id] = array(); } $rev = max($rev, 0); + $direction = (int) $direction; //no direction given or last rev, so no follow-up - if(!$direction || ($direction > 0 && isset($INFO['meta']['last_change']['date']) && $rev == $INFO['meta']['last_change']['date'])) { + if(!$direction || + ($direction > 0 + && isset($INFO['meta']['last_change']['date']) + && $rev == $INFO['meta']['last_change']['date'])) { return false; } @@ -583,42 +541,125 @@ function getRelativeRevision($id, $rev, $direction, $chunk_size = 8192, $media = } else { $file = metaFN($id, '.changes'); } + + //get lines from changelog + list($fp, $lines, $head, $tail, $eof) = _readloglines($file, $rev, $chunk_size); + if(empty($lines)) return false; + + // look for revisions later/earlier then $rev, when founded count till the wanted revision is reached + // also parse and cache changelog lines for getRevisionInfo(). + $revcounter = 0; + $relativerev = false; + $checkotherchunck = true; //always runs once + while(!$relativerev && $checkotherchunck) { + $tmp = array(); + //parse in normal or reverse order + $count = count($lines); + if($direction > 0) { + $start = 0; + $step = 1; + } else { + $start = $count - 1; + $step = -1; + } + for($i = $start; $i >= 0 && $i < $count; $i = $i + $step) { + $tmp = parseChangelogLine($lines[$i]); + if($tmp !== false) { + $cache[$id][$tmp['date']] = $tmp; + //look for revs older/earlier then reference $rev and select $direction-th one + if(($direction > 0 && $tmp['date'] > $rev) || ($direction < 0 && $tmp['date'] < $rev)) { + $revcounter++; + if($revcounter == abs($direction)) { + $relativerev = $tmp['date']; + } + } + } + } + + //true when $rev is found, but not the wanted follow-up. + $checkotherchunck = $fp + && ($tmp['date'] == $rev || ($revcounter > 0 && !$relativerev)) + && !(($tail == $eof && $direction > 0) || ($head == 0 && $direction < 0)); + + if($checkotherchunck) { + //search bounds of chunck, rounded on new line, but smaller than $chunck_size + if($direction > 0) { + $head = $tail; + $lookpointer = true; + $tail = $head + floor($chunk_size * (2 / 3)); + while($lookpointer) { + $tail = min($tail, $eof); + $tail = _getNewlinepointer($fp, $tail); + $lookpointer = $tail - $head > $chunk_size; + if($lookpointer) { + $tail = $head + floor(($tail - $head) / 2); + } + if($tail == $head) break; + } + } else { + $tail = $head; + $head = max($tail - $chunk_size, 0); + $head = _getNewlinepointer($fp, $head); + } + + //load next chunck + $lines = _readChunk($fp, $head, $tail); + if(empty($lines)) break; + } + } + if($fp) { + fclose($fp); + } + + if(isset($INFO['meta']['last_change']) && $relativerev == $INFO['meta']['last_change']['date']) { + return 'current'; + } + return $relativerev; +} + +/** + * get lines from changelog. + * If file larger than $chuncksize, only chunck is read that could contain $rev. + * + * @param int $file path to changelog file + * @param int $rev revision timestamp + * @param int $chunk_size maximum block size read from file + * @return array(fp, array(changeloglines), $head, $tail, $eof)|bool + * returns false when not succeed. fp only defined for chuck reading, needs closing. + */ +function _readloglines($file, $rev, $chunk_size) { if(!@file_exists($file)) { return false; } - //get $lines from changelog - $lines = array(); $fp = null; - $tail = 0; $head = 0; + $tail = 0; $eof = 0; if(filesize($file) < $chunk_size || $chunk_size == 0) { // read whole file - $uses_chuncks = false; - $lines = file($file); + $lines = file($file); if($lines === false) { return false; } } else { // read by chunk - $uses_chuncks = true; - $fp = fopen($file, 'rb'); // "file pointer" + $fp = fopen($file, 'rb'); // "file pointer" if($fp === false) { return false; - } //error + } $head = 0; - fseek($fp, 0, SEEK_END); //set file position indicator 0 byte from end. - $tail = ftell($fp); //return current position of pointer as integer - $eof = $tail; + fseek($fp, 0, SEEK_END); + $eof = ftell($fp); + $tail = $eof; $finger = 0; $finger_rev = 0; // find chunk while($tail - $head > $chunk_size) { $finger = $head + floor(($tail - $head) / 2.0); - $finger = getNewlinepointer($fp, $finger); - $tmp = fgets($fp); // then read at that location + $finger = _getNewlinepointer($fp, $finger); + $tmp = fgets($fp); $tmp = parseChangelogLine($tmp); $finger_rev = $tmp['date']; if($finger == $head || $finger == $tail) { @@ -637,87 +678,15 @@ function getRelativeRevision($id, $rev, $direction, $chunk_size = 8192, $media = return false; } - $lines = readChunk($fp, $head, $tail); - } - - // look for revisions later then $rev, when founded count till the wanted revision is reached - // also parse and cache changelog lines that pass - $revcounter = 0; - $relrev = false; - $tmp = array(); - $checkotherchunck = true; //always runs once - while(!$relrev && $checkotherchunck) { - - if($direction > 0) { - foreach($lines as $value) { - $tmp = parseChangelogLine($value); - if($tmp !== false) { - $cache[$id][$tmp['date']] = $tmp; - //look for revs older then reference $rev and select $direction-th one - if($tmp['date'] > $rev) { - $revcounter++; - if($revcounter == $direction) { - $relrev = $tmp['date']; - } - } - } - } - } else { - //parse in reverse order - for($i = count($lines) - 1; $i >= 0; $i--) { - $tmp = parseChangelogLine($lines[$i]); - if($tmp !== false) { - $cache[$id][$tmp['date']] = $tmp; - //look for revs older then reference $rev and select $direction-th one - if($tmp['date'] < $rev) { - $revcounter++; - if($revcounter == abs($direction)) { - $relrev = $tmp['date']; - } - } - } - } - } - - //true when $rev is found, but not the wanted follow-up. - $checkotherchunck = $uses_chuncks - && ($tmp['date'] == $rev || ($revcounter > 0 && !$relrev)) - && !(($tail == $eof && $direction > 0) || ($head == 0 && $direction < 0)); - - if($checkotherchunck) { - if($direction > 0) { - //get interval of next chunck, smaller than $chunck_size - $head = $tail; - $lookpointer = true; - $tail = $head + floor($chunk_size * (2 / 3)); - while($lookpointer) { - $tail = min($tail, $eof); - $tail = getNewlinepointer($fp, $tail); - $lookpointer = $tail - $head > $chunk_size; - if($lookpointer) { - $tail = $head + floor(($tail - $head) / 2); - } - if($tail == $head) break; - } - } else { - $tail = $head; - $head = max($tail - $chunk_size, 0); - $head = getNewlinepointer($fp, $head); - } - - //load next chunck - $lines = readChunk($fp, $head, $tail); - if(empty($lines)) break; - } - } - if($uses_chuncks) { - fclose($fp); + $lines = _readChunk($fp, $head, $tail); } - - if(isset($INFO['meta']['last_change']) && $relrev == $INFO['meta']['last_change']['date']) { - return 'current'; - } - return $relrev; + return array( + $fp, + $lines, + $head, + $tail, + $eof + ); } /** @@ -729,16 +698,16 @@ function getRelativeRevision($id, $rev, $direction, $chunk_size = 8192, $media = * @param $tail int end point chunck * @return array lines read from chunck */ -function readChunk($fp, $head, $tail) { +function _readChunk($fp, $head, $tail) { $chunk = ''; $chunk_size = max($tail - $head, 0); // found chunk size $got = 0; fseek($fp, $head); while($got < $chunk_size && !feof($fp)) { $tmp = @fread($fp, max($chunk_size - $got, 0)); - if($tmp === false) { + if($tmp === false) { //error state break; - } //error state + } $got += strlen($tmp); $chunk .= $tmp; } @@ -754,7 +723,7 @@ function readChunk($fp, $head, $tail) { * @param $finger int a pointer * @return int pointer */ -function getNewlinepointer($fp, $finger) { +function _getNewlinepointer($fp, $finger) { fseek($fp, $finger); fgets($fp); // slip the finger forward to a new line return ftell($fp); -- cgit v1.2.3 From 2a2a2ba2f6092b0b68a7de0ccc798062682487f4 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Fri, 2 Aug 2013 21:35:13 +0100 Subject: added basic suport for embedding (html5) videos --- inc/parser/xhtml.php | 66 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 62 insertions(+), 4 deletions(-) (limited to 'inc') diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 84a999e56..747f0e8a0 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -795,8 +795,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),($linking=='direct')); - }elseif($mime == 'application/x-shockwave-flash' && $render){ - // don't link flash movies + }elseif(($mime == 'application/x-shockwave-flash' || substr($mime,0,5) == 'video') && $render){ + // don't link movies $noLink = true; }else{ // add file icons @@ -831,8 +831,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' || substr($mime,0,5) == 'video') && $render){ + // don't link movies $noLink = true; }else{ // add file icons @@ -1093,6 +1093,28 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $ret .= ' />'; + }elseif(substr($mime,0,5) == '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, $title, $mime, $width, $height, $att); + }elseif($mime == 'application/x-shockwave-flash'){ if (!$render) { // if the flash is not supposed to be rendered @@ -1226,6 +1248,42 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } + /** + * Embed video(s) in HTML + * + * @author Anika Henke + * + * @param string $src - ID of video to embed + * @param string $title - title of the video + * @param string $mime - mimetype of the video + * @param int $width - width of the video in pixels + * @param int $height - height of the video in pixels + * @param array $atts - additional attributes for the