67 function get_page_headers(
string $for =
'frontend',
bool $print_output =
true,
bool $individual =
false)
70 if (defined(
'LEP_HEADERS_SENT'))
75 if (!$for || $for ==
'' || ($for !=
'frontend' && $for !=
'backend'))
93 if (($for ===
'backend') && (file_exists(LEPTON_PATH .
'/templates/' . DEFAULT_THEME .
'/headers.inc.php')))
95 LEPTON_core::addItems($for, LEPTON_PATH .
'/templates/' . DEFAULT_THEME);
101 if ((defined(
"TEMPLATE")) && (TEMPLATE != DEFAULT_TEMPLATE))
103 if (file_exists(LEPTON_PATH .
'/templates/' . TEMPLATE .
'/headers.inc.php'))
105 LEPTON_core::addItems($for, LEPTON_PATH .
'/templates/' . TEMPLATE);
108 elseif (file_exists( LEPTON_PATH .
'/templates/' . DEFAULT_TEMPLATE .
'/headers.inc.php' ) )
110 LEPTON_core::addItems( $for, LEPTON_PATH .
'/templates/' . DEFAULT_TEMPLATE );
122 if ($for ==
"frontend")
129 $current_template = ((isset($oLEPTON->page[
'template'])) && ($oLEPTON->page[
'template'] !=
""))
130 ? $oLEPTON->page[
'template']
134 $lookup_file =
"templates/" . $current_template .
"/frontend/lib_search";
136 foreach ([$lookup_file,
'modules/lib_search/templates'] as $directory )
138 $file = $directory .
'/' . $for .
'.css';
139 if ((file_exists(LEPTON_PATH .
'/' . $file)) && (
false === $css_loaded))
141 LEPTON_core::$HEADERS[ $for ][
'css' ][] = array(
148 $file = $directory .
'/' . $for .
'.js';
149 if ((file_exists(LEPTON_PATH .
'/' . $file)) && (
false === $js_loaded))
151 LEPTON_core::$HEADERS[ $for ][
'js' ][] = $file;
159 if (stripos($_SERVER[
'REQUEST_URI'],
"/account/") !== FALSE ) {
161 $lookup_files = array(
162 "templates/" . $current_template .
"/frontend/login/css/frontend.css",
163 "account/css/frontend.css"
166 foreach ($lookup_files as &$lookup_file) {
167 if (file_exists(LEPTON_PATH .
"/" . $lookup_file)) {
168 LEPTON_core::$HEADERS[
'frontend'][
'css'][] = array(
170 'file' => $lookup_file
180 if ( ( $for ==
'frontend' )
181 && ( isset( $page_id ) )
182 && ( is_numeric( $page_id ) )
183 && ( file_exists( LEPTON_PATH .
'/framework/summary.droplets.php' ) )
186 get_droplet_headers( $page_id );
196 if ( $for ==
'backend' && ( $sToolName !==
"" ) && file_exists( LEPTON_PATH .
'/modules/' . $sToolName .
'/tool.php' ) )
199 $css_subdirs[] = array(
200 'modules/' . $sToolName,
201 'modules/' . $sToolName .
'/css'
204 $temp_lookup_path = LEPTON_PATH.
"/templates/".DEFAULT_THEME.
"/backend/".$sToolName.
"/";
205 if( file_exists($temp_lookup_path) )
207 $ref = &$css_subdirs[ (count($css_subdirs)-1) ];
208 $ref[] =
"templates/".DEFAULT_THEME.
"/backend/".$sToolName;
209 $ref[] =
"templates/".DEFAULT_THEME.
"/backend/".$sToolName.
"/css";
210 $ref = array_reverse($ref);
214 $js_subdirs[] = array(
215 '/modules/' . $sToolName,
216 '/modules/' . $sToolName .
'/js'
219 if( file_exists($temp_lookup_path) )
221 $ref = &$js_subdirs[ (count($js_subdirs)-1) ];
222 $ref[] =
"templates/".DEFAULT_THEME.
"/backend/".$sToolName;
223 $ref[] =
"templates/".DEFAULT_THEME.
"/backend/".$sToolName.
"/js";
224 $ref = array_reverse($ref);
228 if ( file_exists( LEPTON_PATH .
'/modules/' . $sToolName .
'/headers.inc.php' ) )
230 LEPTON_core::addItems( $for, LEPTON_PATH .
'/modules/' . $sToolName );
235 elseif ( $page_id && is_numeric( $page_id ) )
240 if ( ( is_array( $sections ) ) && ( count( $sections ) > 0 ) )
242 global $current_section;
246 $processed_modules = array();
248 foreach ( $sections as $section )
250 $module = $section[
'module' ];
252 if(in_array($module, $processed_modules)) {
256 $processed_modules[] = $module;
259 $headers_path = LEPTON_PATH .
'/modules/' . $module;
261 if ( $for ==
'backend' && !strcasecmp( $module,
'wysiwyg' ) )
264 if ( defined(
'WYSIWYG_EDITOR' ) && WYSIWYG_EDITOR !=
"none" )
266 $headers_path = LEPTON_PATH .
'/modules/' . WYSIWYG_EDITOR;
270 if ( file_exists( $headers_path .
'/headers.inc.php' ) )
272 $current_section = $section[
'section_id' ];
273 LEPTON_core::addItems( $for, $headers_path );
282 if (is_object($oLEPTON)) {
283 $current_template = ((isset($oLEPTON->page[
'template'])) && ($oLEPTON->page[
'template'] !=
""))
284 ? $oLEPTON->page[
'template']
288 $lookup_file = LEPTON_PATH.
"/templates/".$current_template.
"/frontend/".$module;
289 if (file_exists($lookup_file.
"/headers.inc.php")) {
290 LEPTON_core::addItems( $for,$lookup_file );
297 'modules/' . $module,
298 'modules/' . $module .
'/css'
302 'modules/' . $module,
303 'modules/' . $module .
'/js'
308 if ($for ==
'frontend')
311 $current_template = $oLEPTON->page[
'template'] !=
"" ? $oLEPTON->page[
'template'] : DEFAULT_TEMPLATE;
312 $lookup_file =
"templates/".$current_template.
"/frontend/".$module;
314 $temp_css[] = $lookup_file;
315 $temp_css[] = $lookup_file.
"/css";
317 $temp_js[] = $lookup_file;
318 $temp_js[] = $lookup_file.
"/js";
325 $current_theme = DEFAULT_THEME;
326 $lookup_file =
"templates/".$current_theme.
"/backend/".$module;
327 $temp_css[] = $lookup_file;
328 $temp_css[] = $lookup_file.
"/css";
330 $temp_js[] = $lookup_file;
331 $temp_js[] = $lookup_file.
"/js";
336 $css_subdirs[]= array_reverse($temp_css);
337 $js_subdirs[]= array_reverse($temp_js);
349 foreach ($css_subdirs as $first_level_ref)
353 foreach( $first_level_ref as $directory )
356 $file = $directory .
'/' . $for .
'.css';
357 if ((file_exists(LEPTON_PATH .
'/' . $file)) && ($css_found ===
false))
359 LEPTON_core::$HEADERS[ $for ][
'css' ][] = array(
373 if ( $for ==
'frontend' ) {
374 $current_template = $oLEPTON->page[
'template'] !=
"" ? $oLEPTON->page[
'template'] : DEFAULT_TEMPLATE;
375 $lookup_files = array(
376 "templates/".$current_template.
"/css/".$page_id.
".css",
377 "templates/".$current_template.
"/".$page_id.
".css"
380 foreach($lookup_files as &$file) {
381 if ( file_exists( LEPTON_PATH .
'/' . $file ) ) {
382 LEPTON_core::$HEADERS[ $for ][
'css' ][] = array(
394 foreach( $js_subdirs as &$first_level_ref )
397 foreach( $first_level_ref as $directory )
399 $file = $directory .
'/' . $for .
'.js';
400 if( ( file_exists( LEPTON_PATH .
'/' . $file ) ) && ($got_js ===
false) )
402 LEPTON_core::$HEADERS[ $for ][
'js' ][] = $file;
409 $HEADERS = &LEPTON_core::$HEADERS;
411 foreach ([
'css',
'jquery',
'js'] as $key )
413 if ( !isset( $HEADERS[ $for ][ $key ] ) || !is_array( $HEADERS[ $for ][ $key ] ) )
418 foreach ( $HEADERS[ $for ][ $key ] as $i => $arr )
423 if( file_exists( LEPTON_PATH.
"/".$arr[
'file'] ) )
426 $file = ( preg_match(
'#' . LEPTON_URL .
'#i', $arr[
'file' ] ) ? $arr[
'file' ] : LEPTON_URL .
'/' . $arr[
'file' ] );
427 $output .=
'<link rel="stylesheet" type="text/css" href="' . $file .
'" media="' . ( isset( $arr[
'media' ] ) ? $arr[
'media' ] :
'all' ) .
'" />' .
"\n";
432 $output .=
'<script src="' . LEPTON_URL .
'/' . $arr .
'"></script>' .
"\n";
436 trigger_error(
'Unknown header type [' . $key .
'] [index '.$i.
']!', E_USER_NOTICE );
442 if (
true === $print_output )
445 define(
'LEP_HEADERS_SENT',
true );