summaryrefslogtreecommitdiff
path: root/inc/parser/xhtml.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/parser/xhtml.php')
-rw-r--r--inc/parser/xhtml.php87
1 files changed, 42 insertions, 45 deletions
diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index 32aa99a1b..5fca1bf45 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -33,6 +33,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
private $lastsecid = 0; // last section edit id, used by startSectionEdit
var $headers = array();
+ /** @var array a list of footnotes, list starts at 1! */
var $footnotes = array();
var $lastlevel = 0;
var $node = array(0,0,0,0,0);
@@ -59,7 +60,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
* Finish an edit section range
*
* @param $end int The byte position for the edit end; null for the rest of
- the page
+ * the page
* @author Adrian Lang <lang@cosmocode.de>
*/
public function finishSectionEdit($end = null) {
@@ -100,10 +101,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
if ( count ($this->footnotes) > 0 ) {
$this->doc .= '<div class="footnotes">'.DOKU_LF;
- $id = 0;
- foreach ( $this->footnotes as $footnote ) {
- $id++; // the number of the current footnote
-
+ foreach ( $this->footnotes as $id => $footnote ) {
// check its not a placeholder that indicates actual footnote text is elsewhere
if (substr($footnote, 0, 5) != "@@FNT") {
@@ -116,11 +114,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$alt = array_keys($this->footnotes, "@@FNT$id");
if (count($alt)) {
- foreach ($alt as $ref) {
- // set anchor and backlink for the other footnotes
- $this->doc .= ', <sup><a href="#fnt__'.($ref+1).'" id="fn__'.($ref+1).'" class="fn_bot">';
- $this->doc .= ($ref+1).')</a></sup> '.DOKU_LF;
- }
+ foreach ($alt as $ref) {
+ // set anchor and backlink for the other footnotes
+ $this->doc .= ', <sup><a href="#fnt__'.($ref).'" id="fn__'.($ref).'" class="fn_bot">';
+ $this->doc .= ($ref).')</a></sup> '.DOKU_LF;
+ }
}
// add footnote markup and close this footnote
@@ -295,6 +293,10 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
* @author Andreas Gohr
*/
function footnote_close() {
+ /** @var $fnid int takes track of seen footnotes, assures they are unique even across multiple docs FS#2841 */
+ static $fnid = 0;
+ // assign new footnote id (we start at 1)
+ $fnid++;
// recover footnote into the stack and restore old content
$footnote = $this->doc;
@@ -306,17 +308,14 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
if ($i === false) {
// its a new footnote, add it to the $footnotes array
- $id = count($this->footnotes)+1;
- $this->footnotes[count($this->footnotes)] = $footnote;
+ $this->footnotes[$fnid] = $footnote;
} else {
- // seen this one before, translate the index to an id and save a placeholder
- $i++;
- $id = count($this->footnotes)+1;
- $this->footnotes[count($this->footnotes)] = "@@FNT".($i);
+ // seen this one before, save a placeholder
+ $this->footnotes[$fnid] = "@@FNT".($i);
}
// output the footnote reference and link
- $this->doc .= '<sup><a href="#fn__'.$id.'" id="fnt__'.$id.'" class="fn_top">'.$id.')</a></sup>';
+ $this->doc .= '<sup><a href="#fn__'.$fnid.'" id="fnt__'.$fnid.'" class="fn_top">'.$fnid.')</a></sup>';
}
function listu_open() {
@@ -367,12 +366,12 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
global $conf;
if($conf['phpok']){
- ob_start();
- eval($text);
- $this->doc .= ob_get_contents();
- ob_end_clean();
+ ob_start();
+ eval($text);
+ $this->doc .= ob_get_contents();
+ ob_end_clean();
} else {
- $this->doc .= p_xhtml_cached_geshi($text, 'php', $wrapper);
+ $this->doc .= p_xhtml_cached_geshi($text, 'php', $wrapper);
}
}
@@ -392,9 +391,9 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
global $conf;
if($conf['htmlok']){
- $this->doc .= $text;
+ $this->doc .= $text;
} else {
- $this->doc .= p_xhtml_cached_geshi($text, 'html4strict', $wrapper);
+ $this->doc .= p_xhtml_cached_geshi($text, 'html4strict', $wrapper);
}
}
@@ -541,13 +540,13 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
}
/**
- */
+ */
function camelcaselink($link) {
- $this->internallink($link,$link);
+ $this->internallink($link,$link);
}
- function locallink($hash, $name = NULL){
+ function locallink($hash, $name = null){
global $ID;
$name = $this->_getLinkTitle($name, $hash, $isImage);
$hash = $this->_headerToLink($hash);
@@ -565,7 +564,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
- function internallink($id, $name = NULL, $search=NULL,$returnonly=false,$linktype='content') {
+ function internallink($id, $name = null, $search=null,$returnonly=false,$linktype='content') {
global $conf;
global $ID;
global $INFO;
@@ -644,7 +643,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
}
}
- function externallink($url, $name = NULL) {
+ function externallink($url, $name = null) {
global $conf;
$name = $this->_getLinkTitle($name, $url, $isImage);
@@ -687,7 +686,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
/**
*/
- function interwikilink($match, $name = NULL, $wikiName, $wikiUri) {
+ function interwikilink($match, $name = null, $wikiName, $wikiUri) {
global $conf;
$link = array();
@@ -721,7 +720,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
/**
*/
- function windowssharelink($url, $name = NULL) {
+ function windowssharelink($url, $name = null) {
global $conf;
global $lang;
//simple setup
@@ -737,7 +736,6 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$link['class'] = 'media';
}
-
$link['title'] = $this->_xmlEntities($url);
$url = str_replace('\\','/',$url);
$url = 'file:///'.$url;
@@ -747,7 +745,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$this->doc .= $this->_formatLink($link);
}
- function emaillink($address, $name = NULL) {
+ function emaillink($address, $name = null) {
global $conf;
//simple setup
$link = array();
@@ -782,8 +780,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$this->doc .= $this->_formatLink($link);
}
- function internalmedia ($src, $title=NULL, $align=NULL, $width=NULL,
- $height=NULL, $cache=NULL, $linking=NULL, $return=NULL) {
+ function internalmedia ($src, $title=null, $align=null, $width=null,
+ $height=null, $cache=null, $linking=null, $return=NULL) {
global $ID;
list($src,$hash) = explode('#',$src,2);
resolve_mediaid(getNS($ID),$src, $exists);
@@ -823,8 +821,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
}
}
- function externalmedia ($src, $title=NULL, $align=NULL, $width=NULL,
- $height=NULL, $cache=NULL, $linking=NULL) {
+ function externalmedia ($src, $title=null, $align=null, $width=null,
+ $height=null, $cache=null, $linking=null) {
list($src,$hash) = explode('#',$src,2);
$noLink = false;
$render = ($linking == 'linkonly') ? false : true;
@@ -880,7 +878,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$mod = 1;
$start = 0;
$end = $feed->get_item_quantity();
- $end = ($end > $params['max']) ? $params['max'] : $end;;
+ $end = ($end > $params['max']) ? $params['max'] : $end;
}
$this->doc .= '<ul class="rss">';
@@ -964,7 +962,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$this->doc .= DOKU_LF . DOKU_TAB . '</tr>' . DOKU_LF;
}
- function tableheader_open($colspan = 1, $align = NULL, $rowspan = 1){
+ function tableheader_open($colspan = 1, $align = null, $rowspan = 1){
$class = 'class="col' . $this->_counter['cell_counter']++;
if ( !is_null($align) ) {
$class .= ' '.$align.'align';
@@ -985,7 +983,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$this->doc .= '</th>';
}
- function tablecell_open($colspan = 1, $align = NULL, $rowspan = 1){
+ function tablecell_open($colspan = 1, $align = null, $rowspan = 1){
$class = 'class="col' . $this->_counter['cell_counter']++;
if ( !is_null($align) ) {
$class .= ' '.$align.'align';
@@ -1051,8 +1049,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
- function _media ($src, $title=NULL, $align=NULL, $width=NULL,
- $height=NULL, $cache=NULL, $render = true) {
+ function _media ($src, $title=null, $align=null, $width=null,
+ $height=null, $cache=null, $render = true) {
$ret = '';
@@ -1196,7 +1194,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* @author Harry Fuecks <hfuecks@gmail.com>
*/
- function _getLinkTitle($title, $default, & $isImage, $id=NULL, $linktype='content') {
+ function _getLinkTitle($title, $default, & $isImage, $id=null, $linktype='content') {
global $conf;
$isImage = false;
@@ -1255,8 +1253,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
* @access protected
* @return array
*/
- function _getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render)
- {
+ function _getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render) {
global $conf;
$link = array();