<?php /* Copyright 2004 Patrick R. Michaud (pmichaud@pobox.com). This script adds markup of the form [:randomincl PageName:], which includes the text of another page selected at random. The PageName argument names a page that contains a list of pages to randomly choose from (e.g., any page that can be used as a WikiTrail index). The code also keeps track of which pages have been included, so that multiple instances of [:randomincl ...:] markup won't result in the same page being selected twice. */ $BrowseDirectives['/\\[:randomincl (.*):\\]/e'] = "RandomIncl('$1')"; function RandomIncl($listpage) { static $included; # get the list of pages to choose from $trail = ReadTrail($listpage); # pick a random page from the list for($i=0;$i<100;$i++) { $pgname = $trail[rand(0,count($trail)-1)]['name']; if (!$included[$pgname]) break; } $included[$pgname]++; $pg = ReadPage($pgname); return $pg['text']; } ?>