diff options
author | Matt Perry <matt@mattperry.com> | 2013-08-22 01:01:41 -0700 |
---|---|---|
committer | Matt Perry <matt@mattperry.com> | 2013-08-22 01:01:41 -0700 |
commit | 7ef8e99fe605c5da36ab6b5d317b22fcd17f665b (patch) | |
tree | 2245231ac0dcbeea7084a751f89699e3307133f2 /inc/parser | |
parent | 104262381eb89124eb900397f5054fde8e3d5658 (diff) | |
download | rpg-7ef8e99fe605c5da36ab6b5d317b22fcd17f665b.tar.gz rpg-7ef8e99fe605c5da36ab6b5d317b22fcd17f665b.tar.bz2 |
Fix CodeSniffer violations
Change indentation to ensure code confirms to CodeSniffer rules.
Diffstat (limited to 'inc/parser')
-rw-r--r-- | inc/parser/handler.php | 190 | ||||
-rw-r--r-- | inc/parser/lexer.php | 42 | ||||
-rw-r--r-- | inc/parser/metadata.php | 724 | ||||
-rw-r--r-- | inc/parser/parser.php | 8 | ||||
-rw-r--r-- | inc/parser/renderer.php | 10 | ||||
-rw-r--r-- | inc/parser/xhtml.php | 26 |
6 files changed, 500 insertions, 500 deletions
diff --git a/inc/parser/handler.php b/inc/parser/handler.php index 1cf32aaed..b2d0f9df4 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -35,8 +35,8 @@ class Doku_Handler { $this->CallWriter->finalise(); if ( $this->status['section'] ) { - $last_call = end($this->calls); - array_push($this->calls,array('section_close',array(), $last_call[2])); + $last_call = end($this->calls); + array_push($this->calls,array('section_close',array(), $last_call[2])); } if ( $this->rewriteBlocks ) { @@ -75,7 +75,7 @@ class Doku_Handler { $data = $plugin->handle($match, $state, $pos, $this); } if ($data !== false) { - $this->addPluginCall($pluginname,$data,$state,$pos,$match); + $this->addPluginCall($pluginname,$data,$state,$pos,$match); } return true; } @@ -190,8 +190,8 @@ class Doku_Handler { // footnotes can not be nested - however due to limitations in lexer it can't be prevented // we will still enter a new footnote mode, we just do nothing if ($this->_footnote) { - $this->_addCall('cdata',array($match), $pos); - break; + $this->_addCall('cdata',array($match), $pos); + break; } $this->_footnote = true; @@ -203,8 +203,8 @@ class Doku_Handler { case DOKU_LEXER_EXIT: // check whether we have already exitted the footnote mode, can happen if the modes were nested if (!$this->_footnote) { - $this->_addCall('cdata',array($match), $pos); - break; + $this->_addCall('cdata',array($match), $pos); + break; } $this->_footnote = false; @@ -433,7 +433,7 @@ class Doku_Handler { //decide which kind of link it is if ( preg_match('/^[a-zA-Z0-9\.]+>{1}.*$/u',$link[0]) ) { - // Interwiki + // Interwiki $interwiki = explode('>',$link[0],2); $this->_addCall( 'interwikilink', @@ -441,35 +441,35 @@ class Doku_Handler { $pos ); }elseif ( preg_match('/^\\\\\\\\[^\\\\]+?\\\\/u',$link[0]) ) { - // Windows Share + // Windows Share $this->_addCall( 'windowssharelink', array($link[0],$link[1]), $pos ); }elseif ( preg_match('#^([a-z0-9\-\.+]+?)://#i',$link[0]) ) { - // external link (accepts all protocols) + // external link (accepts all protocols) $this->_addCall( 'externallink', array($link[0],$link[1]), $pos ); }elseif ( preg_match('<'.PREG_PATTERN_VALID_EMAIL.'>',$link[0]) ) { - // E-Mail (pattern above is defined in inc/mail.php) + // E-Mail (pattern above is defined in inc/mail.php) $this->_addCall( 'emaillink', array($link[0],$link[1]), $pos ); }elseif ( preg_match('!^#.+!',$link[0]) ){ - // local link + // local link $this->_addCall( 'locallink', array(substr($link[0],1),$link[1]), $pos ); }else{ - // internal link + // internal link $this->_addCall( 'internallink', array($link[0],$link[1]), @@ -520,10 +520,10 @@ class Doku_Handler { $p['details'] = (preg_match('/\b(desc|detail)/',$params)); if (preg_match('/\b(\d+)([dhm])\b/',$params,$match)) { - $period = array('d' => 86400, 'h' => 3600, 'm' => 60); - $p['refresh'] = max(600,$match[1]*$period[$match[2]]); // n * period in seconds, minimum 10 minutes + $period = array('d' => 86400, 'h' => 3600, 'm' => 60); + $p['refresh'] = max(600,$match[1]*$period[$match[2]]); // n * period in seconds, minimum 10 minutes } else { - $p['refresh'] = 14400; // default to 4 hours + $p['refresh'] = 14400; // default to 4 hours } $this->_addCall('rss',array($link,$p),$pos); @@ -1034,7 +1034,7 @@ class Doku_Handler_Preformatted { break; case 'preformatted_end': if (trim($this->text)) { - $this->CallWriter->writeCall(array('preformatted',array($this->text),$this->pos)); + $this->CallWriter->writeCall(array('preformatted',array($this->text),$this->pos)); } // see FS#1699 & FS#1652, add 'eol' instructions to ensure proper triggering of following p_open $this->CallWriter->writeCall(array('eol',array(),$this->pos)); @@ -1289,116 +1289,116 @@ class Doku_Handler_Table { $call = $this->tableCalls[$key]; switch ($call[0]) { - case 'tablerow_open': + case 'tablerow_open': - $lastRow++; - $lastCell = 0; - break; + $lastRow++; + $lastCell = 0; + break; - case 'tablecell_open': - case 'tableheader_open': + case 'tablecell_open': + case 'tableheader_open': - $lastCell++; - $cellKey[$lastRow][$lastCell] = $key; - break; + $lastCell++; + $cellKey[$lastRow][$lastCell] = $key; + break; - case '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')); - // If the cell is empty, align left - if ($prev && $next) { - $this->tableCalls[$key-1][1][1] = 'left'; + $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')); + // If the cell is empty, align left + if ($prev && $next) { + $this->tableCalls[$key-1][1][1] = 'left'; - // If the previous element was a cell open, align right - } elseif ($prev) { - $this->tableCalls[$key-1][1][1] = 'right'; + // If the previous element was a cell open, align right + } elseif ($prev) { + $this->tableCalls[$key-1][1][1] = 'right'; - // If the next element is the close of an element, align either center or left - } elseif ( $next) { - if ( $this->tableCalls[$cellKey[$lastRow][$lastCell]][1][1] == 'right' ) { - $this->tableCalls[$cellKey[$lastRow][$lastCell]][1][1] = 'center'; - } else { - $this->tableCalls[$cellKey[$lastRow][$lastCell]][1][1] = 'left'; - } + // If the next element is the close of an element, align either center or left + } elseif ( $next) { + if ( $this->tableCalls[$cellKey[$lastRow][$lastCell]][1][1] == 'right' ) { + $this->tableCalls[$cellKey[$lastRow][$lastCell]][1][1] = 'center'; + } else { + $this->tableCalls[$cellKey[$lastRow][$lastCell]][1][1] = 'left'; + } - } + } - // Now convert the whitespace back to cdata - $this->tableCalls[$key][0] = 'cdata'; - break; + // Now convert the whitespace back to cdata + $this->tableCalls[$key][0] = 'cdata'; + break; - case 'colspan': + case 'colspan': - $this->tableCalls[$key-1][1][0] = false; + $this->tableCalls[$key-1][1][0] = false; - for($i = $key-2; $i >= $cellKey[$lastRow][1]; $i--) { + for($i = $key-2; $i >= $cellKey[$lastRow][1]; $i--) { - if ( $this->tableCalls[$i][0] == 'tablecell_open' || $this->tableCalls[$i][0] == 'tableheader_open' ) { + if ( $this->tableCalls[$i][0] == 'tablecell_open' || $this->tableCalls[$i][0] == 'tableheader_open' ) { - if ( false !== $this->tableCalls[$i][1][0] ) { - $this->tableCalls[$i][1][0]++; - break; - } + if ( false !== $this->tableCalls[$i][1][0] ) { + $this->tableCalls[$i][1][0]++; + break; + } + } } - } - $toDelete[] = $key-1; - $toDelete[] = $key; - $toDelete[] = $key+1; - break; + $toDelete[] = $key-1; + $toDelete[] = $key; + $toDelete[] = $key+1; + break; - case '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 - $this->tableCalls[$key][0] = 'cdata'; + 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 + $this->tableCalls[$key][0] = 'cdata'; - } else { + } else { - $spanning_cell = null; - for($i = $lastRow-1; $i > 0; $i--) { + $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 ( $this->tableCalls[$cellKey[$i][$lastCell]][0] == 'tablecell_open' || $this->tableCalls[$cellKey[$i][$lastCell]][0] == 'tableheader_open' ) { - if ($this->tableCalls[$cellKey[$i][$lastCell]][1][2] >= $lastRow - $i) { - $spanning_cell = $i; - break; - } + 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]++; + 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; + $this->tableCalls[$key-1][1][2] = false; - $toDelete[] = $key-1; - $toDelete[] = $key; - $toDelete[] = $key+1; - } - break; + $toDelete[] = $key-1; + $toDelete[] = $key; + $toDelete[] = $key+1; + } + break; - case 'tablerow_close': + 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; - } + // 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; + break; } } diff --git a/inc/parser/lexer.php b/inc/parser/lexer.php index b5bcb9612..9fe1be583 100644 --- a/inc/parser/lexer.php +++ b/inc/parser/lexer.php @@ -176,25 +176,25 @@ class Doku_LexerParallelRegex { */ switch($elt) { - case '(': - $pattern .= '\('; - break; - case ')': - if ($level > 0) - $level--; /* closing (? */ - else - $pattern .= '\\'; - $pattern .= ')'; - break; - case '(?': - $level++; - $pattern .= '(?'; - break; - default: - if (substr($elt, 0, 1) == '\\') - $pattern .= $elt; - else - $pattern .= str_replace('/', '\/', $elt); + case '(': + $pattern .= '\('; + break; + case ')': + if ($level > 0) + $level--; /* closing (? */ + else + $pattern .= '\\'; + $pattern .= ')'; + break; + case '(?': + $level++; + $pattern .= '(?'; + break; + default: + if (substr($elt, 0, 1) == '\\') + $pattern .= $elt; + else + $pattern .= str_replace('/', '\/', $elt); } } $this->_patterns[$i] = "($pattern)"; @@ -513,8 +513,8 @@ class Doku_Lexer { // modes starting with plugin_ are all handled by the same // handler but with an additional parameter if(substr($handler,0,7)=='plugin_'){ - list($handler,$plugin) = explode('_',$handler,2); - return $this->_parser->$handler($content, $is_match, $pos, $plugin); + list($handler,$plugin) = explode('_',$handler,2); + return $this->_parser->$handler($content, $is_match, $pos, $plugin); } return $this->_parser->$handler($content, $is_match, $pos); diff --git a/inc/parser/metadata.php b/inc/parser/metadata.php index 7d186e069..2d9da823d 100644 --- a/inc/parser/metadata.php +++ b/inc/parser/metadata.php @@ -23,448 +23,448 @@ require_once DOKU_INC . 'inc/parser/renderer.php'; */ class Doku_Renderer_metadata extends Doku_Renderer { - var $doc = ''; - var $meta = array(); - var $persistent = array(); + var $doc = ''; + var $meta = array(); + var $persistent = array(); - var $headers = array(); - var $capture = true; - var $store = ''; - var $firstimage = ''; + var $headers = array(); + var $capture = true; + var $store = ''; + var $firstimage = ''; - function getFormat(){ - return 'metadata'; - } - - function document_start(){ - global $ID; - - $this->headers = array(); - - // external pages are missing create date - if(!$this->persistent['date']['created']){ - $this->persistent['date']['created'] = filectime(wikiFN($ID)); + function getFormat(){ + return 'metadata'; } - if(!isset($this->persistent['user'])){ - $this->persistent['user'] = ''; - } - if(!isset($this->persistent['creator'])){ - $this->persistent['creator'] = ''; + + function document_start(){ + global $ID; + + $this->headers = array(); + + // external pages are missing create date + if(!$this->persistent['date']['created']){ + $this->persistent['date']['created'] = filectime(wikiFN($ID)); + } + if(!isset($this->persistent['user'])){ + $this->persistent['user'] = ''; + } + if(!isset($this->persistent['creator'])){ + $this->persistent['creator'] = ''; + } + // reset metadata to persistent values + $this->meta = $this->persistent; } - // reset metadata to persistent values - $this->meta = $this->persistent; - } - function document_end(){ - global $ID; + function document_end(){ + global $ID; - // store internal info in metadata (notoc,nocache) - $this->meta['internal'] = $this->info; + // store internal info in metadata (notoc,nocache) + $this->meta['internal'] = $this->info; - if (!isset($this->meta['description']['abstract'])){ - // cut off too long abstracts - $this->doc = trim($this->doc); - if (strlen($this->doc) > 500) - $this->doc = utf8_substr($this->doc, 0, 500).'…'; - $this->meta['description']['abstract'] = $this->doc; - } + if (!isset($this->meta['description']['abstract'])){ + // cut off too long abstracts + $this->doc = trim($this->doc); + if (strlen($this->doc) > 500) + $this->doc = utf8_substr($this->doc, 0, 500).'…'; + $this->meta['description']['abstract'] = $this->doc; + } - $this->meta['relation']['firstimage'] = $this->firstimage; + $this->meta['relation']['firstimage'] = $this->firstimage; + + if(!isset($this->meta['date']['modified'])){ + $this->meta['date']['modified'] = filemtime(wikiFN($ID)); + } - if(!isset($this->meta['date']['modified'])){ - $this->meta['date']['modified'] = filemtime(wikiFN($ID)); } - } + function toc_additem($id, $text, $level) { + global $conf; - function toc_additem($id, $text, $level) { - global $conf; + //only add items within configured levels + if($level >= $conf['toptoclevel'] && $level <= $conf['maxtoclevel']){ + // the TOC is one of our standard ul list arrays ;-) + $this->meta['description']['tableofcontents'][] = array( + 'hid' => $id, + 'title' => $text, + 'type' => 'ul', + 'level' => $level-$conf['toptoclevel']+1 + ); + } - //only add items within configured levels - if($level >= $conf['toptoclevel'] && $level <= $conf['maxtoclevel']){ - // the TOC is one of our standard ul list arrays ;-) - $this->meta['description']['tableofcontents'][] = array( - 'hid' => $id, - 'title' => $text, - 'type' => 'ul', - 'level' => $level-$conf['toptoclevel']+1 - ); } - } - - function header($text, $level, $pos) { - if (!isset($this->meta['title'])) $this->meta['title'] = $text; + function header($text, $level, $pos) { + if (!isset($this->meta['title'])) $this->meta['title'] = $text; - // add the header to the TOC - $hid = $this->_headerToLink($text,'true'); - $this->toc_additem($hid, $text, $level); + // add the header to the TOC + $hid = $this->_headerToLink($text,'true'); + $this->toc_additem($hid, $text, $level); - // add to summary - if ($this->capture && ($level > 1)) $this->doc .= DOKU_LF.$text.DOKU_LF; - } + // add to summary + if ($this->capture && ($level > 1)) $this->doc .= DOKU_LF.$text.DOKU_LF; + } - function section_open($level){} - function section_close(){} + function section_open($level){} + function section_close(){} - function cdata($text){ - if ($this->capture) $this->doc .= $text; - } + function cdata($text){ + if ($this->capture) $this->doc .= $text; + } - function p_open(){ - if ($this->capture) $this->doc .= DOKU_LF; - } + function p_open(){ + if ($this->capture) $this->doc .= DOKU_LF; + } - function p_close(){ - if ($this->capture){ - if (strlen($this->doc) > 250) $this->capture = false; - else $this->doc .= DOKU_LF; + function p_close(){ + if ($this->capture){ + if (strlen($this->doc) > 250) $this->capture = false; + else $this->doc .= DOKU_LF; + } } - } - function linebreak(){ - if ($this->capture) $this->doc .= DOKU_LF; - } + function linebreak(){ + if ($this->capture) $this->doc .= DOKU_LF; + } - function hr(){ - if ($this->capture){ - if (strlen($this->doc) > 250) $this->capture = false; - else $this->doc .= DOKU_LF.'----------'.DOKU_LF; + function hr(){ + if ($this->capture){ + if (strlen($this->doc) > 250) $this->capture = false; + else $this->doc .= DOKU_LF.'----------'.DOKU_LF; + } } - } - /** - * Callback for footnote start syntax - * - * All following content will go to the footnote instead of - * the document. To achieve this the previous rendered content - * is moved to $store and $doc is cleared - * - * @author Andreas Gohr <andi@splitbrain.org> - */ - function footnote_open() { - if ($this->capture){ - // move current content to store and record footnote - $this->store = $this->doc; - $this->doc = ''; + /** + * Callback for footnote start syntax + * + * All following content will go to the footnote instead of + * the document. To achieve this the previous rendered content + * is moved to $store and $doc is cleared + * + * @author Andreas Gohr <andi@splitbrain.org> + */ + function footnote_open() { + if ($this->capture){ + // move current content to store and record footnote + $this->store = $this->doc; + $this->doc = ''; + } } - } - /** - * Callback for footnote end syntax - * - * All rendered content is moved to the $footnotes array and the old - * content is restored from $store again - * - * @author Andreas Gohr - */ - function footnote_close() { - if ($this->capture){ - // restore old content - $this->doc = $this->store; - $this->store = ''; - } - } - - function listu_open(){ - if ($this->capture) $this->doc .= DOKU_LF; - } - - function listu_close(){ - if ($this->capture && (strlen($this->doc) > 250)) $this->capture = false; - } - - function listo_open(){ - if ($this->capture) $this->doc .= DOKU_LF; - } - - function listo_close(){ - if ($this->capture && (strlen($this->doc) > 250)) $this->capture = false; - } - - function listitem_open($level){ - if ($this->capture) $this->doc .= str_repeat(DOKU_TAB, $level).'* '; - } - - function listitem_close(){ - if ($this->capture) $this->doc .= DOKU_LF; - } - - function listcontent_open(){} - function listcontent_close(){} - - function unformatted($text){ - if ($this->capture) $this->doc .= $text; - } - - function preformatted($text){ - if ($this->capture) $this->doc .= $text; - } - - function file($text, $lang = null, $file = null){ - if ($this->capture){ - $this->doc .= DOKU_LF.$text; - if (strlen($this->doc) > 250) $this->capture = false; - else $this->doc .= DOKU_LF; - } - } - - function quote_open(){ - if ($this->capture) $this->doc .= DOKU_LF.DOKU_TAB.'"'; - } - - function quote_close(){ - if ($this->capture){ - $this->doc .= '"'; - if (strlen($this->doc) > 250) $this->capture = false; - else $this->doc .= DOKU_LF; - } - } - - function code($text, $language = NULL, $file = null){ - if ($this->capture){ - $this->doc .= DOKU_LF.$text; - if (strlen($this->doc) > 250) $this->capture = false; - else $this->doc .= DOKU_LF; - } - } + /** + * Callback for footnote end syntax + * + * All rendered content is moved to the $footnotes array and the old + * content is restored from $store again + * + * @author Andreas Gohr + */ + function footnote_close() { + if ($this->capture){ + // restore old content + $this->doc = $this->store; + $this->store = ''; + } + } - function acronym($acronym){ - if ($this->capture) $this->doc .= $acronym; - } + function listu_open(){ + if ($this->capture) $this->doc .= DOKU_LF; + } - function smiley($smiley){ - if ($this->capture) $this->doc .= $smiley; - } + function listu_close(){ + if ($this->capture && (strlen($this->doc) > 250)) $this->capture = false; + } - function entity($entity){ - if ($this->capture) $this->doc .= $entity; - } + function listo_open(){ + if ($this->capture) $this->doc .= DOKU_LF; + } - function multiplyentity($x, $y){ - if ($this->capture) $this->doc .= $x.'×'.$y; - } + function listo_close(){ + if ($this->capture && (strlen($this->doc) > 250)) $this->capture = false; + } - function singlequoteopening(){ - global $lang; - if ($this->capture) $this->doc .= $lang['singlequoteopening']; - } + function listitem_open($level){ + if ($this->capture) $this->doc .= str_repeat(DOKU_TAB, $level).'* '; + } - function singlequoteclosing(){ - global $lang; - if ($this->capture) $this->doc .= $lang['singlequoteclosing']; - } + function listitem_close(){ + if ($this->capture) $this->doc .= DOKU_LF; + } - function apostrophe() { - global $lang; - if ($this->capture) $this->doc .= $lang['apostrophe']; - } + function listcontent_open(){} + function listcontent_close(){} - function doublequoteopening(){ - global $lang; - if ($this->capture) $this->doc .= $lang['doublequoteopening']; - } + function unformatted($text){ + if ($this->capture) $this->doc .= $text; + } - function doublequoteclosing(){ - global $lang; - if ($this->capture) $this->doc .= $lang['doublequoteclosing']; - } + function preformatted($text){ + if ($this->capture) $this->doc .= $text; + } - function camelcaselink($link) { - $this->internallink($link, $link); - } + function file($text, $lang = null, $file = null){ + if ($this->capture){ + $this->doc .= DOKU_LF.$text; + if (strlen($this->doc) > 250) $this->capture = false; + else $this->doc .= DOKU_LF; + } + } - function locallink($hash, $name = NULL){} + function quote_open(){ + if ($this->capture) $this->doc .= DOKU_LF.DOKU_TAB.'"'; + } - /** - * keep track of internal links in $this->meta['relation']['references'] - */ - function internallink($id, $name = NULL){ - global $ID; + function quote_close(){ + if ($this->capture){ + $this->doc .= '"'; + if (strlen($this->doc) > 250) $this->capture = false; + else $this->doc .= DOKU_LF; + } + } - if(is_array($name)) { - $this->_firstimage($name['src']); - if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']); + function code($text, $language = NULL, $file = null){ + if ($this->capture){ + $this->doc .= DOKU_LF.$text; + if (strlen($this->doc) > 250) $this->capture = false; + else $this->doc .= DOKU_LF; + } } - $parts = explode('?', $id, 2); - if (count($parts) === 2) { - $id = $parts[0]; + function acronym($acronym){ + if ($this->capture) $this->doc .= $acronym; } + function smiley($smiley){ + if ($this->capture) $this->doc .= $smiley; + } - $default = $this->_simpleTitle($id); + function entity($entity){ + if ($this->capture) $this->doc .= $entity; + } - // first resolve and clean up the $id - resolve_pageid(getNS($ID), $id, $exists); - list($page, $hash) = explode('#', $id, 2); + function multiplyentity($x, $y){ + if ($this->capture) $this->doc .= $x.'×'.$y; + } - // set metadata - $this->meta['relation']['references'][$page] = $exists; - // $data = array('relation' => array('isreferencedby' => array($ID => true))); - // p_set_metadata($id, $data); + function singlequoteopening(){ + global $lang; + if ($this->capture) $this->doc .= $lang['singlequoteopening']; + } - // add link title to summary - if ($this->capture){ - $name = $this->_getLinkTitle($name, $default, $id); - $this->doc .= $name; + function singlequoteclosing(){ + global $lang; + if ($this->capture) $this->doc .= $lang['singlequoteclosing']; } - } - function externallink($url, $name = NULL){ - if(is_array($name)) { - $this->_firstimage($name['src']); - if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']); + function apostrophe() { + global $lang; + if ($this->capture) $this->doc .= $lang['apostrophe']; } - if ($this->capture){ - $this->doc .= $this->_getLinkTitle($name, '<' . $url . '>'); + function doublequoteopening(){ + global $lang; + if ($this->capture) $this->doc .= $lang['doublequoteopening']; } - } - function interwikilink($match, $name = NULL, $wikiName, $wikiUri){ - if(is_array($name)) { - $this->_firstimage($name['src']); - if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']); + function doublequoteclosing(){ + global $lang; + if ($this->capture) $this->doc .= $lang['doublequoteclosing']; } - if ($this->capture){ - list($wikiUri, $hash) = explode('#', $wikiUri, 2); - $name = $this->_getLinkTitle($name, $wikiUri); - $this->doc .= $name; + function camelcaselink($link) { + $this->internallink($link, $link); } - } - function windowssharelink($url, $name = NULL){ - if(is_array($name)) { - $this->_firstimage($name['src']); - if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']); + function locallink($hash, $name = NULL){} + + /** + * keep track of internal links in $this->meta['relation']['references'] + */ + function internallink($id, $name = NULL){ + global $ID; + + if(is_array($name)) { + $this->_firstimage($name['src']); + if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']); + } + + $parts = explode('?', $id, 2); + if (count($parts) === 2) { + $id = $parts[0]; + } + + + $default = $this->_simpleTitle($id); + + // first resolve and clean up the $id + resolve_pageid(getNS($ID), $id, $exists); + list($page, $hash) = explode('#', $id, 2); + + // set metadata + $this->meta['relation']['references'][$page] = $exists; + // $data = array('relation' => array('isreferencedby' => array($ID => true))); + // p_set_metadata($id, $data); + + // add link title to summary + if ($this->capture){ + $name = $this->_getLinkTitle($name, $default, $id); + $this->doc .= $name; + } } - if ($this->capture){ - if ($name) $this->doc .= $name; - else $this->doc .= '<'.$url.'>'; + function externallink($url, $name = NULL){ + if(is_array($name)) { + $this->_firstimage($name['src']); + if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']); + } + + if ($this->capture){ + $this->doc .= $this->_getLinkTitle($name, '<' . $url . '>'); + } } - } - function emaillink($address, $name = NULL){ - if(is_array($name)) { - $this->_firstimage($name['src']); - if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']); + function interwikilink($match, $name = NULL, $wikiName, $wikiUri){ + if(is_array($name)) { + $this->_firstimage($name['src']); + if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']); + } + + if ($this->capture){ + list($wikiUri, $hash) = explode('#', $wikiUri, 2); + $name = $this->_getLinkTitle($name, $wikiUri); + $this->doc .= $name; + } } - if ($this->capture){ - if ($name) $this->doc .= $name; - else $this->doc .= '<'.$address.'>'; + function windowssharelink($url, $name = NULL){ + if(is_array($name)) { + $this->_firstimage($name['src']); + if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']); + } + + if ($this->capture){ + if ($name) $this->doc .= $name; + else $this->doc .= '<'.$url.'>'; + } } - } - function internalmedia($src, $title=NULL, $align=NULL, $width=NULL, - $height=NULL, $cache=NULL, $linking=NULL){ - if ($this->capture && $title) $this->doc .= '['.$title.']'; - $this->_firstimage($src); - $this->_recordMediaUsage($src); - } + function emaillink($address, $name = NULL){ + if(is_array($name)) { + $this->_firstimage($name['src']); + if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']); + } - function externalmedia($src, $title=NULL, $align=NULL, $width=NULL, - $height=NULL, $cache=NULL, $linking=NULL){ - if ($this->capture && $title) $this->doc .= '['.$title.']'; - $this->_firstimage($src); - } + if ($this->capture){ + if ($name) $this->doc .= $name; + else $this->doc .= '<'.$address.'>'; + } + } - function rss($url,$params) { - $this->meta['relation']['haspart'][$url] = true; + function internalmedia($src, $title=NULL, $align=NULL, $width=NULL, + $height=NULL, $cache=NULL, $linking=NULL){ + if ($this->capture && $title) $this->doc .= '['.$title.']'; + $this->_firstimage($src); + $this->_recordMediaUsage($src); + } - $this->meta['date']['valid']['age'] = - isset($this->meta['date']['valid']['age']) ? - min($this->meta['date']['valid']['age'],$params['refresh']) : - $params['refresh']; - } + function externalmedia($src, $title=NULL, $align=NULL, $width=NULL, + $height=NULL, $cache=NULL, $linking=NULL){ + if ($this->capture && $title) $this->doc .= '['.$title.']'; + $this->_firstimage($src); + } - //---------------------------------------------------------- - // Utils + function rss($url,$params) { + $this->meta['relation']['haspart'][$url] = true; - /** - * Removes any Namespace from the given name but keeps - * casing and special chars - * - * @author Andreas Gohr <andi@splitbrain.org> - */ - function _simpleTitle($name){ - global $conf; + $this->meta['date']['valid']['age'] = + isset($this->meta['date']['valid']['age']) ? + min($this->meta['date']['valid']['age'],$params['refresh']) : + $params['refresh']; + } - if(is_array($name)) return ''; - - if($conf['useslash']){ - $nssep = '[:;/]'; - }else{ - $nssep = '[:;]'; - } - $name = preg_replace('!.*'.$nssep.'!','',$name); - //if there is a hash we use the anchor name only - $name = preg_replace('!.*#!','',$name); - return $name; - } - - /** - * Creates a linkid from a headline - * - * @param string $title The headline title - * @param boolean $create Create a new unique ID? - * @author Andreas Gohr <andi@splitbrain.org> - */ - function _headerToLink($title, $create=false) { - if($create){ - return sectionID($title,$this->headers); - }else{ - $check = false; - return sectionID($title,$check); - } - } - - /** - * Construct a title and handle images in titles - * - * @author Harry Fuecks <hfuecks@gmail.com> - */ - function _getLinkTitle($title, $default, $id=NULL) { - global $conf; - - $isImage = false; - if (is_array($title)){ - if($title['title']) return '['.$title['title'].']'; - } else if (is_null($title) || trim($title)==''){ - if (useHeading('content') && $id){ - $heading = p_get_first_heading($id,METADATA_DONT_RENDER); - if ($heading) return $heading; - } - return $default; - } else { - return $title; + //---------------------------------------------------------- + // Utils + + /** + * Removes any Namespace from the given name but keeps + * casing and special chars + * + * @author Andreas Gohr <andi@splitbrain.org> + */ + function _simpleTitle($name){ + global $conf; + + if(is_array($name)) return ''; + + if($conf['useslash']){ + $nssep = '[:;/]'; + }else{ + $nssep = '[:;]'; + } + $name = preg_replace('!.*'.$nssep.'!','',$name); + //if there is a hash we use the anchor name only + $name = preg_replace('!.*#!','',$name); + return $name; } - } - function _firstimage($src){ - if($this->firstimage) return; - global $ID; + /** + * Creates a linkid from a headline + * + * @param string $title The headline title + * @param boolean $create Create a new unique ID? + * @author Andreas Gohr <andi@splitbrain.org> + */ + function _headerToLink($title, $create=false) { + if($create){ + return sectionID($title,$this->headers); + }else{ + $check = false; + return sectionID($title,$check); + } + } - list($src,$hash) = explode('#',$src,2); - if(!media_isexternal($src)){ - resolve_mediaid(getNS($ID),$src, $exists); + /** + * Construct a title and handle images in titles + * + * @author Harry Fuecks <hfuecks@gmail.com> + */ + function _getLinkTitle($title, $default, $id=NULL) { + global $conf; + + $isImage = false; + if (is_array($title)){ + if($title['title']) return '['.$title['title'].']'; + } else if (is_null($title) || trim($title)==''){ + if (useHeading('content') && $id){ + $heading = p_get_first_heading($id,METADATA_DONT_RENDER); + if ($heading) return $heading; + } + return $default; + } else { + return $title; + } } - if(preg_match('/.(jpe?g|gif|png)$/i',$src)){ - $this->firstimage = $src; + + function _firstimage($src){ + if($this->firstimage) return; + global $ID; + + list($src,$hash) = explode('#',$src,2); + if(!media_isexternal($src)){ + resolve_mediaid(getNS($ID),$src, $exists); + } + if(preg_match('/.(jpe?g|gif|png)$/i',$src)){ + $this->firstimage = $src; + } } - } - function _recordMediaUsage($src) { - global $ID; + function _recordMediaUsage($src) { + global $ID; - list ($src, $hash) = explode('#', $src, 2); - if (media_isexternal($src)) return; - resolve_mediaid(getNS($ID), $src, $exists); - $this->meta['relation']['media'][$src] = $exists; - } + list ($src, $hash) = explode('#', $src, 2); + if (media_isexternal($src)) return; + resolve_mediaid(getNS($ID), $src, $exists); + $this->meta['relation']['media'][$src] = $exists; + } } //Setup VIM: ex: et ts=4 : diff --git a/inc/parser/parser.php b/inc/parser/parser.php index 4af1cd333..064178a54 100644 --- a/inc/parser/parser.php +++ b/inc/parser/parser.php @@ -621,7 +621,7 @@ class Doku_Parser_Mode_acronym extends Doku_Parser_Mode { var $pattern = ''; function Doku_Parser_Mode_acronym($acronyms) { - usort($acronyms,array($this,'_compare')); + usort($acronyms,array($this,'_compare')); $this->acronyms = $acronyms; } @@ -652,12 +652,12 @@ class Doku_Parser_Mode_acronym extends Doku_Parser_Mode { $a_len = strlen($a); $b_len = strlen($b); if ($a_len > $b_len) { - return -1; + return -1; } else if ($a_len < $b_len) { - return 1; + return 1; } - return 0; + return 0; } } diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index 7df369478..4f99c668d 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -74,12 +74,12 @@ class Doku_Renderer extends DokuWiki_Plugin { */ function nest($instructions) { - foreach ( $instructions as $instruction ) { - // execute the callback against ourself - if (method_exists($this,$instruction[0])) { - call_user_func_array(array($this, $instruction[0]), $instruction[1] ? $instruction[1] : array()); + foreach ( $instructions as $instruction ) { + // execute the callback against ourself + if (method_exists($this,$instruction[0])) { + call_user_func_array(array($this, $instruction[0]), $instruction[1] ? $instruction[1] : array()); + } } - } } // dummy closing instruction issued by Doku_Handler_Nest, normally the syntax mode should diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 84a999e56..84d837c08 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -116,11 +116,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+1).'" id="fn__'.($ref+1).'" class="fn_bot">'; + $this->doc .= ($ref+1).')</a></sup> '.DOKU_LF; + } } // add footnote markup and close this footnote @@ -367,12 +367,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 +392,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); } } @@ -543,7 +543,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { /** */ function camelcaselink($link) { - $this->internallink($link,$link); + $this->internallink($link,$link); } |