function register_frontend_modfiles($file_id = "css")
 {
     // sanity check of parameter passed to the function
     $file_id = strtolower($file_id);
     $aAllowedAction = array('css', 'script', 'js', 'jquery', 'javascript');
     if (!in_array($file_id, $aAllowedAction)) {
         return false;
     }
     global $wb, $database, $include_head_link_css, $include_head_links, $page_id;
     // define default baselink and filename for optional module javascript and stylesheet files
     $head_links = "";
     $base_file = '';
     $base_link = '';
     switch ($file_id) {
         case '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";
             if (!empty($include_head_link_css)) {
                 $head_links .= !strpos($head_links, $include_head_link_css) ? $include_head_link_css : '';
                 $include_head_link_css = '';
             }
             break;
         case 'jquery':
             $aFilterSettings = getOutputFilterSettings();
             $key = preg_replace('=^.*?filter([^\\.\\/\\\\]+)(\\.[^\\.]+)?$=is', '\\1', 'filterJquery.inc');
             $bLoadJquery = !isset($aFilterSettings[$key]);
             $bLoadJquery = @(!$aFilterSettings[$key]) ?: $bLoadJquery;
             if ($bLoadJquery) {
                 $head_links .= bind_jquery($file_id);
             }
             break;
         case 'js':
             //                $base_link = '<script src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/frontend.js" type="text/javascript"></script>';
             //                $base_file = "frontend.js";
             //                if(!empty($include_head_links))
             //                {
             //                  $head_links .= !strpos($head_links, $include_head_links) ? $include_head_links : '';
             //                  $include_head_links = '';
             //                }
             break;
         case 'script_old':
             break;
         default:
             break;
     }
     if ($file_id != 'jquery_old') {
         // gather information for all models embedded on actual page
         //            $page_id = $wb->page_id;
         $sql = 'SELECT `module` FROM `' . TABLE_PREFIX . 'sections` ' . 'WHERE `page_id` = ' . (int) $page_id;
         if ($oModules = $database->query($sql)) {
             while ($row = $oModules->fetchRow(MYSQLI_ASSOC)) {
                 // 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);
                     // define constant indicating that the register_frontent_files was invoked
                     if ($file_id == 'css') {
                         if (!defined('MOD_FRONTEND_CSS_REGISTERED')) {
                             define('MOD_FRONTEND_CSS_REGISTERED', true);
                         }
                     } else {
                         if (!defined('MOD_FRONTEND_JAVASCRIPT_REGISTERED')) {
                             define('MOD_FRONTEND_JAVASCRIPT_REGISTERED', true);
                         }
                     }
                     // ensure that frontend.js or frontend.css is only added once per module type
                     if ($tmp_link && strpos($head_links, $tmp_link) === false) {
                         $head_links .= $tmp_link . "\n";
                     }
                 }
             }
         }
     }
     print $head_links;
 }
 function register_frontend_modfiles($file_id = "css")
 {
     // sanity check of parameter passed to the function
     $file_id = strtolower($file_id);
     if ($file_id !== "css" && $file_id !== "javascript" && $file_id !== "js" && $file_id !== "jquery") {
         return;
     }
     global $wb, $database, $include_head_link_css, $include_head_links;
     // define default baselink and filename for optional module javascript and stylesheet files
     $head_links = "";
     switch ($file_id) {
         case '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";
             if (!empty($include_head_link_css)) {
                 $head_links .= !strpos($head_links, $include_head_link_css) ? $include_head_link_css : '';
                 $include_head_link_css = '';
             }
             break;
         case 'jquery':
             $head_links .= bind_jquery($file_id);
             break;
         case 'js':
             $base_link = '<script src="' . WB_URL . '/modules/{MODULE_DIRECTORY}/frontend.js" type="text/javascript"></script>';
             $base_file = "frontend.js";
             if (!empty($include_head_links)) {
                 $head_links .= !strpos($head_links, $include_head_links) ? $include_head_links : '';
                 $include_head_links = '';
             }
             break;
         default:
             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);
                     // define constant indicating that the register_frontent_files was invoked
                     if ($file_id == 'css') {
                         if (!defined('MOD_FRONTEND_CSS_REGISTERED')) {
                             define('MOD_FRONTEND_CSS_REGISTERED', true);
                         }
                     } else {
                         if (!defined('MOD_FRONTEND_JAVASCRIPT_REGISTERED')) {
                             define('MOD_FRONTEND_JAVASCRIPT_REGISTERED', true);
                         }
                     }
                     // ensure that frontend.js or frontend.css is only added once per module type
                     if (strpos($head_links, $tmp_link) === false) {
                         $head_links .= $tmp_link . "\n";
                     }
                 }
             }
         }
         // include the Javascript email protection function
         if ($file_id != 'css' && file_exists(WB_PATH . '/modules/droplets/js/mdcr.js')) {
             $head_links .= '<script src="' . WB_URL . '/modules/droplets/js/mdcr.js" type="text/javascript"></script>' . "\n";
         } elseif ($file_id != 'css' && file_exists(WB_PATH . '/modules/output_filter/js/mdcr.js')) {
             $head_links .= '<script src="' . WB_URL . '/modules/output_filter/js/mdcr.js" type="text/javascript"></script>' . "\n";
         }
     }
     print $head_links;
 }