function testVideoOGVInternal() { $file = 'wiki:kind_zu_katze.ogv'; $parser_response = p_get_instructions('{{' . $file . '}}'); $calls = array(array('document_start', array()), array('p_open', array()), array('internalmedia', array($file, null, null, null, null, 'cache', 'details')), array('cdata', array(null)), array('p_close', array()), array('document_end', array())); $this->assertEquals(array_map('stripbyteindex', $parser_response), $calls); $Renderer = new Doku_Renderer_xhtml(); $url = $Renderer->externalmedia($file, null, null, null, null, 'cache', 'details', true); $video = '<video class="media" width="320" height="240" controls="controls" poster="' . DOKU_BASE . 'lib/exe/fetch.php?media=wiki:kind_zu_katze.png">'; $substr_start = 0; $substr_len = strlen($video); $this->assertEquals($video, substr($url, $substr_start, $substr_len)); // find $source_webm in $url $source_webm = '<source src="' . DOKU_BASE . 'lib/exe/fetch.php?media=wiki:kind_zu_katze.webm" type="video/webm" />'; $substr_start = strpos($url, $source_webm, $substr_start + $substr_len); $this->assertNotSame(false, $substr_start, 'Substring not found.'); // find $source_ogv in $url $source_ogv = '<source src="' . DOKU_BASE . 'lib/exe/fetch.php?media=wiki:kind_zu_katze.ogv" type="video/ogg" />'; $substr_start = strpos($url, $source_ogv, $substr_start + strlen($source_webm)); $this->assertNotSame(false, $substr_start, 'Substring not found.'); // find $a_webm in $url $a_webm = '<a href="' . DOKU_BASE . 'lib/exe/fetch.php?id=&cache=&media=wiki:kind_zu_katze.webm" class="media mediafile mf_webm" title="wiki:kind_zu_katze.webm (99.1 KB)">kind_zu_katze.webm</a>'; $substr_start = strpos($url, $a_webm, $substr_start + strlen($source_ogv)); $this->assertNotSame(false, $substr_start, 'Substring not found.'); // find $a_webm in $url $a_ogv = '<a href="' . DOKU_BASE . 'lib/exe/fetch.php?id=&cache=&media=wiki:kind_zu_katze.ogv" class="media mediafile mf_ogv" title="wiki:kind_zu_katze.ogv (44.8 KB)">kind_zu_katze.ogv</a>'; $substr_start = strpos($url, $a_ogv, $substr_start + strlen($a_webm)); $this->assertNotSame(false, $substr_start, 'Substring not found.'); $rest = '</video>' . "\n"; $substr_start = strlen($url) - strlen($rest); $this->assertEquals($rest, substr($url, $substr_start)); }
/** * Convenience function to quickly build a wikilink * * @author Andreas Gohr <*****@*****.**> */ function html_wikilink($id, $name = NULL, $search = '') { static $xhtml_renderer = NULL; if (is_null($xhtml_renderer)) { require_once DOKU_INC . 'inc/parser/xhtml.php'; $xhtml_renderer = new Doku_Renderer_xhtml(); } return $xhtml_renderer->internallink($id, $name, $search, true, 'navigation'); }
function test_emaillink_with_media() { global $conf; $conf['mailguard'] = 'visible'; $conf['userewrite'] = 2; $image = array('type' => 'internalmedia', 'src' => 'img.gif', 'title' => 'Some Image', 'align' => NULL, 'width' => 10, 'height' => 20, 'cache' => 'nocache', 'linking' => 'details'); $p = new Doku_Renderer_xhtml(); $p->emaillink('*****@*****.**', $image); $expect = '<a href="mailto:foo%20%5Bat%5D%20example%20%5Bdot%5D%20com" class="media" title="foo [at] example [dot] com"><img src="' . DOKU_BASE . 'lib/exe/fetch.php/img.gif?w=10&h=20&cache=nocache" class="media" title="Some Image" alt="Some Image" width="10" height="20" /></a>'; $this->assertEqual($p->doc, $expect); }
protected function convertToLink($href, $label, $varspace = array()) { $href = trim($href); if ($href === '') { return $label; } if (is_array($varspace) && count($varspace)) { $href = $this->replaceMarkup($href, $varspace); } if (strpos($href, '://') !== false) { // embed external link in header // externallink() is adding to renderer->doc() ... // --> remove from doc afterwards, thus store its length now $length = strlen($this->renderer->doc); $this->renderer->externallink($href, $label); // --> now extract rendered link from doc $label = substr($this->renderer->doc, $length); $this->renderer->doc = substr_replace($this->renderer->doc, '', $length); } else { // embed internal link in header resolve_pageid(getNS(self::getPageID()), $href, $exists); $label = $this->renderer->internallink($href, $label, NULL, true); } return $label; }
/** * Initialize the rendering */ function document_start() { global $ID; global $conf; global $lang; // call the parent parent::document_start(); // store the content type headers in metadata $headers = array( 'Content-Type' => 'text/html; charset=utf-8' ); $theme = isset($_GET['theme'])?$_GET['theme']:$this->getConf('theme'); p_set_metadata($ID,array('format' => array('revealjs' => $headers) )); $this->base = DOKU_BASE.'lib/plugins/revealjs/'; $this->doc = ' <!DOCTYPE html> <html lang="'.$conf['lang'].'" dir="'.$lang['direction'].'"> <head> <meta charset="utf-8"> <title>'.tpl_pagetitle($ID, true).'</title> <meta name="description" content="A framework for easily creating beautiful presentations using HTML"> <meta name="author" content="Hakim El Hattab"> <meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui"> <link rel="stylesheet" href="'.$this->base.'css/reveal.css"> <link rel="stylesheet" href="'.$this->base.'css/theme/'.$theme.'.css" id="theme"> <link rel="stylesheet" href="'.$this->base.'doku-substitutes.css"> <!-- Code syntax highlighting --> <link rel="stylesheet" href="'.$this->base.'lib/css/zenburn.css"> <!-- Printing and PDF exports --> <script> var link = document.createElement( \'link\' ); link.rel = \'stylesheet\'; link.type = \'text/css\'; link.href = window.location.search.match( /print-pdf/gi ) ? \''.$this->base.'css/print/pdf.css\' : \''.$this->base.'css/print/paper.css\'; document.getElementsByTagName( \'head\' )[0].appendChild( link ); </script> <!--[if lt IE 9]> <script src='.$this->base.'"lib/js/html5shiv.js"></script> <![endif]--> </head> <body> <div class="reveal"> <!-- Any section element inside of this container is displayed as a slide --> <div class="slides"> '; }
public function p_close() { parent::p_close(); if ($this->sum_capture && $this->sum_paragraphs >= 2) { $this->sum_summary .= $this->doc; $this->sum_capture = false; } }
/** * Initialize the rendering */ function document_start() { global $ID; // call the parent parent::document_start(); // store the content type headers in metadata $headers = array('Content-Type' => 'text/html; charset=utf-8'); p_set_metadata($ID, array('format' => array('s5' => $headers))); $this->base = DOKU_BASE . 'lib/plugins/s5/ui/'; $this->tpl = $this->getConf('template'); }
function internallink($id, $name = null, $search = null, $returnonly = false, $linktype = 'content') { $name = trim($name); if (!$name) { $id = trim($id); if (preg_match('/(.*?\\?)$/', $id, $matches)) { $name = $matches[1]; } } parent::internallink($id, $name, $search, $returnonly, $linktype); }
function header($text, $level, $pos) { parent::header($text, $level, $pos); if ($this->_displayPN()) { $pnid = $this->_getID($this->getConf('numbering') ? 2 : 1); $linkText = $this->getConf('linkText') ? $pnid : '§'; $link = ' <a href="#' . $pnid . '" id="' . $pnid; $link .= '" class="pn" title="' . $this->getLang('sectionlink') . '">' . $linkText . '</a>'; $link .= $this->_getAnnotationLink(); $this->doc = preg_replace('/(<\\/h[1-5]>)$/', $link . '\\1', $this->doc); } }
/** * Initialize the rendering */ function document_start() { global $ID; // call the parent parent::document_start(); // store the content type headers in metadata $headers = array('Content-Type' => 'text/html; charset=utf-8'); p_set_metadata($ID, array('format' => array('s5reloaded' => $headers))); $this->base = DOKU_MEDIA . 'lib/plugins/s5reloaded/ui/'; /* $this->tpl = $this->getConf('template'); */ $this->tpl = isset($_GET['s5theme']) ? $_GET['s5theme'] : $this->getConf('template'); }
function testVideoOGVInternal() { $this->markTestSkipped('Skipped because it is failing'); $file = 'wiki:kind_zu_katze.ogv'; $parser_response = p_get_instructions('{{' . $file . '}}'); $calls = array(array('document_start', array()), array('p_open', array()), array('internalmedia', array($file, null, null, null, null, 'cache', 'details')), array('cdata', array(null)), array('p_close', array()), array('document_end', array())); $this->assertEquals(array_map('stripbyteindex', $parser_response), $calls); $Renderer = new Doku_Renderer_xhtml(); $url = $Renderer->externalmedia($file, null, null, null, null, 'cache', 'details', true); $video = '<video class="media" width="320" height="240" controls="controls" poster="/./lib/exe/fetch.php?media=wiki:kind_zu_katze.png">'; $this->assertEquals(substr($url, 0, 125), $video); $source_webm = '<source src="/./lib/exe/fetch.php?media=wiki:kind_zu_katze.webm" type="video/webm" />'; $this->assertEquals(substr($url, 126, 85), $source_webm); $source_ogv = '<source src="/./lib/exe/fetch.php?media=wiki:kind_zu_katze.ogv" type="video/ogg" />'; $this->assertEquals(substr($url, 212, 83), $source_ogv); $a_webm = '<a href="/./lib/exe/fetch.php?id=&cache=&media=wiki:kind_zu_katze.webm" class="media mediafile mf_webm" title="wiki:kind_zu_katze.webm (99.1 KB)">kind_zu_katze.webm</a>'; $a_ogv = '<a href="/./lib/exe/fetch.php?id=&cache=&media=wiki:kind_zu_katze.ogv" class="media mediafile mf_ogv" title="wiki:kind_zu_katze.ogv (44.8 KB)">kind_zu_katze.ogv</a>'; $this->assertEquals(substr($url, 296, 176), $a_webm); $this->assertEquals(substr($url, 472, 172), $a_ogv); $rest = '</video>' . "\n"; $this->assertEquals(substr($url, 644), $rest); }
/** * Initialize the rendering */ function document_start() { global $ID; // call the parent parent::document_start(); // store the content type headers in metadata $headers = array('Content-Type' => 'text/html; charset=utf-8'); p_set_metadata($ID, array('format' => array('s5' => $headers))); $this->base = DOKU_BASE . 'lib/plugins/s5/ui/'; $this->tpl = isset($_GET['s5theme']) ? $_GET['s5theme'] : $this->getConf('template'); $this->tpl = preg_replace('/[^a-z0-9_-]+/', '', $this->tpl); // clean user provided path }
function section_close() { global $sectionCount; global $hasContent; global $sectionTitle; global $ID; // I want to do this // Only if in "trail" (learning) mode session_start(); //error_log("section_close on ".$ID." isTrailing: ".print_r(isset($_SESSION[DOKU_COOKIE]['isTrailing']),true)); if (isset($_SESSION[DOKU_COOKIE]['isTrailing'])) { if ($hasContent && $sectionCount != 1) { $this->doc .= DOKU_LF . '<div class=\'secedit editbutton_' . $sectionCount . '\'><form class=\'button btn_secedit\'>'; $this->doc .= '<a href="#" class="likeLink" onclick="driver_addSectionJump(\'' . $sectionTitle . '\');return false;">'; $this->doc .= 'Like</a></form></div>'; } } // parent code parent::section_close(); //$this->doc .= DOKU_LF.'</div>'.DOKU_LF; }
/** * no obfuscation for email addresses */ function emaillink($address, $name = NULL) { global $conf; $old = $conf['mailguard']; $conf['mailguard'] = 'none'; parent::emaillink($address, $name); $conf['mailguard'] = $old; }
/** * Lists all links contained in a wiki page * * @author Michael Klier <*****@*****.**> */ function listLinks($id) { $id = $this->resolvePageId($id); if (auth_quickaclcheck($id) < AUTH_READ) { throw new RemoteAccessDeniedException('You are not allowed to read this page', 111); } $links = array(); // resolve page instructions $ins = p_cached_instructions(wikiFN($id)); // instantiate new Renderer - needed for interwiki links include DOKU_INC . 'inc/parser/xhtml.php'; $Renderer = new Doku_Renderer_xhtml(); $Renderer->interwiki = getInterwiki(); // parse parse instructions foreach ($ins as $in) { $link = array(); switch ($in[0]) { case 'internallink': $link['type'] = 'local'; $link['page'] = $in[1][0]; $link['href'] = wl($in[1][0]); array_push($links, $link); break; case 'externallink': $link['type'] = 'extern'; $link['page'] = $in[1][0]; $link['href'] = $in[1][0]; array_push($links, $link); break; case 'interwikilink': $url = $Renderer->_resolveInterWiki($in[1][2], $in[1][3]); $link['type'] = 'extern'; $link['page'] = $url; $link['href'] = $url; array_push($links, $link); break; } } return $links; }
/** * Produced by syntax like [[#test|my caption]] */ function test_empty_locallink_with_caption() { $page = 'my:spacex'; $caption = 'my caption'; global $ID; $ID = $page; global $conf; $conf['basedir'] = '/'; $conf['useheading'] = 0; $conf['userewrite'] = 0; $conf['useslash'] = 0; $conf['canonical'] = 0; $p = new Doku_Renderer_xhtml(); $p->locallink('test', $caption); $expect = '<a href="#test" title="' . $page . ' ↵" class="wikilink1">' . $caption . '</a>'; $this->assertEqual($p->doc, $expect); }
/** * Displays list of selected/deleted pages * * @param Doku_Renderer_xhtml $renderer * @param array $list array with pageids as key, status as value * @param string $action 'remove' or 'include' */ private function showPagelist($renderer, $list, $action) { $jslang = $this->getLang('js'); if ($action == 'remove') { $id = 'deletedpagelist'; $heading = 'removed'; $actiontitle = $jslang['include']; } else { $id = 'pagelist'; $heading = 'toprint'; $actiontitle = $jslang['remove']; } $renderer->header($this->getLang($heading), 2, 0); $renderer->doc .= "<ul id={$id} class='pagelist {$action}'>"; foreach ($list as $pageid => $cpt) { if ($action == 'remove' && $cpt == 0 || $action == 'include' && $cpt == 1) { $renderer->doc .= "<li class='level1' id='pg__{$pageid}' title='{$this->getLang('sortable')}'>"; $renderer->doc .= "<a class='action' title='{$actiontitle}'></a>"; $renderer->doc .= ' '; $renderer->doc .= $this->createLink($pageid); $renderer->listitem_close(); } } $renderer->listu_close(); }
/** * Return XHTML formated data, depending on column type * * @param array $column * @param string $value * @param Doku_Renderer_xhtml $R * @return string */ function _formatData($column, $value, Doku_Renderer_xhtml $R) { global $conf; $vals = explode("\n", $value); $outs = array(); //multivalued line from db result for pageid and wiki has only in first value the ID $storedID = ''; foreach ($vals as $val) { $val = trim($val); if ($val == '') { continue; } $type = $column['type']; if (is_array($type)) { $type = $type['type']; } switch ($type) { case 'page': $val = $this->_addPrePostFixes($column['type'], $val); $val = $this->ensureAbsoluteId($val); $outs[] = $R->internallink($val, null, null, true); break; case 'title': list($id, $title) = explode('|', $val, 2); $id = $this->_addPrePostFixes($column['type'], $id); $id = $this->ensureAbsoluteId($id); $outs[] = $R->internallink($id, $title, null, true); break; case 'pageid': list($id, $title) = explode('|', $val, 2); //use ID from first value of the multivalued line if ($title == null) { $title = $id; if (!empty($storedID)) { $id = $storedID; } } else { $storedID = $id; } $id = $this->_addPrePostFixes($column['type'], $id); $outs[] = $R->internallink($id, $title, null, true); break; case 'nspage': // no prefix/postfix here $val = ':' . $column['key'] . ":{$val}"; $outs[] = $R->internallink($val, null, null, true); break; case 'mail': list($id, $title) = explode(' ', $val, 2); $id = $this->_addPrePostFixes($column['type'], $id); $id = obfuscate(hsc($id)); if (!$title) { $title = $id; } else { $title = hsc($title); } if ($conf['mailguard'] == 'visible') { $id = rawurlencode($id); } $outs[] = '<a href="mailto:' . $id . '" class="mail" title="' . $id . '">' . $title . '</a>'; break; case 'url': $val = $this->_addPrePostFixes($column['type'], $val); $outs[] = $this->external_link($val, false, 'urlextern'); break; case 'tag': // per default use keyname as target page, but prefix on aliases if (!is_array($column['type'])) { $target = $column['key'] . ':'; } else { $target = $this->_addPrePostFixes($column['type'], ''); } $outs[] = '<a href="' . wl(str_replace('/', ':', cleanID($target)), $this->_getTagUrlparam($column, $val)) . '" title="' . sprintf($this->getLang('tagfilter'), hsc($val)) . '" class="wikilink1">' . hsc($val) . '</a>'; break; case 'timestamp': $outs[] = dformat($val); break; case 'wiki': global $ID; $oldid = $ID; list($ID, $data) = explode('|', $val, 2); //use ID from first value of the multivalued line if ($data == null) { $data = $ID; $ID = $storedID; } else { $storedID = $ID; } $data = $this->_addPrePostFixes($column['type'], $data); // Trim document_{start,end}, p_{open,close} from instructions $allinstructions = p_get_instructions($data); $wraps = 1; if (isset($allinstructions[1]) && $allinstructions[1][0] == 'p_open') { $wraps++; } $instructions = array_slice($allinstructions, $wraps, -$wraps); $outs[] = p_render('xhtml', $instructions, $byref_ignore); $ID = $oldid; break; default: $val = $this->_addPrePostFixes($column['type'], $val); //type '_img' or '_img<width>' if (substr($type, 0, 3) == 'img') { $width = (int) substr($type, 3); if (!$width) { $width = $this->getConf('image_width'); } list($mediaid, $title) = explode('|', $val, 2); if ($title === null) { $title = $column['key'] . ': ' . basename(str_replace(':', '/', $mediaid)); } else { $title = trim($title); } if (media_isexternal($val)) { $html = $R->externalmedia($mediaid, $title, $align = null, $width, $height = null, $cache = null, $linking = 'direct', true); } else { $html = $R->internalmedia($mediaid, $title, $align = null, $width, $height = null, $cache = null, $linking = 'direct', true); } if (strpos($html, 'mediafile') === false) { $html = str_replace('href', 'rel="lightbox" href', $html); } $outs[] = $html; } else { $outs[] = hsc($val); } } } return join(', ', $outs); }
function table_open($maxcols = null, $numrows = null, $pos = null) { $this->doc .= "\n<span class='np_break'> </span>\n"; parent::table_open($maxcols = null, $numrows = null, $pos = null); }
public function section_close() { $this->doc .= "</div>"; parent::section_close(); }
function _xmlEntities($string) { $string = parent::_xmlEntities($string); if ($this->info['scriptmode']) { $string = str_replace(array("<%", "%>", "<?", "?>"), array("<%", "%>", "<?", "?>"), $string); } return $string; }
/** * Adds a TOC item */ function _addToTOC($text, $level, Doku_Renderer_xhtml &$renderer) { global $conf; if ($level >= $conf['toptoclevel'] && $level <= $conf['maxtoclevel']) { $hid = $renderer->_headerToLink($text, 'true'); $renderer->toc[] = array('hid' => $hid, 'title' => $text, 'type' => 'ul', 'level' => $level - $conf['toptoclevel'] + 1); } return $hid; }
function document_end() { // Pump the last doc $this->sections[$this->sectionNumber] = array('level' => $this->previousNodeLevel, 'position' => $this->previousNodePosition, 'content' => $this->doc, 'text' => $this->previousSectionTextHeader); // Recreate the doc $this->doc = ''; foreach ($this->sections as $sectionNumber => $section) { // The content $this->doc .= $section['content']; // No TOC or bar for an admin page global $ACT; if ($ACT != 'admin' and $ACT != 'search') { // TOC After the content if ($this->info['toc'] == true and $section['level'] == 1 and $section['position'] == 1) { global $conf; if (count($this->toc) > $conf['tocminheads']) { global $TOC; $TOC = $this->toc; $this->doc .= tpl_toc($return = true); } } // Adbar after the content // Adbar later // if ($section['level'] == 2 and // $section['position'] == 1 and // $ID <> 'adbar12' and // $ID <> 'start' // ) { // // // $ID <> 'adbar12' to not come in a recursive call // // as tpl_include_call also the renderer process // // $this->doc .= tpl_include_page('adbar12', $print = false, $propagate = true); // // } } } parent::document_end(); }