From 627fc03f93cc74f443af98f4fbf25564cc24d3fc Mon Sep 17 00:00:00 2001 From: Guy Brand Date: Tue, 30 Jul 2013 11:10:34 +0200 Subject: Fix for the FS#1833 parser error --- 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 915899f53..6aef3fda5 100644 --- a/inc/parser/parser.php +++ b/inc/parser/parser.php @@ -454,8 +454,8 @@ class Doku_Parser_Mode_table extends Doku_Parser_Mode { } function connectTo($mode) { - $this->Lexer->addEntryPattern('\n\^',$mode,'table'); - $this->Lexer->addEntryPattern('\n\|',$mode,'table'); + $this->Lexer->addEntryPattern('\s*\n\^',$mode,'table'); + $this->Lexer->addEntryPattern('\s*\n\|',$mode,'table'); } function postConnect() { -- cgit v1.2.3 From fc498a423a295d14127239e3838b6fb7bb0c8529 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Tue, 30 Jul 2013 18:48:02 +0200 Subject: FS#2770 - prevent and syntax regex matching token names which start 'Lexer->addEntryPattern(')',$mode,'code'); + $this->Lexer->addEntryPattern(')',$mode,'code'); } function postConnect() { @@ -571,7 +571,7 @@ class Doku_Parser_Mode_code extends Doku_Parser_Mode { class Doku_Parser_Mode_file extends Doku_Parser_Mode { function connectTo($mode) { - $this->Lexer->addEntryPattern(')',$mode,'file'); + $this->Lexer->addEntryPattern(')',$mode,'file'); } function postConnect() { -- cgit v1.2.3 From e5d09fddcd17a2fe896650b64b81313a7d000975 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Wed, 31 Jul 2013 17:30:08 +0200 Subject: Index media file usage in the metadata index and use it in ft_mediause() --- inc/parser/metadata.php | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'inc/parser') diff --git a/inc/parser/metadata.php b/inc/parser/metadata.php index e17b82f8b..d64fe4d77 100644 --- a/inc/parser/metadata.php +++ b/inc/parser/metadata.php @@ -282,8 +282,10 @@ class Doku_Renderer_metadata extends Doku_Renderer { function internallink($id, $name = NULL){ global $ID; - if(is_array($name)) + if(is_array($name)) { $this->_firstimage($name['src']); + if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']); + } $default = $this->_simpleTitle($id); @@ -304,8 +306,10 @@ class Doku_Renderer_metadata extends Doku_Renderer { } function externallink($url, $name = NULL){ - if(is_array($name)) + 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 . '>'); @@ -313,8 +317,10 @@ class Doku_Renderer_metadata extends Doku_Renderer { } function interwikilink($match, $name = NULL, $wikiName, $wikiUri){ - if(is_array($name)) + 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); @@ -324,8 +330,10 @@ class Doku_Renderer_metadata extends Doku_Renderer { } function windowssharelink($url, $name = NULL){ - if(is_array($name)) + if(is_array($name)) { $this->_firstimage($name['src']); + if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']); + } if ($this->capture){ if ($name) $this->doc .= $name; @@ -334,8 +342,10 @@ class Doku_Renderer_metadata extends Doku_Renderer { } function emaillink($address, $name = NULL){ - if(is_array($name)) + if(is_array($name)) { $this->_firstimage($name['src']); + if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']); + } if ($this->capture){ if ($name) $this->doc .= $name; @@ -347,6 +357,7 @@ class Doku_Renderer_metadata extends Doku_Renderer { $height=NULL, $cache=NULL, $linking=NULL){ if ($this->capture && $title) $this->doc .= '['.$title.']'; $this->_firstimage($src); + $this->_recordMediaUsage($src); } function externalmedia($src, $title=NULL, $align=NULL, $width=NULL, @@ -439,6 +450,15 @@ class Doku_Renderer_metadata extends Doku_Renderer { $this->firstimage = $src; } } + + 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; + } } //Setup VIM: ex: et ts=4 : -- cgit v1.2.3 From 66d935e75f9ebbb37332c14e0a9425170c7c9330 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sat, 17 Aug 2013 21:33:32 +0200 Subject: Fix backlinks for internal links with parameters This adds the parameter extraction code from the xhtml renderer to the metadata renderer in order to not to include the parameters in the id that is recorded as link target. A test case checks that the link is actually returned as backlink (fails without the fix). --- inc/parser/metadata.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'inc/parser') diff --git a/inc/parser/metadata.php b/inc/parser/metadata.php index d64fe4d77..7d186e069 100644 --- a/inc/parser/metadata.php +++ b/inc/parser/metadata.php @@ -287,6 +287,12 @@ class Doku_Renderer_metadata extends Doku_Renderer { 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 -- cgit v1.2.3 From 7ef8e99fe605c5da36ab6b5d317b22fcd17f665b Mon Sep 17 00:00:00 2001 From: Matt Perry Date: Thu, 22 Aug 2013 01:01:41 -0700 Subject: Fix CodeSniffer violations Change indentation to ensure code confirms to CodeSniffer rules. --- inc/parser/handler.php | 190 ++++++------- inc/parser/lexer.php | 42 +-- inc/parser/metadata.php | 724 ++++++++++++++++++++++++------------------------ inc/parser/parser.php | 8 +- inc/parser/renderer.php | 10 +- inc/parser/xhtml.php | 26 +- 6 files changed, 500 insertions(+), 500 deletions(-) (limited to 'inc/parser') 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 - */ - 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 + */ + 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 - */ - 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 - */ - 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 - */ - 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 + */ + 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 + */ + 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 + */ + 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 .= ', '; - $this->doc .= ($ref+1).') '.DOKU_LF; - } + foreach ($alt as $ref) { + // set anchor and backlink for the other footnotes + $this->doc .= ', '; + $this->doc .= ($ref+1).') '.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); } -- cgit v1.2.3 From 0ea51e63908793de4c5d5fa2b4d82c2769fec559 Mon Sep 17 00:00:00 2001 From: Matt Perry Date: Fri, 23 Aug 2013 02:41:39 -0700 Subject: Fix CodeSniffer violations for PHP files Fix violations for Generic.PHP.LowerCaseConstant.Found --- inc/parser/code.php | 4 ++-- inc/parser/handler.php | 28 ++++++++++++++-------------- inc/parser/metadata.php | 24 ++++++++++++------------ inc/parser/renderer.php | 32 ++++++++++++++++---------------- inc/parser/xhtml.php | 30 +++++++++++++++--------------- 5 files changed, 59 insertions(+), 59 deletions(-) (limited to 'inc/parser') diff --git a/inc/parser/code.php b/inc/parser/code.php index 6e159b041..0b8e3ee02 100644 --- a/inc/parser/code.php +++ b/inc/parser/code.php @@ -15,7 +15,7 @@ class Doku_Renderer_code extends Doku_Renderer { * * When the correct block was found it exits the script. */ - function code($text, $language = NULL, $filename='' ) { + function code($text, $language = null, $filename='' ) { global $INPUT; if(!$language) $language = 'txt'; if(!$filename) $filename = 'snippet.'.$language; @@ -36,7 +36,7 @@ class Doku_Renderer_code extends Doku_Renderer { /** * Wraps around code() */ - function file($text, $language = NULL, $filename='') { + function file($text, $language = null, $filename='') { $this->code($text, $language, $filename); } diff --git a/inc/parser/handler.php b/inc/parser/handler.php index b2d0f9df4..6e6cca1a9 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -4,9 +4,9 @@ if (!defined('DOKU_PARSER_EOL')) define('DOKU_PARSER_EOL',"\n"); // add this t class Doku_Handler { - var $Renderer = NULL; + var $Renderer = null; - var $CallWriter = NULL; + var $CallWriter = null; var $calls = array(); @@ -423,7 +423,7 @@ class Doku_Handler { // Split title from URL $link = explode('|',$link,2); if ( !isset($link[1]) ) { - $link[1] = NULL; + $link[1] = null; } else if ( preg_match('/^\{\{[^\}]+\}\}$/',$link[1]) ) { // If the title is an image, convert it to an array containing the image details $link[1] = Doku_Handler_Parse_Media($link[1]); @@ -481,12 +481,12 @@ class Doku_Handler { } function filelink($match, $state, $pos) { - $this->_addCall('filelink',array($match, NULL), $pos); + $this->_addCall('filelink',array($match, null), $pos); return true; } function windowssharelink($match, $state, $pos) { - $this->_addCall('windowssharelink',array($match, NULL), $pos); + $this->_addCall('windowssharelink',array($match, null), $pos); return true; } @@ -550,7 +550,7 @@ class Doku_Handler { function emaillink($match, $state, $pos) { $email = preg_replace(array('/^$/'),'',$match); - $this->_addCall('emaillink',array($email, NULL), $pos); + $this->_addCall('emaillink',array($email, null), $pos); return true; } @@ -631,12 +631,12 @@ function Doku_Handler_Parse_Media($match) { } else if ( $lalign ) { $align = 'left'; } else { - $align = NULL; + $align = null; } // The title... if ( !isset($link[1]) ) { - $link[1] = NULL; + $link[1] = null; } //remove aligning spaces @@ -654,11 +654,11 @@ function Doku_Handler_Parse_Media($match) { //parse width and height if(preg_match('#(\d+)(x(\d+))?#i',$param,$size)){ - ($size[1]) ? $w = $size[1] : $w = NULL; - ($size[3]) ? $h = $size[3] : $h = NULL; + ($size[1]) ? $w = $size[1] : $w = null; + ($size[3]) ? $h = $size[3] : $h = null; } else { - $w = NULL; - $h = NULL; + $w = null; + $h = null; } //get linking command @@ -1247,12 +1247,12 @@ class Doku_Handler_Table { } $this->tableCalls[] = array($this->lastCellType.'_close',array(),$call[2]); - $this->tableCalls[] = array($call[0].'_open',array(1,NULL,1),$call[2]); + $this->tableCalls[] = array($call[0].'_open',array(1,null,1),$call[2]); $this->lastCellType = $call[0]; } else { - $this->tableCalls[] = array($call[0].'_open',array(1,NULL,1),$call[2]); + $this->tableCalls[] = array($call[0].'_open',array(1,null,1),$call[2]); $this->lastCellType = $call[0]; $this->firstCell = false; diff --git a/inc/parser/metadata.php b/inc/parser/metadata.php index 2d9da823d..094c3ad05 100644 --- a/inc/parser/metadata.php +++ b/inc/parser/metadata.php @@ -221,7 +221,7 @@ class Doku_Renderer_metadata extends Doku_Renderer { } } - function code($text, $language = NULL, $file = null){ + function code($text, $language = null, $file = null){ if ($this->capture){ $this->doc .= DOKU_LF.$text; if (strlen($this->doc) > 250) $this->capture = false; @@ -274,12 +274,12 @@ class Doku_Renderer_metadata extends Doku_Renderer { $this->internallink($link, $link); } - function locallink($hash, $name = NULL){} + function locallink($hash, $name = null){} /** * keep track of internal links in $this->meta['relation']['references'] */ - function internallink($id, $name = NULL){ + function internallink($id, $name = null){ global $ID; if(is_array($name)) { @@ -311,7 +311,7 @@ class Doku_Renderer_metadata extends Doku_Renderer { } } - function externallink($url, $name = NULL){ + function externallink($url, $name = null){ if(is_array($name)) { $this->_firstimage($name['src']); if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']); @@ -322,7 +322,7 @@ class Doku_Renderer_metadata extends Doku_Renderer { } } - function interwikilink($match, $name = NULL, $wikiName, $wikiUri){ + function interwikilink($match, $name = null, $wikiName, $wikiUri){ if(is_array($name)) { $this->_firstimage($name['src']); if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']); @@ -335,7 +335,7 @@ class Doku_Renderer_metadata extends Doku_Renderer { } } - function windowssharelink($url, $name = NULL){ + function windowssharelink($url, $name = null){ if(is_array($name)) { $this->_firstimage($name['src']); if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']); @@ -347,7 +347,7 @@ class Doku_Renderer_metadata extends Doku_Renderer { } } - function emaillink($address, $name = NULL){ + function emaillink($address, $name = null){ if(is_array($name)) { $this->_firstimage($name['src']); if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']); @@ -359,15 +359,15 @@ class Doku_Renderer_metadata extends Doku_Renderer { } } - function internalmedia($src, $title=NULL, $align=NULL, $width=NULL, - $height=NULL, $cache=NULL, $linking=NULL){ + 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 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){ if ($this->capture && $title) $this->doc .= '['.$title.']'; $this->_firstimage($src); } @@ -427,7 +427,7 @@ class Doku_Renderer_metadata extends Doku_Renderer { * * @author Harry Fuecks */ - function _getLinkTitle($title, $default, $id=NULL) { + function _getLinkTitle($title, $default, $id=null) { global $conf; $isImage = false; diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index 4f99c668d..c697e990c 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -203,42 +203,42 @@ class Doku_Renderer extends DokuWiki_Plugin { // $link like 'SomePage' function camelcaselink($link) {} - function locallink($hash, $name = NULL) {} + function locallink($hash, $name = null) {} // $link like 'wiki:syntax', $title could be an array (media) - function internallink($link, $title = NULL) {} + function internallink($link, $title = null) {} // $link is full URL with scheme, $title could be an array (media) - function externallink($link, $title = NULL) {} + function externallink($link, $title = null) {} function rss ($url,$params) {} // $link is the original link - probably not much use // $wikiName is an indentifier for the wiki // $wikiUri is the URL fragment to append to some known URL - function interwikilink($link, $title = NULL, $wikiName, $wikiUri) {} + function interwikilink($link, $title = null, $wikiName, $wikiUri) {} // Link to file on users OS, $title could be an array (media) - function filelink($link, $title = NULL) {} + function filelink($link, $title = null) {} // Link to a Windows share, , $title could be an array (media) - function windowssharelink($link, $title = NULL) {} + function windowssharelink($link, $title = null) {} -// function email($address, $title = NULL) {} - function emaillink($address, $name = NULL) {} +// function email($address, $title = null) {} + function emaillink($address, $name = null) {} - function internalmedia ($src, $title=NULL, $align=NULL, $width=NULL, - $height=NULL, $cache=NULL, $linking=NULL) {} + function internalmedia ($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) {} + function externalmedia ($src, $title=null, $align=null, $width=null, + $height=null, $cache=null, $linking=null) {} function internalmedialink ( - $src,$title=NULL,$align=NULL,$width=NULL,$height=NULL,$cache=NULL + $src,$title=null,$align=null,$width=null,$height=null,$cache=null ) {} function externalmedialink( - $src,$title=NULL,$align=NULL,$width=NULL,$height=NULL,$cache=NULL + $src,$title=null,$align=null,$width=null,$height=null,$cache=null ) {} function table_open($maxcols = null, $numrows = null, $pos = null){} @@ -249,11 +249,11 @@ class Doku_Renderer extends DokuWiki_Plugin { function tablerow_close(){} - function tableheader_open($colspan = 1, $align = NULL, $rowspan = 1){} + function tableheader_open($colspan = 1, $align = null, $rowspan = 1){} function tableheader_close(){} - function tablecell_open($colspan = 1, $align = NULL, $rowspan = 1){} + function tablecell_open($colspan = 1, $align = null, $rowspan = 1){} function tablecell_close(){} diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 84d837c08..a719bca26 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -547,7 +547,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } - function locallink($hash, $name = NULL){ + function locallink($hash, $name = null){ global $ID; $name = $this->_getLinkTitle($name, $hash, $isImage); $hash = $this->_headerToLink($hash); @@ -565,7 +565,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { * * @author Andreas Gohr */ - 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 +644,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 +687,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 +721,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { /** */ - function windowssharelink($url, $name = NULL) { + function windowssharelink($url, $name = null) { global $conf; global $lang; //simple setup @@ -747,7 +747,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 +782,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) { + function internalmedia ($src, $title=null, $align=null, $width=null, + $height=null, $cache=null, $linking=null) { global $ID; list($src,$hash) = explode('#',$src,2); resolve_mediaid(getNS($ID),$src, $exists); @@ -818,8 +818,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer { else $this->doc .= $this->_formatLink($link); } - 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; @@ -959,7 +959,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $this->doc .= DOKU_LF . DOKU_TAB . '' . 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'; @@ -980,7 +980,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $this->doc .= ''; } - 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'; @@ -1046,8 +1046,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer { * * @author Andreas Gohr */ - 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 = ''; @@ -1149,7 +1149,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { * * @author Harry Fuecks */ - function _getLinkTitle($title, $default, & $isImage, $id=NULL, $linktype='content') { + function _getLinkTitle($title, $default, & $isImage, $id=null, $linktype='content') { global $conf; $isImage = false; -- cgit v1.2.3 From c404cb3b0b4946f6308f66b6324a24489b2ef5b8 Mon Sep 17 00:00:00 2001 From: Matt Perry Date: Fri, 23 Aug 2013 03:08:41 -0700 Subject: Fix CodeSniffer violations for PHP files Fix violations for Squiz.Commenting.DocCommentAlignment.SpaceBeforeTag Conflicts: inc/parser/xhtml.php --- inc/parser/lexer.php | 372 +++++++++++++++++++++++++------------------------- inc/parser/parser.php | 14 +- inc/parser/xhtml.php | 4 +- 3 files changed, 197 insertions(+), 193 deletions(-) (limited to 'inc/parser') diff --git a/inc/parser/lexer.php b/inc/parser/lexer.php index 9fe1be583..2e84eca7c 100644 --- a/inc/parser/lexer.php +++ b/inc/parser/lexer.php @@ -1,18 +1,18 @@ _case = $case; @@ -52,15 +54,16 @@ class Doku_LexerParallelRegex { } /** - * Adds a pattern with an optional label. - * @param mixed $pattern Perl style regex. Must be UTF-8 - * encoded. If its a string, the (, ) - * lose their meaning unless they - * form part of a lookahead or - * lookbehind assertation. - * @param string $label Label of regex to be returned - * on a match. Label must be ASCII - * @access public + * Adds a pattern with an optional label. + * + * @param mixed $pattern Perl style regex. Must be UTF-8 + * encoded. If its a string, the (, ) + * lose their meaning unless they + * form part of a lookahead or + * lookbehind assertation. + * @param string $label Label of regex to be returned + * on a match. Label must be ASCII + * @access public */ function addPattern($pattern, $label = true) { $count = count($this->_patterns); @@ -70,13 +73,13 @@ class Doku_LexerParallelRegex { } /** - * Attempts to match all patterns at once against - * a string. - * @param string $subject String to match against. - * @param string $match First matched portion of - * subject. - * @return boolean True on success. - * @access public + * Attempts to match all patterns at once against a string. + * + * @param string $subject String to match against. + * @param string $match First matched portion of + * subject. + * @return boolean True on success. + * @access public */ function match($subject, &$match) { if (count($this->_patterns) == 0) { @@ -98,14 +101,14 @@ class Doku_LexerParallelRegex { } /** - * Attempts to split the string against all patterns at once + * Attempts to split the string against all patterns at once * - * @param string $subject String to match against. - * @param array $split The split result: array containing, pre-match, match & post-match strings - * @return boolean True on success. - * @access public + * @param string $subject String to match against. + * @param array $split The split result: array containing, pre-match, match & post-match strings + * @return boolean True on success. + * @access public * - * @author Christopher Smith + * @author Christopher Smith */ function split($subject, &$split) { if (count($this->_patterns) == 0) { @@ -143,12 +146,13 @@ class Doku_LexerParallelRegex { } /** - * Compounds the patterns into a single - * regular expression separated with the - * "or" operator. Caches the regex. - * Will automatically escape (, ) and / tokens. - * @param array $patterns List of patterns in order. - * @access private + * Compounds the patterns into a single + * regular expression separated with the + * "or" operator. Caches the regex. + * Will automatically escape (, ) and / tokens. + * + * @param array $patterns List of patterns in order. + * @access private */ function _getCompoundedRegex() { if ($this->_regex == null) { @@ -205,9 +209,9 @@ class Doku_LexerParallelRegex { } /** - * Accessor for perl regex mode flags to use. - * @return string Perl regex flags. - * @access private + * Accessor for perl regex mode flags to use. + * @return string Perl regex flags. + * @access private */ function _getPerlMatchingFlags() { return ($this->_case ? "msS" : "msSi"); @@ -215,47 +219,47 @@ class Doku_LexerParallelRegex { } /** - * States for a stack machine. - * @package Lexer - * @subpackage Lexer + * States for a stack machine. + * @package Lexer + * @subpackage Lexer */ class Doku_LexerStateStack { var $_stack; /** - * Constructor. Starts in named state. - * @param string $start Starting state name. - * @access public + * Constructor. Starts in named state. + * @param string $start Starting state name. + * @access public */ function Doku_LexerStateStack($start) { $this->_stack = array($start); } /** - * Accessor for current state. - * @return string State. - * @access public + * Accessor for current state. + * @return string State. + * @access public */ function getCurrent() { return $this->_stack[count($this->_stack) - 1]; } /** - * Adds a state to the stack and sets it - * to be the current state. - * @param string $state New state. - * @access public + * Adds a state to the stack and sets it + * to be the current state. + * @param string $state New state. + * @access public */ function enter($state) { array_push($this->_stack, $state); } /** - * Leaves the current state and reverts - * to the previous one. - * @return boolean False if we drop off - * the bottom of the list. - * @access public + * Leaves the current state and reverts + * to the previous one. + * @return boolean False if we drop off + * the bottom of the list. + * @access public */ function leave() { if (count($this->_stack) == 1) { @@ -267,13 +271,13 @@ class Doku_LexerStateStack { } /** - * Accepts text and breaks it into tokens. - * Some optimisation to make the sure the - * content is only scanned by the PHP regex - * parser once. Lexer modes must not start - * with leading underscores. - * @package Doku - * @subpackage Lexer + * Accepts text and breaks it into tokens. + * Some optimisation to make the sure the + * content is only scanned by the PHP regex + * parser once. Lexer modes must not start + * with leading underscores. + * @package Doku + * @subpackage Lexer */ class Doku_Lexer { var $_regexes; @@ -283,13 +287,13 @@ class Doku_Lexer { var $_case; /** - * Sets up the lexer in case insensitive matching - * by default. - * @param Doku_Parser $parser Handling strategy by - * reference. - * @param string $start Starting handler. - * @param boolean $case True for case sensitive. - * @access public + * Sets up the lexer in case insensitive matching + * by default. + * @param Doku_Parser $parser Handling strategy by + * reference. + * @param string $start Starting handler. + * @param boolean $case True for case sensitive. + * @access public */ function Doku_Lexer(&$parser, $start = "accept", $case = false) { $this->_case = $case; @@ -300,15 +304,15 @@ class Doku_Lexer { } /** - * Adds a token search pattern for a particular - * parsing mode. The pattern does not change the - * current mode. - * @param string $pattern Perl style regex, but ( and ) - * lose the usual meaning. - * @param string $mode Should only apply this - * pattern when dealing with - * this type of input. - * @access public + * Adds a token search pattern for a particular + * parsing mode. The pattern does not change the + * current mode. + * @param string $pattern Perl style regex, but ( and ) + * lose the usual meaning. + * @param string $mode Should only apply this + * pattern when dealing with + * this type of input. + * @access public */ function addPattern($pattern, $mode = "accept") { if (! isset($this->_regexes[$mode])) { @@ -318,17 +322,17 @@ class Doku_Lexer { } /** - * Adds a pattern that will enter a new parsing - * mode. Useful for entering parenthesis, strings, - * tags, etc. - * @param string $pattern Perl style regex, but ( and ) - * lose the usual meaning. - * @param string $mode Should only apply this - * pattern when dealing with - * this type of input. - * @param string $new_mode Change parsing to this new - * nested mode. - * @access public + * Adds a pattern that will enter a new parsing + * mode. Useful for entering parenthesis, strings, + * tags, etc. + * @param string $pattern Perl style regex, but ( and ) + * lose the usual meaning. + * @param string $mode Should only apply this + * pattern when dealing with + * this type of input. + * @param string $new_mode Change parsing to this new + * nested mode. + * @access public */ function addEntryPattern($pattern, $mode, $new_mode) { if (! isset($this->_regexes[$mode])) { @@ -338,12 +342,12 @@ class Doku_Lexer { } /** - * Adds a pattern that will exit the current mode - * and re-enter the previous one. - * @param string $pattern Perl style regex, but ( and ) - * lose the usual meaning. - * @param string $mode Mode to leave. - * @access public + * Adds a pattern that will exit the current mode + * and re-enter the previous one. + * @param string $pattern Perl style regex, but ( and ) + * lose the usual meaning. + * @param string $mode Mode to leave. + * @access public */ function addExitPattern($pattern, $mode) { if (! isset($this->_regexes[$mode])) { @@ -353,16 +357,16 @@ class Doku_Lexer { } /** - * Adds a pattern that has a special mode. Acts as an entry - * and exit pattern in one go, effectively calling a special - * parser handler for this token only. - * @param string $pattern Perl style regex, but ( and ) - * lose the usual meaning. - * @param string $mode Should only apply this - * pattern when dealing with - * this type of input. - * @param string $special Use this mode for this one token. - * @access public + * Adds a pattern that has a special mode. Acts as an entry + * and exit pattern in one go, effectively calling a special + * parser handler for this token only. + * @param string $pattern Perl style regex, but ( and ) + * lose the usual meaning. + * @param string $mode Should only apply this + * pattern when dealing with + * this type of input. + * @param string $special Use this mode for this one token. + * @access public */ function addSpecialPattern($pattern, $mode, $special) { if (! isset($this->_regexes[$mode])) { @@ -372,24 +376,24 @@ class Doku_Lexer { } /** - * Adds a mapping from a mode to another handler. - * @param string $mode Mode to be remapped. - * @param string $handler New target handler. - * @access public + * Adds a mapping from a mode to another handler. + * @param string $mode Mode to be remapped. + * @param string $handler New target handler. + * @access public */ function mapHandler($mode, $handler) { $this->_mode_handlers[$mode] = $handler; } /** - * Splits the page text into tokens. Will fail - * if the handlers report an error or if no - * content is consumed. If successful then each - * unparsed and parsed token invokes a call to the - * held listener. - * @param string $raw Raw HTML text. - * @return boolean True on success, else false. - * @access public + * Splits the page text into tokens. Will fail + * if the handlers report an error or if no + * content is consumed. If successful then each + * unparsed and parsed token invokes a call to the + * held listener. + * @param string $raw Raw HTML text. + * @return boolean True on success, else false. + * @access public */ function parse($raw) { if (! isset($this->_parser)) { @@ -418,18 +422,18 @@ class Doku_Lexer { } /** - * Sends the matched token and any leading unmatched - * text to the parser changing the lexer to a new - * mode if one is listed. - * @param string $unmatched Unmatched leading portion. - * @param string $matched Actual token match. - * @param string $mode Mode after match. A boolean - * false mode causes no change. - * @param int $pos Current byte index location in raw doc - * thats being parsed - * @return boolean False if there was any error - * from the parser. - * @access private + * Sends the matched token and any leading unmatched + * text to the parser changing the lexer to a new + * mode if one is listed. + * @param string $unmatched Unmatched leading portion. + * @param string $matched Actual token match. + * @param string $mode Mode after match. A boolean + * false mode causes no change. + * @param int $pos Current byte index location in raw doc + * thats being parsed + * @return boolean False if there was any error + * from the parser. + * @access private */ function _dispatchTokens($unmatched, $matched, $mode = false, $initialPos, $matchPos) { if (! $this->_invokeParser($unmatched, DOKU_LEXER_UNMATCHED, $initialPos) ){ @@ -456,50 +460,50 @@ class Doku_Lexer { } /** - * Tests to see if the new mode is actually to leave - * the current mode and pop an item from the matching - * mode stack. - * @param string $mode Mode to test. - * @return boolean True if this is the exit mode. - * @access private + * Tests to see if the new mode is actually to leave + * the current mode and pop an item from the matching + * mode stack. + * @param string $mode Mode to test. + * @return boolean True if this is the exit mode. + * @access private */ function _isModeEnd($mode) { return ($mode === "__exit"); } /** - * Test to see if the mode is one where this mode - * is entered for this token only and automatically - * leaves immediately afterwoods. - * @param string $mode Mode to test. - * @return boolean True if this is the exit mode. - * @access private + * Test to see if the mode is one where this mode + * is entered for this token only and automatically + * leaves immediately afterwoods. + * @param string $mode Mode to test. + * @return boolean True if this is the exit mode. + * @access private */ function _isSpecialMode($mode) { return (strncmp($mode, "_", 1) == 0); } /** - * Strips the magic underscore marking single token - * modes. - * @param string $mode Mode to decode. - * @return string Underlying mode name. - * @access private + * Strips the magic underscore marking single token + * modes. + * @param string $mode Mode to decode. + * @return string Underlying mode name. + * @access private */ function _decodeSpecial($mode) { return substr($mode, 1); } /** - * Calls the parser method named after the current - * mode. Empty content will be ignored. The lexer - * has a parser handler for each mode in the lexer. - * @param string $content Text parsed. - * @param boolean $is_match Token is recognised rather - * than unparsed data. - * @param int $pos Current byte index location in raw doc - * thats being parsed - * @access private + * Calls the parser method named after the current + * mode. Empty content will be ignored. The lexer + * has a parser handler for each mode in the lexer. + * @param string $content Text parsed. + * @param boolean $is_match Token is recognised rather + * than unparsed data. + * @param int $pos Current byte index location in raw doc + * thats being parsed + * @access private */ function _invokeParser($content, $is_match, $pos) { if (($content === "") || ($content === false)) { @@ -521,18 +525,18 @@ class Doku_Lexer { } /** - * Tries to match a chunk of text and if successful - * removes the recognised chunk and any leading - * unparsed data. Empty strings will not be matched. - * @param string $raw The subject to parse. This is the - * content that will be eaten. - * @return array Three item list of unparsed - * content followed by the - * recognised token and finally the - * action the parser is to take. - * True if no match, false if there - * is a parsing error. - * @access private + * Tries to match a chunk of text and if successful + * removes the recognised chunk and any leading + * unparsed data. Empty strings will not be matched. + * @param string $raw The subject to parse. This is the + * content that will be eaten. + * @return array Three item list of unparsed + * content followed by the + * recognised token and finally the + * action the parser is to take. + * True if no match, false if there + * is a parsing error. + * @access private */ function _reduce(&$raw) { if (! isset($this->_regexes[$this->_mode->getCurrent()])) { @@ -550,9 +554,9 @@ class Doku_Lexer { } /** -* Escapes regex characters other than (, ) and / -* @TODO -*/ + * Escapes regex characters other than (, ) and / + * @TODO + */ function Doku_Lexer_Escape($str) { //$str = addslashes($str); $chars = array( diff --git a/inc/parser/parser.php b/inc/parser/parser.php index 064178a54..3caad834a 100644 --- a/inc/parser/parser.php +++ b/inc/parser/parser.php @@ -45,9 +45,9 @@ $PARSER_MODES = array( //------------------------------------------------------------------- /** -* Sets up the Lexer with modes and points it to the Handler -* For an intro to the Lexer see: wiki:parser -*/ + * Sets up the Lexer with modes and points it to the Handler + * For an intro to the Lexer see: wiki:parser + */ class Doku_Parser { var $Handler; @@ -70,9 +70,9 @@ class Doku_Parser { } /** - * PHP preserves order of associative elements - * Mode sequence is important - */ + * PHP preserves order of associative elements + * Mode sequence is important + */ function addMode($name, & $Mode) { if ( !isset($this->modes['base']) ) { $this->addBaseMode(new Doku_Parser_Mode_base()); @@ -134,7 +134,7 @@ class Doku_Parser { * all modes are registered * * @author Harry Fuecks -*/ + */ class Doku_Parser_Mode { /** diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index a719bca26..ff4d7eb41 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -59,7 +59,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 */ public function finishSectionEdit($end = null) { @@ -541,7 +541,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } /** - */ + */ function camelcaselink($link) { $this->internallink($link,$link); } -- cgit v1.2.3 From d91ab76f52f59d264301e18c28a0d3bae996fab8 Mon Sep 17 00:00:00 2001 From: Matt Perry Date: Tue, 27 Aug 2013 01:18:10 -0700 Subject: Fix CodeSniffer violations Fix violations for the following sniff DokuWiki.Functions.OpeningFunctionBrace Also removed an extraneous semicolon. --- inc/parser/xhtml.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'inc/parser') diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index ff4d7eb41..e269563fe 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -875,7 +875,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 .= '
    '; @@ -1208,8 +1208,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(); -- cgit v1.2.3 From 2f7a0e94cadfbc1ece3bd1d3ff23483b845cd420 Mon Sep 17 00:00:00 2001 From: Matt Perry Date: Tue, 10 Sep 2013 22:17:43 -0700 Subject: Fix CodeSniffer whitespace violoations Removed extraneous whitespace to eliminate errors reported by the Squiz.WhiteSpace.SuperfluousWhitespace sniff. --- inc/parser/handler.php | 4 ---- inc/parser/metadata.php | 1 - inc/parser/parser.php | 1 - inc/parser/xhtml.php | 1 - 4 files changed, 7 deletions(-) (limited to 'inc/parser') diff --git a/inc/parser/handler.php b/inc/parser/handler.php index 6e6cca1a9..b72f051ae 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -618,7 +618,6 @@ function Doku_Handler_Parse_Media($match) { // Split title from URL $link = explode('|',$link,2); - // Check alignment $ralign = (bool)preg_match('/^ /',$link[0]); $lalign = (bool)preg_match('/ $/',$link[0]); @@ -1341,7 +1340,6 @@ class Doku_Handler_Table { break; } - } } @@ -1368,7 +1366,6 @@ class Doku_Handler_Table { break; } - } } if (is_null($spanning_cell)) { @@ -1403,7 +1400,6 @@ class Doku_Handler_Table { } } - // condense cdata $cnt = count($this->tableCalls); for( $key = 0; $key < $cnt; $key++){ diff --git a/inc/parser/metadata.php b/inc/parser/metadata.php index 094c3ad05..437559370 100644 --- a/inc/parser/metadata.php +++ b/inc/parser/metadata.php @@ -292,7 +292,6 @@ class Doku_Renderer_metadata extends Doku_Renderer { $id = $parts[0]; } - $default = $this->_simpleTitle($id); // first resolve and clean up the $id diff --git a/inc/parser/parser.php b/inc/parser/parser.php index 3caad834a..e39a4daf5 100644 --- a/inc/parser/parser.php +++ b/inc/parser/parser.php @@ -807,7 +807,6 @@ class Doku_Parser_Mode_quotes extends Doku_Parser_Mode { "\"",$mode,'doublequoteclosing' ); - } function getSort() { diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index e269563fe..848afbd4f 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -737,7 +737,6 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $link['class'] = 'media'; } - $link['title'] = $this->_xmlEntities($url); $url = str_replace('\\','/',$url); $url = 'file:///'.$url; -- cgit v1.2.3 From 6a7e97d53f954bf573a39f6108e688c9e75ab663 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Fri, 20 Sep 2013 14:11:53 +0200 Subject: Display tablecell with rowspan at first row as empty cell. Fixes FS#2810 --- inc/parser/handler.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'inc/parser') diff --git a/inc/parser/handler.php b/inc/parser/handler.php index 6e6cca1a9..b31dd54d0 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -1374,7 +1374,8 @@ class Doku_Handler_Table { 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] = ''; + $this->tableCalls[$key][0] = 'cdata'; + $this->tableCalls[$key][1][0] = ''; continue; } $this->tableCalls[$cellKey[$spanning_cell][$lastCell]][1][2]++; -- cgit v1.2.3 From 16ec3e37ba61fe0c3d045ed3922f46257b392517 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 12 Oct 2013 18:07:59 +0200 Subject: make sure footnote numbers are unique across documents FS#2841 --- inc/parser/xhtml.php | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'inc/parser') diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 848afbd4f..fd02c0ce0 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); @@ -100,10 +101,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { if ( count ($this->footnotes) > 0 ) { $this->doc .= '
    '.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") { @@ -118,8 +116,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer { if (count($alt)) { foreach ($alt as $ref) { // set anchor and backlink for the other footnotes - $this->doc .= ', '; - $this->doc .= ($ref+1).') '.DOKU_LF; + $this->doc .= ', '; + $this->doc .= ($ref).') '.DOKU_LF; } } @@ -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 .= ''.$id.')'; + $this->doc .= ''.$fnid.')'; } function listu_open() { -- cgit v1.2.3 From 45d5ad751f327b10e7256d448d5595daa82c98c4 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Tue, 15 Oct 2013 13:03:30 +0200 Subject: fix php strict notices --- 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 1de981b48..63a4104e2 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -70,7 +70,7 @@ class Doku_Handler { */ function plugin($match, $state, $pos, $pluginname){ $data = array($match); - $plugin =& plugin_load('syntax',$pluginname); + $plugin = plugin_load('syntax',$pluginname); if($plugin != null){ $data = $plugin->handle($match, $state, $pos, $this); } -- cgit v1.2.3 From 443e135d59e9d227eec818dabf9ee64d7a73d474 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Wed, 16 Oct 2013 22:04:01 +0100 Subject: replace boolean conditional checks on possibly uninitialized vars with \!empty/empty/isset as appropriate --- inc/parser/handler.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/parser') diff --git a/inc/parser/handler.php b/inc/parser/handler.php index 63a4104e2..bb284136f 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -653,8 +653,8 @@ function Doku_Handler_Parse_Media($match) { //parse width and height if(preg_match('#(\d+)(x(\d+))?#i',$param,$size)){ - ($size[1]) ? $w = $size[1] : $w = null; - ($size[3]) ? $h = $size[3] : $h = null; + !empty($size[1]) ? $w = $size[1] : $w = null; + !empty($size[3]) ? $h = $size[3] : $h = null; } else { $w = null; $h = null; -- cgit v1.2.3 From 53bfcb5964deda22607f47981b51d17e0f48d7ca Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Wed, 16 Oct 2013 22:06:51 +0100 Subject: initialize $inParagraph before use --- inc/parser/handler.php | 1 + 1 file changed, 1 insertion(+) (limited to 'inc/parser') diff --git a/inc/parser/handler.php b/inc/parser/handler.php index bb284136f..8ae991209 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -1432,6 +1432,7 @@ class Doku_Handler_Table { class Doku_Handler_Block { var $calls = array(); var $skipEol = false; + var $inParagraph = false; // Blocks these should not be inside paragraphs var $blockOpen = array( -- cgit v1.2.3 From 9269d0b1fb78c217069efd497734c183df9937be Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Tue, 29 Oct 2013 20:52:27 +0100 Subject: Fix the media usage index to include local links --- inc/parser/metadata.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'inc/parser') diff --git a/inc/parser/metadata.php b/inc/parser/metadata.php index 437559370..8ba159d62 100644 --- a/inc/parser/metadata.php +++ b/inc/parser/metadata.php @@ -274,7 +274,12 @@ class Doku_Renderer_metadata extends Doku_Renderer { $this->internallink($link, $link); } - function locallink($hash, $name = null){} + function locallink($hash, $name = null){ + if(is_array($name)) { + $this->_firstimage($name['src']); + if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']); + } + } /** * keep track of internal links in $this->meta['relation']['references'] -- cgit v1.2.3