mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-25 12:21:26 +02:00
Add template fetch fallback using egw.link() if template_base_url fails
This commit is contained in:
parent
13941bb0e6
commit
be34f95723
@ -19,8 +19,9 @@
|
|||||||
* @param {string} _url
|
* @param {string} _url
|
||||||
* @param {function} _callback function(_xml)
|
* @param {function} _callback function(_xml)
|
||||||
* @param {object} _context for _callback
|
* @param {object} _context for _callback
|
||||||
|
* @param {function} _fail_callback function(_xml)
|
||||||
*/
|
*/
|
||||||
function et2_loadXMLFromURL(_url, _callback, _context)
|
function et2_loadXMLFromURL(_url, _callback, _context, _fail_callback)
|
||||||
{
|
{
|
||||||
if (typeof _context == "undefined")
|
if (typeof _context == "undefined")
|
||||||
{
|
{
|
||||||
@ -52,6 +53,10 @@ function et2_loadXMLFromURL(_url, _callback, _context)
|
|||||||
},
|
},
|
||||||
error: function(_xmlhttp, _err) {
|
error: function(_xmlhttp, _err) {
|
||||||
egw().debug('error', 'Loading eTemplate from '+_url+' failed! '+_xmlhttp.status+' '+_xmlhttp.statusText);
|
egw().debug('error', 'Loading eTemplate from '+_url+' failed! '+_xmlhttp.status+' '+_xmlhttp.statusText);
|
||||||
|
if(typeof _fail_callback !== 'undefined')
|
||||||
|
{
|
||||||
|
_fail_callback.call(_context, _err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -117,8 +117,9 @@ var et2_template = (function(){ "use strict"; return et2_DOMWidget.extend(
|
|||||||
if (!this.options.url)
|
if (!this.options.url)
|
||||||
{
|
{
|
||||||
var splitted = template_name.split('.');
|
var splitted = template_name.split('.');
|
||||||
|
var app = splitted.shift();
|
||||||
// use template base url from initial template, to continue using webdav, if that was loaded via webdav
|
// use template base url from initial template, to continue using webdav, if that was loaded via webdav
|
||||||
url = this.getRoot()._inst.template_base_url + splitted.shift() + "/templates/default/" +
|
url = this.getRoot()._inst.template_base_url + app + "/templates/default/" +
|
||||||
splitted.join('.')+ ".xet" + (cache_buster ? '?download='+cache_buster : '');
|
splitted.join('.')+ ".xet" + (cache_buster ? '?download='+cache_buster : '');
|
||||||
}
|
}
|
||||||
// if server did not give a cache-buster, fall back to current time
|
// if server did not give a cache-buster, fall back to current time
|
||||||
@ -126,7 +127,7 @@ var et2_template = (function(){ "use strict"; return et2_DOMWidget.extend(
|
|||||||
|
|
||||||
if(this.options.url || splitted.length)
|
if(this.options.url || splitted.length)
|
||||||
{
|
{
|
||||||
et2_loadXMLFromURL(url, function(_xmldoc) {
|
var fetch_url_callback = function(_xmldoc) {
|
||||||
// Scan for templates and store them
|
// Scan for templates and store them
|
||||||
for(var i = 0; i < _xmldoc.childNodes.length; i++) {
|
for(var i = 0; i < _xmldoc.childNodes.length; i++) {
|
||||||
var template = _xmldoc.childNodes[i];
|
var template = _xmldoc.childNodes[i];
|
||||||
@ -140,7 +141,14 @@ var et2_template = (function(){ "use strict"; return et2_DOMWidget.extend(
|
|||||||
// Update flag
|
// Update flag
|
||||||
this.loading.resolve();
|
this.loading.resolve();
|
||||||
|
|
||||||
}, this);
|
}
|
||||||
|
|
||||||
|
et2_loadXMLFromURL(url, fetch_url_callback, this, function( error) {
|
||||||
|
url = egw.link('/'+ app + "/templates/default/" +
|
||||||
|
splitted.join('.')+ ".xet", {download:cache_buster? cache_buster :(new Date).valueOf()});
|
||||||
|
|
||||||
|
et2_loadXMLFromURL(url, fetch_url_callback, this);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user