From 73d87edc76e0bdba8a1249d339bf28a078336c6c Mon Sep 17 00:00:00 2001 From: Leo Feyer Date: Thu, 26 Sep 2013 17:20:25 +0200 Subject: [PATCH] Send an "X-Ajax-Location" header to redirect upon Ajax requests (see #5647) --- assets/contao/js/core-uncompressed.js | 8 +- assets/contao/js/core.js | 2 +- assets/mootools/mootao/Mootao-uncompressed.js | 8 +- assets/mootools/mootao/Mootao.js | 2 +- system/docs/CHANGELOG.md | 3 + system/initialize.php | 3 +- system/modules/core/classes/BackendUser.php | 7 -- .../core/library/Contao/Controller.php | 76 ++++++++++--------- .../core/library/Contao/Environment.php | 11 +++ 9 files changed, 69 insertions(+), 51 deletions(-) diff --git a/assets/contao/js/core-uncompressed.js b/assets/contao/js/core-uncompressed.js index 715bae7f2c..f1917a1a46 100644 --- a/assets/contao/js/core-uncompressed.js +++ b/assets/contao/js/core-uncompressed.js @@ -512,10 +512,10 @@ var AjaxRequest = // Send request if (publish) { image.src = image.src.replace('invisible.gif', 'visible.gif'); - new Request({'url':window.location.href}).get({'tid':id, 'state':1}); + new Request.Contao({'url':window.location.href}).get({'tid':id, 'state':1}); } else { image.src = image.src.replace('visible.gif', 'invisible.gif'); - new Request({'url':window.location.href}).get({'tid':id, 'state':0}); + new Request.Contao({'url':window.location.href}).get({'tid':id, 'state':0}); } return false; @@ -1184,13 +1184,13 @@ var Backend = pid = el.getPrevious('li').get('id').replace(/li_/, ''), req = window.location.search.replace(/id=[0-9]*/, 'id=' + id) + '&act=cut&mode=1&pid=' + pid, href = window.location.href.replace(/\?.*$/, ''); - new Request({'url':href+req}).get(); + new Request.Contao({'url':href+req}).get(); } else if (el.getParent('ul')) { var id = el.get('id').replace(/li_/, ''), pid = el.getParent('ul').get('id').replace(/ul_/, ''), req = window.location.search.replace(/id=[0-9]*/, 'id=' + id) + '&act=cut&mode=2&pid=' + pid, href = window.location.href.replace(/\?.*$/, ''); - new Request({'url':href+req}).get(); + new Request.Contao({'url':href+req}).get(); } }); }, diff --git a/assets/contao/js/core.js b/assets/contao/js/core.js index 9870a9e763..9fe59d372c 100644 --- a/assets/contao/js/core.js +++ b/assets/contao/js/core.js @@ -1,2 +1,2 @@ /* Contao Open Source CMS, (c) 2005-2013 Leo Feyer, LGPL license */ -var AjaxRequest={toggleNavigation:function(e,t){e.blur();var n=$(t),r=$(e).getFirst("img");return n?(n.getStyle("display")=="none"?(n.setStyle("display","inline"),r.src=r.src.replace("modPlus.gif","modMinus.gif"),$(e).store("tip:title",Contao.lang.collapse),(new Request.Contao).post({action:"toggleNavigation",id:t,state:1,REQUEST_TOKEN:Contao.request_token})):(n.setStyle("display","none"),r.src=r.src.replace("modMinus.gif","modPlus.gif"),$(e).store("tip:title",Contao.lang.expand),(new Request.Contao).post({action:"toggleNavigation",id:t,state:0,REQUEST_TOKEN:Contao.request_token})),!1):((new Request.Contao({evalScripts:!0,onRequest:AjaxRequest.displayBox(Contao.lang.loading+" …"),onSuccess:function(n,i){var s=(new Element("li",{id:t,"class":"tl_parent",html:n,styles:{display:"inline"}})).inject($(e).getParent("li"),"after");s.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(e).store("tip:title",Contao.lang.collapse),r.src=r.src.replace("modPlus.gif","modMinus.gif"),AjaxRequest.hideBox(),window.fireEvent("ajax_change")}})).post({action:"loadNavigation",id:t,state:1,REQUEST_TOKEN:Contao.request_token}),!1)},toggleStructure:function(e,t,n,r){e.blur();var i=$(t),s=$(e).getFirst("img");return i?(i.getStyle("display")=="none"?(i.setStyle("display","inline"),s.src=s.src.replace("folPlus.gif","folMinus.gif"),$(e).store("tip:title",Contao.lang.collapse),(new Request.Contao({field:e})).post({action:"toggleStructure",id:t,state:1,REQUEST_TOKEN:Contao.request_token})):(i.setStyle("display","none"),s.src=s.src.replace("folMinus.gif","folPlus.gif"),$(e).store("tip:title",Contao.lang.expand),(new Request.Contao({field:e})).post({action:"toggleStructure",id:t,state:0,REQUEST_TOKEN:Contao.request_token})),!1):((new Request.Contao({field:e,evalScripts:!0,onRequest:AjaxRequest.displayBox(Contao.lang.loading+" …"),onSuccess:function(i,o){var u=new Element("li",{id:t,"class":"parent",styles:{display:"inline"}}),a=(new Element("ul",{"class":"level_"+n,html:i})).inject(u,"bottom");if(r==5)u.inject($(e).getParent("li"),"after");else{var f=!1,l=$(e).getParent("li");while(typeOf(l)=="element"&&(next=l.getNext("li"))){l=next;if(l.hasClass("tl_folder")){f=!0;break}}f?u.inject(l,"before"):u.inject(l,"after")}u.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(e).store("tip:title",Contao.lang.collapse),s.src=s.src.replace("folPlus.gif","folMinus.gif"),window.fireEvent("structure"),AjaxRequest.hideBox(),window.fireEvent("ajax_change")}})).post({action:"loadStructure",id:t,level:n,state:1,REQUEST_TOKEN:Contao.request_token}),!1)},toggleFileManager:function(e,t,n,r){e.blur();var i=$(t),s=$(e).getFirst("img"),o=$(e).getNext("img");return i?(i.getStyle("display")=="none"?(i.setStyle("display","inline"),s.src=s.src.replace("folPlus.gif","folMinus.gif"),o.src=o.src.replace("folderC","folderO"),$(e).store("tip:title",Contao.lang.collapse),(new Request.Contao({field:e})).post({action:"toggleFileManager",id:t,state:1,REQUEST_TOKEN:Contao.request_token})):(i.setStyle("display","none"),s.src=s.src.replace("folMinus.gif","folPlus.gif"),o.src=o.src.replace("folderO","folderC"),$(e).store("tip:title",Contao.lang.expand),(new Request.Contao({field:e})).post({action:"toggleFileManager",id:t,state:0,REQUEST_TOKEN:Contao.request_token})),!1):((new Request.Contao({field:e,evalScripts:!0,onRequest:AjaxRequest.displayBox(Contao.lang.loading+" …"),onSuccess:function(n,i){var u=new Element("li",{id:t,"class":"parent",styles:{display:"inline"}}),a=(new Element("ul",{"class":"level_"+r,html:n})).inject(u,"bottom");u.inject($(e).getParent("li"),"after"),u.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(e).store("tip:title",Contao.lang.collapse),s.src=s.src.replace("folPlus.gif","folMinus.gif"),o.src=o.src.replace("folderC.gif","folderO.gif"),AjaxRequest.hideBox(),window.fireEvent("ajax_change")}})).post({action:"loadFileManager",id:t,level:r,folder:n,state:1,REQUEST_TOKEN:Contao.request_token}),!1)},togglePagetree:function(e,t,n,r,i){e.blur(),Backend.getScrollOffset();var s=$(t),o=$(e).getFirst("img");return s?(s.getStyle("display")=="none"?(s.setStyle("display","inline"),o.src=o.src.replace("folPlus.gif","folMinus.gif"),$(e).store("tip:title",Contao.lang.collapse),(new Request.Contao({field:e})).post({action:"togglePagetree",id:t,state:1,REQUEST_TOKEN:Contao.request_token})):(s.setStyle("display","none"),o.src=o.src.replace("folMinus.gif","folPlus.gif"),$(e).store("tip:title",Contao.lang.expand),(new Request.Contao({field:e})).post({action:"togglePagetree",id:t,state:0,REQUEST_TOKEN:Contao.request_token})),!1):((new Request.Contao({field:e,evalScripts:!0,onRequest:AjaxRequest.displayBox(Contao.lang.loading+" …"),onSuccess:function(n,r){var s=new Element("li",{id:t,"class":"parent",styles:{display:"inline"}}),u=(new Element("ul",{"class":"level_"+i,html:n})).inject(s,"bottom");s.inject($(e).getParent("li"),"after"),s.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(e).store("tip:title",Contao.lang.collapse),o.src=o.src.replace("folPlus.gif","folMinus.gif"),AjaxRequest.hideBox(),window.fireEvent("ajax_change")}})).post({action:"loadPagetree",id:t,level:i,field:n,name:r,state:1,REQUEST_TOKEN:Contao.request_token}),!1)},toggleFiletree:function(e,t,n,r,i,s){e.blur(),Backend.getScrollOffset();var o=$(t),u=$(e).getFirst("img");return o?(o.getStyle("display")=="none"?(o.setStyle("display","inline"),u.src=u.src.replace("folPlus.gif","folMinus.gif"),$(e).store("tip:title",Contao.lang.collapse),(new Request.Contao({field:e})).post({action:"toggleFiletree",id:t,state:1,REQUEST_TOKEN:Contao.request_token})):(o.setStyle("display","none"),u.src=u.src.replace("folMinus.gif","folPlus.gif"),$(e).store("tip:title",Contao.lang.expand),(new Request.Contao({field:e})).post({action:"toggleFiletree",id:t,state:0,REQUEST_TOKEN:Contao.request_token})),!1):((new Request.Contao({field:e,evalScripts:!0,onRequest:AjaxRequest.displayBox(Contao.lang.loading+" …"),onSuccess:function(n,r){var i=new Element("li",{id:t,"class":"parent",styles:{display:"inline"}}),o=(new Element("ul",{"class":"level_"+s,html:n})).inject(i,"bottom");i.inject($(e).getParent("li"),"after"),i.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(e).store("tip:title",Contao.lang.collapse),u.src=u.src.replace("folPlus.gif","folMinus.gif"),AjaxRequest.hideBox(),window.fireEvent("ajax_change")}})).post({action:"loadFiletree",id:t,folder:n,level:s,field:r,name:i,state:1,REQUEST_TOKEN:Contao.request_token}),!1)},toggleSubpalette:function(e,t,n){e.blur();var r=$(t);if(r){e.value?(e.value="",e.checked="",r.setStyle("display","none"),(new Request.Contao({field:e})).post({action:"toggleSubpalette",id:t,field:n,state:0,REQUEST_TOKEN:Contao.request_token})):(e.value=1,e.checked="checked",r.setStyle("display","block"),(new Request.Contao({field:e})).post({action:"toggleSubpalette",id:t,field:n,state:1,REQUEST_TOKEN:Contao.request_token}));return}(new Request.Contao({field:e,evalScripts:!1,onRequest:AjaxRequest.displayBox(Contao.lang.loading+" …"),onSuccess:function(n,r){var i=(new Element("div",{id:t,html:n,styles:{display:"block"}})).inject($(e).getParent("div").getParent("div"),"after");r.javascript&&Browser.exec(r.javascript),e.value=1,e.checked="checked",i.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),AjaxRequest.hideBox(),Backend.addColorPicker(),window.fireEvent("subpalette"),window.fireEvent("ajax_change")}})).post({action:"toggleSubpalette",id:t,field:n,load:1,state:1,REQUEST_TOKEN:Contao.request_token})},toggleVisibility:function(e,t,n){e.blur();var r=null,i=$(e).getFirst("img"),s=i.src.indexOf("invisible")!=-1,o=e.getParent("div");o.hasClass("tl_right")?r=o.getPrevious("div").getElement("img"):o.hasClass("tl_listing_container")?(r=e.getParent("td").getPrevious("td").getFirst("div.list_icon"),r==null&&(r=e.getParent("td").getPrevious("td").getElement("div.cte_type")),r==null&&(r=e.getParent("tr").getFirst("td").getElement("div.list_icon_new"))):(next=o.getNext("div"))&&next.hasClass("cte_type")&&(r=next);if(r!=null)if(r.nodeName.toLowerCase()=="img")if(r.getParent("ul.tl_listing").hasClass("tl_tree_xtnd"))s?r.src=r.src.replace(/_\.(gif|png|jpe?g)/,".$1"):r.src=r.src.replace(/\.(gif|png|jpe?g)/,"_.$1");else{r.src.match(/folPlus|folMinus/)&&(r.getParent("a").getNext("a")?r=r.getParent("a").getNext("a").getFirst("img"):r=new Element("img"));if(s){var u=r.src.replace(/.*_([0-9])\.(gif|png|jpe?g)/,"$1");r.src=r.src.replace(/_[0-9]\.(gif|png|jpe?g)/,(u.toInt()==1?"":"_"+(u.toInt()-1))+".$1")}else{var u=r.src.replace(/.*_([0-9])\.(gif|png|jpe?g)/,"$1");r.src=r.src.replace(/(_[0-9])?\.(gif|png|jpe?g)/,(u==r.src?"_1":"_"+(u.toInt()+1))+".$2")}}else r.hasClass("cte_type")?s?(r.addClass("published"),r.removeClass("unpublished")):(r.addClass("unpublished"),r.removeClass("published")):s?r.setStyle("background-image",r.getStyle("background-image").replace(/_\.(gif|png|jpe?g)/,".$1")):r.setStyle("background-image",r.getStyle("background-image").replace(/\.(gif|png|jpe?g)/,"_.$1"));return n=="tl_style"&&o.getParent("div").getElement("pre").toggleClass("disabled"),s?(i.src=i.src.replace("invisible.gif","visible.gif"),(new Request({url:window.location.href})).get({tid:t,state:1})):(i.src=i.src.replace("visible.gif","invisible.gif"),(new Request({url:window.location.href})).get({tid:t,state:0})),!1},toggleFeatured:function(e,t){e.blur();var n=$(e).getFirst("img"),r=n.src.indexOf("featured_")==-1;return r?(n.src=n.src.replace("featured.gif","featured_.gif"),(new Request.Contao).post({action:"toggleFeatured",id:t,state:0,REQUEST_TOKEN:Contao.request_token})):(n.src=n.src.replace("featured_.gif","featured.gif"),(new Request.Contao).post({action:"toggleFeatured",id:t,state:1,REQUEST_TOKEN:Contao.request_token})),!1},toggleFieldset:function(e,t,n){e.blur();var r=$("pal_"+t);return r.hasClass("collapsed")?(r.removeClass("collapsed"),(new Request.Contao).post({action:"toggleFieldset",id:t,table:n,state:1,REQUEST_TOKEN:Contao.request_token})):(r.addClass("collapsed"),(new Request.Contao).post({action:"toggleFieldset",id:t,table:n,state:0,REQUEST_TOKEN:Contao.request_token})),!1},toggleCheckboxGroup:function(e,t){e.blur();var n=$(t),r=$(e).getFirst("img");return n?(n.getStyle("display")!="block"?(n.setStyle("display","block"),r.src=r.src.replace("folPlus.gif","folMinus.gif"),(new Request.Contao).post({action:"toggleCheckboxGroup",id:t,state:1,REQUEST_TOKEN:Contao.request_token})):(n.setStyle("display","none"),r.src=r.src.replace("folMinus.gif","folPlus.gif"),(new Request.Contao).post({action:"toggleCheckboxGroup",id:t,state:0,REQUEST_TOKEN:Contao.request_token})),!0):!1},liveUpdate:function(e,t){var n=$(t);if(!n)return;(new Request.Contao({onRequest:$("lu_message").set("html",'

Connecting to the Live Update server

'),onSuccess:function(t,n){t?$("lu_message").set("html",n.content):$(e).submit()}})).post({action:"liveUpdate",id:n.value,REQUEST_TOKEN:Contao.request_token})},displayBox:function(e){var t=$("tl_ajaxBox"),n=$("tl_ajaxOverlay"),r=window.getScroll();n==null&&(n=(new Element("div",{id:"tl_ajaxOverlay"})).inject($(document.body),"bottom")),n.set({styles:{display:"block",top:r.y+"px"}}),t==null&&(t=(new Element("div",{id:"tl_ajaxBox"})).inject($(document.body),"bottom")),t.set({html:e,styles:{display:"block",top:r.y+100+"px"}})},hideBox:function(){var e=$("tl_ajaxBox"),t=$("tl_ajaxOverlay");t&&t.setStyle("display","none"),e&&e.setStyle("display","none")}},Backend={currentId:null,xMousePosition:0,yMousePosition:0,popupWindow:null,getMousePosition:function(e){Backend.xMousePosition=e.client.x,Backend.yMousePosition=e.client.y},openWindow:function(e,t,n){e.blur(),t=Browser.ie?t+40:t+17,n=Browser.ie?n+30:n+17,Backend.popupWindow=window.open(e.href,"","width="+t+",height="+n+",modal=yes,left=100,top=50,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no")},openModalWindow:function(e,t,n){(new SimpleModal({width:e,hideFooter:!0,draggable:!1,overlayOpacity:.5,onShow:function(){document.body.setStyle("overflow","hidden")},onHide:function(){document.body.setStyle("overflow","auto")}})).show({title:t,contents:n})},openModalImage:function(e){var t=e||{},n=new SimpleModal({width:t.width,hideFooter:!0,draggable:!1,overlayOpacity:.5,onShow:function(){document.body.setStyle("overflow","hidden")},onHide:function(){document.body.setStyle("overflow","auto")}});n.show({title:t.title,contents:''})},openModalIframe:function(e){var t=e||{},n=(window.getSize().y-180).toInt();if(!t.height||t.height>n)t.height=n;var r=new SimpleModal({width:t.width,hideFooter:!0,draggable:!1,overlayOpacity:.5,onShow:function(){document.body.setStyle("overflow","hidden")},onHide:function(){document.body.setStyle("overflow","auto")}});r.show({title:t.title,contents:''})},openModalSelector:function(e){var t=e||{},n=(window.getSize().y-180).toInt();if(!t.height||t.height>n)t.height=n;var r=new SimpleModal({width:t.width,btn_ok:Contao.lang.close,draggable:!1,overlayOpacity:.5,onShow:function(){document.body.setStyle("overflow","hidden")},onHide:function(){document.body.setStyle("overflow","auto")}});r.addButton(Contao.lang.close,"btn",function(){this.hide()}),r.addButton(Contao.lang.apply,"btn primary",function(){var e=[],n=null,r=window.frames;for(var i=0;i',model:"modal"})},getScrollOffset:function(){document.cookie="BE_PAGE_OFFSET="+window.getScroll().y+"; path="+(Contao.path||"/")},autoSubmit:function(e){Backend.getScrollOffset();var t=new Element("input",{type:"hidden",name:"SUBMIT_TYPE",value:"auto"}),n=$(e)||e;t.inject(n,"bottom"),n.submit()},vScrollTo:function(e){window.addEvent("load",function(){window.scrollTo(null,parseInt(e))})},limitPreviewHeight:function(){var e=null,t=null,n="",r=0;$$("div.limit_height").each(function(i){e=i.getCoordinates(),r===0&&(r=i.className.replace(/[^0-9]*/,"").toInt());if(!r)return;i.setStyle("height",r);var s=Contao.script_url+"system/themes/"+Contao.theme+"/images/";t=new Element("img",{"class":"limit_toggler",alt:"",title:Contao.lang.expand,width:20,height:24}),new Tips.Contao(t,{offset:{x:0,y:30}});if(e.heightr?r:""),this.src.indexOf("expand.gif")!=-1?(this.src=s+"collapse.gif",this.store("tip:title",Contao.lang.collapse)):(this.src=s+"expand.gif",this.store("tip:title",Contao.lang.expand))}),t.inject(i,"after")})},toggleCheckboxes:function(e,t){var n=$$("input"),r=e.checked?"checked":"";for(var i=0;i1?i.destroy():i.getFirst("input").set("value","")}l=r.getChildren();for(c=0;c1?u.destroy():u.getElements("textarea").set("text","");break;case"ccopy":for(d=0;d0)for(d=0;d2){for(d=0;d1&&s.destroy()}o=i.getChildren();for(h=0;h1&&s.destroy()}o=i.getChildren();for(l=0;l1&&s.destroy()}o=i.getChildren();for(l=0;l0?(t.getElement("a.module_link").setStyle("display","inline"),t.getElement("img.module_image").setStyle("display","none")):(t.getElement("a.module_link").setStyle("display","none"),t.getElement("img.module_image").setStyle("display","inline"))},convertEnableModules:function(){$$("img.mw_enable").each(function(e){e.addEvent("click",function(){Backend.getScrollOffset();var t=e.getNext("input");t.checked?(t.checked="",e.src=e.src.replace("visible.gif","invisible.gif")):(t.checked="checked",e.src=e.src.replace("invisible.gif","visible.gif"))})})}};document.addEvent("mousedown",function(e){Backend.getMousePosition(e)}),window.addEvent("domready",function(){$(document.body).addClass("js"),Browser.Features.Touch&&$(document.body).addClass("touch"),Backend.collapsePalettes(),Backend.addInteractiveHelp(),Backend.addColorPicker(),Backend.convertEnableModules(),Backend.makeWizardsSortable(),Elements.chosen!=undefined&&$$("select.tl_chosen").chosen(),$$("textarea.monospace").each(function(e){Backend.toggleWrap(e)})}),window.addEvent("load",function(){Backend.limitPreviewHeight()}),window.addEvent("ajax_change",function(){Backend.addInteractiveHelp(),Backend.makeWizardsSortable(),Elements.chosen!=undefined&&$$("select.tl_chosen").filter(function(e){return e.getStyle("display")!="none"}).chosen()}),Browser.Features.Touch&&function(){delete Element.NativeEvents.mousedown,Element.defineCustomEvent("mousedown",{base:"touchstart"}),delete Element.NativeEvents.mousemove,Element.defineCustomEvent("mousemove",{base:"touchmove"}),delete Element.NativeEvents.mouseup,Element.defineCustomEvent("mouseup",{base:"touchend"})}();var TinyCallback={getScrollOffset:function(e){tinymce.dom.Event.add(tinymce.isGecko?e.getDoc():e.getWin(),"focus",function(){Backend.getScrollOffset()})},fileBrowser:function(e,t,n,r){var i=new SimpleModal({width:765,btn_ok:Contao.lang.close,draggable:!1,overlayOpacity:.5,onShow:function(){document.body.setStyle("overflow","hidden")},onHide:function(){document.body.setStyle("overflow","auto")}});i.addButton(Contao.lang.close,"btn",function(){this.hide()}),i.addButton(Contao.lang.apply,"btn primary",function(){var t=window.frames,i,s,o;for(var u=0;u'}}this.hide()}),i.show({title:r.document.title,contents:'',model:"modal"})}}; \ No newline at end of file +var AjaxRequest={toggleNavigation:function(e,t){e.blur();var n=$(t),r=$(e).getFirst("img");return n?(n.getStyle("display")=="none"?(n.setStyle("display","inline"),r.src=r.src.replace("modPlus.gif","modMinus.gif"),$(e).store("tip:title",Contao.lang.collapse),(new Request.Contao).post({action:"toggleNavigation",id:t,state:1,REQUEST_TOKEN:Contao.request_token})):(n.setStyle("display","none"),r.src=r.src.replace("modMinus.gif","modPlus.gif"),$(e).store("tip:title",Contao.lang.expand),(new Request.Contao).post({action:"toggleNavigation",id:t,state:0,REQUEST_TOKEN:Contao.request_token})),!1):((new Request.Contao({evalScripts:!0,onRequest:AjaxRequest.displayBox(Contao.lang.loading+" …"),onSuccess:function(n,i){var s=(new Element("li",{id:t,"class":"tl_parent",html:n,styles:{display:"inline"}})).inject($(e).getParent("li"),"after");s.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(e).store("tip:title",Contao.lang.collapse),r.src=r.src.replace("modPlus.gif","modMinus.gif"),AjaxRequest.hideBox(),window.fireEvent("ajax_change")}})).post({action:"loadNavigation",id:t,state:1,REQUEST_TOKEN:Contao.request_token}),!1)},toggleStructure:function(e,t,n,r){e.blur();var i=$(t),s=$(e).getFirst("img");return i?(i.getStyle("display")=="none"?(i.setStyle("display","inline"),s.src=s.src.replace("folPlus.gif","folMinus.gif"),$(e).store("tip:title",Contao.lang.collapse),(new Request.Contao({field:e})).post({action:"toggleStructure",id:t,state:1,REQUEST_TOKEN:Contao.request_token})):(i.setStyle("display","none"),s.src=s.src.replace("folMinus.gif","folPlus.gif"),$(e).store("tip:title",Contao.lang.expand),(new Request.Contao({field:e})).post({action:"toggleStructure",id:t,state:0,REQUEST_TOKEN:Contao.request_token})),!1):((new Request.Contao({field:e,evalScripts:!0,onRequest:AjaxRequest.displayBox(Contao.lang.loading+" …"),onSuccess:function(i,o){var u=new Element("li",{id:t,"class":"parent",styles:{display:"inline"}}),a=(new Element("ul",{"class":"level_"+n,html:i})).inject(u,"bottom");if(r==5)u.inject($(e).getParent("li"),"after");else{var f=!1,l=$(e).getParent("li");while(typeOf(l)=="element"&&(next=l.getNext("li"))){l=next;if(l.hasClass("tl_folder")){f=!0;break}}f?u.inject(l,"before"):u.inject(l,"after")}u.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(e).store("tip:title",Contao.lang.collapse),s.src=s.src.replace("folPlus.gif","folMinus.gif"),window.fireEvent("structure"),AjaxRequest.hideBox(),window.fireEvent("ajax_change")}})).post({action:"loadStructure",id:t,level:n,state:1,REQUEST_TOKEN:Contao.request_token}),!1)},toggleFileManager:function(e,t,n,r){e.blur();var i=$(t),s=$(e).getFirst("img"),o=$(e).getNext("img");return i?(i.getStyle("display")=="none"?(i.setStyle("display","inline"),s.src=s.src.replace("folPlus.gif","folMinus.gif"),o.src=o.src.replace("folderC","folderO"),$(e).store("tip:title",Contao.lang.collapse),(new Request.Contao({field:e})).post({action:"toggleFileManager",id:t,state:1,REQUEST_TOKEN:Contao.request_token})):(i.setStyle("display","none"),s.src=s.src.replace("folMinus.gif","folPlus.gif"),o.src=o.src.replace("folderO","folderC"),$(e).store("tip:title",Contao.lang.expand),(new Request.Contao({field:e})).post({action:"toggleFileManager",id:t,state:0,REQUEST_TOKEN:Contao.request_token})),!1):((new Request.Contao({field:e,evalScripts:!0,onRequest:AjaxRequest.displayBox(Contao.lang.loading+" …"),onSuccess:function(n,i){var u=new Element("li",{id:t,"class":"parent",styles:{display:"inline"}}),a=(new Element("ul",{"class":"level_"+r,html:n})).inject(u,"bottom");u.inject($(e).getParent("li"),"after"),u.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(e).store("tip:title",Contao.lang.collapse),s.src=s.src.replace("folPlus.gif","folMinus.gif"),o.src=o.src.replace("folderC.gif","folderO.gif"),AjaxRequest.hideBox(),window.fireEvent("ajax_change")}})).post({action:"loadFileManager",id:t,level:r,folder:n,state:1,REQUEST_TOKEN:Contao.request_token}),!1)},togglePagetree:function(e,t,n,r,i){e.blur(),Backend.getScrollOffset();var s=$(t),o=$(e).getFirst("img");return s?(s.getStyle("display")=="none"?(s.setStyle("display","inline"),o.src=o.src.replace("folPlus.gif","folMinus.gif"),$(e).store("tip:title",Contao.lang.collapse),(new Request.Contao({field:e})).post({action:"togglePagetree",id:t,state:1,REQUEST_TOKEN:Contao.request_token})):(s.setStyle("display","none"),o.src=o.src.replace("folMinus.gif","folPlus.gif"),$(e).store("tip:title",Contao.lang.expand),(new Request.Contao({field:e})).post({action:"togglePagetree",id:t,state:0,REQUEST_TOKEN:Contao.request_token})),!1):((new Request.Contao({field:e,evalScripts:!0,onRequest:AjaxRequest.displayBox(Contao.lang.loading+" …"),onSuccess:function(n,r){var s=new Element("li",{id:t,"class":"parent",styles:{display:"inline"}}),u=(new Element("ul",{"class":"level_"+i,html:n})).inject(s,"bottom");s.inject($(e).getParent("li"),"after"),s.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(e).store("tip:title",Contao.lang.collapse),o.src=o.src.replace("folPlus.gif","folMinus.gif"),AjaxRequest.hideBox(),window.fireEvent("ajax_change")}})).post({action:"loadPagetree",id:t,level:i,field:n,name:r,state:1,REQUEST_TOKEN:Contao.request_token}),!1)},toggleFiletree:function(e,t,n,r,i,s){e.blur(),Backend.getScrollOffset();var o=$(t),u=$(e).getFirst("img");return o?(o.getStyle("display")=="none"?(o.setStyle("display","inline"),u.src=u.src.replace("folPlus.gif","folMinus.gif"),$(e).store("tip:title",Contao.lang.collapse),(new Request.Contao({field:e})).post({action:"toggleFiletree",id:t,state:1,REQUEST_TOKEN:Contao.request_token})):(o.setStyle("display","none"),u.src=u.src.replace("folMinus.gif","folPlus.gif"),$(e).store("tip:title",Contao.lang.expand),(new Request.Contao({field:e})).post({action:"toggleFiletree",id:t,state:0,REQUEST_TOKEN:Contao.request_token})),!1):((new Request.Contao({field:e,evalScripts:!0,onRequest:AjaxRequest.displayBox(Contao.lang.loading+" …"),onSuccess:function(n,r){var i=new Element("li",{id:t,"class":"parent",styles:{display:"inline"}}),o=(new Element("ul",{"class":"level_"+s,html:n})).inject(i,"bottom");i.inject($(e).getParent("li"),"after"),i.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(e).store("tip:title",Contao.lang.collapse),u.src=u.src.replace("folPlus.gif","folMinus.gif"),AjaxRequest.hideBox(),window.fireEvent("ajax_change")}})).post({action:"loadFiletree",id:t,folder:n,level:s,field:r,name:i,state:1,REQUEST_TOKEN:Contao.request_token}),!1)},toggleSubpalette:function(e,t,n){e.blur();var r=$(t);if(r){e.value?(e.value="",e.checked="",r.setStyle("display","none"),(new Request.Contao({field:e})).post({action:"toggleSubpalette",id:t,field:n,state:0,REQUEST_TOKEN:Contao.request_token})):(e.value=1,e.checked="checked",r.setStyle("display","block"),(new Request.Contao({field:e})).post({action:"toggleSubpalette",id:t,field:n,state:1,REQUEST_TOKEN:Contao.request_token}));return}(new Request.Contao({field:e,evalScripts:!1,onRequest:AjaxRequest.displayBox(Contao.lang.loading+" …"),onSuccess:function(n,r){var i=(new Element("div",{id:t,html:n,styles:{display:"block"}})).inject($(e).getParent("div").getParent("div"),"after");r.javascript&&Browser.exec(r.javascript),e.value=1,e.checked="checked",i.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),AjaxRequest.hideBox(),Backend.addColorPicker(),window.fireEvent("subpalette"),window.fireEvent("ajax_change")}})).post({action:"toggleSubpalette",id:t,field:n,load:1,state:1,REQUEST_TOKEN:Contao.request_token})},toggleVisibility:function(e,t,n){e.blur();var r=null,i=$(e).getFirst("img"),s=i.src.indexOf("invisible")!=-1,o=e.getParent("div");o.hasClass("tl_right")?r=o.getPrevious("div").getElement("img"):o.hasClass("tl_listing_container")?(r=e.getParent("td").getPrevious("td").getFirst("div.list_icon"),r==null&&(r=e.getParent("td").getPrevious("td").getElement("div.cte_type")),r==null&&(r=e.getParent("tr").getFirst("td").getElement("div.list_icon_new"))):(next=o.getNext("div"))&&next.hasClass("cte_type")&&(r=next);if(r!=null)if(r.nodeName.toLowerCase()=="img")if(r.getParent("ul.tl_listing").hasClass("tl_tree_xtnd"))s?r.src=r.src.replace(/_\.(gif|png|jpe?g)/,".$1"):r.src=r.src.replace(/\.(gif|png|jpe?g)/,"_.$1");else{r.src.match(/folPlus|folMinus/)&&(r.getParent("a").getNext("a")?r=r.getParent("a").getNext("a").getFirst("img"):r=new Element("img"));if(s){var u=r.src.replace(/.*_([0-9])\.(gif|png|jpe?g)/,"$1");r.src=r.src.replace(/_[0-9]\.(gif|png|jpe?g)/,(u.toInt()==1?"":"_"+(u.toInt()-1))+".$1")}else{var u=r.src.replace(/.*_([0-9])\.(gif|png|jpe?g)/,"$1");r.src=r.src.replace(/(_[0-9])?\.(gif|png|jpe?g)/,(u==r.src?"_1":"_"+(u.toInt()+1))+".$2")}}else r.hasClass("cte_type")?s?(r.addClass("published"),r.removeClass("unpublished")):(r.addClass("unpublished"),r.removeClass("published")):s?r.setStyle("background-image",r.getStyle("background-image").replace(/_\.(gif|png|jpe?g)/,".$1")):r.setStyle("background-image",r.getStyle("background-image").replace(/\.(gif|png|jpe?g)/,"_.$1"));return n=="tl_style"&&o.getParent("div").getElement("pre").toggleClass("disabled"),s?(i.src=i.src.replace("invisible.gif","visible.gif"),(new Request.Contao({url:window.location.href})).get({tid:t,state:1})):(i.src=i.src.replace("visible.gif","invisible.gif"),(new Request.Contao({url:window.location.href})).get({tid:t,state:0})),!1},toggleFeatured:function(e,t){e.blur();var n=$(e).getFirst("img"),r=n.src.indexOf("featured_")==-1;return r?(n.src=n.src.replace("featured.gif","featured_.gif"),(new Request.Contao).post({action:"toggleFeatured",id:t,state:0,REQUEST_TOKEN:Contao.request_token})):(n.src=n.src.replace("featured_.gif","featured.gif"),(new Request.Contao).post({action:"toggleFeatured",id:t,state:1,REQUEST_TOKEN:Contao.request_token})),!1},toggleFieldset:function(e,t,n){e.blur();var r=$("pal_"+t);return r.hasClass("collapsed")?(r.removeClass("collapsed"),(new Request.Contao).post({action:"toggleFieldset",id:t,table:n,state:1,REQUEST_TOKEN:Contao.request_token})):(r.addClass("collapsed"),(new Request.Contao).post({action:"toggleFieldset",id:t,table:n,state:0,REQUEST_TOKEN:Contao.request_token})),!1},toggleCheckboxGroup:function(e,t){e.blur();var n=$(t),r=$(e).getFirst("img");return n?(n.getStyle("display")!="block"?(n.setStyle("display","block"),r.src=r.src.replace("folPlus.gif","folMinus.gif"),(new Request.Contao).post({action:"toggleCheckboxGroup",id:t,state:1,REQUEST_TOKEN:Contao.request_token})):(n.setStyle("display","none"),r.src=r.src.replace("folMinus.gif","folPlus.gif"),(new Request.Contao).post({action:"toggleCheckboxGroup",id:t,state:0,REQUEST_TOKEN:Contao.request_token})),!0):!1},liveUpdate:function(e,t){var n=$(t);if(!n)return;(new Request.Contao({onRequest:$("lu_message").set("html",'

Connecting to the Live Update server

'),onSuccess:function(t,n){t?$("lu_message").set("html",n.content):$(e).submit()}})).post({action:"liveUpdate",id:n.value,REQUEST_TOKEN:Contao.request_token})},displayBox:function(e){var t=$("tl_ajaxBox"),n=$("tl_ajaxOverlay"),r=window.getScroll();n==null&&(n=(new Element("div",{id:"tl_ajaxOverlay"})).inject($(document.body),"bottom")),n.set({styles:{display:"block",top:r.y+"px"}}),t==null&&(t=(new Element("div",{id:"tl_ajaxBox"})).inject($(document.body),"bottom")),t.set({html:e,styles:{display:"block",top:r.y+100+"px"}})},hideBox:function(){var e=$("tl_ajaxBox"),t=$("tl_ajaxOverlay");t&&t.setStyle("display","none"),e&&e.setStyle("display","none")}},Backend={currentId:null,xMousePosition:0,yMousePosition:0,popupWindow:null,getMousePosition:function(e){Backend.xMousePosition=e.client.x,Backend.yMousePosition=e.client.y},openWindow:function(e,t,n){e.blur(),t=Browser.ie?t+40:t+17,n=Browser.ie?n+30:n+17,Backend.popupWindow=window.open(e.href,"","width="+t+",height="+n+",modal=yes,left=100,top=50,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no")},openModalWindow:function(e,t,n){(new SimpleModal({width:e,hideFooter:!0,draggable:!1,overlayOpacity:.5,onShow:function(){document.body.setStyle("overflow","hidden")},onHide:function(){document.body.setStyle("overflow","auto")}})).show({title:t,contents:n})},openModalImage:function(e){var t=e||{},n=new SimpleModal({width:t.width,hideFooter:!0,draggable:!1,overlayOpacity:.5,onShow:function(){document.body.setStyle("overflow","hidden")},onHide:function(){document.body.setStyle("overflow","auto")}});n.show({title:t.title,contents:''})},openModalIframe:function(e){var t=e||{},n=(window.getSize().y-180).toInt();if(!t.height||t.height>n)t.height=n;var r=new SimpleModal({width:t.width,hideFooter:!0,draggable:!1,overlayOpacity:.5,onShow:function(){document.body.setStyle("overflow","hidden")},onHide:function(){document.body.setStyle("overflow","auto")}});r.show({title:t.title,contents:''})},openModalSelector:function(e){var t=e||{},n=(window.getSize().y-180).toInt();if(!t.height||t.height>n)t.height=n;var r=new SimpleModal({width:t.width,btn_ok:Contao.lang.close,draggable:!1,overlayOpacity:.5,onShow:function(){document.body.setStyle("overflow","hidden")},onHide:function(){document.body.setStyle("overflow","auto")}});r.addButton(Contao.lang.close,"btn",function(){this.hide()}),r.addButton(Contao.lang.apply,"btn primary",function(){var e=[],n=null,r=window.frames;for(var i=0;i',model:"modal"})},getScrollOffset:function(){document.cookie="BE_PAGE_OFFSET="+window.getScroll().y+"; path="+(Contao.path||"/")},autoSubmit:function(e){Backend.getScrollOffset();var t=new Element("input",{type:"hidden",name:"SUBMIT_TYPE",value:"auto"}),n=$(e)||e;t.inject(n,"bottom"),n.submit()},vScrollTo:function(e){window.addEvent("load",function(){window.scrollTo(null,parseInt(e))})},limitPreviewHeight:function(){var e=null,t=null,n="",r=0;$$("div.limit_height").each(function(i){e=i.getCoordinates(),r===0&&(r=i.className.replace(/[^0-9]*/,"").toInt());if(!r)return;i.setStyle("height",r);var s=Contao.script_url+"system/themes/"+Contao.theme+"/images/";t=new Element("img",{"class":"limit_toggler",alt:"",title:Contao.lang.expand,width:20,height:24}),new Tips.Contao(t,{offset:{x:0,y:30}});if(e.heightr?r:""),this.src.indexOf("expand.gif")!=-1?(this.src=s+"collapse.gif",this.store("tip:title",Contao.lang.collapse)):(this.src=s+"expand.gif",this.store("tip:title",Contao.lang.expand))}),t.inject(i,"after")})},toggleCheckboxes:function(e,t){var n=$$("input"),r=e.checked?"checked":"";for(var i=0;i1?i.destroy():i.getFirst("input").set("value","")}l=r.getChildren();for(c=0;c1?u.destroy():u.getElements("textarea").set("text","");break;case"ccopy":for(d=0;d0)for(d=0;d2){for(d=0;d1&&s.destroy()}o=i.getChildren();for(h=0;h1&&s.destroy()}o=i.getChildren();for(l=0;l1&&s.destroy()}o=i.getChildren();for(l=0;l0?(t.getElement("a.module_link").setStyle("display","inline"),t.getElement("img.module_image").setStyle("display","none")):(t.getElement("a.module_link").setStyle("display","none"),t.getElement("img.module_image").setStyle("display","inline"))},convertEnableModules:function(){$$("img.mw_enable").each(function(e){e.addEvent("click",function(){Backend.getScrollOffset();var t=e.getNext("input");t.checked?(t.checked="",e.src=e.src.replace("visible.gif","invisible.gif")):(t.checked="checked",e.src=e.src.replace("invisible.gif","visible.gif"))})})}};document.addEvent("mousedown",function(e){Backend.getMousePosition(e)}),window.addEvent("domready",function(){$(document.body).addClass("js"),Browser.Features.Touch&&$(document.body).addClass("touch"),Backend.collapsePalettes(),Backend.addInteractiveHelp(),Backend.addColorPicker(),Backend.convertEnableModules(),Backend.makeWizardsSortable(),Elements.chosen!=undefined&&$$("select.tl_chosen").chosen(),$$("textarea.monospace").each(function(e){Backend.toggleWrap(e)})}),window.addEvent("load",function(){Backend.limitPreviewHeight()}),window.addEvent("ajax_change",function(){Backend.addInteractiveHelp(),Backend.makeWizardsSortable(),Elements.chosen!=undefined&&$$("select.tl_chosen").filter(function(e){return e.getStyle("display")!="none"}).chosen()}),Browser.Features.Touch&&function(){delete Element.NativeEvents.mousedown,Element.defineCustomEvent("mousedown",{base:"touchstart"}),delete Element.NativeEvents.mousemove,Element.defineCustomEvent("mousemove",{base:"touchmove"}),delete Element.NativeEvents.mouseup,Element.defineCustomEvent("mouseup",{base:"touchend"})}();var TinyCallback={getScrollOffset:function(e){tinymce.dom.Event.add(tinymce.isGecko?e.getDoc():e.getWin(),"focus",function(){Backend.getScrollOffset()})},fileBrowser:function(e,t,n,r){var i=new SimpleModal({width:765,btn_ok:Contao.lang.close,draggable:!1,overlayOpacity:.5,onShow:function(){document.body.setStyle("overflow","hidden")},onHide:function(){document.body.setStyle("overflow","auto")}});i.addButton(Contao.lang.close,"btn",function(){this.hide()}),i.addButton(Contao.lang.apply,"btn primary",function(){var t=window.frames,i,s,o;for(var u=0;u'}}this.hide()}),i.show({title:r.document.title,contents:'',model:"modal"})}}; \ No newline at end of file diff --git a/assets/mootools/mootao/Mootao-uncompressed.js b/assets/mootools/mootao/Mootao-uncompressed.js index 24456fc4f1..41c3f64bc6 100644 --- a/assets/mootools/mootao/Mootao-uncompressed.js +++ b/assets/mootools/mootao/Mootao-uncompressed.js @@ -44,7 +44,13 @@ Request.Contao = new Class( }, success: function(text) { - var json; + var url = this.getHeader('X-Ajax-Location'), + json; + + if (url) { + location.replace(url); + return; + } // Support both plain text and JSON responses try { diff --git a/assets/mootools/mootao/Mootao.js b/assets/mootools/mootao/Mootao.js index c13647ce5a..020bb98346 100644 --- a/assets/mootools/mootao/Mootao.js +++ b/assets/mootools/mootao/Mootao.js @@ -1,2 +1,2 @@ /* Contao Open Source CMS, (c) 2005-2013 Leo Feyer, LGPL license */ -Request.Contao=new Class({Extends:Request.JSON,options:{url:window.location.href},initialize:function(e){if(e)try{this.options.url=e.field.getParent("form").getAttribute("action")}catch(t){}this.parent(e)},success:function(e){var t;try{t=this.response.json=JSON.decode(e,this.options.secure)}catch(n){t={content:e}}t==null&&(t={content:""}),t.content!=""&&(t.content=t.content.stripScripts(function(e){t.javascript=e.replace(/||/g,"")}),t.javascript&&this.options.evalScripts&&Browser.exec(t.javascript)),this.onSuccess(t.content,t)}}),Request.Mixed=Request.Contao,Tips.Contao=new Class({Extends:Tips,options:{id:"tip",onShow:function(){this.tip.setStyle("display","block")},onHide:function(){this.tip.setStyle("display","none")},title:"title",text:"",showDelay:1e3,hideDelay:100,className:"tip-wrap",offset:{x:16,y:16},windowPadding:{x:0,y:0},fixed:!0,waiAria:!0},position:function(e){this.tip||document.id(this);var t=window.getSize(),n=window.getScroll(),r={x:this.tip.offsetWidth,y:this.tip.offsetHeight},i={x:"left",y:"top"},s={y:!1,x2:!1,y2:!1,x:!1},o={};for(var u in i)o[i[u]]=e.page[u]+this.options.offset[u],o[i[u]]<0&&(s[u]=!0),o[i[u]]+r[u]-n[u]>t[u]-this.options.windowPadding[u]&&(u=="x"&&(o[i[u]]=e.page[u]-this.options.offset[u]-r[u]),s[u+"2"]=!0);var a=this.tip.getElement("div.tip-top");s.x2?(o["margin-left"]="24px",a.setStyles({left:"auto",right:"9px"})):(o["margin-left"]="-9px",a.setStyles({left:"9px",right:"auto"})),this.fireEvent("bound",s),this.tip.setStyles(o)},hide:function(e){this.tip||document.id(this),this.fireEvent("hide",[this.tip,e])}}); \ No newline at end of file +Request.Contao=new Class({Extends:Request.JSON,options:{url:window.location.href},initialize:function(e){if(e)try{this.options.url=e.field.getParent("form").getAttribute("action")}catch(t){}this.parent(e)},success:function(e){var t=this.getHeader("X-Ajax-Location"),n;if(t){location.replace(t);return}try{n=this.response.json=JSON.decode(e,this.options.secure)}catch(r){n={content:e}}n==null&&(n={content:""}),n.content!=""&&(n.content=n.content.stripScripts(function(e){n.javascript=e.replace(/||/g,"")}),n.javascript&&this.options.evalScripts&&Browser.exec(n.javascript)),this.onSuccess(n.content,n)}}),Request.Mixed=Request.Contao,Tips.Contao=new Class({Extends:Tips,options:{id:"tip",onShow:function(){this.tip.setStyle("display","block")},onHide:function(){this.tip.setStyle("display","none")},title:"title",text:"",showDelay:1e3,hideDelay:100,className:"tip-wrap",offset:{x:16,y:16},windowPadding:{x:0,y:0},fixed:!0,waiAria:!0},position:function(e){this.tip||document.id(this);var t=window.getSize(),n=window.getScroll(),r={x:this.tip.offsetWidth,y:this.tip.offsetHeight},i={x:"left",y:"top"},s={y:!1,x2:!1,y2:!1,x:!1},o={};for(var u in i)o[i[u]]=e.page[u]+this.options.offset[u],o[i[u]]<0&&(s[u]=!0),o[i[u]]+r[u]-n[u]>t[u]-this.options.windowPadding[u]&&(u=="x"&&(o[i[u]]=e.page[u]-this.options.offset[u]-r[u]),s[u+"2"]=!0);var a=this.tip.getElement("div.tip-top");s.x2?(o["margin-left"]="24px",a.setStyles({left:"auto",right:"9px"})):(o["margin-left"]="-9px",a.setStyles({left:"9px",right:"auto"})),this.fireEvent("bound",s),this.tip.setStyles(o)},hide:function(e){this.tip||document.id(this),this.fireEvent("hide",[this.tip,e])}}); \ No newline at end of file diff --git a/system/docs/CHANGELOG.md b/system/docs/CHANGELOG.md index 8c10d32298..78641995ea 100644 --- a/system/docs/CHANGELOG.md +++ b/system/docs/CHANGELOG.md @@ -4,6 +4,9 @@ Contao Open Source CMS Changelog Version 3.2.beta1 (2013-XX-XX) ------------------------------ +### Changed +Send an "X-Ajax-Location" header to redirect upon Ajax requests (see #5647). + ### New Added new DCA table config flags (see #5254): diff --git a/system/initialize.php b/system/initialize.php index 3f9487d339..f0fd4c81e3 100644 --- a/system/initialize.php +++ b/system/initialize.php @@ -256,7 +256,8 @@ class_alias('Contao\\ModuleLoader', 'ModuleLoader'); // Force a JavaScript redirect upon Ajax requests (IE requires absolute link) if (Environment::get('isAjaxRequest')) { - echo ''; + header('HTTP/1.1 204 No Content'); + header('X-Ajax-Location: ' . Environment::get('base') . 'contao/'); } else { diff --git a/system/modules/core/classes/BackendUser.php b/system/modules/core/classes/BackendUser.php index 44f7ef2a11..684b59580c 100644 --- a/system/modules/core/classes/BackendUser.php +++ b/system/modules/core/classes/BackendUser.php @@ -190,13 +190,6 @@ public function authenticate() $strRedirect .= '?referer=' . base64_encode(\Environment::get('request')); } - // Force JavaScript redirect on Ajax requests (IE requires an absolute link) - if (\Environment::get('isAjaxRequest')) - { - echo ''; - exit; - } - \Controller::redirect($strRedirect); } diff --git a/system/modules/core/library/Contao/Controller.php b/system/modules/core/library/Contao/Controller.php index 33f7c1ff82..993471a1c0 100644 --- a/system/modules/core/library/Contao/Controller.php +++ b/system/modules/core/library/Contao/Controller.php @@ -2078,21 +2078,25 @@ public static function addToUrl($strRequest) */ public static function reload() { - $strLocation = \Environment::get('url') . \Environment::get('requestUri'); + if (headers_sent()) + { + exit; + } + + $strLocation = \Environment::get('uri'); // Ajax request if (\Environment::get('isAjaxRequest')) { - echo $strLocation; - exit; + header('HTTP/1.1 204 No Content'); + header('X-Ajax-Location: ' . $strLocation); } - - if (headers_sent()) + else { - exit; + header('HTTP/1.1 303 See Other'); + header('Location: ' . $strLocation); } - header('Location: ' . $strLocation); exit; } @@ -2105,49 +2109,49 @@ public static function reload() */ public static function redirect($strLocation, $intStatus=303) { - $strLocation = str_replace('&', '&', $strLocation); - - // Ajax request - if (\Environment::get('isAjaxRequest')) + if (headers_sent()) { - echo $strLocation; exit; } - if (headers_sent()) + $strLocation = str_replace('&', '&', $strLocation); + + // Make the location an absolute URL + if (!preg_match('@^https?://@i', $strLocation)) { - exit; + $strLocation = \Environment::get('base') . $strLocation; } - // Header - switch ($intStatus) + // Ajax request + if (\Environment::get('isAjaxRequest')) { - case 301: - header('HTTP/1.1 301 Moved Permanently'); - break; + header('HTTP/1.1 204 No Content'); + header('X-Ajax-Location: ' . $strLocation); + } + else + { + // Add the HTTP header + switch ($intStatus) + { + case 301: + header('HTTP/1.1 301 Moved Permanently'); + break; - case 302: - header('HTTP/1.1 302 Found'); - break; + case 302: + header('HTTP/1.1 302 Found'); + break; - case 303: - header('HTTP/1.1 303 See Other'); - break; + case 303: + header('HTTP/1.1 303 See Other'); + break; - case 307: - header('HTTP/1.1 307 Temporary Redirect'); - break; - } + case 307: + header('HTTP/1.1 307 Temporary Redirect'); + break; + } - // Check the target address - if (preg_match('@^https?://@i', $strLocation)) - { header('Location: ' . $strLocation); } - else - { - header('Location: ' . \Environment::get('base') . $strLocation); - } exit; } diff --git a/system/modules/core/library/Contao/Environment.php b/system/modules/core/library/Contao/Environment.php index a33edf94ab..dc3a036a41 100644 --- a/system/modules/core/library/Contao/Environment.php +++ b/system/modules/core/library/Contao/Environment.php @@ -320,6 +320,17 @@ protected static function url() } + /** + * Return the current URL with path or query string + * + * @return string The URL + */ + protected static function uri() + { + return static::get('url') . static::get('requestUri'); + } + + /** * Return the real REMOTE_ADDR even if a proxy server is used *