1 |
1621
|
darkviper
|
//:Randomly display one WYSIWYG section from a given list
|
2 |
|
|
//:Use [[ShowRandomWysiwyg?section=10,12,15,20]] possible Delimiters: [ ,;:|-+#/ ]
|
3 |
|
|
global $database;
|
4 |
|
|
$content = '';
|
5 |
|
|
if (isset($section)) {
|
6 |
|
|
if( preg_match('/^[0-9]+(?:\s*\[\,\|\-\;\:\+\#\/]\s*[0-9]+\s*)*$/', $section)) {
|
7 |
|
|
if (is_readable(WB_PATH.'/modules/wysiwyg/view.php')) {
|
8 |
|
|
// if valid arguments given and module wysiwyg is installed
|
9 |
|
|
$iOldSectionId = intval($section_id); // save old SectionId
|
10 |
|
|
// split and sanitize arguments
|
11 |
|
|
$aSections = preg_split('/[\s\,\|\-\;\:\+\#\/]+/', $section);
|
12 |
|
|
$section_id = $sections[array_rand($sections)]; // get random element
|
13 |
|
|
ob_start(); // generate output by wysiwyg module
|
14 |
|
|
require(WB_PATH.'/modules/wysiwyg/view.php');
|
15 |
|
|
$content = ob_get_clean();
|
16 |
|
|
$section_id = $ioldSectionId; // restore old SectionId
|
17 |
|
|
}
|
18 |
|
|
}
|
19 |
|
|
}
|
20 |
|
|
return $content;
|