diff options
-rw-r--r-- | inc/parser/handler.php | 189 | ||||
-rw-r--r-- | inc/parser/renderer.php | 14 | ||||
-rw-r--r-- | inc/parser/spamcheck.php | 73 | ||||
-rw-r--r-- | inc/parser/xhtml.php | 43 | ||||
-rw-r--r-- | inc/parser/xhtmlsummary.php | 26 |
5 files changed, 17 insertions, 328 deletions
diff --git a/inc/parser/handler.php b/inc/parser/handler.php index dc5315fdd..1b73c458f 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -35,13 +35,6 @@ class Doku_Handler { $this->calls = $B->process($this->calls); } -/** FIXME deprecated - if ( $this->meta['toc'] ) { - $T = & new Doku_Handler_Toc(); - $this->calls = $T->process($this->calls); - } -*/ - array_unshift($this->calls,array('document_start',array(),0)); $last_call = end($this->calls); array_push($this->calls,array('document_end',array(),$last_call[2])); @@ -1494,186 +1487,4 @@ class Doku_Handler_Block { } } -//------------------------------------------------------------------------ - -/** FIXME deprecated - -define('DOKU_TOC_OPEN',1); -define('DOKU_TOCBRANCH_OPEN',2); -define('DOKU_TOCITEM_OPEN',3); -define('DOKU_TOC_ELEMENT',4); -define('DOKU_TOCITEM_CLOSE',5); -define('DOKU_TOCBRANCH_CLOSE',6); -define('DOKU_TOC_CLOSE',7); - -class Doku_Handler_Toc { - - var $calls = array(); - var $tocStack = array(); - var $toc = array(); - var $numHeaders = 0; - - function process($calls) { - #FIXME can this be done better? - - global $conf; - - if ( isset($conf['toptoclevel']) ) { - // retrieve vars once to save time - $toplevel = $conf['toptoclevel']; - } else { - $toplevel = 0; - } - - if ( isset($conf['maxtoclevel']) ) { - $maxlevel = $conf['maxtoclevel']; - } else { - $maxlevel = 0; - } - - foreach ( $calls as $call ) { - if ( !isset($call[1][1]) ) { - $this->calls[] = $call; - continue; - } - $level = $call[1][1]; - if ( $call[0] == 'header' && $level >= $toplevel && $level <= $maxlevel ) { - $this->numHeaders++; - $this->addToToc($level - $toplevel + 1, $call); - } - $this->calls[] = $call; - } - - // Complete the table of contents then prepend to the calls - $this->finalizeToc($call); - return $this->calls; - } - - function addToToc($depth, $call) { - - // If it's the opening item... - if ( count ( $this->toc) == 0 ) { - - $this->addTocCall($call, DOKU_TOC_OPEN); - - for ( $i = 1; $i <= $depth; $i++ ) { - - $this->addTocCall(array($call[0],array($call[1][0],$i),$call[2]), DOKU_TOCBRANCH_OPEN); - - if ( $i != $depth ) { - $this->addTocCall(array($call[0],array($call[1][0], $i, '', TRUE),$call[2]), DOKU_TOCITEM_OPEN); - } else { - $this->addTocCall(array($call[0],array($call[1][0], $i),$call[2]), DOKU_TOCITEM_OPEN); - $this->addTocCall(array($call[0],array($call[1][0], $i),$call[2]), DOKU_TOC_ELEMENT); - } - - $this->tocStack[] = $i; - - } - return; - } - - $currentDepth = end($this->tocStack); - $initialDepth = $currentDepth; - - // Create new branches as needed - if ( $depth > $currentDepth ) { - - for ($i = $currentDepth+1; $i <= $depth; $i++ ) { - $this->addTocCall(array($call[0],array($call[1][0],$i),$call[2]), DOKU_TOCBRANCH_OPEN); - // It's just a filler - if ( $i != $depth ) { - $this->addTocCall(array($call[0],array($call[1][0], $i, '', TRUE),$call[2]), DOKU_TOCITEM_OPEN); - } else { - $this->addTocCall(array($call[0],array($call[1][0], $i),$call[2]), DOKU_TOCITEM_OPEN); - } - $this->tocStack[] = $i; - } - - $currentDepth = $i-1; - - } - - // Going down - if ( $depth < $currentDepth ) { - for ( $i = $currentDepth; $i >= $depth; $i-- ) { - if ( $i != $depth ) { - array_pop($this->tocStack); - $this->addTocCall(array($call[0],array($call[1][0],$i),$call[2]), DOKU_TOCITEM_CLOSE); - $this->addTocCall(array($call[0],array($call[1][0],$i),$call[2]), DOKU_TOCBRANCH_CLOSE); - } else { - $this->addTocCall(array($call[0],array($call[1][0],$i),$call[2]), DOKU_TOCITEM_CLOSE); - $this->addTocCall(array($call[0],array($call[1][0],$i),$call[2]), DOKU_TOCITEM_OPEN); - $this->addTocCall($call, DOKU_TOC_ELEMENT); - return; - } - } - } - - if ( $depth == $initialDepth ) { - $this->addTocCall($call, DOKU_TOCITEM_CLOSE); - $this->addTocCall($call, DOKU_TOCITEM_OPEN); - } - - $this->addTocCall($call, DOKU_TOC_ELEMENT); - - - } - - function addTocCall($call, $type) { - switch ( $type ) { - case DOKU_TOC_OPEN: - $this->toc[] = array('toc_open',array(),$call[2]); - break; - - case DOKU_TOCBRANCH_OPEN: - $this->toc[] = array('tocbranch_open',array($call[1][1]),$call[2]); - break; - - case DOKU_TOCITEM_OPEN: - if ( isset( $call[1][3] ) ) { - $this->toc[] = array('tocitem_open',array($call[1][1], TRUE),$call[2]); - } else { - $this->toc[] = array('tocitem_open',array($call[1][1]),$call[2]); - } - break; - - case DOKU_TOC_ELEMENT: - $this->toc[] = array('tocelement',array($call[1][1],$call[1][0]),$call[2]); - break; - - case DOKU_TOCITEM_CLOSE: - $this->toc[] = array('tocitem_close',array($call[1][1]),$call[2]); - break; - - case DOKU_TOCBRANCH_CLOSE: - $this->toc[] = array('tocbranch_close',array($call[1][1]),$call[2]); - break; - - case DOKU_TOC_CLOSE: - if ( count($this->toc) > 0 ) { - $this->toc[] = array('toc_close',array(),$call[2]); - } - break; - } - } - - function finalizeToc($call) { - global $conf; - if ( isset($conf['maxtoclevel']) && $this->numHeaders < $conf['maxtoclevel'] ) { - return; - } - if ( count ($this->tocStack) > 0 ) { - while ( NULL !== ($toc = array_pop($this->tocStack)) ) { - $this->addTocCall(array($call[0],array('',$toc),$call[2]), DOKU_TOCITEM_CLOSE); - $this->addTocCall(array($call[0],array('',$toc),$call[2]), DOKU_TOCBRANCH_CLOSE); - } - } - $this->addTocCall($call, DOKU_TOC_CLOSE); - $this->calls = array_merge($this->toc, $this->calls); - } - -} -*/ - //Setup VIM: ex: et ts=4 enc=utf-8 : diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index 303af3db3..8d6f7028c 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -39,19 +39,7 @@ class Doku_Renderer { function document_end() {} - function toc_open() {} - - function tocbranch_open($level) {} - - function tocitem_open($level, $empty = FALSE) {} - - function tocelement($level, $title) {} - - function tocitem_close($level) {} - - function tocbranch_close($level) {} - - function toc_close() {} + function render_TOC() { return '' } function header($text, $level, $pos) {} diff --git a/inc/parser/spamcheck.php b/inc/parser/spamcheck.php deleted file mode 100644 index 42b9781c5..000000000 --- a/inc/parser/spamcheck.php +++ /dev/null @@ -1,73 +0,0 @@ -<?php -if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); - -require_once DOKU_INC . 'inc/parser/renderer.php'; - -class Doku_Renderer_SpamCheck extends Doku_Renderer { - - // This should be populated by the code executing the instructions - var $currentCall; - - // An array of instructions that contain spam - var $spamFound = array(); - - // pcre pattern for finding spam - var $spamPattern = '#^$#'; - - function internallink($link, $title = NULL) { - $this->_checkTitle($title); - } - - function externallink($link, $title = NULL) { - $this->_checkLinkForSpam($link); - $this->_checkTitle($title); - } - - function interwikilink($link, $title = NULL) { - $this->_checkTitle($title); - } - - function filelink($link, $title = NULL) { - $this->_checkLinkForSpam($link); - $this->_checkTitle($title); - } - - function windowssharelink($link, $title = NULL) { - $this->_checkLinkForSpam($link); - $this->_checkTitle($title); - } - - function email($address, $title = NULL) { - $this->_checkLinkForSpam($address); - $this->_checkTitle($title); - } - - function internalmedialink ($src) { - $this->_checkLinkForSpam($src); - } - - function externalmedialink($src) { - $this->_checkLinkForSpam($src); - } - - function _checkTitle($title) { - if ( is_array($title) && isset($title['src'])) { - $this->_checkLinkForSpam($title['src']); - } - } - - // Pattern matching happens here - /** - * @TODO What about links like www.google.com - no http:// - */ - function _checkLinkForSpam($link) { - if( preg_match($this->spamPattern,$link) ) { - $spam = $this->currentCall; - $spam[3] = $link; - $this->spamFound[] = $spam; - } - } -} - - -//Setup VIM: ex: et ts=2 enc=utf-8 : diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 4cdfdf5c2..2d241589f 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -120,49 +120,6 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $this->_xmlEntities($item['title']).'</a></span>'; } -/** FIXME deprecated - - function toc_open() { - global $lang; - $this->doc .= '<div class="toc">'.DOKU_LF; - $this->doc .= '<div class="tocheader toctoggle" id="toc__header">'; - $this->doc .= $lang['toc']; - $this->doc .= '</div>'.DOKU_LF; - $this->doc .= '<div id="toc__inside">'.DOKU_LF; - } - - function tocbranch_open($level) { - $this->doc .= '<ul class="toc">'.DOKU_LF; - } - - function tocitem_open($level, $empty = FALSE) { - if ( !$empty ) { - $this->doc .= '<li class="level'.$level.'">'; - } else { - $this->doc .= '<li class="clear">'; - } - } - - function tocelement($level, $title) { - $this->doc .= '<span class="li"><a href="#'.$this->_headerToLink($title).'" class="toc">'; - $this->doc .= $this->_xmlEntities($title); - $this->doc .= '</a></span>'; - } - - function tocitem_close($level) { - $this->doc .= '</li>'.DOKU_LF; - } - - function tocbranch_close($level) { - $this->doc .= '</ul>'.DOKU_LF; - } - - function toc_close() { - $this->doc .= '</div>'.DOKU_LF.'</div>'.DOKU_LF; - } - -*/ - function header($text, $level, $pos) { global $conf; //handle section editing diff --git a/inc/parser/xhtmlsummary.php b/inc/parser/xhtmlsummary.php index 669fa46e3..d6e3fc8b9 100644 --- a/inc/parser/xhtmlsummary.php +++ b/inc/parser/xhtmlsummary.php @@ -4,16 +4,20 @@ if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../') require_once DOKU_INC . 'inc/parser/xhtml.php'; /** -* The summary XHTML form selects either up to the first two paragraphs -* it find in a page or the first section (whichever comes first) -* It strips out the table of contents if one exists -* Section divs are not used - everything should be nested in a single -* div with CSS class "page" -* Headings have their a name link removed and section editing links -* removed -* It also attempts to capture the first heading in a page for -* use as the title of the page. -*/ + * The summary XHTML form selects either up to the first two paragraphs + * it find in a page or the first section (whichever comes first) + * It strips out the table of contents if one exists + * Section divs are not used - everything should be nested in a single + * div with CSS class "page" + * Headings have their a name link removed and section editing links + * removed + * It also attempts to capture the first heading in a page for + * use as the title of the page. + * + * + * @author Harry Fuecks <hfuecks@gmail.com> + * @todo Is this currently used anywhere? Should it? + */ class Doku_Renderer_xhtmlsummary extends Doku_Renderer_xhtml { // Namespace these variables to @@ -33,10 +37,12 @@ class Doku_Renderer_xhtmlsummary extends Doku_Renderer_xhtml { $this->doc .= DOKU_LF.'</div>'.DOKU_LF; } + // FIXME not supported anymore function toc_open() { $this->sum_summary .= $this->doc; } + // FIXME not supported anymore function toc_close() { $this->doc = ''; } |