From 76f793a7214ab8decbe6de5da0b15f234610c3ac Mon Sep 17 00:00:00 2001 From: Cambell Date: Sat, 30 Jan 2016 21:50:20 +0700 Subject: [PATCH] Added functions for custom css files registered by modules --- includes/main.inc | 18 ++++++++++++++++++ includes/page/header.inc | 23 +++++++++++++++++++---- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/includes/main.inc b/includes/main.inc index d6a34531..322a51bb 100644 --- a/includes/main.inc +++ b/includes/main.inc @@ -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; diff --git a/includes/page/header.inc b/includes/page/header.inc index 793adc03..ec80dc16 100644 --- a/includes/page/header.inc +++ b/includes/page/header.inc @@ -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 " \n"; + } + if ($css) + { + echo " \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 "\n"; echo ""; - echo " \n"; - echo " \n"; - if ($css) - echo ''; + echo " \n"; + + send_css($css); send_scripts(); -- 2.30.2