Skip to content

Commit

Permalink
Added functions for custom css files registered by modules
Browse files Browse the repository at this point in the history
  • Loading branch information
apmuthu committed Sep 2, 2016
1 parent 1f4c3b9 commit 5dbacd3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
5 changes: 5 additions & 0 deletions core/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2016-08-30 Cambell
Added functions for custom css files registered by modules
M includes/main.inc
M includes/page/header.inc

2016-08-30 Cambell
Supplier Payment: by default bank account is selected to be the same as that used on the last payment for the supplier (if any, or default currency account otherwise).
M purchasing/includes/db/supp_trans_db.inc
Expand Down
18 changes: 18 additions & 0 deletions core/includes/main.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
23 changes: 19 additions & 4 deletions core/includes/page/header.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 5dbacd3

Please sign in to comment.