1 |
2024
|
darkviper
|
//:search for blockcontent in current page and parent pages if not found
|
2 |
|
|
//:Use: [[iParentBlock?block=2]] Display the content of a defined block
|
3 |
|
|
// Select all WYSIWYG-sections from a defined block on this page or it's parent pages
|
4 |
|
|
// @author: Werner von der Decken
|
5 |
|
|
global $wb, $database;
|
6 |
|
|
$oDb = WbDatabase::getInstance();
|
7 |
|
|
$rt_content = '';
|
8 |
|
|
$block = !isset($block) ? 1 : intval($block);
|
9 |
|
|
$tmp_trail = $wb->page_trail;
|
10 |
|
|
while( ($pid = array_pop($tmp_trail)) != null )
|
11 |
|
|
{
|
12 |
|
|
$sql = 'SELECT `w`.`content`, `s`.`section_id`, `p`.`page_id`, `p`.`visibility`, ';
|
13 |
|
|
$sql .= '`p`.`viewing_groups`, `p`.`viewing_users` ';
|
14 |
|
|
$sql .= 'FROM `'.$oDb->TablePrefix.'mod_wysiwyg` `w` ';
|
15 |
|
|
$sql .= 'LEFT JOIN `'.$oDb->TablePrefix.'sections` `s` ON `w`.`section_id`= `s`.`section_id` ';
|
16 |
|
|
$sql .= 'LEFT JOIN `'.$oDb->TablePrefix.'pages` `p` ON `s`.`page_id`=`p`.`page_id` ';
|
17 |
|
|
$sql .= 'WHERE `s`.`block`='.$block.' AND `s`.`page_id`='.$pid.' ';
|
18 |
|
|
$sql .= 'ORDER BY `s`.`position` ASC';
|
19 |
|
|
if( $rs_pages = $oDb->doQuery($sql) )
|
20 |
|
|
{
|
21 |
|
|
while( $rec_page = $rs_pages->fetchRow(MYSQL_ASSOC) )
|
22 |
|
|
{
|
23 |
|
|
if( $wb->page_is_visible($rec_page) )
|
24 |
|
|
{
|
25 |
|
|
if( $wb->section_is_active($rec_page['section_id']) )
|
26 |
|
|
{
|
27 |
|
|
$rt_content .= trim($rec_page['content']);
|
28 |
|
|
}
|
29 |
|
|
}
|
30 |
|
|
}
|
31 |
|
|
}
|
32 |
|
|
if($rt_content != '') { break; }
|
33 |
|
|
}
|
34 |
|
|
return $rt_content;
|