Added functions for custom css files registered by modules
authorCambell <cambell.prince@gmail.com>
Sat, 30 Jan 2016 14:50:20 +0000 (21:50 +0700)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Tue, 30 Aug 2016 18:10:08 +0000 (20:10 +0200)
includes/main.inc
includes/page/header.inc

index d6a3453118731fe25034152e010727be21df1937..322a51bb8ee442e14eb77aa628534afe0cfd0e7e 100644 (file)
@@ -68,6 +68,24 @@ function end_page($no_menu=false, $is_index=false, $final_screen=false, $type_no
        page_footer($no_menu, $is_index);
 }
 
+function css_files_ensure_init() {
+       global $css_files, $path_to_root;
+
+       if (!isset($css_files))
+       {
+               $theme = user_theme();
+               $css_files = array();
+               $css_files[] = $path_to_root . "/themes/$theme/default.css";
+       }
+}
+
+function add_css_file($filename)
+{
+       global $css_files;
+       css_files_ensure_init();
+       $css_files[] = $filename;
+}
+
 function cache_js_file($fpath, $text) 
 {
        global $SysPrefs;
index 793adc030678f06265548dc5768dde38a5810a45..ec80dc160973052d407325a37d60e7e951cc453c 100644 (file)
@@ -45,6 +45,22 @@ function help_url($context=null)
                .'&ctxhelp=1&lang='.$country, ENT_QUOTES);
 }
 
+function send_css($css = '')
+{
+       global $css_files;
+
+       css_files_ensure_init();
+
+       foreach ($css_files as $css_file)
+       {
+               echo "<link href='$css_file' rel='stylesheet' type='text/css'> \n";
+       }
+       if ($css)
+       {
+               echo "<link href='$css' rel='stylesheet' type='text/css'> \n";
+       }
+}
+
 function send_scripts()
 {
     global $SysPrefs, $path_to_root, $js_static, $js_path, $js_userlib;
@@ -125,10 +141,9 @@ function page_header($title, $no_menu=false, $is_index=false, $onload="", $js=""
        if (strpos($_SERVER['HTTP_USER_AGENT'], 'Trident/7.0; rv:11.0') != -1) // IE 11 doesn't work with input file type in form.
                echo "<meta http-equiv='X-UA-Compatible' content='IE=10'>\n";
        echo "<meta http-equiv='Content-type' content='text/html; charset=$encoding'>";
-       echo "<link href='$path_to_root/themes/$theme/default.css' rel='stylesheet' type='text/css'> \n";
-       echo "<link href='$path_to_root/themes/default/images/favicon.ico' rel='icon' type='image/x-icon'> \n";
-       if ($css)
-               echo '<link href="'.$css.'" rel="stylesheet" type="text/css">';
+       echo "<link href='$path_to_root/themes/default/images/favicon.ico' rel='icon' type='image/x-icon'> \n";
+
+       send_css($css);
 
        send_scripts();