diff --git a/src/Umbraco.Web.UI/umbraco/settings/stylesheet/editstylesheet.aspx b/src/Umbraco.Web.UI/umbraco/settings/stylesheet/editstylesheet.aspx
index 2f40b04ae0..55b243c94c 100644
--- a/src/Umbraco.Web.UI/umbraco/settings/stylesheet/editstylesheet.aspx
+++ b/src/Umbraco.Web.UI/umbraco/settings/stylesheet/editstylesheet.aspx
@@ -1,6 +1,5 @@
<%@ Page Language="c#" MasterPageFile="../../masterpages/umbracoPage.Master" CodeBehind="editstylesheet.aspx.cs" AutoEventWireup="True"
Inherits="Umbraco.Web.UI.Umbraco.Settings.Stylesheet.EditStyleSheet" ValidateRequest="False" %>
-<%@ Import Namespace="Umbraco.Core" %>
<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %>
<%@ Register TagPrefix="cdf" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %>
@@ -14,12 +13,16 @@
$(document).ready(function () {
var editor = new Umbraco.Editors.EditStyleSheet({
nameTxtBox: $('#<%= NameTxt.ClientID %>'),
- originalFileName: '<%= NameTxt.Text %>',
+ originalFileName: '<%= NameTxt.Text.Replace("\\", "\\\\") %>',
+ cssId: '<%= Request.QueryString["id"] %>',
saveButton: $("#<%= ((Control)SaveButton).ClientID %>"),
editorSourceElement: $('#<%= editorSource.ClientID %>'),
- restServiceLocation: "<%= Url.GetSaveFileServicePath() %>",
- treeSyncPath: "<%= TreeSyncPath %>",
- lttPathElement: $('#<%= lttPath.ClientID %>')
+ text: {
+ cssErrorHeader: '<%= HttpUtility.JavaScriptStringEncode(umbraco.ui.Text("speechBubbles", "cssErrorHeader")) %>',
+ cssSavedHeader: '<%= HttpUtility.JavaScriptStringEncode(umbraco.ui.Text("speechBubbles", "cssSavedHeader")) %>',
+ cssSavedText: '<%= HttpUtility.JavaScriptStringEncode(umbraco.ui.Text("speechBubbles", "cssSavedText")) %>',
+ cssErrorText: 'Please make sure that you have permissions set correctly',
+ }
});
editor.init();
diff --git a/src/Umbraco.Web.UI/umbraco_client/Editors/EditScript.js b/src/Umbraco.Web.UI/umbraco_client/Editors/EditScript.js
index c1506b9ffd..022f421ec6 100644
--- a/src/Umbraco.Web.UI/umbraco_client/Editors/EditScript.js
+++ b/src/Umbraco.Web.UI/umbraco_client/Editors/EditScript.js
@@ -61,7 +61,7 @@
});
},
- submitSuccess: function (args) {
+ submitSuccess: function(args) {
var msg = args.message;
var header = args.header;
var path = this._opts.treeSyncPath;
diff --git a/src/Umbraco.Web.UI/umbraco_client/Editors/EditStyleSheet.js b/src/Umbraco.Web.UI/umbraco_client/Editors/EditStyleSheet.js
index 990ed3edee..7d0ab93bd8 100644
--- a/src/Umbraco.Web.UI/umbraco_client/Editors/EditStyleSheet.js
+++ b/src/Umbraco.Web.UI/umbraco_client/Editors/EditStyleSheet.js
@@ -30,80 +30,37 @@
doSubmit: function() {
var self = this;
- var filename = this._opts.nameTxtBox.val();
- var codeval = this._opts.editorSourceElement.val();
+ var fileName = this._opts.nameTxtBox.val();
+ var codeVal = this._opts.editorSourceElement.val();
//if CodeMirror is not defined, then the code editor is disabled.
if (typeof(CodeMirror) != "undefined") {
- codeval = UmbEditor.GetCode();
+ codeVal = UmbEditor.GetCode();
}
+ umbraco.presentation.webservices.codeEditorSave.SaveCss(
+ fileName, self._opts.originalFileName, codeVal, 0,
+ function (t) { self.submitSucces(t, fileName); },
+ function(t) { self.submitFailure(t); });
+
- this.save(
- filename,
- self._opts.originalFileName,
- codeval);
},
- save: function (filename, oldName, contents) {
- var self = this;
-
- $.post(self._opts.restServiceLocation + "SaveStylesheet",
- JSON.stringify({
- filename: filename,
- oldName: oldName,
- contents: contents
- }),
- function (e) {
- if (e.success) {
- self.submitSuccess(e);
- } else {
- self.submitFailure(e.message, e.header);
- }
- });
- },
-
- submitSuccess: function (args) {
- var msg = args.message;
- var header = args.header;
- var path = this._opts.treeSyncPath;
- var pathChanged = false;
- if (args.path) {
- if (path != args.path) {
- pathChanged = true;
- }
- path = args.path;
- }
- if (args.contents) {
- UmbEditor.SetCode(args.contents);
- }
-
- UmbClientMgr.mainTree().setActiveTreeType("stylesheets");
- if (pathChanged) {
- // file is used in url so we need to redirect
- var qs = window.location.search;
- if (qs.startsWith("?")) qs = qs.substring("?".length);
- var qp1 = qs.split("&");
- var qp2 = [];
- for (var i = 0; i < qp1.length; i++)
- if (!qp1[i].startsWith("id="))
- qp2.push(qp1[i]);
-
- var location = window.location.pathname + "?" + qp2.join("&") + "&id=" + args.name;
- UmbClientMgr.contentFrame(location);
-
- // need to do it after we navigate otherwise the navigation waits until the message timeout is done
- top.UmbSpeechBubble.ShowMessage("save", header, msg);
+ submitSucces: function (t, fileName) {
+ if (t != 'true') {
+ top.UmbSpeechBubble.ShowMessage('error', unescape(this._opts.text.cssErrorHeader), unescape(this._opts.text.cssErrorText));
}
else {
- top.UmbSpeechBubble.ShowMessage("save", header, msg);
- this._opts.lttPathElement.prop("href", args.url).html(args.url);
- this._opts.originalFileName = args.name;
- this._opts.treeSyncPath = args.path;
- UmbClientMgr.mainTree().syncTree(path, true);
+ top.UmbSpeechBubble.ShowMessage('save', unescape(this._opts.text.cssSavedHeader), unescape(this._opts.text.cssSavedText));
}
+
+ UmbClientMgr.mainTree().setActiveTreeType('stylesheets');
+ UmbClientMgr.mainTree().syncTree("-1,init," + fileName, true);
+
+ //update the originalFileName prop
+ this._opts.originalFileName = this._opts.nameTxtBox.val();
},
- submitFailure: function(err, header) {
- top.UmbSpeechBubble.ShowMessage('error', header, err);
+ submitFailure: function(t) {
+ top.UmbSpeechBubble.ShowMessage('error', unescape(this._opts.text.cssErrorHeader), unescape(this._opts.text.cssErrorText));
}
});
})(jQuery);
\ No newline at end of file
diff --git a/src/Umbraco.Web/WebServices/SaveFileController.cs b/src/Umbraco.Web/WebServices/SaveFileController.cs
index aeb06882c6..cae33983da 100644
--- a/src/Umbraco.Web/WebServices/SaveFileController.cs
+++ b/src/Umbraco.Web/WebServices/SaveFileController.cs
@@ -223,7 +223,7 @@ namespace Umbraco.Web.WebServices
[HttpPost]
public JsonResult SaveStylesheet(string filename, string oldName, string contents)
{
- filename = filename.TrimStart('/', '\\').EnsureEndsWith(".css");
+ filename = filename.TrimStart('/', '\\');
var svce = (FileService) Services.FileService;
var stylesheet = svce.GetStylesheetByName(oldName);
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/settings/scripts/editScript.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/settings/scripts/editScript.aspx.cs
index f3c993a05f..ba2ab86d51 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/settings/scripts/editScript.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/settings/scripts/editScript.aspx.cs
@@ -42,7 +42,9 @@ namespace umbraco.cms.presentation.settings.scripts
protected MenuButton SaveButton;
private string filename;
+
protected string ScriptTreeSyncPath { get; private set; }
+ protected int ScriptId { get; private set; }
protected override void OnLoad(EventArgs e)
{
@@ -82,7 +84,7 @@ namespace umbraco.cms.presentation.settings.scripts
{
base.OnInit(e);
- filename = Request.QueryString["file"].Replace('\\', '/').TrimStart('/');
+ filename = Request.QueryString["file"].TrimStart('/');
//need to change the editor type if it is XML
if (filename.EndsWith("xml"))
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/settings/stylesheet/editstylesheet.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/settings/stylesheet/editstylesheet.aspx.cs
index 0d4fd61881..ce19c7991c 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/settings/stylesheet/editstylesheet.aspx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/settings/stylesheet/editstylesheet.aspx.cs
@@ -1,5 +1,4 @@
using System;
-using System.IO;
using System.Linq;
using System.Web.UI;
using Umbraco.Core.IO;
@@ -7,7 +6,6 @@ using Umbraco.Web;
using umbraco.BasePages;
using umbraco.BusinessLogic;
using umbraco.cms.businesslogic.web;
-using umbraco.cms.helpers;
using umbraco.cms.presentation.Trees;
using umbraco.uicontrols;
using Umbraco.Core;
@@ -19,10 +17,9 @@ namespace umbraco.cms.presentation.settings.stylesheet
///
public partial class editstylesheet : UmbracoEnsuredPage
{
- protected MenuButton SaveButton;
+ private Umbraco.Core.Models.Stylesheet _sheet;
- private string filename;
- protected string TreeSyncPath { get; private set; }
+ protected MenuButton SaveButton;
public editstylesheet()
{
@@ -33,7 +30,6 @@ namespace umbraco.cms.presentation.settings.stylesheet
{
base.OnInit(e);
- filename = Request.QueryString["id"].Replace('\\', '/').TrimStart('/');
var editor = Panel1.NewTabPage(ui.Text("stylesheet"));
editor.Controls.Add(Pane7);
@@ -41,6 +37,7 @@ namespace umbraco.cms.presentation.settings.stylesheet
var props = Panel1.NewTabPage(ui.Text("properties"));
props.Controls.Add(Pane8);
+
SaveButton = Panel1.Menu.NewButton();
SaveButton.Text = ui.Text("save");
SaveButton.ButtonType = MenuButtonType.Primary;
@@ -49,26 +46,28 @@ namespace umbraco.cms.presentation.settings.stylesheet
}
protected void Page_Load(object sender, EventArgs e)
- {
+ {
+
Panel1.Text = ui.Text("stylesheet", "editstylesheet", UmbracoUser);
pp_name.Text = ui.Text("name", UmbracoUser);
pp_path.Text = ui.Text("path", UmbracoUser);
- var stylesheet = Services.FileService.GetStylesheetByName(filename);
- if (stylesheet == null) // not found
- throw new FileNotFoundException("Could not find file '" + filename + "'.");
+ _sheet = Services.FileService.GetStylesheetByName(Request.QueryString["id"]);
+ if (_sheet == null) throw new InvalidOperationException("No stylesheet found with name: " + Request.QueryString["id"]);
- lttPath.Text = "" + stylesheet.VirtualPath + "";
- editorSource.Text = stylesheet.Content;
- TreeSyncPath = DeepLink.GetTreePathFromFilePath(filename);
+ lttPath.Text = "" + _sheet.VirtualPath + "";
- NameTxt.Text = stylesheet.Path.TrimEnd(".css");
if (IsPostBack == false)
{
+ NameTxt.Text = _sheet.Path.TrimEnd(".css");
+ editorSource.Text = _sheet.Content;
+
ClientTools
.SetActiveTreeType(Constants.Trees.Stylesheets)
- .SyncTree(TreeSyncPath, false);
+ .SyncTree("-1,init," + _sheet.Path
+ //needs a double escape to work with JS
+ .Replace("\\", "\\\\").TrimEnd(".css"), false);
}
}
@@ -79,7 +78,6 @@ namespace umbraco.cms.presentation.settings.stylesheet
ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference("../webservices/legacyAjaxCalls.asmx"));
//Clean the name field for xss
- // fixme - NOT on preRender !
NameTxt.Text = NameTxt.Text.CleanForXss(ignoreFromClean:'\\');
}
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/codeEditorSave.asmx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/codeEditorSave.asmx.cs
index 954cd3860b..23d30181a9 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/codeEditorSave.asmx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/codeEditorSave.asmx.cs
@@ -34,8 +34,7 @@ namespace umbraco.presentation.webservices
[ScriptService]
public class codeEditorSave : UmbracoAuthorizedWebService
{
-
- [Obsolete("This method has been superceded by the REST service /Umbraco/RestServices/SaveFile/SaveStylesheet which is powered by the SaveFileController.")]
+
[WebMethod]
public string SaveCss(string fileName, string oldName, string fileContents, int fileID)
{