From: <var...@us...> - 2010-09-20 16:09:13
|
Revision: 7701 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=7701&view=rev Author: vargenau Date: 2010-09-20 16:09:07 +0000 (Mon, 20 Sep 2010) Log Message: ----------- Display correct TOC in history Modified Paths: -------------- trunk/lib/plugin/CreateToc.php trunk/pgsrc/Help%2FCreateTocPlugin Modified: trunk/lib/plugin/CreateToc.php =================================================================== --- trunk/lib/plugin/CreateToc.php 2010-09-20 16:03:26 UTC (rev 7700) +++ trunk/lib/plugin/CreateToc.php 2010-09-20 16:09:07 UTC (rev 7701) @@ -67,6 +67,7 @@ 'width' => '200px', 'with_counter' => 0, 'with_toclink' => 0, // link back to TOC + 'version' => false, ); } // Initialisation of toc counter @@ -168,13 +169,13 @@ $level, &$hstart, &$hend, $basepage=false) { $hstart = 0; $hend = 0; - $h = $this->_getHeader($level); + $h = $this->_getHeader($level); $qheading = $this->_quote($heading); - for ($j=$start_index; $j < count($content); $j++) { + 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; + return $j; } elseif (isa($content[$j], 'cached_link')) { @@ -213,10 +214,10 @@ } } } - } } - trigger_error("Heading <$h> $heading </$h> not found\n", E_USER_NOTICE); - return 0; + } + trigger_error("Heading <$h> $heading </$h> not found\n", E_USER_NOTICE); + return 0; } /** prevent from duplicate anchors, @@ -371,7 +372,7 @@ $pagename = $page->name; } if (!$pagename) { - return $this->error(_("no page specified")); + return $this->error(_("No page specified.")); } if (isBrowserIE() and browserDetect("Mac")) { $jshide = 0; @@ -380,22 +381,39 @@ $with_counter = 1; } - // Check if user is allowed to get the Page. + // Check if page exists. + if (!($dbi->isWikiPage($pagename))) { + return $this->error(sprintf(_("Page '%s' does not exist."), $pagename)); + } + + // 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)); } $page = $dbi->getPage($pagename); + + if ($version) { + $r = $page->getRevision($version); + if ((!$r) || ($r->hasDefaultContents())) { + return $this->error(sprintf(_("%s: no such revision %d."), + $pagename, $version)); + } + } else { + $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'))) { - trigger_error(_("CreateToc disabled for old markup"), E_USER_WARNING); - return ''; + return $this->error(_("CreateToc disabled for old markup.")); } } - $content = $current->getContent(); + + $content = $r->getContent(); + $html = HTML::div(array('class' => 'toc', 'id'=> GenerateId("toc"))); if ($notoc) { $html->setAttr('style','display:none;'); Modified: trunk/pgsrc/Help%2FCreateTocPlugin =================================================================== --- trunk/pgsrc/Help%2FCreateTocPlugin 2010-09-20 16:03:26 UTC (rev 7700) +++ trunk/pgsrc/Help%2FCreateTocPlugin 2010-09-20 16:09:07 UTC (rev 7701) @@ -1,4 +1,4 @@ -Date: Fri, 10 Sep 2010 13:46:13 +0000 +Date: Mon, 20 Sep 2010 18:07:40 +0000 Mime-Version: 1.0 (Produced by PhpWiki 1.4.0RC1) X-Rcs-Id: $Id$ Content-Type: application/x-phpwiki; @@ -63,6 +63,10 @@ | Table of Contents of which page? | current pagename |- +| **version** +| page version +| most recent version +|- | **position** | Where to display the Table of Contents: full, left or right. | full This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |