56 $FOOTERS = &LEPTON_core::$FOOTERS;
59 if ( defined(
'LEP_FOOTERS_SENT' ) )
65 $sAdditionalInfo =
"";
70 if (($for !=
'frontend') && ($for !=
'backend'))
73 $oLEPTON = LEPTON_frontend::getInstance();
78 if (is_null($page_id))
85 $sMyTool = filter_input(INPUT_GET,
'tool',FILTER_SANITIZE_SPECIAL_CHARS) ??
'';
86 if ($for ==
'backend' && isset($sMyTool) && file_exists(LEPTON_PATH.
'/modules/'.$sMyTool.
'/tool.php'))
89 'modules/'.$sMyTool.
'/js',
92 if (file_exists(LEPTON_PATH.
'/modules/'.$sMyTool.
'/footers.inc.php'))
94 LEPTON_core::addItems($for, LEPTON_PATH.
'/modules/'.$sMyTool,
true);
97 elseif ($page_id && is_numeric($page_id))
100 if (is_array($sections) && count($sections))
102 global $current_section;
105 $loaded_modules = [];
107 foreach ($sections as $section)
110 $module = $section[
'module'];
112 if (in_array($module, $loaded_modules))
116 $loaded_modules[] = $module;
119 if (file_exists(LEPTON_PATH.
'/modules/'.$module.
'/footers.inc.php'))
121 $current_section = $section[
'section_id'];
122 LEPTON_core::addItems($for, LEPTON_PATH.
'/modules/'.$module,
true);
126 $current_template = (isset($oLEPTON->page[
'template']) && ($oLEPTON->page[
'template'] !=
'')) ? $oLEPTON->page[
'template'] : DEFAULT_TEMPLATE;
128 if (file_exists(LEPTON_PATH.
'/templates/'.$current_template.
'/footers.inc.php'))
130 $current_section = $section[
'section_id'];
131 LEPTON_core::addItems($for, LEPTON_PATH.
'/templates/'.$current_template,
true);
138 'modules/'.$module.
'/js'
141 if ($for ==
'frontend')
143 $current_template = (isset($oLEPTON->page[
'template']) && ($oLEPTON->page[
'template'] !=
'')) ? $oLEPTON->page[
'template'] : DEFAULT_TEMPLATE;
144 $lookup_file =
"templates/".$current_template.
"/frontend/".$module;
149 $current_theme = DEFAULT_THEME;
150 $lookup_file =
"templates/".$current_theme.
"/backend/".$module;
154 $temp_js[] = $lookup_file;
155 $temp_js[] = $lookup_file.
"/js";
157 $js_subdirs[]= array_reverse($temp_js);
162 if ($for ==
'frontend')
166 PAGES_DIRECTORY .
'/js'
173 $sAdditionalInfo .=
"\n<!-- no page_id, no modules -->\n";
176 $sTempPagePath = filter_input(INPUT_SERVER,
"REQUEST_URI", FILTER_SANITIZE_FULL_SPECIAL_CHARS);
178 if (str_contains($sTempPagePath,
"frontend_result"))
180 $sAdditionalInfo .=
"\n<!-- search results -->\n";
186 $sTempLookUp = LEPTON_PATH.
"/templates/".$sTempTemplateName.
"/footers.inc.php";
187 if (file_exists($sTempLookUp))
190 LEPTON_core::addItems($for, LEPTON_PATH.
'/templates/'.$sTempTemplateName,
true);
198 $sAdditionalInfo .=
"\n<!-- default frontend template -->\n";
201 $sTempLookUp = LEPTON_PATH.
"/templates/".DEFAULT_TEMPLATE.
"/footers.inc.php";
202 if (file_exists($sTempLookUp))
205 LEPTON_core::addItems($for, LEPTON_PATH .
'/templates/' . DEFAULT_TEMPLATE,
true);
212 if ($for ==
'backend')
214 $subdir = (defined(
'DEFAULT_THEME') ? DEFAULT_THEME : NULL);
216 $subdir = (defined(
'TEMPLATE') ? TEMPLATE : NULL);
219 if (($module !=
'') && (!isset($loaded_modules)))
221 $js_subdirs[0][] =
'templates/'.$subdir.
'/backend/'.$module;
222 $js_subdirs[0][] =
'templates/'.$subdir.
'/backend/'.$module.
'/js';
223 $js_subdirs[0]= array_reverse($js_subdirs[0]);
227 'templates/' . $subdir .
'/js',
228 'templates/' . $subdir
232 foreach ($js_subdirs as $first_level_dir)
234 foreach ($first_level_dir as $directory)
238 $footersFile = LEPTON_PATH.
'/'.$directory.
'/footers.inc.php';
240 if (file_exists($footersFile))
243 LEPTON_core::addItems($for, LEPTON_PATH.
'/'.$directory,
true);
246 $file = $directory.
'/'.$for.
'_body.js';
248 if (file_exists(LEPTON_PATH.
'/'.$file))
250 $FOOTERS[$for][
'js'][] = $file;
258 foreach ($FOOTERS[$for][
'js'] as $arr)
260 $output .=
'<script src="'.LEPTON_URL.
'/'.$arr.
'"></script>'.
"\n";
263 define(
'LEP_FOOTERS_SENT',
true);
265 $sAdditionalInfo .=
"\n<!-- get_page_footer - ".$for.
"-->\n";
268 if ($for ==
'frontend')
270 echo $sAdditionalInfo.$output;
276 return $sAdditionalInfo.$output;