Update of /cvsroot/phpwiki/phpwiki/lib/plugin
In directory usw-pr-cvs1:/tmp/cvs-serv12400/lib/plugin
Modified Files:
IncludePage.php
Log Message:
Detect and bail upon recursive inclusions.
Add rudimentary error reporting.
Gettextify.
Index: IncludePage.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/plugin/IncludePage.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** IncludePage.php 2001/12/02 02:12:21 1.1
--- IncludePage.php 2001/12/06 18:26:50 1.2
***************
*** 37,49 ****
return $new;
}
function run($dbi, $argstr, $request) {
extract($this->getArgs($argstr, $request));
! if (!$page) return ''; // FIXME: error reporting?
$p = $dbi->getPage($page);
if ($rev) {
$r = $p->getRevision($rev);
! if (!$r) return ''; // FIXME: error reporting?
} else {
$r = $p->getCurrentRevision();
--- 37,70 ----
return $new;
}
+
+ function error($msg) {
+ // FIXME: better error reporting?
+ trigger_error($msg, E_USER_NOTICE);
+ }
function run($dbi, $argstr, $request) {
+
extract($this->getArgs($argstr, $request));
!
! if (!$page) {
! $this->error(_("no page specified"));
! return '';
! }
!
! static $included_pages = array();
! if ($page == $request->getArg('pagename')
! || in_array($page, $included_pages)) {
! $this->error(sprintf(_("recursive inclusion of page %s"), $page));
! return '';
! }
!
$p = $dbi->getPage($page);
if ($rev) {
$r = $p->getRevision($rev);
! if (!$r) {
! $this->error(sprintf(_("%s(%d): no such revision"), $page, $rev));
! return '';
! }
} else {
$r = $p->getCurrentRevision();
***************
*** 56,68 ****
if ($words)
$c = $this->firstNWordsOfContent($words, $c);
!
$content = do_transform($c);
if ($quiet) return $content;
! return
! '<p class="transclusion-title">Included from '
! . LinkExistingWikiWord($page)
! . '</p>'
! . '<div class="transclusion">' . $content
! . '</div>';
}
};
--- 77,91 ----
if ($words)
$c = $this->firstNWordsOfContent($words, $c);
!
! array_push($included_pages, $page);
$content = do_transform($c);
+ array_pop($included_pages);
+
if ($quiet) return $content;
!
! return Element('p', array('class' => 'transclusion-title'),
! sprintf(_("Included from %s"), LinkExistingWikiWord($page)))
! . Element('div', array('class' => 'transclusion'),
! $content);
}
};
|