6 * $imgSet = new randomImage($WikiTheme->file("images/pictures"));
7 * $imgFile = "pictures/" . $imgSet->filename;
9 function randomImage ($dirname) {
11 $this->filename = ""; // Pick up your filename here.
13 $_imageSet = new imageSet($dirname);
14 $this->imageList = $_imageSet->getFiles();
17 if (empty($this->imageList)) {
18 trigger_error(sprintf(_("%s is empty."), $dirname),
21 $dummy = $this->pickRandom();
25 function pickRandom() {
26 better_srand(); // Start with a good seed.
27 $this->filename = $this->imageList[array_rand($this->imageList)];
28 //trigger_error(sprintf(_("random image chosen: %s"),
30 // E_USER_NOTICE); //debugging
31 return $this->filename;
35 class imageSet extends fileSet {
37 * A file is considered an image when the suffix matches one from
40 function _filenameSelector($filename) {
41 return preg_match("/(" . INLINE_IMAGES . ")$/i", $filename);
49 // c-hanging-comment-ender-p: nil
50 // indent-tabs-mode: nil