SourceForge logo
SourceForge logo
Menu

phpwiki-checkins

From: <var...@us...> - 2008年08月22日 14:14:27
Revision: 6190
 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=6190&view=rev
Author: vargenau
Date: 2008年08月22日 14:14:37 +0000 (2008年8月22日)
Log Message:
-----------
CreateToc takes into account Wikicreole headers
Modified Paths:
--------------
 trunk/lib/plugin/CreateToc.php
Modified: trunk/lib/plugin/CreateToc.php
===================================================================
--- trunk/lib/plugin/CreateToc.php	2008年08月22日 13:18:48 UTC (rev 6189)
+++ trunk/lib/plugin/CreateToc.php	2008年08月22日 14:14:37 UTC (rev 6190)
@@ -25,8 +25,7 @@
 * CreateToc: Create a Table of Contents and automatically link to headers
 *
 * Usage: 
- * <?plugin CreateToc headers=!!!,!! with_toclink||=1 
- * jshide||=1 ?>
+ * <?plugin CreateToc arguments ?>
 * @author: Reini Urban, Marc-Etienne Vargenau
 *
 * Known problems: 
@@ -58,8 +57,8 @@
 
 function getDefaultArguments() {
 return array( 'pagename' => '[pagename]', // TOC of another page here?
- // or headers=1,2,3 is also possible.
- 'headers' => "!!!,!!,!", // "!!!"=>h1, "!!"=>h2, "!"=>h3
+ 'headers' => "1,2,3,4,5", // "!!!"=>h2, "!!"=>h3, "!"=>h4
+ // "1"=>h2, "2"=>h3, "3"=>h4, "4"=>h5, "5"=>h6
 'noheader' => 0, // omit "Table of Contents" header
 'notoc' => 0, // do not display TOC, only number headers
 'position' => 'right', // or left
@@ -74,15 +73,14 @@
 }
 // Initialisation of toc counter
 function _initTocCounter() {
- $counter = array(1=>0, 2=>0, 3=>0);
+ $counter = array(1=>0, 2=>0, 3=>0, 4=>0, 5=>0);
 return $counter;
 }
 
 // Update toc counter with a new title
 function _tocCounter(&$counter, $level) {
 $counter[$level]++;
- $level--;
- for($i = $level; $i > 0; $i--) {
+ for($i = $level+1; $i <= 5; $i++) {
 $counter[$i] = 0;
 }
 }
@@ -114,13 +112,13 @@
 // Get string corresponding to the current title
 function _getCounter(&$counter, $level, $firstlevelstyle) {
 if ($firstlevelstyle == 'roman') {
- $str= $this->_roman_counter($counter[3]);
+ $str= $this->_roman_counter($counter[1]);
 } else if ($firstlevelstyle == 'letter') {
- $str= $this->_letter_counter($counter[3]);
+ $str= $this->_letter_counter($counter[1]);
 } else {
- $str=$counter[3];
+ $str=$counter[1];
 }
- for($i = 2; $i > 0; $i--) {
+ for($i = 2; $i <= 5; $i++) {
 if($counter[$i] != 0)
 $str .= '.'.$counter[$i];
 }
@@ -132,15 +130,24 @@
 		 array('\/','\.','\?','\*'), $heading);
 }
 
- // Get HTML header corresponding to current level (level is set of !)
+ // Get HTML header corresponding to current level (level is set of ! or =)
 function _getHeader($level) {
- 	$count = substr_count($level,'!');
- 	switch ($count) {
- 	 case 1: $h = "h4"; break;
- 	 case 2: $h = "h3"; break;
- 	 case 3: $h = "h2"; break;
- 	}
- return $h;
+
+ $count = substr_count($level,'!');
+ switch ($count) {
+ case 3: return "h2";
+ case 2: return "h3";
+ case 1: return "h4";
+ }
+ $count = substr_count($level,'=');
+ switch ($count) {
+ case 2: return "h2";
+ case 3: return "h3";
+ case 4: return "h4";
+ case 5: return "h5";
+ case 6: return "h6";
+ }
+ return "";
 }
 
 function _quote($heading) {
@@ -242,9 +249,12 @@
 $j = 0;
 for ($i=0; $i<count($content); $i++) {
 foreach ($levels as $level) {
- if ($level < 1 or $level > 3) continue;
- if (preg_match('/^\s*(!{'.$level.','.$level.'})([^!].*)$/',
- $content[$i], $match)) 
+ if ($level < 1 or $level > 5) continue;
+ $phpwikiclassiclevel = 4 -$level;
+ $wikicreolelevel = $level + 1;
+ if ($phpwikiclassiclevel < 1 or $phpwikiclassiclevel > 3) continue;
+ if ((preg_match('/^\s*(!{'.$phpwikiclassiclevel.','.$phpwikiclassiclevel.'})([^!].*)$/', $content[$i], $match))
+ or (preg_match('/^\s*(={'.$wikicreolelevel.','.$wikicreolelevel.'})([^=].*)$/', $content[$i], $match)) )
 {
 $this->_tocCounter($tocCounter, $level); 	
 if (!strstr($content[$i],'#[')) {
@@ -378,7 +388,7 @@
 $level = min(max(1, $hcount),3);
 $levels[] = $level;
 } else {
- $level = min(max(1, (int) $h), 3);
+ $level = min(max(1, (int) $h), 5);
 $levels[] = $level;
 }
 }
@@ -391,7 +401,7 @@
 foreach ($headers as $h) {
 // proper heading indent
 $level = $h['level'];
- $indent = 3 - $level;
+ $indent = $level - 1;
 $link = new WikiPageName($pagename,$page,$h['anchor']);
 $li = WikiLink($link,'known',$h['text']);
 if ($liststyle == 'dl')
@@ -454,135 +464,6 @@
 }
 };
 
-// $Log: not supported by cvs2svn $
-// Revision 1.43 2008年08月19日 18:29:12 vargenau
-// Correct TOC numbering
-//
-// Revision 1.42 2008年08月19日 18:27:06 vargenau
-// Implement "noheader" parameter
-//
-// Revision 1.41 2008年08月19日 18:25:18 vargenau
-// Use p with id=toctitle instead of h4 for TOC (easier to style)
-//
-// Revision 1.40 2008年08月19日 18:21:35 vargenau
-// Do not force height and width of image
-//
-// Revision 1.39 2008年08月19日 18:19:01 vargenau
-// Implement "firstlevelstyle" parameter
-//
-// Revision 1.38 2008年08月19日 18:15:28 vargenau
-// Implement "notoc" parameter
-//
-// Revision 1.37 2008年05月04日 08:37:42 vargenau
-// Add alt attribute
-//
-// Revision 1.36 2007年07月19日 12:41:25 labbenes
-// Correct TOC numbering. It should start from '1' not from '1.1'.
-//
-// Revision 1.35 2007年02月17日 14:17:48 rurban
-// declare vars for IE6
-//
-// Revision 1.34 2007年01月28日 22:47:06 rurban
-// fix # back link
-//
-// Revision 1.33 2007年01月28日 22:37:04 rurban
-// beautify +/- collapse icon
-//
-// Revision 1.32 2007年01月20日 11:25:30 rurban
-// remove align
-//
-// Revision 1.31 2007年01月09日 12:35:05 rurban
-// Change align to position. Add extracollapse. js now always active, jshide just denotes the initial state.
-//
-// Revision 1.30 2006年12月22日 17:49:38 rurban
-// fix quoting
-//
-// Revision 1.29 2006年04月15日 12:26:54 rurban
-// need basepage for subpages like /Remove (within CreateTOC)
-//
-// Revision 1.28 2005年10月12日 06:15:25 rurban
-// just aesthetics
-//
-// Revision 1.27 2005年10月10日 19:50:45 rurban
-// fix the missing formatting problems, add with_counter arg by ?? (20050106), Thanks to ManuelVacelet for the testcase
-//
-// Revision 1.26 2004年09月20日 14:07:16 rurban
-// fix Constant toc_full_syntax already defined warning
-//
-// Revision 1.25 2004年07月08日 20:30:07 rurban
-// plugin->run consistency: request as reference, added basepage.
-// encountered strange bug in AllPages (and the test) which destroys ->_dbi
-//
-// Revision 1.24 2004年06月28日 13:27:03 rurban
-// CreateToc disabled for old markup and Apache2 only
-//
-// Revision 1.23 2004年06月28日 13:13:58 rurban
-// CreateToc disabled for old markup
-//
-// Revision 1.22 2004年06月15日 14:56:37 rurban
-// more allow_call_time_pass_reference false fixes
-//
-// Revision 1.21 2004年06月13日 09:45:23 rurban
-// display bug workaround for MacIE browsers, jshide: 0
-//
-// Revision 1.20 2004年05月11日 13:57:46 rurban
-// enable TOC_FULL_SYNTAX per default
-// don't <a name>$header</a> to disable css formatting for such anchors
-// => <a name></a>$header
-//
-// Revision 1.19 2004年05月08日 16:59:27 rurban
-// requires optional TOC_FULL_SYNTAX constnat to enable full link and
-// wikiword syntax in headers.
-//
-// Revision 1.18 2004年04月29日 21:55:15 rurban
-// fixed TOC backlinks with USE_PATH_INFO false
-// with_toclink=1, sf.net bug #940682
-//
-// Revision 1.17 2004年04月26日 19:43:03 rurban
-// support most cases of header markup. fixed duplicate MangleXmlIdentifier name
-//
-// Revision 1.16 2004年04月26日 14:46:14 rurban
-// better comments
-//
-// Revision 1.14 2004年04月21日 04:29:50 rurban
-// write WikiURL consistently (not WikiUrl)
-//
-// Revision 1.12 2004年03月22日 14:13:53 rurban
-// fixed links to equal named headers
-//
-// Revision 1.11 2004年03月15日 09:52:59 rurban
-// jshide button: dynamic titles
-//
-// Revision 1.10 2004年03月14日 20:30:21 rurban
-// jshide button
-//
-// Revision 1.9 2004年03月09日 19:24:20 rurban
-// custom indentstr
-// h2 toc header
-//
-// Revision 1.8 2004年03月09日 19:05:12 rurban
-// new liststyle arg. default: dl (no bullets)
-//
-// Revision 1.7 2004年03月09日 11:51:54 rurban
-// support jshide=1: DHTML button hide/unhide TOC
-//
-// Revision 1.6 2004年03月09日 10:25:37 rurban
-// slightly better formatted TOC indentation
-//
-// Revision 1.5 2004年03月09日 08:57:10 rurban
-// convert space to "_" instead of "x20." in anchors
-// proper heading indent
-// handle duplicate headers
-// allow multiple headers like "!!!,!!" or "1,2"
-//
-// Revision 1.4 2004年03月02日 18:21:29 rurban
-// typo: ref=>href
-//
-// Revision 1.1 2004年03月01日 18:10:28 rurban
-// first version, without links, anchors and jscript folding
-//
-//
-
 // For emacs users
 // Local Variables:
 // mode: php
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <var...@us...> - 2008年08月28日 18:18:40
Revision: 6219
 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=6219&view=rev
Author: vargenau
Date: 2008年08月28日 18:18:50 +0000 (2008年8月28日)
Log Message:
-----------
getDefaultArguments: same order as in documentation
Modified Paths:
--------------
 trunk/lib/plugin/CreateToc.php
Modified: trunk/lib/plugin/CreateToc.php
===================================================================
--- trunk/lib/plugin/CreateToc.php	2008年08月28日 18:16:28 UTC (rev 6218)
+++ trunk/lib/plugin/CreateToc.php	2008年08月28日 18:18:50 UTC (rev 6219)
@@ -56,20 +56,20 @@
 }
 
 function getDefaultArguments() {
- return array( 'pagename' => '[pagename]', // TOC of another page here?
- 'headers' => "1,2,3,4,5", // "!!!"=>h2, "!!"=>h3, "!"=>h4
- // "1"=>h2, "2"=>h3, "3"=>h4, "4"=>h5, "5"=>h6
- 'noheader' => 0, // omit "Table of Contents" header
- 'notoc' => 0, // do not display TOC, only number headers
- 'position' => 'right', // or left
- 'with_toclink' => 0, // link back to TOC
- 'jshide' => 0, // collapsed TOC as DHTML button
-		 'extracollapse' => 1, // provide an entry +/- link to collapse
- 'liststyle' => 'dl', // 'dl' or 'ul' or 'ol'
- 'indentstr' => '&nbsp;&nbsp;',
-		 'with_counter' => 0,
- 'firstlevelstyle' => 'number' // 'number', 'letter' or 'roman'
- );
+ return array('extracollapse' => 1, // provide an entry +/- link to collapse
+ 'firstlevelstyle' => 'number', // 'number', 'letter' or 'roman'
+ 'headers' => "1,2,3,4,5", // "!!!"=>h2, "!!"=>h3, "!"=>h4
+ // "1"=>h2, "2"=>h3, "3"=>h4, "4"=>h5, "5"=>h6
+ 'indentstr' => '&nbsp;&nbsp;',
+ 'jshide' => 0, // collapsed TOC as DHTML button
+ 'liststyle' => 'dl', // 'dl' or 'ul' or 'ol'
+ 'noheader' => 0, // omit "Table of Contents" header
+ 'notoc' => 0, // do not display TOC, only number headers
+ 'pagename' => '[pagename]', // TOC of another page here?
+ 'position' => 'full', // full, right or left
+ 'with_counter' => 0,
+ 'with_toclink' => 0, // link back to TOC
+ );
 }
 // Initialisation of toc counter
 function _initTocCounter() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <var...@us...> - 2008年08月29日 15:16:11
Revision: 6223
 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=6223&view=rev
Author: vargenau
Date: 2008年08月29日 15:16:20 +0000 (2008年8月29日)
Log Message:
-----------
Allow Wikicreole syntax with '='s at the end
Modified Paths:
--------------
 trunk/lib/plugin/CreateToc.php
Modified: trunk/lib/plugin/CreateToc.php
===================================================================
--- trunk/lib/plugin/CreateToc.php	2008年08月29日 13:52:09 UTC (rev 6222)
+++ trunk/lib/plugin/CreateToc.php	2008年08月29日 15:16:20 UTC (rev 6223)
@@ -259,6 +259,11 @@
 $this->_tocCounter($tocCounter, $level); 	
 if (!strstr($content[$i],'#[')) {
 $s = trim($match[2]);
+ // If it is Wikicreole syntax, remove '='s at the end
+ if (string_starts_with($match[1], "=")) {
+ $s = trim($s, "=");
+ $s = trim($s);
+ }
 $anchor = $this->_nextAnchor($s);
 $manchor = MangleXmlIdentifier($anchor);
 $texts = $s;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <var...@us...> - 2008年08月29日 15:19:01
Revision: 6224
 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=6224&view=rev
Author: vargenau
Date: 2008年08月29日 15:19:11 +0000 (2008年8月29日)
Log Message:
-----------
Implement 'position' and 'width' arguments
Modified Paths:
--------------
 trunk/lib/plugin/CreateToc.php
Modified: trunk/lib/plugin/CreateToc.php
===================================================================
--- trunk/lib/plugin/CreateToc.php	2008年08月29日 15:16:20 UTC (rev 6223)
+++ trunk/lib/plugin/CreateToc.php	2008年08月29日 15:19:11 UTC (rev 6224)
@@ -374,6 +374,9 @@
 if ($notoc) {
 $html->setAttr('style','display:none;');
 }
+ if (($position == "left") or ($position == "right")) {
+ $html->setAttr('style','float:'.$position.'; width:'.$width.';');
+ }
 if ($liststyle == 'dl')
 $list = HTML::dl(array('id'=>'toclist','class' => 'toc'));
 elseif ($liststyle == 'ul')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <var...@us...> - 2008年08月29日 15:22:22
Revision: 6225
 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=6225&view=rev
Author: vargenau
Date: 2008年08月29日 15:22:32 +0000 (2008年8月29日)
Log Message:
-----------
Use paragraphs instead of lists
Modified Paths:
--------------
 trunk/lib/plugin/CreateToc.php
Modified: trunk/lib/plugin/CreateToc.php
===================================================================
--- trunk/lib/plugin/CreateToc.php	2008年08月29日 15:19:11 UTC (rev 6224)
+++ trunk/lib/plugin/CreateToc.php	2008年08月29日 15:22:32 UTC (rev 6225)
@@ -377,12 +377,7 @@
 if (($position == "left") or ($position == "right")) {
 $html->setAttr('style','float:'.$position.'; width:'.$width.';');
 }
- if ($liststyle == 'dl')
- $list = HTML::dl(array('id'=>'toclist','class' => 'toc'));
- elseif ($liststyle == 'ul')
- $list = HTML::ul(array('id'=>'toclist','class' => 'toc'));
- elseif ($liststyle == 'ol')
- $list = HTML::ol(array('id'=>'toclist','class' => 'toc'));
+ $list = HTML::div(array('id'=>'toclist'));
 if (!strstr($headers,",")) {
 $headers = array($headers);	
 } else {
@@ -412,12 +407,8 @@
 $indent = $level - 1;
 $link = new WikiPageName($pagename,$page,$h['anchor']);
 $li = WikiLink($link,'known',$h['text']);
- if ($liststyle == 'dl')
- $list->pushContent(HTML::dt(HTML::raw
- (str_repeat($indentstr,$indent)),$li));
- else
- $list->pushContent(HTML::li(HTML::raw
- (str_repeat($indentstr,$indent)),$li));
+ $list->pushContent(HTML::p(HTML::raw
+ (str_repeat($indentstr,$indent)),$li));
 }
 }
 	$list->setAttr('style','display:'.($jshide?'none;':'block;'));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <var...@us...> - 2008年09月04日 16:01:25
Revision: 6230
 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=6230&view=rev
Author: vargenau
Date: 2008年09月04日 16:01:29 +0000 (2008年9月04日)
Log Message:
-----------
width was missing in getDefaultArguments
Modified Paths:
--------------
 trunk/lib/plugin/CreateToc.php
Modified: trunk/lib/plugin/CreateToc.php
===================================================================
--- trunk/lib/plugin/CreateToc.php	2008年09月02日 15:21:42 UTC (rev 6229)
+++ trunk/lib/plugin/CreateToc.php	2008年09月04日 16:01:29 UTC (rev 6230)
@@ -67,6 +67,7 @@
 'notoc' => 0, // do not display TOC, only number headers
 'pagename' => '[pagename]', // TOC of another page here?
 'position' => 'full', // full, right or left
+ 'width' => '200px',
 'with_counter' => 0,
 'with_toclink' => 0, // link back to TOC
 );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <var...@us...> - 2009年02月26日 16:34:23
Revision: 6586
 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=6586&view=rev
Author: vargenau
Date: 2009年02月26日 16:34:14 +0000 (2009年2月26日)
Log Message:
-----------
Missing quotes
Modified Paths:
--------------
 trunk/lib/plugin/CreateToc.php
Modified: trunk/lib/plugin/CreateToc.php
===================================================================
--- trunk/lib/plugin/CreateToc.php	2009年02月26日 16:31:19 UTC (rev 6585)
+++ trunk/lib/plugin/CreateToc.php	2009年02月26日 16:34:14 UTC (rev 6586)
@@ -379,7 +379,7 @@
 $html->setAttr('style','float:'.$position.'; width:'.$width.';');
 }
 $toclistid = GenerateId("toclist");
- $list = HTML::div(array('id'=>$toclistid, 'class'=>toclist));
+ $list = HTML::div(array('id'=>$toclistid, 'class'=>'toclist'));
 if (!strstr($headers,",")) {
 $headers = array($headers);	
 } else {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <var...@us...> - 2009年10月28日 17:14:29
Revision: 7240
 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=7240&view=rev
Author: vargenau
Date: 2009年10月28日 17:14:18 +0000 (2009年10月28日)
Log Message:
-----------
Fix problem between MediawikiTable and CreateToc plugins
Modified Paths:
--------------
 trunk/lib/plugin/CreateToc.php
Modified: trunk/lib/plugin/CreateToc.php
===================================================================
--- trunk/lib/plugin/CreateToc.php	2009年10月28日 17:08:09 UTC (rev 7239)
+++ trunk/lib/plugin/CreateToc.php	2009年10月28日 17:14:18 UTC (rev 7240)
@@ -2,7 +2,7 @@
 rcs_id('$Id$');
 /*
 Copyright 2004,2005 $ThePhpWikiProgrammingTeam
- Copyright 2008 Marc-Etienne Vargenau, Alcatel-Lucent
+ Copyright 2008-2009 Marc-Etienne Vargenau, Alcatel-Lucent
 
 This file is part of PhpWiki.
 
@@ -24,16 +24,18 @@
 /**
 * CreateToc: Create a Table of Contents and automatically link to headers
 *
- * Usage: 
- * <?plugin CreateToc arguments ?>
+ * Usage:
+ * <<CreateToc arguments>>
 * @author: Reini Urban, Marc-Etienne Vargenau
 *
- * Known problems: 
+ * Known problems:
 * - MacIE will not work with jshide.
 * - it will crash with old markup and Apache2 (?)
- * - Certain corner-edges will not work with TOC_FULL_SYNTAX. 
+ * - Certain corner-edges will not work with TOC_FULL_SYNTAX.
 * I believe I fixed all of them now, but who knows?
 * - bug #969495 "existing labels not honored" seems to be fixed.
+ * - some constructs might incorrectly be recognized as a header
+ * (e.g. lines starting with "!!!" or "==" inside <verbatim>)
 */
 
 if (!defined('TOC_FULL_SYNTAX'))
@@ -130,7 +132,7 @@
 return str_replace(array("/",".","?","*"),
 		 array('\/','\.','\?','\*'), $heading);
 }
- 
+
 // Get HTML header corresponding to current level (level is set of ! or =)
 function _getHeader($level) {
 
@@ -156,18 +158,18 @@
 $theading = TransformInline($heading);
 if ($theading)
 return preg_quote($theading->asXML(), "/");
- else 
+ else
 return XmlContent::_quote(preg_quote($heading, "/"));
 } else {
 return XmlContent::_quote(preg_quote($heading, "/"));
 }
 }
- 
+
 /*
 * @param $hstart id (in $content) of heading start
 * @param $hend id (in $content) of heading end
 */
- function searchHeader ($content, $start_index, $heading, 
+ function searchHeader ($content, $start_index, $heading,
 $level, &$hstart, &$hend, $basepage=false) {
 $hstart = 0;
 $hend = 0;
@@ -175,7 +177,7 @@
 $qheading = $this->_quote($heading);
 	for ($j=$start_index; $j < count($content); $j++) {
 if (is_string($content[$j])) {
- 		if (preg_match("/<$h>$qheading<\/$h>/", 
+ 		if (preg_match("/<$h>$qheading<\/$h>/",
 		 $content[$j]))
 		 return $j;
 }
@@ -188,19 +190,19 @@
 		 $content[$j] = $content[$j]->asString();
 		// shortcut for single wikiword or link headers
 		if ($content[$j] == $heading
-		 and substr($content[$j-1],-4,4) == "<$h>" 
-		 and substr($content[$j+1],0,5) == "</$h>") 
+		 and substr($content[$j-1],-4,4) == "<$h>"
+		 and substr($content[$j+1],0,5) == "</$h>")
 		{
 		 $hstart = $j-1;
 		 $hend = $j+1;
 		 return $j; // single wikiword
-		} 
+		}
 		elseif (TOC_FULL_SYNTAX) {
 		 //DONE: To allow "!! WikiWord link" or !! http://anylink/
 		 // Check against joined content (after cached_plugininvocation).
 		 // The first link is the anchor then.
 		 if (preg_match("/<$h>(?!.*<\/$h>)/", $content[$j-1])) {
-			$hstart = $j-1; 	 	 
+			$hstart = $j-1;
 			$joined = '';
 			for ($k=max($j-1,$start_index);$k<count($content);$k++) {
 			 if (is_string($content[$k]))
@@ -237,18 +239,38 @@
 $anchors[$anchor] = $i;
 return $anchor;
 }
- 
+
+ // We have to find headers in both:
+ // - classic Phpwiki syntax (lines starting with "!", "!!" or "!!!")
+ // - Wikicreole syntax (lines starting with "==", "===", etc.)
+ // We must omit lines starting with "!" if inside a Mediawiki table
+ // (they represent a table header)
+ // Some constructs might incorrectly be recognized as a header
+ // (e.g. lines starting with "!!!" or "==" inside <verbatim>)
 // Feature request: proper nesting; multiple levels (e.g. 1,3)
- function extractHeaders (&$content, &$markup, $backlink=0, 
+ function extractHeaders (&$content, &$markup, $backlink=0,
 $counter=0, $levels=false, $firstlevelstyle='number', $basepage='')
 {
+
 if (!$levels) $levels = array(1,2);
- $tocCounter = $this->_initTocCounter(); 
+ $tocCounter = $this->_initTocCounter();
 reset($levels);
 sort($levels);
 $headers = array();
 $j = 0;
+ $insidetable = false;
 for ($i=0; $i<count($content); $i++) {
+ if (preg_match('/^\s*{\|/', $content[$i])) {
+ $insidetable = true;
+ continue;
+ }
+ if (preg_match('/^\s*\|}/', $content[$i])) {
+ $insidetable = false;
+ continue;
+ }
+ if ($insidetable) {
+ continue;
+ }
 foreach ($levels as $level) {
 if ($level < 1 or $level > 5) continue;
 $phpwikiclassiclevel = 4 -$level;
@@ -257,7 +279,7 @@
 if ((preg_match('/^\s*(!{'.$phpwikiclassiclevel.','.$phpwikiclassiclevel.'})([^!].*)$/', $content[$i], $match))
 or (preg_match('/^\s*(={'.$wikicreolelevel.','.$wikicreolelevel.'})([^=].*)$/', $content[$i], $match)) )
 {
- $this->_tocCounter($tocCounter, $level); 	
+ $this->_tocCounter($tocCounter, $level);
 if (!strstr($content[$i],'#[')) {
 $s = trim($match[2]);
 // If it is Wikicreole syntax, remove '='s at the end
@@ -271,8 +293,8 @@
 if($counter) {
 $texts = $this->_getCounter($tocCounter, $level, $firstlevelstyle).' '.$s;
 }
- $headers[] = array('text' => $texts, 
- 'anchor' => $anchor, 
+ $headers[] = array('text' => $texts,
+ 'anchor' => $anchor,
 'level' => $level);
 // Change original wikitext, but that is useless art...
 $content[$i] = $match[1]." #[|$manchor][$s|#TOC]";
@@ -280,8 +302,9 @@
 // Search <hn>$s</hn> line in markup
 /* Url for backlink */
 $url = WikiURL(new WikiPageName($basepage,false,"TOC"));
- $j = $this->searchHeader($markup->_content, $j, $s, 
- $match[1], $hstart, $hend, 
+
+ $j = $this->searchHeader($markup->_content, $j, $s,
+ $match[1], $hstart, $hend,
 $markup->_basepage);
 if ($j and isset($markup->_content[$j])) {
 $x = $markup->_content[$j];
@@ -313,9 +336,9 @@
 $h = $this->_getHeader($match[1]);
 
 if ($backlink) {
- if ($counter)
+ if ($counter) {
 $anchorString = "\1ドル<a href=\"$url\" name=\"$manchor\">$counterString</a> - ";
- else {
+ } else {
 /* Not possible to make a backlink on a
 * title with a WikiWord */
 $anchorString = "\1ドル<a name=\"$manchor\"></a>";
@@ -326,10 +349,10 @@
 if ($counter)
 $anchorString .= "$counterString - ";
 }
- $x = preg_replace("/(<$h>)(?!.*<\/$h>)/", 
+ $x = preg_replace("/(<$h>)(?!.*<\/$h>)/",
 $anchorString, $x, 1);
 if ($backlink) {
- $x = preg_replace("/(<$h>)(?!.*<\/$h>)/", 
+ $x = preg_replace("/(<$h>)(?!.*<\/$h>)/",
 $anchorString,
 $markup->_content[$hstart],1);
 }
@@ -342,7 +365,7 @@
 }
 return $headers;
 }
- 
+
 function run($dbi, $argstr, &$request, $basepage) {
 global $WikiTheme;
 extract($this->getArgs($argstr, $request));
@@ -388,7 +411,7 @@
 $toclistid = GenerateId("toclist");
 $list = HTML::div(array('id'=>$toclistid, 'class'=>'toclist'));
 if (!strstr($headers,",")) {
- $headers = array($headers);	
+ $headers = array($headers);
 } else {
 $headers = explode(",",$headers);
 }
@@ -406,8 +429,8 @@
 }
 if (TOC_FULL_SYNTAX)
 require_once("lib/InlineParser.php");
- if ($headers = $this->extractHeaders($content, $dbi->_markup, 
- $with_toclink, $with_counter, 
+ if ($headers = $this->extractHeaders($content, $dbi->_markup,
+ $with_toclink, $with_counter,
 $levels, $firstlevelstyle, $basepage))
 {
 foreach ($headers as $h) {
@@ -416,6 +439,8 @@
 $indent = $level - 1;
 $link = new WikiPageName($pagename,$page,$h['anchor']);
 $li = WikiLink($link,'known',$h['text']);
+ // Hack to suppress pagename before #
+ // $li->_attr["href"] = strstr($li->_attr["href"], '#');
 $list->pushContent(HTML::p(HTML::raw
 (str_repeat($indentstr,$indent)),$li));
 }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <var...@us...> - 2010年03月31日 09:00:33
Revision: 7310
 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=7310&view=rev
Author: vargenau
Date: 2010年03月31日 09:00:27 +0000 (2010年3月31日)
Log Message:
-----------
Make all 5 levels work
Modified Paths:
--------------
 trunk/lib/plugin/CreateToc.php
Modified: trunk/lib/plugin/CreateToc.php
===================================================================
--- trunk/lib/plugin/CreateToc.php	2010年03月30日 11:38:23 UTC (rev 7309)
+++ trunk/lib/plugin/CreateToc.php	2010年03月31日 09:00:27 UTC (rev 7310)
@@ -2,7 +2,7 @@
 rcs_id('$Id$');
 /*
 * Copyright 2004,2005 $ThePhpWikiProgrammingTeam
- * Copyright 2008-2009 Marc-Etienne Vargenau, Alcatel-Lucent
+ * Copyright 2008-2010 Marc-Etienne Vargenau, Alcatel-Lucent
 *
 * This file is part of PhpWiki.
 *
@@ -275,10 +275,12 @@
 if ($level < 1 or $level > 5) continue;
 $phpwikiclassiclevel = 4 -$level;
 $wikicreolelevel = $level + 1;
- if ($phpwikiclassiclevel < 1 or $phpwikiclassiclevel > 3) continue;
- if ((preg_match('/^\s*(!{'.$phpwikiclassiclevel.','.$phpwikiclassiclevel.'})([^!].*)$/', $content[$i], $match))
- or (preg_match('/^\s*(={'.$wikicreolelevel.','.$wikicreolelevel.'})([^=].*)$/', $content[$i], $match)) )
- {
+ $trim = trim($content[$i]);
+
+ if ((((strpos($trim, '=') === 0))
+ && (preg_match('/^\s*(={'.$wikicreolelevel.','.$wikicreolelevel.'})([^=].*)$/', $content[$i], $match)))
+ or (((strpos($trim, '!') === 0))
+ && ((preg_match('/^\s*(!{'.$phpwikiclassiclevel.','.$phpwikiclassiclevel.'})([^!].*)$/', $content[$i], $match))))) {
 $this->_tocCounter($tocCounter, $level);
 if (!strstr($content[$i],'#[')) {
 $s = trim($match[2]);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <var...@us...> - 2010年06月25日 11:53:02
Revision: 7572
 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=7572&view=rev
Author: vargenau
Date: 2010年06月25日 11:52:55 +0000 (2010年6月25日)
Log Message:
-----------
Use "id" instead of "name" for <a>
Modified Paths:
--------------
 trunk/lib/plugin/CreateToc.php
Modified: trunk/lib/plugin/CreateToc.php
===================================================================
--- trunk/lib/plugin/CreateToc.php	2010年06月24日 16:31:07 UTC (rev 7571)
+++ trunk/lib/plugin/CreateToc.php	2010年06月25日 11:52:55 UTC (rev 7572)
@@ -311,9 +311,9 @@
 if (($hstart === 0) && is_string($markup->_content[$j])) {
 if ($backlink) {
 if ($counter)
- $anchorString = "<a href=\"$url\" name=\"$manchor\">$counterString</a> - \2ドル";
+ $anchorString = "<a href=\"$url\" id=\"$manchor\">$counterString</a> - \2ドル";
 else
- $anchorString = "<a href=\"$url\" name=\"$manchor\">\2ドル</a>";
+ $anchorString = "<a href=\"$url\" id=\"$manchor\">\2ドル</a>";
 } else {
 $anchorString = "<a id=\"$manchor\"></a>";
 if ($counter)
@@ -334,7 +334,7 @@
 
 if ($backlink) {
 if ($counter) {
- $anchorString = "\1ドル<a href=\"$url\" name=\"$manchor\">$counterString</a> - ";
+ $anchorString = "\1ドル<a href=\"$url\" id=\"$manchor\">$counterString</a> - ";
 } else {
 /* Not possible to make a backlink on a
 * title with a WikiWord */
@@ -457,11 +457,10 @@
 'class'=>'wikiaction',
 'title'=>_("Click to display to TOC"),
 'onclick'=>"toggletoc(this, '".$open."', '".$close."', '".$toclistid."')",
- 'border' => 0,
 'alt' => 'toctoggle',
 'src' => $jshide ? $close : $open )));
 else
- $toclink = HTML::a(array('name'=>'TOC',
+ $toclink = HTML::a(array('id'=>'TOC',
 'class'=>'wikiaction',
 'title'=>_("Click to display"),
 'onclick'=>"toggletoc(this, '".$open."', '".$close."', '".$toclistid."')"),
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <var...@us...> - 2010年06月25日 11:56:11
Revision: 7573
 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=7573&view=rev
Author: vargenau
Date: 2010年06月25日 11:56:05 +0000 (2010年6月25日)
Log Message:
-----------
Use "id" instead of "name" for <a>
Modified Paths:
--------------
 trunk/lib/plugin/CreateToc.php
Modified: trunk/lib/plugin/CreateToc.php
===================================================================
--- trunk/lib/plugin/CreateToc.php	2010年06月25日 11:52:55 UTC (rev 7572)
+++ trunk/lib/plugin/CreateToc.php	2010年06月25日 11:56:05 UTC (rev 7573)
@@ -451,7 +451,7 @@
 if ($extracollapse)
 $toclink = HTML(_("Table of Contents"),
 " ",
- HTML::a(array('name'=>'TOC')),
+ HTML::a(array('id'=>'TOC')),
 HTML::img(array(
 'id'=>$toctoggleid,
 'class'=>'wikiaction',
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <var...@us...> - 2010年09月17日 08:41:16
Revision: 7689
 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=7689&view=rev
Author: vargenau
Date: 2010年09月17日 08:41:10 +0000 (2010年9月17日)
Log Message:
-----------
Whitespace only
Modified Paths:
--------------
 trunk/lib/plugin/CreateToc.php
Modified: trunk/lib/plugin/CreateToc.php
===================================================================
--- trunk/lib/plugin/CreateToc.php	2010年09月13日 15:05:24 UTC (rev 7688)
+++ trunk/lib/plugin/CreateToc.php	2010年09月17日 08:41:10 UTC (rev 7689)
@@ -246,7 +246,6 @@
 function extractHeaders (&$content, &$markup, $backlink=0,
 $counter=0, $levels=false, $firstlevelstyle='number', $basepage='')
 {
-
 if (!$levels) $levels = array(1,2);
 $tocCounter = $this->_initTocCounter();
 reset($levels);
@@ -374,8 +373,7 @@
 if (!$pagename) {
 return $this->error(_("no page specified"));
 }
- if ($jshide and isBrowserIE() and browserDetect("Mac")) {
- //trigger_error(_("jshide set to 0 on Mac IE"), E_USER_NOTICE);
+ if (isBrowserIE() and browserDetect("Mac")) {
 $jshide = 0;
 }
 if (($notoc) or ($liststyle == 'ol')) {
@@ -384,8 +382,8 @@
 
 // Check if user is allowed to get the Page.
 if (!mayAccessPage ('view', $pagename)) {
- return $this->error(sprintf(_("Illegal access to page %s: no read access"),
- $pagename));
+ return $this->error(sprintf(_("Illegal access to page %s: no read access"),
+ $pagename));
 }
 
 $page = $dbi->getPage($pagename);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ru...@us...> - 2010年09月21日 07:09:03
Revision: 7704
 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=7704&view=rev
Author: rurban
Date: 2010年09月21日 07:08:56 +0000 (2010年9月21日)
Log Message:
-----------
revert 7551-7553. we use named anchors to jump to, not internal ids
Modified Paths:
--------------
 trunk/lib/plugin/CreateToc.php
Modified: trunk/lib/plugin/CreateToc.php
===================================================================
--- trunk/lib/plugin/CreateToc.php	2010年09月21日 06:28:07 UTC (rev 7703)
+++ trunk/lib/plugin/CreateToc.php	2010年09月21日 07:08:56 UTC (rev 7704)
@@ -311,11 +311,11 @@
 if (($hstart === 0) && is_string($markup->_content[$j])) {
 if ($backlink) {
 if ($counter)
- $anchorString = "<a href=\"$url\" id=\"$manchor\">$counterString</a> - \2ドル";
+ $anchorString = "<a href=\"$url\" name=\"$manchor\">$counterString</a> - \2ドル";
 else
- $anchorString = "<a href=\"$url\" id=\"$manchor\">\2ドル</a>";
+ $anchorString = "<a href=\"$url\" name=\"$manchor\">\2ドル</a>";
 } else {
- $anchorString = "<a id=\"$manchor\"></a>";
+ $anchorString = "<a name=\"$manchor\"></a>";
 if ($counter)
 $anchorString .= "$counterString - ";
 }
@@ -334,15 +334,15 @@
 
 if ($backlink) {
 if ($counter) {
- $anchorString = "\1ドル<a href=\"$url\" id=\"$manchor\">$counterString</a> - ";
+ $anchorString = "\1ドル<a href=\"$url\" name=\"$manchor\">$counterString</a> - ";
 } else {
 /* Not possible to make a backlink on a
 * title with a WikiWord */
- $anchorString = "\1ドル<a id=\"$manchor\"></a>";
+ $anchorString = "\1ドル<a name=\"$manchor\"></a>";
 }
 }
 else {
- $anchorString = "\1ドル<a id=\"$manchor\"></a>";
+ $anchorString = "\1ドル<a name=\"$manchor\"></a>";
 if ($counter)
 $anchorString .= "$counterString - ";
 }
@@ -404,10 +404,9 @@
 $r = $page->getCurrentRevision();
 }
 
- $current = $page->getCurrentRevision();
 //FIXME: I suspect this only to crash with Apache2
- if (!$current->get('markup') or $current->get('markup') < 2) {
- if (in_array(php_sapi_name(),array('apache2handler','apache2filter'))) {
+ if (!$r->get('markup') or $r->get('markup') < 2) {
+ if (in_array(php_sapi_name(), array('apache2handler','apache2filter'))) {
 return $this->error(_("CreateToc disabled for old markup."));
 }
 }
@@ -467,7 +466,7 @@
 if ($extracollapse)
 $toclink = HTML(_("Table of Contents"),
 " ",
- HTML::a(array('id'=>'TOC')),
+ HTML::a(array('name'=>'TOC')),
 HTML::img(array(
 'id'=>$toctoggleid,
 'class'=>'wikiaction',
@@ -476,7 +475,7 @@
 'alt' => 'toctoggle',
 'src' => $jshide ? $close : $open )));
 else
- $toclink = HTML::a(array('id'=>'TOC',
+ $toclink = HTML::a(array('name'=>'TOC',
 'class'=>'wikiaction',
 'title'=>_("Click to display"),
 'onclick'=>"toggletoc(this, '".$open."', '".$close."', '".$toclistid."')"),
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <var...@us...> - 2010年09月30日 15:49:00
Revision: 7709
 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=7709&view=rev
Author: vargenau
Date: 2010年09月30日 15:48:54 +0000 (2010年9月30日)
Log Message:
-----------
Fixed: Some constructs might incorrectly be recognized as a header (e.g. lines starting with "!!!" or "==" inside <verbatim>)
Modified Paths:
--------------
 trunk/lib/plugin/CreateToc.php
Modified: trunk/lib/plugin/CreateToc.php
===================================================================
--- trunk/lib/plugin/CreateToc.php	2010年09月22日 18:19:06 UTC (rev 7708)
+++ trunk/lib/plugin/CreateToc.php	2010年09月30日 15:48:54 UTC (rev 7709)
@@ -34,8 +34,6 @@
 * - Certain corner-edges will not work with TOC_FULL_SYNTAX.
 * I believe I fixed all of them now, but who knows?
 * - bug #969495 "existing labels not honored" seems to be fixed.
- * - some constructs might incorrectly be recognized as a header
- * (e.g. lines starting with "!!!" or "==" inside <verbatim>)
 */
 
 if (!defined('TOC_FULL_SYNTAX'))
@@ -241,8 +239,6 @@
 // - Wikicreole syntax (lines starting with "==", "===", etc.)
 // We must omit lines starting with "!" if inside a Mediawiki table
 // (they represent a table header)
- // Some constructs might incorrectly be recognized as a header
- // (e.g. lines starting with "!!!" or "==" inside <verbatim>)
 // Feature request: proper nesting; multiple levels (e.g. 1,3)
 function extractHeaders (&$content, &$markup, $backlink=0,
 $counter=0, $levels=false, $firstlevelstyle='number', $basepage='')
@@ -254,16 +250,26 @@
 $headers = array();
 $j = 0;
 $insidetable = false;
+ $insideverbatim = false;
 for ($i=0; $i<count($content); $i++) {
 if (preg_match('/^\s*{\|/', $content[$i])) {
 $insidetable = true;
 continue;
- }
- if (preg_match('/^\s*\|}/', $content[$i])) {
+ } else if (preg_match('/^\s*{{{/', $content[$i]) 
+ || preg_match('/^\s*<pre>/', $content[$i]) 
+ || preg_match('/^\s*<verbatim>/', $content[$i])) {
+ $insideverbatim = true;
+ continue;
+ } else if (preg_match('/^\s*\|}/', $content[$i])) {
 $insidetable = false;
 continue;
+ } else if (preg_match('/^\s*}}}/', $content[$i]) 
+ || preg_match('/^\s*<\/pre>/', $content[$i]) 
+ || preg_match('/^\s*<\/verbatim>/', $content[$i])) {
+ $insideverbatim = false;
+ continue;
 }
- if ($insidetable) {
+ if (($insidetable) || ($insideverbatim)) {
 continue;
 }
 foreach ($levels as $level) {
@@ -311,11 +317,11 @@
 if (($hstart === 0) && is_string($markup->_content[$j])) {
 if ($backlink) {
 if ($counter)
- $anchorString = "<a href=\"$url\" name=\"$manchor\">$counterString</a> - \2ドル";
+ $anchorString = "<a href=\"$url\" id=\"$manchor\">$counterString</a> - \2ドル";
 else
- $anchorString = "<a href=\"$url\" name=\"$manchor\">\2ドル</a>";
+ $anchorString = "<a href=\"$url\" id=\"$manchor\">\2ドル</a>";
 } else {
- $anchorString = "<a name=\"$manchor\"></a>";
+ $anchorString = "<a id=\"$manchor\"></a>";
 if ($counter)
 $anchorString .= "$counterString - ";
 }
@@ -334,15 +340,15 @@
 
 if ($backlink) {
 if ($counter) {
- $anchorString = "\1ドル<a href=\"$url\" name=\"$manchor\">$counterString</a> - ";
+ $anchorString = "\1ドル<a href=\"$url\" id=\"$manchor\">$counterString</a> - ";
 } else {
 /* Not possible to make a backlink on a
 * title with a WikiWord */
- $anchorString = "\1ドル<a name=\"$manchor\"></a>";
+ $anchorString = "\1ドル<a id=\"$manchor\"></a>";
 }
 }
 else {
- $anchorString = "\1ドル<a name=\"$manchor\"></a>";
+ $anchorString = "\1ドル<a id=\"$manchor\"></a>";
 if ($counter)
 $anchorString .= "$counterString - ";
 }
@@ -404,9 +410,10 @@
 $r = $page->getCurrentRevision();
 }
 
+ $current = $page->getCurrentRevision();
 //FIXME: I suspect this only to crash with Apache2
- if (!$r->get('markup') or $r->get('markup') < 2) {
- if (in_array(php_sapi_name(), array('apache2handler','apache2filter'))) {
+ if (!$current->get('markup') or $current->get('markup') < 2) {
+ if (in_array(php_sapi_name(),array('apache2handler','apache2filter'))) {
 return $this->error(_("CreateToc disabled for old markup."));
 }
 }
@@ -466,7 +473,7 @@
 if ($extracollapse)
 $toclink = HTML(_("Table of Contents"),
 " ",
- HTML::a(array('name'=>'TOC')),
+ HTML::a(array('id'=>'TOC')),
 HTML::img(array(
 'id'=>$toctoggleid,
 'class'=>'wikiaction',
@@ -475,7 +482,7 @@
 'alt' => 'toctoggle',
 'src' => $jshide ? $close : $open )));
 else
- $toclink = HTML::a(array('name'=>'TOC',
+ $toclink = HTML::a(array('id'=>'TOC',
 'class'=>'wikiaction',
 'title'=>_("Click to display"),
 'onclick'=>"toggletoc(this, '".$open."', '".$close."', '".$toclistid."')"),
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <var...@us...> - 2010年12月10日 09:58:47
Revision: 7774
 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=7774&view=rev
Author: vargenau
Date: 2010年12月10日 09:58:41 +0000 (2010年12月10日)
Log Message:
-----------
Remove function preg_quote (it is a standard PHP function)
Modified Paths:
--------------
 trunk/lib/plugin/CreateToc.php
Modified: trunk/lib/plugin/CreateToc.php
===================================================================
--- trunk/lib/plugin/CreateToc.php	2010年12月09日 19:41:24 UTC (rev 7773)
+++ trunk/lib/plugin/CreateToc.php	2010年12月10日 09:58:41 UTC (rev 7774)
@@ -122,11 +122,6 @@
 return $str;
 }
 
- function preg_quote ($heading) {
- return str_replace(array("/",".","?","*"),
- array('\/','\.','\?','\*'), $heading);
- }
-
 // Get HTML header corresponding to current level (level is set of ! or =)
 function _getHeader($level) {
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <var...@us...> - 2011年04月11日 13:44:22
Revision: 8036
 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=8036&view=rev
Author: vargenau
Date: 2011年04月11日 13:44:13 +0000 (2011年4月11日)
Log Message:
-----------
Do not trigger error, it happens e.g. for "<<CreateToc pagename=AnotherPage>>"
Modified Paths:
--------------
 trunk/lib/plugin/CreateToc.php
Modified: trunk/lib/plugin/CreateToc.php
===================================================================
--- trunk/lib/plugin/CreateToc.php	2011年04月11日 12:51:58 UTC (rev 8035)
+++ trunk/lib/plugin/CreateToc.php	2011年04月11日 13:44:13 UTC (rev 8036)
@@ -209,7 +209,9 @@
 }
 }
 }
- trigger_error("Heading <$h> $heading </$h> not found\n", E_USER_NOTICE);
+ // Do not trigger error, it happens e.g. for "<<CreateToc pagename=AnotherPage>>"
+ // trigger_error("Heading <$h> $heading </$h> not found\n", E_USER_NOTICE);
+
 return 0;
 }
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <var...@us...> - 2011年05月04日 10:22:09
Revision: 8062
 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=8062&view=rev
Author: vargenau
Date: 2011年05月04日 10:22:03 +0000 (2011年5月04日)
Log Message:
-----------
Check version is a positive integer; check firstlevelstyle is correct
Modified Paths:
--------------
 trunk/lib/plugin/CreateToc.php
Modified: trunk/lib/plugin/CreateToc.php
===================================================================
--- trunk/lib/plugin/CreateToc.php	2011年05月04日 10:20:46 UTC (rev 8061)
+++ trunk/lib/plugin/CreateToc.php	2011年05月04日 10:22:03 UTC (rev 8062)
@@ -383,6 +383,11 @@
 if (($notoc) or ($liststyle == 'ol')) {
 $with_counter = 1;
 }
+ if ($firstlevelstyle and ($firstlevelstyle != 'number') 
+ and ($firstlevelstyle != 'letter')
+ and ($firstlevelstyle != 'roman')) {
+ return $this->error(_("Error: firstlevelstyle must be 'number', 'letter' or 'roman'"));
+ }
 
 // Check if page exists.
 if (!($dbi->isWikiPage($pagename))) {
@@ -398,6 +403,9 @@
 $page = $dbi->getPage($pagename);
 
 if ($version) {
+ if (!is_whole_number($version) or !($version>0)) {
+ return $this->error(_("Error: version must be a positive integer."));
+ }
 $r = $page->getRevision($version);
 if ((!$r) || ($r->hasDefaultContents())) {
 return $this->error(sprintf(_("%s: no such revision %d."),
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <var...@us...> - 2013年04月16日 14:29:40
Revision: 8750
 http://sourceforge.net/p/phpwiki/code/8750
Author: vargenau
Date: 2013年04月16日 14:29:36 +0000 (2013年4月16日)
Log Message:
-----------
Remove underscore for private functions
Modified Paths:
--------------
 trunk/lib/plugin/CreateToc.php
Modified: trunk/lib/plugin/CreateToc.php
===================================================================
--- trunk/lib/plugin/CreateToc.php	2013年04月16日 14:17:35 UTC (rev 8749)
+++ trunk/lib/plugin/CreateToc.php	2013年04月16日 14:29:36 UTC (rev 8750)
@@ -72,14 +72,14 @@
 }
 
 // Initialisation of toc counter
- private function _initTocCounter()
+ private function initTocCounter()
 {
 $counter = array(1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0);
 return $counter;
 }
 
 // Update toc counter with a new title
- private function _tocCounter(&$counter, $level)
+ private function tocCounter(&$counter, $level)
 {
 $counter[$level]++;
 for ($i = $level + 1; $i <= 5; $i++) {
@@ -87,7 +87,7 @@
 }
 }
 
- private function _roman_counter($number)
+ private function roman_counter($number)
 {
 
 $n = intval($number);
@@ -104,7 +104,7 @@
 return $result;
 }
 
- private function _letter_counter($number)
+ private function letter_counter($number)
 {
 if ($number <= 26) {
 return chr(ord("A") + $number - 1);
@@ -114,12 +114,12 @@
 }
 
 // Get string corresponding to the current title
- private function _getCounter(&$counter, $level, $firstlevelstyle)
+ private function getCounter(&$counter, $level, $firstlevelstyle)
 {
 if ($firstlevelstyle == 'roman') {
- $str = $this->_roman_counter($counter[1]);
+ $str = $this->roman_counter($counter[1]);
 } elseif ($firstlevelstyle == 'letter') {
- $str = $this->_letter_counter($counter[1]);
+ $str = $this->letter_counter($counter[1]);
 } else {
 $str = $counter[1];
 }
@@ -131,7 +131,7 @@
 }
 
 // Get HTML header corresponding to current level (level is set of ! or =)
- private function _getHeader($level)
+ private function getHeader($level)
 {
 
 $count = substr_count($level, '!');
@@ -159,7 +159,7 @@
 return "";
 }
 
- private function _quote($heading)
+ private function quote($heading)
 {
 if (TOC_FULL_SYNTAX) {
 $theading = TransformInline($heading);
@@ -181,8 +181,8 @@
 {
 $hstart = 0;
 $hend = 0;
- $h = $this->_getHeader($level);
- $qheading = $this->_quote($heading);
+ $h = $this->getHeader($level);
+ $qheading = $this->quote($heading);
 for ($j = $start_index; $j < count($content); $j++) {
 if (is_string($content[$j])) {
 if (preg_match("/<$h>$qheading<\/$h>/",
@@ -234,7 +234,7 @@
 /** prevent from duplicate anchors,
 * beautify spaces: " " => "_" and not "x20."
 */
- private function _nextAnchor($s)
+ private function nextAnchor($s)
 {
 static $anchors = array();
 
@@ -258,7 +258,7 @@
 $counter = 0, $levels = false, $firstlevelstyle = 'number', $basepage = '')
 {
 if (!$levels) $levels = array(1, 2);
- $tocCounter = $this->_initTocCounter();
+ $tocCounter = $this->initTocCounter();
 reset($levels);
 sort($levels);
 $headers = array();
@@ -299,7 +299,7 @@
 or (((strpos($trim, '!') === 0))
 && ((preg_match('/^\s*(!{' . $phpwikiclassiclevel . ',' . $phpwikiclassiclevel . '})([^!].*)$/', $content[$i], $match))))
 ) {
- $this->_tocCounter($tocCounter, $level);
+ $this->tocCounter($tocCounter, $level);
 if (!strstr($content[$i], '#[')) {
 $s = trim($match[2]);
 // If it is Wikicreole syntax, remove '='s at the end
@@ -307,11 +307,11 @@
 $s = trim($s, "=");
 $s = trim($s);
 }
- $anchor = $this->_nextAnchor($s);
+ $anchor = $this->nextAnchor($s);
 $manchor = MangleXmlIdentifier($anchor);
 $texts = $s;
 if ($counter) {
- $texts = $this->_getCounter($tocCounter, $level, $firstlevelstyle) . ' ' . $s;
+ $texts = $this->getCounter($tocCounter, $level, $firstlevelstyle) . ' ' . $s;
 }
 $headers[] = array('text' => $texts,
 'anchor' => $anchor,
@@ -328,9 +328,9 @@
 $markup->_basepage);
 if ($j and isset($markup->_content[$j])) {
 $x = $markup->_content[$j];
- $qheading = $this->_quote($s);
+ $qheading = $this->quote($s);
 if ($counter)
- $counterString = $this->_getCounter($tocCounter, $level, $firstlevelstyle);
+ $counterString = $this->getCounter($tocCounter, $level, $firstlevelstyle);
 if (($hstart === 0) && is_string($markup->_content[$j])) {
 if ($backlink) {
 if ($counter)
@@ -354,7 +354,7 @@
 }
 } else {
 $x = $markup->_content[$hstart];
- $h = $this->_getHeader($match[1]);
+ $h = $this->getHeader($match[1]);
 
 if ($backlink) {
 if ($counter) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <var...@us...> - 2013年04月16日 14:39:01
Revision: 8751
 http://sourceforge.net/p/phpwiki/code/8751
Author: vargenau
Date: 2013年04月16日 14:38:58 +0000 (2013年4月16日)
Log Message:
-----------
More private functions
Modified Paths:
--------------
 trunk/lib/plugin/CreateToc.php
Modified: trunk/lib/plugin/CreateToc.php
===================================================================
--- trunk/lib/plugin/CreateToc.php	2013年04月16日 14:29:36 UTC (rev 8750)
+++ trunk/lib/plugin/CreateToc.php	2013年04月16日 14:38:58 UTC (rev 8751)
@@ -176,7 +176,7 @@
 * @param $hstart id (in $content) of heading start
 * @param $hend id (in $content) of heading end
 */
- function searchHeader($content, $start_index, $heading,
+ private function searchHeader($content, $start_index, $heading,
 $level, &$hstart, &$hend, $basepage = false)
 {
 $hstart = 0;
@@ -254,7 +254,7 @@
 // We must omit lines starting with "!" if inside a Mediawiki table
 // (they represent a table header)
 // Feature request: proper nesting; multiple levels (e.g. 1,3)
- function extractHeaders(&$content, &$markup, $backlink = 0,
+ private function extractHeaders(&$content, &$markup, $backlink = 0,
 $counter = 0, $levels = false, $firstlevelstyle = 'number', $basepage = '')
 {
 if (!$levels) $levels = array(1, 2);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <var...@us...> - 2013年04月16日 15:53:49
Revision: 8760
 http://sourceforge.net/p/phpwiki/code/8760
Author: vargenau
Date: 2013年04月16日 15:53:47 +0000 (2013年4月16日)
Log Message:
-----------
Remove unused param in getCounter
Modified Paths:
--------------
 trunk/lib/plugin/CreateToc.php
Modified: trunk/lib/plugin/CreateToc.php
===================================================================
--- trunk/lib/plugin/CreateToc.php	2013年04月16日 15:42:21 UTC (rev 8759)
+++ trunk/lib/plugin/CreateToc.php	2013年04月16日 15:53:47 UTC (rev 8760)
@@ -114,7 +114,7 @@
 }
 
 // Get string corresponding to the current title
- private function getCounter(&$counter, $level, $firstlevelstyle)
+ private function getCounter(&$counter, $firstlevelstyle)
 {
 if ($firstlevelstyle == 'roman') {
 $str = $this->roman_counter($counter[1]);
@@ -311,7 +311,7 @@
 $manchor = MangleXmlIdentifier($anchor);
 $texts = $s;
 if ($counter) {
- $texts = $this->getCounter($tocCounter, $level, $firstlevelstyle) . ' ' . $s;
+ $texts = $this->getCounter($tocCounter, $firstlevelstyle) . ' ' . $s;
 }
 $headers[] = array('text' => $texts,
 'anchor' => $anchor,
@@ -330,7 +330,7 @@
 $x = $markup->_content[$j];
 $qheading = $this->quote($s);
 if ($counter)
- $counterString = $this->getCounter($tocCounter, $level, $firstlevelstyle);
+ $counterString = $this->getCounter($tocCounter, $firstlevelstyle);
 if (($hstart === 0) && is_string($markup->_content[$j])) {
 if ($backlink) {
 if ($counter)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <var...@us...> - 2014年08月26日 13:05:20
Revision: 9051
 http://sourceforge.net/p/phpwiki/code/9051
Author: vargenau
Date: 2014年08月26日 13:05:08 +0000 (2014年8月26日)
Log Message:
-----------
Fix warnings
Modified Paths:
--------------
 trunk/lib/plugin/CreateToc.php
Modified: trunk/lib/plugin/CreateToc.php
===================================================================
--- trunk/lib/plugin/CreateToc.php	2014年08月26日 12:10:14 UTC (rev 9050)
+++ trunk/lib/plugin/CreateToc.php	2014年08月26日 13:05:08 UTC (rev 9051)
@@ -160,9 +160,9 @@
 if ($theading)
 return preg_quote($theading->asXML(), "/");
 else
- return XmlContent::_quote(preg_quote($heading, "/"));
+ return htmlspecialchars(preg_quote($heading, "/"), ENT_COMPAT, 'UTF-8');
 } else {
- return XmlContent::_quote(preg_quote($heading, "/"));
+ return htmlspecialchars(preg_quote($heading, "/"), ENT_COMPAT, 'UTF-8');
 }
 }
 
@@ -245,8 +245,8 @@
 // We must omit lines starting with "!" if inside a Mediawiki table
 // (they represent a table header)
 // Feature request: proper nesting; multiple levels (e.g. 1,3)
- private function extractHeaders(&$content, &$markup, $backlink = 0,
- $counter = 0, $levels = false, $firstlevelstyle = 'number', $basepage = '')
+ private function extractHeaders(&$content, &$markup, $backlink,
+ $counter, $levels, $firstlevelstyle, $basepage)
 {
 if (!$levels) $levels = array(1, 2);
 $tocCounter = $this->initTocCounter();
@@ -425,7 +425,6 @@
 $r = $page->getCurrentRevision();
 }
 
- $current = $page->getCurrentRevision();
 $content = $r->getContent();
 
 $html = HTML::div(array('class' => 'toc', 'id' => GenerateId("toc")));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <var...@us...> - 2016年12月12日 13:52:57
Revision: 9993
 http://sourceforge.net/p/phpwiki/code/9993
Author: vargenau
Date: 2016年12月12日 13:52:55 +0000 (2016年12月12日)
Log Message:
-----------
Add braces
Modified Paths:
--------------
 trunk/lib/plugin/CreateToc.php
Modified: trunk/lib/plugin/CreateToc.php
===================================================================
--- trunk/lib/plugin/CreateToc.php	2016年12月12日 13:40:01 UTC (rev 9992)
+++ trunk/lib/plugin/CreateToc.php	2016年12月12日 13:52:55 UTC (rev 9993)
@@ -161,10 +161,11 @@
 {
 if (TOC_FULL_SYNTAX) {
 $theading = TransformInline($heading);
- if ($theading)
+ if ($theading) {
 return preg_quote($theading->asXML(), "/");
- else
+ } else {
 return htmlspecialchars(preg_quote($heading, "/"), ENT_COMPAT, 'UTF-8');
+ }
 } else {
 return htmlspecialchars(preg_quote($heading, "/"), ENT_COMPAT, 'UTF-8');
 }
@@ -191,8 +192,9 @@
 if (method_exists($content[$j], 'asXML')) {
 $content[$j]->_basepage = $basepage;
 $content[$j] = $content[$j]->asXML();
- } else
+ } else {
 $content[$j] = $content[$j]->asString();
+ }
 // shortcut for single wikiword or link headers
 if ($content[$j] == $heading
 and substr($content[$j - 1], -4, 4) == "<$h>"
@@ -209,11 +211,13 @@
 $hstart = $j - 1;
 $joined = '';
 for ($k = max($j - 1, $start_index); $k < count($content); $k++) {
- if (is_string($content[$k]))
+ if (is_string($content[$k])) {
 $joined .= $content[$k];
- elseif (method_exists($content[$k], 'asXML'))
- $joined .= $content[$k]->asXML(); else
+ } elseif (method_exists($content[$k], 'asXML')) {
+ $joined .= $content[$k]->asXML();
+ } else {
 $joined .= $content[$k]->asString();
+ }
 if (preg_match("/<$h>$qheading<\/$h>/", $joined)) {
 $hend = $k;
 return $k;
@@ -328,14 +332,16 @@
 $counterString = $this->getCounter($tocCounter, $firstlevelstyle);
 if (($hstart === 0) && is_string($markup->_content[$j])) {
 if ($backlink) {
- if ($counter)
+ if ($counter) {
 $anchorString = "<a href=\"$url\" id=\"$manchor\">$counterString</a> - \2ドル";
- else
+ } else {
 $anchorString = "<a href=\"$url\" id=\"$manchor\">\2ドル</a>";
+ }
 } else {
 $anchorString = "<a id=\"$manchor\"></a>";
- if ($counter)
+ if ($counter) {
 $anchorString .= "$counterString - ";
+ }
 }
 if ($x = preg_replace('/(<h\d>)(' . $qheading . ')(<\/h\d>)/',
 "\1ドル$anchorString\2ドル\3ドル", $x, 1)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <var...@us...> - 2021年01月09日 11:31:25
Revision: 10235
 http://sourceforge.net/p/phpwiki/code/10235
Author: vargenau
Date: 2021年01月09日 11:31:22 +0000 (2021年1月09日)
Log Message:
-----------
lib/plugin/CreateToc.php: check all boolean arguments
Modified Paths:
--------------
 trunk/lib/plugin/CreateToc.php
Modified: trunk/lib/plugin/CreateToc.php
===================================================================
--- trunk/lib/plugin/CreateToc.php	2021年01月08日 17:26:59 UTC (rev 10234)
+++ trunk/lib/plugin/CreateToc.php	2021年01月09日 11:31:22 UTC (rev 10235)
@@ -51,21 +51,22 @@
 
 function getDefaultArguments()
 {
- return array('extracollapse' => 1, // provide an entry +/- link to collapse
+ return array(
+ 'extracollapse' => true, // provide an entry +/- link to collapse
 'firstlevelstyle' => 'number', // 'number', 'letter' or 'roman'
 'headers' => "1,2,3,4,5", // "!!!"=>h2, "!!"=>h3, "!"=>h4
- // "1"=>h2, "2"=>h3, "3"=>h4, "4"=>h5, "5"=>h6
+ // "1"=>h2, "2"=>h3, "3"=>h4, "4"=>h5, "5"=>h6
 'indentstr' => '&nbsp;&nbsp;',
- 'jshide' => 0, // collapsed TOC as DHTML button
+ 'jshide' => false, // collapsed TOC as DHTML button
 'liststyle' => 'dl', // 'dl' or 'ul' or 'ol'
- 'noheader' => 0, // omit "Table of Contents" header
- 'notoc' => 0, // do not display TOC, only number headers
+ 'noheader' => false, // omit "Table of Contents" header
+ 'notoc' => false, // do not display TOC, only number headers
 'pagename' => '[pagename]', // TOC of another page here?
 'position' => 'full', // full, right or left
+ 'version' => false, // Most recent version
 'width' => '200px',
- 'with_counter' => 0,
- 'with_toclink' => 0, // link back to TOC
- 'version' => false,
+ 'with_counter' => false,
+ 'with_toclink' => false, // link back to TOC
 );
 }
 
@@ -398,6 +399,7 @@
 {
 global $WikiTheme;
 extract($this->getArgs($argstr, $request));
+
 if ($pagename) {
 // Expand relative page names.
 $page = new WikiPageName($pagename, $basepage);
@@ -406,6 +408,55 @@
 if (!$pagename) {
 return $this->error(sprintf(_("A required argument "%s" is missing."), 'pagename'));
 }
+
+ if (($extracollapse == '0') || ($extracollapse == 'false')) {
+ $extracollapse = false;
+ } elseif (($extracollapse == '1') || ($extracollapse == 'true')) {
+ $extracollapse = true;
+ } else {
+ return $this->error(sprintf(_("Argument '%s' must be a boolean"), "extracollapse"));
+ }
+
+ if (($jshide == '0') || ($jshide == 'false')) {
+ $jshide = false;
+ } elseif (($jshide == '1') || ($jshide == 'true')) {
+ $jshide = true;
+ } else {
+ return $this->error(sprintf(_("Argument '%s' must be a boolean"), "jshide"));
+ }
+
+ if (($noheader == '0') || ($noheader == 'false')) {
+ $noheader = false;
+ } elseif (($noheader == '1') || ($noheader == 'true')) {
+ $noheader = true;
+ } else {
+ return $this->error(sprintf(_("Argument '%s' must be a boolean"), "noheader"));
+ }
+
+ if (($notoc == '0') || ($notoc == 'false')) {
+ $notoc = false;
+ } elseif (($notoc == '1') || ($notoc == 'true')) {
+ $notoc = true;
+ } else {
+ return $this->error(sprintf(_("Argument '%s' must be a boolean"), "notoc"));
+ }
+
+ if (($with_counter == '0') || ($with_counter == 'false')) {
+ $with_counter = false;
+ } elseif (($with_counter == '1') || ($with_counter == 'true')) {
+ $with_counter = true;
+ } else {
+ return $this->error(sprintf(_("Argument '%s' must be a boolean"), "with_counter"));
+ }
+
+ if (($with_toclink == '0') || ($with_toclink == 'false')) {
+ $with_toclink = false;
+ } elseif (($with_toclink == '1') || ($with_toclink == 'true')) {
+ $with_toclink = true;
+ } else {
+ return $this->error(sprintf(_("Argument '%s' must be a boolean"), "with_toclink"));
+ }
+
 if (($notoc) or ($liststyle == 'ol')) {
 $with_counter = 1;
 }
@@ -415,9 +466,6 @@
 ) {
 return $this->error(_("Error: firstlevelstyle must be 'number', 'letter' or 'roman'"));
 }
- if ($extracollapse == 'false') {
- $extracollapse = false;
- }
 
 // Check if page exists.
 if (!($dbi->isWikiPage($pagename))) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <var...@us...> - 2021年09月20日 07:56:54
Revision: 10572
 http://sourceforge.net/p/phpwiki/code/10572
Author: vargenau
Date: 2021年09月20日 07:56:53 +0000 (2021年9月20日)
Log Message:
-----------
Simplify initialisation of toc counter
Modified Paths:
--------------
 trunk/lib/plugin/CreateToc.php
Modified: trunk/lib/plugin/CreateToc.php
===================================================================
--- trunk/lib/plugin/CreateToc.php	2021年09月17日 16:35:51 UTC (rev 10571)
+++ trunk/lib/plugin/CreateToc.php	2021年09月20日 07:56:53 UTC (rev 10572)
@@ -70,13 +70,6 @@
 );
 }
 
- // Initialisation of toc counter
- private function initTocCounter()
- {
- $counter = array(1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0);
- return $counter;
- }
-
 // Update toc counter with a new title
 private function tocCounter(&$counter, $level)
 {
@@ -258,7 +251,7 @@
 $counter, $levels, $firstlevelstyle, $basepage)
 {
 if (!$levels) $levels = array(1, 2);
- $tocCounter = $this->initTocCounter();
+ $tocCounter = array(1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0);
 reset($levels);
 sort($levels);
 $headers = array();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <var...@us...> - 2021年11月19日 08:18:00
Revision: 10660
 http://sourceforge.net/p/phpwiki/code/10660
Author: vargenau
Date: 2021年11月19日 08:17:57 +0000 (2021年11月19日)
Log Message:
-----------
Remove unused public
Modified Paths:
--------------
 trunk/lib/plugin/CreateToc.php
Modified: trunk/lib/plugin/CreateToc.php
===================================================================
--- trunk/lib/plugin/CreateToc.php	2021年11月18日 14:39:10 UTC (rev 10659)
+++ trunk/lib/plugin/CreateToc.php	2021年11月19日 08:17:57 UTC (rev 10660)
@@ -42,8 +42,6 @@
 class WikiPlugin_CreateToc
 extends WikiPlugin
 {
- public $_markup;
-
 function getDescription()
 {
 return _("Create a Table of Contents and automatically link to headers.");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /