Revision 526
Added by doc almost 17 years ago
frontend.functions.php | ||
---|---|---|
312 | 312 |
// define default baselink and filename for optional module javascript and stylesheet files |
313 | 313 |
$head_links = ""; |
314 | 314 |
if($file_id == "css") { |
315 |
$base_link = '<link href="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend.css"';
|
|
315 |
$base_link = '<link href="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend.css"'; |
|
316 | 316 |
$base_link.= ' rel="stylesheet" type="text/css" media="screen" />'; |
317 | 317 |
$base_file = "frontend.css"; |
318 | 318 |
} else { |
... | ... | |
320 | 320 |
$base_file = "frontend.js"; |
321 | 321 |
} |
322 | 322 |
|
323 |
// gather information for all models embedded on actual page
|
|
323 |
// gather information for all models embedded on actual page |
|
324 | 324 |
$page_id = $wb->page_id; |
325 |
$query_modules = $database->query("SELECT module FROM " .TABLE_PREFIX ."sections
|
|
325 |
$query_modules = $database->query("SELECT module FROM " .TABLE_PREFIX ."sections |
|
326 | 326 |
WHERE page_id=$page_id AND module<>'wysiwyg'"); |
327 | 327 |
|
328 |
while($row = $query_modules->fetchRow()) {
|
|
328 |
while($row = $query_modules->fetchRow()) { |
|
329 | 329 |
// check if page module directory contains a frontend.js or frontend.css file |
330 |
if(file_exists(WB_PATH ."/modules/" .$row['module'] ."/$base_file")) {
|
|
330 |
if(file_exists(WB_PATH ."/modules/" .$row['module'] ."/$base_file")) { |
|
331 | 331 |
// create link with frontend.js or frontend.css source for the current module |
332 | 332 |
$tmp_link = str_replace("{MODULE_DIRECTORY}", $row['module'], $base_link); |
333 |
// ensure that frontend.js or frontend.css is only added once per module type |
|
334 |
if(strpos($head_links, $tmp_link) === false) { |
|
333 |
|
|
334 |
// define constant indicating that the register_frontent_files was invoked |
|
335 |
if($file_id == 'css') { |
|
336 |
define('MOD_FRONTEND_CSS_REGISTERED', true); |
|
337 |
} else { |
|
338 |
define('MOD_FRONTEND_JAVASCRIPT_REGISTERED', true); |
|
339 |
} |
|
340 |
|
|
341 |
// ensure that frontend.js or frontend.css is only added once per module type |
|
342 |
if(strpos($head_links, $tmp_link) === false) { |
|
335 | 343 |
$head_links .= $tmp_link ."\n"; |
336 | 344 |
} |
337 | 345 |
} |
338 |
}
|
|
339 |
// write out links with all external module javascript/CSS files, remove last line feed
|
|
346 |
} |
|
347 |
// write out links with all external module javascript/CSS files, remove last line feed |
|
340 | 348 |
echo $head_links; |
341 | 349 |
} |
342 | 350 |
} |
Also available in: Unified diff
Added constants MOD_FRONTEND_CSS_REGISTERED and MOD_FRONTEND_JAVASCRIPT_REGISTERED to function frontend.functions.php to allow modules to check if the register_frontend_modfiles function is invoked from the index.php of the current template.