mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 16:44:20 +01:00
Cachebuster for category CSS
This commit is contained in:
parent
2ce94499c0
commit
d3530c4899
@ -153,7 +153,39 @@ class admin_categories
|
||||
// to reload the whole nextmatch instead of just the row
|
||||
$data = $cats->id2name($content['id'],'data');
|
||||
$change_color = ($data['color'] != $content['data']['color']);
|
||||
|
||||
// Nicely reload just the category window / iframe
|
||||
if($change_color)
|
||||
{
|
||||
if(egw_json_response::isJSONResponse())
|
||||
{
|
||||
// Update category styles
|
||||
egw_json_response::get()->apply('opener.egw.includeCSS',array(categories::css($refresh_app == 'admin' ? categories::GLOBAL_APPNAME : $refresh_app)));
|
||||
if($this->appname != 'admin')
|
||||
{
|
||||
egw_json_response::get()->apply('opener.egw.show_preferences',array(
|
||||
'cats',
|
||||
$this->appname == 'admin' ? categories::GLOBAL_APPNAME : array($refresh_app)
|
||||
));
|
||||
$change_color = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
categories::css($refresh_app == 'admin' ? categories::GLOBAL_APPNAME : $refresh_app);
|
||||
egw_json_response::get()->apply('opener.app.admin.load',array(
|
||||
egw_framework::link('/index.php', array(
|
||||
'menuaction' => $this->list_link,
|
||||
'appname' => $appname
|
||||
)
|
||||
)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
categories::css($refresh_app == 'admin' ? categories::GLOBAL_APPNAME : $refresh_app);
|
||||
egw_framework::refresh_opener('', null, null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
try {
|
||||
$cats->edit($content);
|
||||
$msg = lang('Category saved.');
|
||||
@ -177,7 +209,7 @@ class admin_categories
|
||||
}
|
||||
if ($button == 'save')
|
||||
{
|
||||
egw_framework::refresh_opener($msg, $refresh_app, $content['id'], $change_color ? 'edit' : 'update', $this->appname);
|
||||
egw_framework::refresh_opener($msg, $change_color ? null : $refresh_app, $change_color ? null : $content['id'], $change_color ? null : 'update', $this->appname);
|
||||
egw_framework::window_close();
|
||||
}
|
||||
break;
|
||||
@ -199,8 +231,7 @@ class admin_categories
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
egw_framework::refresh_opener($msg, $refresh_app, $content['id'], $change_color ? 'edit' : 'update', $this->appname);
|
||||
egw_framework::refresh_opener($msg, $change_color ? null : $refresh_app, $content['id'], $change_color ? null : 'update', $this->appname);
|
||||
}
|
||||
$content['msg'] = $msg;
|
||||
if(!$content['appname']) $content['appname'] = $appname;
|
||||
@ -396,11 +427,6 @@ class admin_categories
|
||||
$rows['appname'] = $query['appname'];
|
||||
$rows['edit_link'] = $this->edit_link;
|
||||
|
||||
// Send categories to make sure row colors stay up to date
|
||||
// We use update types to prevent nm from doing unneeded calls to get_rows()
|
||||
// TODO: figure out how to only send this if a category color has changed
|
||||
$rows['sel_options']['cat_id'] = etemplate_widget_menupopup::typeOptions('select-cat', ',,,'.$query['appname'].',0');
|
||||
|
||||
// disable access column for global categories
|
||||
if ($GLOBALS['egw_info']['flags']['currentapp'] == 'admin') $rows['no_access'] = true;
|
||||
|
||||
@ -574,7 +600,7 @@ class admin_categories
|
||||
if($tmpl instanceof etemplate_widget_template)
|
||||
{
|
||||
// Category styles
|
||||
egw_framework::includeCSS('/phpgwapi/categories.php?app='.$appname);
|
||||
categories::css($appname);
|
||||
}
|
||||
|
||||
$tmpl->exec($this->list_link,$content,$sel_options,$readonlys,array(
|
||||
|
@ -222,7 +222,7 @@ class etemplate_new extends etemplate_widget_template
|
||||
egw_framework::validate_file('.','app',$app,false);
|
||||
}
|
||||
// Category styles
|
||||
egw_framework::includeCSS('/phpgwapi/categories.php?app='.$app);
|
||||
categories::css($app);
|
||||
|
||||
// set action attribute for autocomplete form tag
|
||||
// as firefox complains on about:balnk action, thus we have to literaly submit the form to a blank html
|
||||
|
@ -1022,6 +1022,27 @@ class categories
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Have the framework include the CSS file
|
||||
*
|
||||
* We calculate the cachebuster timestamp from the last modified category in
|
||||
* the application.
|
||||
*
|
||||
* @param string appname
|
||||
*
|
||||
* @return Returns the URL, but you do not need to do anything with it.
|
||||
*/
|
||||
public static function css($appname)
|
||||
{
|
||||
$cats = new categories('',$appname);
|
||||
$last_mod = $cats->return_array('all',0,1,'','DESC','last_mod', $appname == self::GLOBAL_APPNAME);
|
||||
$time = count($last_mod) ? $last_mod[0]['last_mod'] : time();
|
||||
$path = '/phpgwapi/categories.php?app='.$appname.'&'.$time;
|
||||
egw_framework::includeCSS($path);
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete categories belonging to a given account, when account got deleted
|
||||
*
|
||||
|
@ -302,7 +302,6 @@ abstract class egw_framework
|
||||
|
||||
// allways load jquery (not -ui) and egw_json first
|
||||
'/phpgwapi/js/jquery/jquery.js',
|
||||
'/phpgwapi/js/./egw_json.js',
|
||||
// always include javascript helper functions
|
||||
'/phpgwapi/js/jsapi/jsapi.js',
|
||||
'/phpgwapi/js/jsapi/egw.js',
|
||||
@ -1390,7 +1389,7 @@ abstract class egw_framework
|
||||
self::includeCSS('/etemplate/templates/default/etemplate2.css');
|
||||
|
||||
// Category styles
|
||||
self::includeCSS('/phpgwapi/categories.php');
|
||||
categories::css(categories::GLOBAL_APPNAME);
|
||||
|
||||
// For mobile user-agent we prefer mobile theme over selected one with a final fallback to theme named as template
|
||||
$themes_to_check = array();
|
||||
@ -2296,7 +2295,7 @@ abstract class egw_framework
|
||||
{
|
||||
unset($query);
|
||||
list($path,$query) = explode('?',$path,2);
|
||||
$path .= '?'. filemtime(EGW_SERVER_ROOT.$path).($query ? '&'.$query : '');
|
||||
$path .= '?'. ($query ? $query : filemtime(EGW_SERVER_ROOT.$path));
|
||||
$response->includeCSS($GLOBALS['egw_info']['server']['webserver_url'].$path);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user