From c471e6a6aee9997e62ce58c3e49dd8ecad28b92a Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 9 Jan 2010 13:21:16 +0100 Subject: fixed double encoding when embedding flash through image syntax --- inc/parser/xhtml.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/parser') diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 4d5333f7a..4ff5f18b8 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -1019,7 +1019,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $att['class'] = "media$align"; if($align == 'right') $att['align'] = 'right'; if($align == 'left') $att['align'] = 'left'; - $ret .= html_flashobject(ml($src,array('cache'=>$cache)),$width,$height, + $ret .= html_flashobject(ml($src,array('cache'=>$cache),true,'&'),$width,$height, array('quality' => 'high'), null, $att, -- cgit v1.2.3 From 67f9913d4a386fe65c9e72ca452b0fa91b010b12 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 15 Jan 2010 12:18:43 +0100 Subject: removed deprecated PHP4 construct Assigning the return value of new by reference is deprecated, PHP5's new automatically assigns by reference --- inc/parser/handler.php | 14 +++++++------- inc/parser/lexer.php | 2 +- inc/parser/parser.php | 2 +- inc/parser/xhtml.php | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) (limited to 'inc/parser') diff --git a/inc/parser/handler.php b/inc/parser/handler.php index 9fe5866ad..eaa42f9bf 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -20,7 +20,7 @@ class Doku_Handler { var $rewriteBlocks = true; function Doku_Handler() { - $this->CallWriter = & new Doku_Handler_CallWriter($this); + $this->CallWriter = new Doku_Handler_CallWriter($this); } function _addCall($handler, $args, $pos) { @@ -47,7 +47,7 @@ class Doku_Handler { } if ( $this->rewriteBlocks ) { - $B = & new Doku_Handler_Block(); + $B = new Doku_Handler_Block(); $this->calls = $B->process($this->calls); } @@ -212,7 +212,7 @@ class Doku_Handler { $this->_footnote = true; - $ReWriter = & new Doku_Handler_Nest($this->CallWriter,'footnote_close'); + $ReWriter = new Doku_Handler_Nest($this->CallWriter,'footnote_close'); $this->CallWriter = & $ReWriter; $this->_addCall('footnote_open', array(), $pos); break; @@ -240,7 +240,7 @@ class Doku_Handler { function listblock($match, $state, $pos) { switch ( $state ) { case DOKU_LEXER_ENTER: - $ReWriter = & new Doku_Handler_List($this->CallWriter); + $ReWriter = new Doku_Handler_List($this->CallWriter); $this->CallWriter = & $ReWriter; $this->_addCall('list_open', array($match), $pos); break; @@ -302,7 +302,7 @@ class Doku_Handler { function preformatted($match, $state, $pos) { switch ( $state ) { case DOKU_LEXER_ENTER: - $ReWriter = & new Doku_Handler_Preformatted($this->CallWriter); + $ReWriter = new Doku_Handler_Preformatted($this->CallWriter); $this->CallWriter = & $ReWriter; $this->_addCall('preformatted_start',array(), $pos); break; @@ -328,7 +328,7 @@ class Doku_Handler { switch ( $state ) { case DOKU_LEXER_ENTER: - $ReWriter = & new Doku_Handler_Quote($this->CallWriter); + $ReWriter = new Doku_Handler_Quote($this->CallWriter); $this->CallWriter = & $ReWriter; $this->_addCall('quote_start',array($match), $pos); break; @@ -580,7 +580,7 @@ class Doku_Handler { case DOKU_LEXER_ENTER: - $ReWriter = & new Doku_Handler_Table($this->CallWriter); + $ReWriter = new Doku_Handler_Table($this->CallWriter); $this->CallWriter = & $ReWriter; $this->_addCall('table_start', array(), $pos); diff --git a/inc/parser/lexer.php b/inc/parser/lexer.php index afd260a05..211945d8f 100644 --- a/inc/parser/lexer.php +++ b/inc/parser/lexer.php @@ -295,7 +295,7 @@ class Doku_Lexer { $this->_case = $case; $this->_regexes = array(); $this->_parser = &$parser; - $this->_mode = &new Doku_LexerStateStack($start); + $this->_mode = new Doku_LexerStateStack($start); $this->_mode_handlers = array(); } diff --git a/inc/parser/parser.php b/inc/parser/parser.php index a78b08a29..48facd6b5 100644 --- a/inc/parser/parser.php +++ b/inc/parser/parser.php @@ -61,7 +61,7 @@ class Doku_Parser { function addBaseMode(& $BaseMode) { $this->modes['base'] = & $BaseMode; if ( !$this->Lexer ) { - $this->Lexer = & new Doku_Lexer($this->Handler,'base', true); + $this->Lexer = new Doku_Lexer($this->Handler,'base', true); } $this->modes['base']->Lexer = & $this->Lexer; } diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 4ff5f18b8..20acf4281 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -966,7 +966,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { }elseif($ext == 'jpg' || $ext == 'jpeg'){ //try to use the caption from IPTC/EXIF require_once(DOKU_INC.'inc/JpegMeta.php'); - $jpeg =& new JpegMeta(mediaFN($src)); + $jpeg =new JpegMeta(mediaFN($src)); if($jpeg !== false) $cap = $jpeg->getTitle(); if($cap){ $title = $this->_xmlEntities($cap); -- cgit v1.2.3 From 07c2b1c7ce9255456bf19c45cf9d34452cec2af1 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 19 Nov 2009 15:06:19 +0100 Subject: Add TABLE range marker for table editing darcs-hash:20091119140619-e4919-15efddc768526a6c1f6472f83ede17019144ffa3.gz --- inc/parser/handler.php | 5 +++-- inc/parser/renderer.php | 2 +- inc/parser/xhtml.php | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'inc/parser') diff --git a/inc/parser/handler.php b/inc/parser/handler.php index eaa42f9bf..ea5a69b35 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -589,10 +589,11 @@ class Doku_Handler { } else { $this->_addCall('tablecell', array(), $pos); } + $this->status['table_begin'] = $pos; break; case DOKU_LEXER_EXIT: - $this->_addCall('table_end', array(), $pos); + $this->_addCall('table_end', array($this->status['table_begin']+1, $pos), $pos); $this->CallWriter->process(); $ReWriter = & $this->CallWriter; $this->CallWriter = & $ReWriter->CallWriter; @@ -1222,7 +1223,7 @@ class Doku_Handler_Table { } function tableEnd($call) { - $this->tableCalls[] = array('table_close',array(),$call[2]); + $this->tableCalls[] = array('table_close',$call[1],$call[2]); $this->finalizeTable(); } diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index 6082e935d..65dcaf8a1 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -233,7 +233,7 @@ class Doku_Renderer extends DokuWiki_Plugin { function table_open($maxcols = NULL, $numrows = NULL){} - function table_close(){} + function table_close($begin, $end){} function tablerow_open(){} diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 20acf4281..4e848ec1d 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -851,8 +851,9 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $this->doc .= ''.DOKU_LF; } - function table_close(){ + function table_close($begin, $end){ $this->doc .= '
'.DOKU_LF; + $this->doc .= ''; } function tablerow_open(){ -- cgit v1.2.3 From 8af66ab927067b9d8f9d71963e266a08967fa9d1 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Fri, 29 Jan 2010 17:08:40 +0100 Subject: table: Remove redundant parser data, update tests --- inc/parser/handler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/parser') diff --git a/inc/parser/handler.php b/inc/parser/handler.php index ea5a69b35..141cbcaf0 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -1205,7 +1205,7 @@ class Doku_Handler_Table { $this->tableCell($call); break; case 'table_end': - $this->tableRowClose(array('tablerow_close',$call[1],$call[2])); + $this->tableRowClose(array('tablerow_close', array())); $this->tableEnd($call); break; default: -- cgit v1.2.3 From 90df9a4d69a2e467433b419b94fe799d11590539 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 4 Feb 2010 14:50:10 +0100 Subject: Rewrite section edit handling according to #1860 --- inc/parser/handler.php | 32 +++---------------- inc/parser/renderer.php | 6 ++-- inc/parser/xhtml.php | 81 +++++++++++++++++++++++++++++++++++-------------- 3 files changed, 66 insertions(+), 53 deletions(-) (limited to 'inc/parser') diff --git a/inc/parser/handler.php b/inc/parser/handler.php index 141cbcaf0..b5d2baaab 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -12,9 +12,6 @@ class Doku_Handler { var $status = array( 'section' => false, - 'section_edit_start' => -1, - 'section_edit_level' => 1, - 'section_edit_title' => '' ); var $rewriteBlocks = true; @@ -40,10 +37,6 @@ class Doku_Handler { if ( $this->status['section'] ) { $last_call = end($this->calls); array_push($this->calls,array('section_close',array(), $last_call[2])); - if ($this->status['section_edit_start']>1) { - // ignore last edit section if there is only one header - array_push($this->calls,array('section_edit',array($this->status['section_edit_start'], 0, $this->status['section_edit_level'], $this->status['section_edit_title']), $last_call[2])); - } } if ( $this->rewriteBlocks ) { @@ -97,8 +90,6 @@ class Doku_Handler { } function header($match, $state, $pos) { - global $conf; - // get level and title $title = trim($match); $level = 7 - strspn($title,'='); @@ -108,13 +99,6 @@ class Doku_Handler { if ($this->status['section']) $this->_addCall('section_close',array(),$pos); - if ($level<=$conf['maxseclevel']) { - $this->_addCall('section_edit',array($this->status['section_edit_start'], $pos-1, $this->status['section_edit_level'], $this->status['section_edit_title']), $pos); - $this->status['section_edit_start'] = $pos; - $this->status['section_edit_level'] = $level; - $this->status['section_edit_title'] = $title; - } - $this->_addCall('header',array($title,$level,$pos), $pos); $this->_addCall('section_open',array($level),$pos); @@ -583,17 +567,16 @@ class Doku_Handler { $ReWriter = new Doku_Handler_Table($this->CallWriter); $this->CallWriter = & $ReWriter; - $this->_addCall('table_start', array(), $pos); + $this->_addCall('table_start', array($pos + 1), $pos); if ( trim($match) == '^' ) { $this->_addCall('tableheader', array(), $pos); } else { $this->_addCall('tablecell', array(), $pos); } - $this->status['table_begin'] = $pos; break; case DOKU_LEXER_EXIT: - $this->_addCall('table_end', array($this->status['table_begin']+1, $pos), $pos); + $this->_addCall('table_end', array($pos), $pos); $this->CallWriter->process(); $ReWriter = & $this->CallWriter; $this->CallWriter = & $ReWriter->CallWriter; @@ -1217,7 +1200,7 @@ class Doku_Handler_Table { } function tableStart($call) { - $this->tableCalls[] = array('table_open',array(),$call[2]); + $this->tableCalls[] = array('table_open',$call[1],$call[2]); $this->tableCalls[] = array('tablerow_open',array(),$call[2]); $this->firstCell = true; } @@ -1288,6 +1271,7 @@ class Doku_Handler_Table { // Adjust to num cols not num col delimeters $this->tableCalls[0][1][] = $this->maxCols - 1; $this->tableCalls[0][1][] = $this->maxRows; + $this->tableCalls[0][1][] = array_shift($this->tableCalls[0][1]); } else { trigger_error('First element in table call list is not table_open'); } @@ -1505,13 +1489,7 @@ class Doku_Handler_Block { //remove the whole paragraph array_splice($this->calls,$i); }else{ - if ($this->calls[count($this->calls)-1][0] == 'section_edit') { - $tmp = array_pop($this->calls); - $this->calls[] = array('p_close',array(), $pos); - $this->calls[] = $tmp; - } else { - $this->calls[] = array('p_close',array(), $pos); - } + $this->calls[] = array('p_close',array(), $pos); } $this->inParagraph = false; diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index 65dcaf8a1..393099003 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -85,8 +85,6 @@ class Doku_Renderer extends DokuWiki_Plugin { function header($text, $level, $pos) {} - function section_edit($start, $end, $level, $name) {} - function section_open($level) {} function section_close() {} @@ -231,9 +229,9 @@ class Doku_Renderer extends DokuWiki_Plugin { $src,$title=NULL,$align=NULL,$width=NULL,$height=NULL,$cache=NULL ) {} - function table_open($maxcols = NULL, $numrows = NULL){} + function table_open($maxcols = NULL, $numrows = NULL, $pos){} - function table_close($begin, $end){} + function table_close($pos){} function tablerow_open(){} diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 4e848ec1d..ef62a3df9 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -29,6 +29,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { var $doc = ''; // will contain the whole document var $toc = array(); // will contain the Table of Contents + private $sectionedits = array(); // A stack of section edit data var $headers = array(); var $footnotes = array(); @@ -39,6 +40,34 @@ class Doku_Renderer_xhtml extends Doku_Renderer { var $_counter = array(); // used as global counter, introduced for table classes var $_codeblock = 0; // counts the code and file blocks, used to provide download links + /** + * Register a new edit section range + * + * @param $type string The section type identifier + * @param $title string The section title + * @param $start int The byte position for the edit start + * @return string A marker class for the starting HTML element + * @author Adrian Lang + */ + protected function startSectionEdit($start, $type, $title) { + static $lastsecid = 0; + $this->sectionedits[] = array(++$lastsecid, $start, $type, $title); + return 'sectionedit' . $lastsecid; + } + + /** + * Finish an edit section range + * + * @param $pos int The byte position for the edit end + * @author Adrian Lang + */ + protected function finishSectionEdit($end) { + list($id, $start, $type, $title) = array_pop($this->sectionedits); + $this->doc .= ""; + } + function getFormat(){ return 'xhtml'; } @@ -51,6 +80,17 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } function document_end() { + // Finish open section edits. + while (count($this->sectionedits) > 0) { + if ($this->sectionedits[count($this->sectionedits) - 1][1] <= 1) { + // If there is only one section, do not write a section edit + // marker. + array_pop($this->sectionedits); + } else { + $this->finishSectionEdit(0); + } + } + if ( count ($this->footnotes) > 0 ) { $this->doc .= '
'.DOKU_LF; @@ -106,6 +146,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } function header($text, $level, $pos) { + global $conf; + if(!$text) return; //skip empty headlines $hid = $this->_headerToLink($text,true); @@ -122,30 +164,24 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } $this->lastlevel = $level; + if ($level <= $conf['maxseclevel'] && + count($this->sectionedits) > 0 && + $this->sectionedits[count($this->sectionedits) - 1][2] === 'section') { + $this->finishSectionEdit($pos); + } + // write the header - $this->doc .= DOKU_LF.''; + $this->doc .= DOKU_LF.'doc .= ' class="' . $this->startSectionEdit($pos, 'section', $text) . '"'; + } + $this->doc .= '>'; $this->doc .= $this->_xmlEntities($text); $this->doc .= "".DOKU_LF; } - /** - * Section edit marker is replaced by an edit button when - * the page is editable. Replacement done in 'inc/html.php#html_secedit' - * - * @author Andreas Gohr - * @author Ben Coburn - */ - function section_edit($start, $end, $level, $name) { - global $conf; - - if ($start!=-1 && $level<=$conf['maxseclevel']) { - $name = str_replace('"', '', $name); - $this->doc .= ''; - } - } - function section_open($level) { - $this->doc .= "
".DOKU_LF; + $this->doc .= "
".DOKU_LF; } function section_close() { @@ -845,15 +881,16 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } // $numrows not yet implemented - function table_open($maxcols = NULL, $numrows = NULL){ + function table_open($maxcols = NULL, $numrows = NULL, $pos){ + global $lang; // initialize the row counter used for classes $this->_counter['row_counter'] = 0; - $this->doc .= ''.DOKU_LF; + $this->doc .= '
'.DOKU_LF; } - function table_close($begin, $end){ + function table_close($pos){ $this->doc .= '
'.DOKU_LF; - $this->doc .= ''; + $this->finishSectionEdit($pos); } function tablerow_open(){ -- cgit v1.2.3 From 6c1f778cae7a02dec2e14017e539d541ce6e74fb Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Mon, 8 Feb 2010 10:11:11 +0100 Subject: Fix section editing killing next section --- inc/parser/xhtml.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/parser') diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index ef62a3df9..9de712303 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -167,7 +167,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { if ($level <= $conf['maxseclevel'] && count($this->sectionedits) > 0 && $this->sectionedits[count($this->sectionedits) - 1][2] === 'section') { - $this->finishSectionEdit($pos); + $this->finishSectionEdit($pos - 1); } // write the header -- cgit v1.2.3 From 40868f2faa85215dfea2fa0c82274a4806d042ab Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Mon, 8 Feb 2010 12:50:20 +0100 Subject: Hide secedit buttons without title --- inc/parser/xhtml.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'inc/parser') diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 9de712303..3ac8ed35c 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -49,7 +49,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { * @return string A marker class for the starting HTML element * @author Adrian Lang */ - protected function startSectionEdit($start, $type, $title) { + protected function startSectionEdit($start, $type, $title = null) { static $lastsecid = 0; $this->sectionedits[] = array(++$lastsecid, $start, $type, $title); return 'sectionedit' . $lastsecid; @@ -63,9 +63,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer { */ protected function finishSectionEdit($end) { list($id, $start, $type, $title) = array_pop($this->sectionedits); - $this->doc .= ""; + $this->doc .= "'; } function getFormat(){ @@ -885,7 +887,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { global $lang; // initialize the row counter used for classes $this->_counter['row_counter'] = 0; - $this->doc .= ''.DOKU_LF; + $this->doc .= '
'.DOKU_LF; } function table_close($pos){ -- cgit v1.2.3 From 00c13053ac33ff41de9796de647da301a8abcc17 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Mon, 15 Feb 2010 11:13:05 +0100 Subject: Validate section edit data --- inc/parser/xhtml.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'inc/parser') diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 3ac8ed35c..b6cc49cba 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -63,6 +63,9 @@ class Doku_Renderer_xhtml extends Doku_Renderer { */ protected function finishSectionEdit($end) { list($id, $start, $type, $title) = array_pop($this->sectionedits); + if ($end <= $start) { + return; + } $this->doc .= "'; + $this->doc .= "[$start-" . (is_null($end) ? '' : $end) . '] -->'; } function getFormat(){ @@ -92,7 +93,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { // marker. array_pop($this->sectionedits); } else { - $this->finishSectionEdit(0); + $this->finishSectionEdit(); } } -- cgit v1.2.3 From 3f9e3215e07f71f721ddd919b9b06ad5d7cc6742 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 4 Mar 2010 11:01:52 +0100 Subject: Really allow plugins to use section editing --- inc/parser/xhtml.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/parser') diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 552a8332d..176411c75 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -49,7 +49,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { * @return string A marker class for the starting HTML element * @author Adrian Lang */ - protected function startSectionEdit($start, $type, $title = null) { + public function startSectionEdit($start, $type, $title = null) { static $lastsecid = 0; $this->sectionedits[] = array(++$lastsecid, $start, $type, $title); return 'sectionedit' . $lastsecid; @@ -62,7 +62,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { the page * @author Adrian Lang */ - protected function finishSectionEdit($end = null) { + public function finishSectionEdit($end = null) { list($id, $start, $type, $title) = array_pop($this->sectionedits); if (!is_null($end) && $end <= $start) { return; -- cgit v1.2.3 From a2ea2dc1716c55791173d806d9a78c96846c72b8 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Tue, 16 Mar 2010 10:52:51 +0100 Subject: Fix special link displaying in abstract --- inc/parser/metadata.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'inc/parser') diff --git a/inc/parser/metadata.php b/inc/parser/metadata.php index fc60e5774..f635ea1d5 100644 --- a/inc/parser/metadata.php +++ b/inc/parser/metadata.php @@ -334,8 +334,7 @@ class Doku_Renderer_metadata extends Doku_Renderer { $this->_firstimage($name['src']); if ($this->capture){ - if ($name) $this->doc .= $name; - else $this->doc .= '<'.$url.'>'; + $this->doc .= $this->_getLinkTitle($name, '<' . $url . '>'); } } @@ -345,7 +344,7 @@ class Doku_Renderer_metadata extends Doku_Renderer { if ($this->capture){ list($wikiUri, $hash) = explode('#', $wikiUri, 2); - $name = $this->_getLinkTitle($name, $wikiName.'>'.$wikiUri); + $name = $this->_getLinkTitle($name, $wikiUri); $this->doc .= $name; } } -- cgit v1.2.3 From 0139312b0d39e61bdff7318a0c092eb20b208a78 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Fri, 26 Mar 2010 13:16:46 +0100 Subject: Better code syntax parsing, less E_NOTICE --- inc/parser/handler.php | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'inc/parser') diff --git a/inc/parser/handler.php b/inc/parser/handler.php index b5d2baaab..8639c5ad8 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -344,21 +344,16 @@ class Doku_Handler { function code($match, $state, $pos, $type='code') { if ( $state == DOKU_LEXER_UNMATCHED ) { $matches = explode('>',$match,2); - $matches[0] = trim($matches[0]); - - list($language,$filename) = explode(' ',$matches[0],2); - $language = trim($language); - $filename = trim($filename); - if ( $language == '' ) $language = null; - if ( $language == '-' ) $language = null; - if ( $filename == '' ) $filename = null; - # We shortcut html here. - if($language == 'html') $language = 'html4strict'; - $this->_addCall( - $type, - array($matches[1],$language,$filename), - $pos - ); + + $param = preg_split('/\s+/', $matches[0], 2, PREG_SPLIT_NO_EMPTY); + while(count($param) < 2) array_push($param, null); + + // We shortcut html here. + if ($param[0] == 'html') $param[0] = 'html4strict'; + if ($param[0] == '-') $param[0] = null; + array_unshift($param, $matches[1]); + + $this->_addCall($type, $param, $pos); } return true; } -- cgit v1.2.3 From f6ec8df813b28547ca3b04bb39f0ce670a6bb990 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Mon, 29 Mar 2010 12:00:30 +0200 Subject: Allow plugins to specify that they have to be instantiated Plugins may return false in isSingleton to let plugin_load return a new instance every time it is called. Renderer plugins are not loaded with $new set to true, but instead specify themself that they are not singletons. This behaviour allows the odt renderer to keep working (see #1598). --- inc/parser/renderer.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'inc/parser') diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index 393099003..4dac75d21 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -49,6 +49,15 @@ class Doku_Renderer extends DokuWiki_Plugin { trigger_error('getFormat() not implemented in '.get_class($this), E_USER_WARNING); } + /** + * Allow the plugin to prevent DokuWiki from reusing an instance + * + * @return bool false if the plugin has to be instantiated + */ + function isSingleton() { + return false; + } + //handle plugin rendering function plugin($name,$data){ -- cgit v1.2.3 From 44653a53fe7db9e1c14e4a1d1034cf63787139b3 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 17 Jun 2010 15:43:30 +0200 Subject: Allow URL params in internal links (FS#1967) --- inc/parser/xhtml.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'inc/parser') diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 176411c75..0ee04e5a1 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -559,6 +559,18 @@ class Doku_Renderer_xhtml extends Doku_Renderer { function internallink($id, $name = NULL, $search=NULL,$returnonly=false,$linktype='content') { global $conf; global $ID; + + $params = array(); + + if (preg_match('/^([^?]*)\?([^?]+)$/', $id, $matches) !== false) { + $id = $matches[1]; + preg_match_all('/(?<=[&^])([^=]+)=([^=]*)(?:&|$)/', $matches[2], + $matches, PREG_SET_ORDER); + foreach($matches as &$param) { + $params[$param[1]] = $param[2]; + } + } + // default name is based on $id as given $default = $this->_simpleTitle($id); @@ -592,7 +604,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } $link['more'] = ''; $link['class'] = $class; - $link['url'] = wl($id); + $link['url'] = wl($id, $params); $link['name'] = $name; $link['title'] = $id; //add search string -- cgit v1.2.3 From f46093a10c862c090052025b72d9e5b604f4f599 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 17 Jun 2010 16:39:24 +0200 Subject: Make normal wikilinks work again --- inc/parser/xhtml.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/parser') diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 0ee04e5a1..f9a33fef0 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -562,7 +562,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $params = array(); - if (preg_match('/^([^?]*)\?([^?]+)$/', $id, $matches) !== false) { + if (preg_match('/^([^?]*)\?([^?]+)$/', $id, $matches)) { $id = $matches[1]; preg_match_all('/(?<=[&^])([^=]+)=([^=]*)(?:&|$)/', $matches[2], $matches, PREG_SET_ORDER); -- cgit v1.2.3 From 3d5e07d9f0f7f71f91cd97f4a7484f4da8a1841a Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Wed, 23 Jun 2010 10:08:28 +0200 Subject: Do not parse URL params in internal links, just pass them through --- inc/parser/xhtml.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'inc/parser') diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index f9a33fef0..c8862eece 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -560,15 +560,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer { global $conf; global $ID; - $params = array(); - - if (preg_match('/^([^?]*)\?([^?]+)$/', $id, $matches)) { - $id = $matches[1]; - preg_match_all('/(?<=[&^])([^=]+)=([^=]*)(?:&|$)/', $matches[2], - $matches, PREG_SET_ORDER); - foreach($matches as &$param) { - $params[$param[1]] = $param[2]; - } + $params = ''; + $parts = explode('?', $id, 2); + if (count($parts) === 2) { + $id = $parts[0]; + $params = $parts[1]; } // default name is based on $id as given -- cgit v1.2.3 From d43aac1c8c239fb7f4ca8d0cb9bf03dc1d6cd958 Mon Sep 17 00:00:00 2001 From: Gina Haeussge Date: Sat, 26 Jun 2010 15:58:14 +0200 Subject: FS#1915: strip one leading and one trailing newline from code content if available --- inc/parser/xhtml.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'inc/parser') diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index c8862eece..c5a8b8218 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -442,6 +442,13 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $this->doc .= ''.DOKU_LF.'
'; } + if ($text{0} == "\n") { + $text = substr($text, 1); + } + if (substr($text, -1) == "\n") { + $text = substr($text, 0, -1); + } + if ( is_null($language) ) { $this->doc .= '
'.$this->_xmlEntities($text).'
'.DOKU_LF; } else { -- cgit v1.2.3 From a8574918a3bd65683f0a2de4a3f26dd0ec2c410f Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Sun, 27 Jun 2010 12:41:23 +0100 Subject: added div around tables to make scrolling too wide ones in restrictive designs possible (FS#1980) --- inc/parser/xhtml.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/parser') diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index c5a8b8218..78f6d3f84 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -906,11 +906,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer { global $lang; // initialize the row counter used for classes $this->_counter['row_counter'] = 0; - $this->doc .= '
'.DOKU_LF; + $this->doc .= '
'.DOKU_LF; } function table_close($pos){ - $this->doc .= '
'.DOKU_LF; + $this->doc .= '
'.DOKU_LF; $this->finishSectionEdit($pos); } -- cgit v1.2.3 From 13ebcbe5742a0b5014e3c70a0d521332cbdcdf79 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Sun, 27 Jun 2010 12:53:18 +0100 Subject: FS#1949 --- inc/parser/parser.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/parser') diff --git a/inc/parser/parser.php b/inc/parser/parser.php index 48facd6b5..435b8aa46 100644 --- a/inc/parser/parser.php +++ b/inc/parser/parser.php @@ -413,8 +413,8 @@ class Doku_Parser_Mode_listblock extends Doku_Parser_Mode { } function connectTo($mode) { - $this->Lexer->addEntryPattern('\n {2,}[\-\*]',$mode,'listblock'); - $this->Lexer->addEntryPattern('\n\t{1,}[\-\*]',$mode,'listblock'); + $this->Lexer->addEntryPattern('[ \t]*\n {2,}[\-\*]',$mode,'listblock'); + $this->Lexer->addEntryPattern('[ \t]*\n\t{1,}[\-\*]',$mode,'listblock'); $this->Lexer->addPattern('\n {2,}[\-\*]','listblock'); $this->Lexer->addPattern('\n\t{1,}[\-\*]','listblock'); -- cgit v1.2.3 From 9708106bad6f238d9aeaccc35258350a66604a6c Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 1 Jul 2010 13:02:28 +0200 Subject: Fix ns: and ns:start handling --- inc/parser/renderer.php | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'inc/parser') diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index 4dac75d21..7e52cfce2 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -271,20 +271,12 @@ class Doku_Renderer extends DokuWiki_Plugin { list($name,$hash) = explode('#',$name,2); if($hash) return $hash; - //trim colons or slash of a namespace link - $name = rtrim($name,':'); - if($conf['useslash']) - $name = rtrim($name,'/'); - + $name = strtr($name,';',':'); if($conf['useslash']){ - $nssep = '[:;/]'; - }else{ - $nssep = '[:;]'; + $name = strtr($name,'/',':'); } - $name = preg_replace('!.*'.$nssep.'!','',$name); - if(!$name) return $this->_simpleTitle($conf['start']); - return $name; + return noNSorNS($name); } /** -- cgit v1.2.3 From 138cf4d45bdc87d14db5c07e22685c0482085c1f Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 1 Jul 2010 16:11:22 +0200 Subject: Fix table edit marker class element in XHTML --- inc/parser/xhtml.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/parser') diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 78f6d3f84..5a3d945d1 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -906,7 +906,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { global $lang; // initialize the row counter used for classes $this->_counter['row_counter'] = 0; - $this->doc .= '
'.DOKU_LF; + $this->doc .= '
'.DOKU_LF; } function table_close($pos){ -- cgit v1.2.3 From aa92c4ccfaf7462eb8f336c6a4e8e2b1468cfada Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 12 Aug 2010 13:46:14 +0200 Subject: clean up table parser handler --- inc/parser/handler.php | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'inc/parser') diff --git a/inc/parser/handler.php b/inc/parser/handler.php index 8639c5ad8..8de0c7490 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -1175,7 +1175,7 @@ class Doku_Handler_Table { $this->tableStart($call); break; case 'table_row': - $this->tableRowClose(array('tablerow_close',$call[1],$call[2])); + $this->tableRowClose($call); $this->tableRowOpen(array('tablerow_open',$call[1],$call[2])); break; case 'tableheader': @@ -1183,7 +1183,7 @@ class Doku_Handler_Table { $this->tableCell($call); break; case 'table_end': - $this->tableRowClose(array('tablerow_close', array())); + $this->tableRowClose($call); $this->tableEnd($call); break; default: @@ -1221,7 +1221,7 @@ class Doku_Handler_Table { break; } } - $this->tableCalls[] = $call; + $this->tableCalls[] = array('tablerow_close', array(), $call[2]); if ( $this->currentCols > $this->maxCols ) { $this->maxCols = $this->currentCols; @@ -1281,17 +1281,21 @@ class Doku_Handler_Table { // that contain colspans foreach ( $this->tableCalls as $key => $call ) { - if ( $call[0] == 'tablerow_open' ) { + switch ($call[0]) { + case 'tablerow_open': $lastRow++; $lastCell = 0; + break; - } else if ( $call[0] == 'tablecell_open' || $call[0] == 'tableheader_open' ) { + case 'tablecell_open': + case 'tableheader_open': $lastCell++; $cellKey[$lastRow][$lastCell] = $key; + break; - } else if ( $call[0] == 'table_align' ) { + case 'table_align': $prev = in_array($this->tableCalls[$key-1][0], array('tablecell_open', 'tableheader_open')); $next = in_array($this->tableCalls[$key+1][0], array('tablecell_close', 'tableheader_close')); @@ -1315,8 +1319,9 @@ class Doku_Handler_Table { // Now convert the whitespace back to cdata $this->tableCalls[$key][0] = 'cdata'; + break; - } else if ( $call[0] == 'colspan' ) { + case 'colspan': $this->tableCalls[$key-1][1][0] = false; @@ -1336,8 +1341,9 @@ class Doku_Handler_Table { $toDelete[] = $key-1; $toDelete[] = $key; $toDelete[] = $key+1; + break; - } else if ( $call[0] == 'rowspan' ) { + case 'rowspan': if ( $this->tableCalls[$key-1][0] == 'cdata' ) { // ignore rowspan if previous call was cdata (text mixed with :::) we don't have to check next call as that wont match regex @@ -1362,8 +1368,10 @@ class Doku_Handler_Table { $toDelete[] = $key-1; $toDelete[] = $key; - $toDelete[] = $key+1; + $toDelete[] = $key+1; } + break; + } } -- cgit v1.2.3 From 6606d6fc9f9fc0d581d23961ec634b24c7d41425 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 12 Aug 2010 14:03:43 +0200 Subject: Try to fix broken tables --- inc/parser/handler.php | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'inc/parser') diff --git a/inc/parser/handler.php b/inc/parser/handler.php index 8de0c7490..0b8b79254 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -1279,7 +1279,8 @@ class Doku_Handler_Table { // Look for the colspan elements and increment the colspan on the // previous non-empty opening cell. Once done, delete all the cells // that contain colspans - foreach ( $this->tableCalls as $key => $call ) { + for ($key = 0 ; $key < count($this->tableCalls) ; ++$key) { + $call = $this->tableCalls[$key]; switch ($call[0]) { case 'tablerow_open': @@ -1351,20 +1352,28 @@ class Doku_Handler_Table { } else { - $this->tableCalls[$key-1][1][2] = false; - + $spanning_cell = null; for($i = $lastRow-1; $i > 0; $i--) { if ( $this->tableCalls[$cellKey[$i][$lastCell]][0] == 'tablecell_open' || $this->tableCalls[$cellKey[$i][$lastCell]][0] == 'tableheader_open' ) { - if ( false !== $this->tableCalls[$cellKey[$i][$lastCell]][1][2] ) { - $this->tableCalls[$cellKey[$i][$lastCell]][1][2]++; + if ($this->tableCalls[$cellKey[$i][$lastCell]][1][2] >= $lastRow - $i) { + $spanning_cell = $i; break; } } } + if (is_null($spanning_cell)) { + // No spanning cell found, so convert this cell to + // an empty one to avoid broken tables + $this->tableCells[$key][1][1] = ''; + continue; + } + $this->tableCalls[$cellKey[$spanning_cell][$lastCell]][1][2]++; + + $this->tableCalls[$key-1][1][2] = false; $toDelete[] = $key-1; $toDelete[] = $key; @@ -1372,6 +1381,19 @@ class Doku_Handler_Table { } break; + case 'tablerow_close': + + // Fix broken tables by adding missing cells + while (++$lastCell < $this->maxCols) { + array_splice($this->tableCalls, $key, 0, array( + array('tablecell_open', array(1, null, 1), $call[2]), + array('cdata', array(''), $call[2]), + array('tablecell_close', array(), $call[2]))); + $key += 3; + } + + break; + } } -- cgit v1.2.3