diff options
Diffstat (limited to 'inc/parser')
-rw-r--r-- | inc/parser/code.php | 1 | ||||
-rw-r--r-- | inc/parser/metadata.php | 4 | ||||
-rw-r--r-- | inc/parser/renderer.php | 48 | ||||
-rw-r--r-- | inc/parser/xhtml.php | 81 | ||||
-rw-r--r-- | inc/parser/xhtmlsummary.php | 1 |
5 files changed, 64 insertions, 71 deletions
diff --git a/inc/parser/code.php b/inc/parser/code.php index 0b8e3ee02..d77ffd1aa 100644 --- a/inc/parser/code.php +++ b/inc/parser/code.php @@ -5,7 +5,6 @@ * @author Andreas Gohr <andi@splitbrain.org> */ if(!defined('DOKU_INC')) die('meh.'); -require_once DOKU_INC . 'inc/parser/renderer.php'; class Doku_Renderer_code extends Doku_Renderer { var $_codeblock=0; diff --git a/inc/parser/metadata.php b/inc/parser/metadata.php index 8ba159d62..82a268fd6 100644 --- a/inc/parser/metadata.php +++ b/inc/parser/metadata.php @@ -16,8 +16,6 @@ if ( !defined('DOKU_TAB') ) { define ('DOKU_TAB',"\t"); } -require_once DOKU_INC . 'inc/parser/renderer.php'; - /** * The Renderer */ @@ -301,7 +299,7 @@ class Doku_Renderer_metadata extends Doku_Renderer { // first resolve and clean up the $id resolve_pageid(getNS($ID), $id, $exists); - list($page, $hash) = explode('#', $id, 2); + @list($page, $hash) = explode('#', $id, 2); // set metadata $this->meta['relation']['references'][$page] = $exists; diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index e3401fd48..0c3c56c56 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -6,8 +6,6 @@ * @author Andreas Gohr <andi@splitbrain.org> */ if(!defined('DOKU_INC')) die('meh.'); -require_once DOKU_INC . 'inc/plugin.php'; -require_once DOKU_INC . 'inc/pluginutils.php'; /** * An empty renderer, produces no output @@ -273,17 +271,17 @@ class Doku_Renderer extends DokuWiki_Plugin { * * @author Andreas Gohr <andi@splitbrain.org> */ - function _simpleTitle($name){ + function _simpleTitle($name) { global $conf; //if there is a hash we use the ancor name only - list($name,$hash) = explode('#',$name,2); + @list($name, $hash) = explode('#', $name, 2); if($hash) return $hash; - if($conf['useslash']){ - $name = strtr($name,';/',';:'); - }else{ - $name = strtr($name,';',':'); + if($conf['useslash']) { + $name = strtr($name, ';/', ';:'); + } else { + $name = strtr($name, ';', ':'); } return noNSorNS($name); @@ -292,9 +290,9 @@ class Doku_Renderer extends DokuWiki_Plugin { /** * Resolve an interwikilink */ - function _resolveInterWiki(&$shortcut,$reference){ + function _resolveInterWiki(&$shortcut, $reference, &$exists=null) { //get interwiki URL - if ( isset($this->interwiki[$shortcut]) ) { + if(isset($this->interwiki[$shortcut])) { $url = $this->interwiki[$shortcut]; } else { // Default to Google I'm feeling lucky @@ -303,25 +301,31 @@ class Doku_Renderer extends DokuWiki_Plugin { } //split into hash and url part - list($reference,$hash) = explode('#',$reference,2); + @list($reference, $hash) = explode('#', $reference, 2); //replace placeholder - if(preg_match('#\{(URL|NAME|SCHEME|HOST|PORT|PATH|QUERY)\}#',$url)){ + if(preg_match('#\{(URL|NAME|SCHEME|HOST|PORT|PATH|QUERY)\}#', $url)) { //use placeholders - $url = str_replace('{URL}',rawurlencode($reference),$url); - $url = str_replace('{NAME}',$reference,$url); + $url = str_replace('{URL}', rawurlencode($reference), $url); + $url = str_replace('{NAME}', $reference, $url); $parsed = parse_url($reference); if(!$parsed['port']) $parsed['port'] = 80; - $url = str_replace('{SCHEME}',$parsed['scheme'],$url); - $url = str_replace('{HOST}',$parsed['host'],$url); - $url = str_replace('{PORT}',$parsed['port'],$url); - $url = str_replace('{PATH}',$parsed['path'],$url); - $url = str_replace('{QUERY}',$parsed['query'],$url); - }else{ + $url = str_replace('{SCHEME}', $parsed['scheme'], $url); + $url = str_replace('{HOST}', $parsed['host'], $url); + $url = str_replace('{PORT}', $parsed['port'], $url); + $url = str_replace('{PATH}', $parsed['path'], $url); + $url = str_replace('{QUERY}', $parsed['query'], $url); + } else { //default - $url = $url.rawurlencode($reference); + $url = $url . rawurlencode($reference); + } + //handle as wiki links + if($url{0} === ':') { + list($id, $urlparam) = explode('?', $url, 2); + $url = wl(cleanID($id), $urlparam); + $exists = page_exists($id); } - if($hash) $url .= '#'.rawurlencode($hash); + if($hash) $url .= '#' . rawurlencode($hash); return $url; } diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index dc0759821..dee3c922d 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -17,9 +17,6 @@ if ( !defined('DOKU_TAB') ) { define ('DOKU_TAB',"\t"); } -require_once DOKU_INC . 'inc/parser/renderer.php'; -require_once DOKU_INC . 'inc/html.php'; - /** * The Renderer */ @@ -563,6 +560,12 @@ class Doku_Renderer_xhtml extends Doku_Renderer { * $search,$returnonly & $linktype are not for the renderer but are used * elsewhere - no need to implement them in other renderers * + * @param string $id pageid + * @param string|null $name link name + * @param string|null $search adds search url param + * @param bool $returnonly whether to return html or write to doc attribute + * @param string $linktype type to set use of headings + * @return void|string writes to doc attribute or returns html depends on $returnonly * @author Andreas Gohr <andi@splitbrain.org> */ function internallink($id, $name = null, $search=null,$returnonly=false,$linktype='content') { @@ -604,7 +607,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } //keep hash anchor - list($id,$hash) = explode('#',$id,2); + @list($id,$hash) = explode('#',$id,2); if(!empty($hash)) $hash = $this->_headerToLink($hash); //prepare for formating @@ -689,7 +692,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } /** - */ + */ function interwikilink($match, $name = null, $wikiName, $wikiUri) { global $conf; @@ -701,19 +704,28 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $link['name'] = $this->_getLinkTitle($name, $wikiUri, $isImage); //get interwiki URL - $url = $this->_resolveInterWiki($wikiName,$wikiUri); + $exists = null; + $url = $this->_resolveInterWiki($wikiName, $wikiUri, $exists); - if ( !$isImage ) { - $class = preg_replace('/[^_\-a-z0-9]+/i','_',$wikiName); + if(!$isImage) { + $class = preg_replace('/[^_\-a-z0-9]+/i', '_', $wikiName); $link['class'] = "interwiki iw_$class"; } else { $link['class'] = 'media'; } //do we stay at the same server? Use local target - if( strpos($url,DOKU_URL) === 0 ){ + if(strpos($url, DOKU_URL) === 0 OR strpos($url, DOKU_BASE) === 0) { $link['target'] = $conf['target']['wiki']; } + if($exists !== null && !$isImage) { + if($exists) { + $link['class'] .= ' wikilink1'; + } else { + $link['class'] .= ' wikilink2'; + $link['rel'] = 'nofollow'; + } + } $link['url'] = $url; $link['title'] = htmlspecialchars($link['url']); @@ -1100,47 +1112,29 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $ret .= ' />'; - }elseif(media_supportedav($mime, 'video')){ + }elseif(media_supportedav($mime, 'video') || 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))); - } + $title = !is_null($title) ? $this->_xmlEntities($title) : false; if (!$render) { - // if the video is not supposed to be rendered - // return the title of the video - return $title; + // if the file is not supposed to be rendered + // return the title of the file (just the sourcename if there is no title) + return $title ? $title : $this->_xmlEntities(utf8_basename(noNS($src))); } $att = array(); $att['class'] = "media$align"; + if ($title) { + $att['title'] = $title; + } - //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 (media_supportedav($mime, 'video')) { + //add video + $ret .= $this->_video($src, $width, $height, $att); } - if (!$title) { - // just show the sourcename - $title = $this->_xmlEntities(utf8_basename(noNS($src))); + if (media_supportedav($mime, 'audio')) { + //add audio + $ret .= $this->_audio($src, $att); } - 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) { @@ -1286,7 +1280,6 @@ class Doku_Renderer_xhtml extends Doku_Renderer { * @return string */ function _video($src,$width,$height,$atts=null){ - // prepare width and height if(is_null($atts)) $atts = array(); $atts['width'] = (int) $width; @@ -1313,7 +1306,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { // output source for each alternative video format foreach($alternatives as $mime => $file) { $url = ml($file,array('cache'=>$cache),true,'&'); - $title = $this->_xmlEntities(utf8_basename(noNS($file))); + $title = $atts['title'] ? $atts['title'] : $this->_xmlEntities(utf8_basename(noNS($file))); $out .= '<source src="'.hsc($url).'" type="'.$mime.'" />'.NL; // alternative content (just a link to the file) @@ -1349,7 +1342,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { // output source for each alternative audio format foreach($alternatives as $mime => $file) { $url = ml($file,array('cache'=>$cache),true,'&'); - $title = $this->_xmlEntities(utf8_basename(noNS($file))); + $title = $atts['title'] ? $atts['title'] : $this->_xmlEntities(utf8_basename(noNS($file))); $out .= '<source src="'.hsc($url).'" type="'.$mime.'" />'.NL; // alternative content (just a link to the file) diff --git a/inc/parser/xhtmlsummary.php b/inc/parser/xhtmlsummary.php index 95f86cbef..867b71f6a 100644 --- a/inc/parser/xhtmlsummary.php +++ b/inc/parser/xhtmlsummary.php @@ -1,6 +1,5 @@ <?php if(!defined('DOKU_INC')) die('meh.'); -require_once DOKU_INC . 'inc/parser/xhtml.php'; /** * The summary XHTML form selects either up to the first two paragraphs |