function register_frontend_modfiles($file_id = "css", $return = false) { // sanitize value $file_id = strtolower($file_id); if ($file_id == "javascript") { $file_id = "js"; } // no valid value , return whith nothing if ($file_id !== "css" && $file_id !== "js" && $file_id !== "jquery") { return; } // Variable declarations static $call_count = 0; // Add system values only once global $wb, $database, $include_head_link_css, $include_head_links; // define default baselink and filename for optional module javascript and stylesheet files $head_links = ""; // Echo systemvars only once if (!$call_count and $file_id != "css") { $head_links .= wb_make_js_sys_vars(); // Sysvars always added to Insert I::DelJs("wbsysvars"); } // defines different "templates" for rendering the Link (css/js) // no templates needed for Jquery switch ($file_id) { case 'css': $head_links = $include_head_link_css; $base_link = '<link href="' . WB_URL . '/modules/{MODULE_DIRECTORY}/frontend.css"'; $base_link .= ' rel="stylesheet" type="text/css" media="screen" />'; $base_file = "frontend.css"; break; case 'jquery': $head_links .= wb_bind_jquery($file_id); $call_count++; break; case 'js': $head_links = $include_head_links; $base_link = '<script src="' . WB_URL . '/modules/{MODULE_DIRECTORY}/frontend.js" type="text/javascript"></script>'; $base_file = "frontend.js"; $call_count++; break; } if ($file_id != 'jquery') { // gather information for all models embedded on actual page $page_id = $wb->page_id; $sql = 'SELECT `module` FROM `' . TABLE_PREFIX . 'sections` '; $sql .= 'WHERE `page_id` = ' . (int) $page_id . ' AND `module`<>\'wysiwyg\''; if ($query_modules = $database->query($sql)) { while ($row = $query_modules->fetchRow()) { // check if page module directory contains a frontend.js or frontend.css file if (file_exists(WB_PATH . "/modules/" . $row['module'] . "/{$base_file}")) { // create link with frontend.js or frontend.css source for the current module $tmp_link = str_replace("{MODULE_DIRECTORY}", $row['module'], $base_link); // ensure that frontend.js or frontend.css is only added once per module type // as it can be loaded already by a snippet if (strpos($head_links, $tmp_link) === false) { $head_links .= $tmp_link . "\n"; } } } } } if ($return) { return $head_links; } print $head_links; }