LEPTON CMS 7.0.0
feel free to keep it strictly simple...
Loading...
Searching...
No Matches
function.get_active_sections.php
Go to the documentation of this file.
1<?php
2
18// include secure.php to protect this file and the whole CMS!
19if(!defined("SEC_FILE")){define("SEC_FILE",'/framework/secure.php' );}
20if (defined('LEPTON_PATH')) {
21 include LEPTON_PATH.SEC_FILE;
22} else {
23 $oneback = "../";
24 $root = $oneback;
25 $level = 1;
26 while (($level < 10) && (!file_exists($root.SEC_FILE))) {
27 $root .= $oneback;
28 $level += 1;
29 }
30 if (file_exists($root.SEC_FILE)) {
31 include $root.SEC_FILE;
32 } else {
33 trigger_error(sprintf("[ <b>%s</b> ] Can't include secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR);
34 }
35}
36// end include secure file
37
38
47function get_active_sections( $page_id, $block = null, $backend = false )
48{
50
51 $lep_active_sections = [];
52
53 // First get all sections for this page
54 $aSections = [];
55 $database->execute_query(
56 "SELECT * FROM `".TABLE_PREFIX."sections` WHERE `page_id` = '". $page_id ."' ORDER BY `block`, `position`",
57 true,
58 $aSections,
59 true
60 );
61
62 if(empty($aSections))
63 {
64 return NULL;
65 }
66
67 $now = time();
68 foreach($aSections as $section)
69 {
70 // skip this section if it is out of publication-date
71 if ( ($backend === false) && !(($now <= $section['publ_end'] || $section['publ_end'] == 0) && ($now >= $section['publ_start'] || $section['publ_start'] == 0)))
72 {
73 continue;
74 }
75 $lep_active_sections[$section['block']][] = $section;
76 }
77
78 $pages_seen[$page_id] = true;
79
80 if ( $block )
81 {
82 return ( isset($lep_active_sections[$block] ) )
83 ? $lep_active_sections[$block]
84 : NULL;
85 }
86
87 $all = [];
88 foreach( $lep_active_sections as $block => $values )
89 {
90 foreach( $values as $value )
91 {
92 $all[] = $value;
93 }
94 }
95
96 // add all parameters to array to get frontend.css for snippets work like modules!
97 $aSnippets = [];
98 $database->execute_query(
99 "SELECT * FROM `".TABLE_PREFIX."addons` WHERE `function` = 'snippet' ",
100 true,
101 $aSnippets,
102 true
103 );
104 foreach($aSnippets as $temp_snippets)
105 {
106 $all[] = [
107 'module' => $temp_snippets['directory'],
108 'section_id' => -1
109 ];
110 }
111
112 return $all;
113
114}
static getInstance(array &$settings=[])
$database
Definition constants.php:52
get_active_sections( $page_id, $block=null, $backend=false)