2 rcs_id('$Id: RandomPage.php,v 1.4 2002-01-30 22:45:33 carstenklapp Exp $');
4 require_once('lib/PageList.php');
8 class WikiPlugin_RandomPage
12 return _("RandomPage");
15 function getDescription () {
16 return _("RandomPage");
19 function getDefaultArguments() {
20 return array('pages' => 1,
22 'pagename' => '[pagename]', // hackish
24 'include_self' => 0, // hackish
28 function run($dbi, $argstr, $request) {
29 extract($this->getArgs($argstr, $request));
31 $allpages = $dbi->getAllPages();
33 while ($page = $allpages->next())
36 better_srand(); // Start with a good seed.
40 $page = $pagearray[array_rand($pagearray)];
41 if (($showname == 'true') || ($showname == 1))
42 return $Theme->linkExistingWikiWord($page->getName());
44 return $Theme->linkExistingWikiWord($page->getName(), _("RandomPage"));
48 $PageList = new PageList();
49 $this->_init($pagename, &$PageList, $info, $exclude, $include_self);
51 while ($PageList->getTotal() < $pages) {
52 $PageList->addPage($pagearray[array_rand($pagearray)]);
54 return $PageList->getContent();
58 function _init(&$page, &$pagelist, $info = '', $exclude = '', $include_self = '') {
60 foreach (explode(",", $info) as $col)
61 $pagelist->insertColumn($col);
64 foreach (explode(",", $exclude) as $excludepage)
65 $pagelist->excludePageName($excludepage);
67 $pagelist->excludePageName($page);
77 // c-hanging-comment-ender-p: nil
78 // indent-tabs-mode: nil