LEPTON CMS 7.2.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
88 $all = [];
89 foreach ($lep_active_sections as $block => $values)
90 {
91 foreach ($values as $value)
92 {
93 $all[] = $value;
94 }
95 }
96
97 // add all parameters to array to get frontend.css for snippets work like modules!
98 $aSnippets = [];
99 $database->execute_query(
100 "SELECT * FROM `".TABLE_PREFIX."addons` WHERE `function` = 'snippet' ",
101 true,
102 $aSnippets,
103 true
104 );
105 foreach ($aSnippets as $temp_snippets)
106 {
107 $all[] = [
108 'module' => $temp_snippets['directory'],
109 'section_id' => -1
110 ];
111 }
112
113 return $all;
114
115}
static getInstance(array &$settings=[])
$database
Definition constants.php:52
get_active_sections( $page_id, $block=null, $backend=false)