Project

General

Profile

1
//:Randomly display one WYSIWYG section from a given list
2
//:Use [[iShowRandomWysiwyg?section=10,12,15,20]] possible Delimiters: [ ,;:|-+#/ ]
3
global $database, $section_id,$module;
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
		// split and sanitize arguments
10
		$aSections = preg_split('/[\s\,\|\-\;\:\+\#\/]+/', $section);
11
		$iOldSectionId = intval($section_id); // save old SectionID
12
		$section_id = $aSections[array_rand($aSections)]; // get random element
13
		ob_start(); // generate output by wysiwyg module
14
		$sectionAnchor = (defined('SEC_ANCHOR') && SEC_ANCHOR!='') ? SEC_ANCHOR : 'Sec';
15
		echo PHP_EOL.'<div id="'.$sectionAnchor.$sSectionIdPrefix.'" class="section m_'.$module.'" >'.PHP_EOL;
16
		require(WB_PATH.'/modules/wysiwyg/view.php');
17
		echo PHP_EOL.'</div><!-- '.$module.$section_id.' -->'.PHP_EOL;
18
		$content = ob_get_clean();
19
		$section_id = $iOldSectionId; // restore old SectionId
20
		}
21
	}
22
}
23
return $content;
(19-19/22)