From: Carsten K. <car...@us...> - 2002-01-30 18:27:15
|
Update of /cvsroot/phpwiki/phpwiki/lib/plugin In directory usw-pr-cvs1:/tmp/cvs-serv18286 Modified Files: BackLinks.php Log Message: Added multiple page exclusion and include_self. Added new message when only 1 match found. Index: BackLinks.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/plugin/BackLinks.php,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** BackLinks.php 2002/01/28 01:01:27 1.14 --- BackLinks.php 2002/01/30 18:27:13 1.15 *************** *** 18,38 **** function getDefaultArguments() { - // FIXME: how to exclude multiple pages? return array('exclude' => '', 'include_self' => 0, 'noheader' => 0, ! 'page' => '[pagename]', 'info' => false ); } // info arg allows multiple columns info=mtime,hits,summary,version,author,locked,minor ! function run($dbi, $argstr, $request) { $this->_args = $this->getArgs($argstr, $request); extract($this->_args); ! if (!$page) return ''; ! $p = $dbi->getPage($page); $backlinks = $p->getLinks(); --- 18,38 ---- function getDefaultArguments() { return array('exclude' => '', 'include_self' => 0, 'noheader' => 0, ! 'pagename' => '[pagename]', 'info' => false ); } // info arg allows multiple columns info=mtime,hits,summary,version,author,locked,minor ! // exclude arg allows multiple pagenames exclude=HomePage,RecentChanges ! function run($dbi, $argstr, $request) { $this->_args = $this->getArgs($argstr, $request); extract($this->_args); ! if (!$pagename) return ''; ! $p = $dbi->getPage($pagename); $backlinks = $p->getLinks(); *************** *** 43,64 **** $pagelist->insertColumn($col); ! while ($backlink = $backlinks->next()) { ! $name = $backlink->getName(); ! if ($exclude && $name == $exclude) ! continue; ! if (!$include_self && $name == $page) ! continue; $pagelist->addPage($backlink); } if (!$noheader) { ! $pagelink = LinkWikiWord($page); ! if ($pagelist->isEmpty()) return HTML::p(fmt("No pages link to %s.", $pagelink)); - $pagelist->setCaption(fmt("%d pages link to %s:", - $pagelist->getTotal(), $pagelink)); $pagelist->setMessageIfEmpty(''); } --- 43,69 ---- $pagelist->insertColumn($col); ! if ($exclude) ! foreach (explode(",", $exclude) as $excludepage) ! $pagelist->excludePageName($excludepage); ! if (!$include_self) ! $pagelist->excludePageName($pagename); + while ($backlink = $backlinks->next()) { $pagelist->addPage($backlink); } if (!$noheader) { ! $pagelink = LinkWikiWord($pagename); ! if ($pagelist->isEmpty()) return HTML::p(fmt("No pages link to %s.", $pagelink)); + + if ($pagelist->getTotal() == 1) + $pagelist->setCaption(fmt("1 page links to %s:", + $pagelink)); + else + $pagelist->setCaption(fmt("%s pages link to %s:", + $pagelist->getTotal(), $pagelink)); $pagelist->setMessageIfEmpty(''); } |