From 15bff44ec1bee77bcb00bbf6db3b71ae046af331 Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Wed, 8 May 2013 17:24:00 -1000 Subject: [PATCH] Patching from 6.1 --- src/Umbraco.Web.UI/Umbraco.Web.UI.csproj | 7 + .../settings/stylesheet/editstylesheet.aspx | 77 +++++------ .../stylesheet/editstylesheet.aspx.cs | 11 ++ .../editstylesheet.aspx.designer.cs | 15 +++ .../umbraco_client/Editors/EditStyleSheet.js | 66 ++++++++++ src/Umbraco.Web/Umbraco.Web.csproj | 11 +- .../settings/stylesheet/editstylesheet.aspx | 52 -------- .../stylesheet/editstylesheet.aspx.cs | 122 ++++++++++++------ .../editstylesheet.aspx.designer.cs | 87 ------------- src/umbraco.controls/CodeArea.cs | 101 ++------------- 10 files changed, 231 insertions(+), 318 deletions(-) create mode 100644 src/Umbraco.Web.UI/umbraco/settings/stylesheet/editstylesheet.aspx.cs create mode 100644 src/Umbraco.Web.UI/umbraco/settings/stylesheet/editstylesheet.aspx.designer.cs create mode 100644 src/Umbraco.Web.UI/umbraco_client/Editors/EditStyleSheet.js delete mode 100644 src/Umbraco.Web/umbraco.presentation/umbraco/settings/stylesheet/editstylesheet.aspx delete mode 100644 src/Umbraco.Web/umbraco.presentation/umbraco/settings/stylesheet/editstylesheet.aspx.designer.cs diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index a954970f34..44f7333b47 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -370,6 +370,12 @@ editTemplate.aspx + + editstylesheet.aspx + + + editstylesheet.aspx + EditView.aspx ASPXCodeBehind @@ -683,6 +689,7 @@ + diff --git a/src/Umbraco.Web.UI/umbraco/settings/stylesheet/editstylesheet.aspx b/src/Umbraco.Web.UI/umbraco/settings/stylesheet/editstylesheet.aspx index fdff83a661..efa825d1ef 100644 --- a/src/Umbraco.Web.UI/umbraco/settings/stylesheet/editstylesheet.aspx +++ b/src/Umbraco.Web.UI/umbraco/settings/stylesheet/editstylesheet.aspx @@ -1,52 +1,55 @@ -<%@ Page Language="c#" MasterPageFile="../../masterpages/umbracoPage.Master" Codebehind="editstylesheet.aspx.cs" AutoEventWireup="True" - Inherits="umbraco.cms.presentation.settings.stylesheet.editstylesheet" ValidateRequest="False" %> +<%@ Page Language="c#" MasterPageFile="../../masterpages/umbracoPage.Master" CodeBehind="editstylesheet.aspx.cs" AutoEventWireup="True" + Inherits="Umbraco.Web.UI.Umbraco.Settings.Stylesheet.EditStyleSheet" ValidateRequest="False" %> + <%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %> +<%@ Register TagPrefix="cdf" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %> - + jQuery(document).ready(function () { + UmbClientMgr.appActions().bindSaveShortCut(); + }); + + - - - - - - - - - - - + + + + + + + + + + + - - - \ No newline at end of file + diff --git a/src/Umbraco.Web.UI/umbraco/settings/stylesheet/editstylesheet.aspx.cs b/src/Umbraco.Web.UI/umbraco/settings/stylesheet/editstylesheet.aspx.cs new file mode 100644 index 0000000000..6e875be4d8 --- /dev/null +++ b/src/Umbraco.Web.UI/umbraco/settings/stylesheet/editstylesheet.aspx.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace Umbraco.Web.UI.Umbraco.Settings.Stylesheet +{ + public partial class EditStyleSheet : global::umbraco.cms.presentation.settings.stylesheet.editstylesheet + { + } +} \ No newline at end of file diff --git a/src/Umbraco.Web.UI/umbraco/settings/stylesheet/editstylesheet.aspx.designer.cs b/src/Umbraco.Web.UI/umbraco/settings/stylesheet/editstylesheet.aspx.designer.cs new file mode 100644 index 0000000000..1adaec56b9 --- /dev/null +++ b/src/Umbraco.Web.UI/umbraco/settings/stylesheet/editstylesheet.aspx.designer.cs @@ -0,0 +1,15 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Umbraco.Web.UI.Umbraco.Settings.Stylesheet { + + + public partial class EditStyleSheet { + } +} diff --git a/src/Umbraco.Web.UI/umbraco_client/Editors/EditStyleSheet.js b/src/Umbraco.Web.UI/umbraco_client/Editors/EditStyleSheet.js new file mode 100644 index 0000000000..1357fa6e0b --- /dev/null +++ b/src/Umbraco.Web.UI/umbraco_client/Editors/EditStyleSheet.js @@ -0,0 +1,66 @@ +Umbraco.Sys.registerNamespace("Umbraco.Editors"); + +(function ($) { + + Umbraco.Editors.EditStyleSheet = base2.Base.extend({ + //private methods/variables + _opts: null, + + // Constructor + constructor: function(opts) { + // Merge options with default + this._opts = $.extend({ + + // Default options go here + }, opts); + }, + + save: function() { + var self = this; + + umbraco.presentation.webservices.codeEditorSave.SaveCss( + self._opts.fileName, self._opts.oldName, self._opts.codeVal, self._opts.cssId, + function(t) { self.submitSucces(t); }, + function(t) { self.submitFailure(t); }); + + }, + + submitSucces: function(t) { + if (t != 'true') { + top.UmbSpeechBubble.ShowMessage('error', this._opts.text.cssErrorHeader, this._opts.text.cssErrorText); + } + else { + top.UmbSpeechBubble.ShowMessage('save', this._opts.text.cssSavedHeader, this._opts.text.cssSavedText); + } + + UmbClientMgr.mainTree().setActiveTreeType('stylesheets'); + UmbClientMgr.mainTree().syncTree("-1,init," + this._opts.cssId, true); + }, + + submitFailure: function(t) { + top.UmbSpeechBubble.ShowMessage('error', this._opts.text.cssErrorHeader, this._opts.text.cssErrorText); + + UmbClientMgr.mainTree().setActiveTreeType('stylesheets'); + UmbClientMgr.mainTree().syncTree("-1,init," + this._opts.cssId, true); + } + }, + { + saveStyleSheet: function(editorSourceClientId, nameTxtClientId, nameTxtValue, cssId) { + //Static method to do the saving + + var codeVal = $('#' + editorSourceClientId).val(); + //if CodeMirror is not defined, then the code editor is disabled. + if (typeof(CodeMirror) != "undefined") { + codeVal = UmbEditor.GetCode(); + } + + var processor = new Umbraco.Editors.EditStyleSheet({ + codeVal: codeVal, + fileName: $('#' + nameTxtClientId).val(), + oldname: nameTxtValue, + cssId: cssId + }); + processor.save(); + } + }); +})(jQuery); \ No newline at end of file diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 9ae52dbb03..3e0507387b 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -417,6 +417,7 @@ ASPXCodeBehind + @@ -1514,13 +1515,6 @@ editScript.aspx ASPXCodeBehind - - editstylesheet.aspx - ASPXCodeBehind - - - editstylesheet.aspx - EditStyleSheetProperty.aspx ASPXCodeBehind @@ -2047,9 +2041,6 @@ ASPXCodeBehind - - ASPXCodeBehind - diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/settings/stylesheet/editstylesheet.aspx b/src/Umbraco.Web/umbraco.presentation/umbraco/settings/stylesheet/editstylesheet.aspx deleted file mode 100644 index fdff83a661..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/settings/stylesheet/editstylesheet.aspx +++ /dev/null @@ -1,52 +0,0 @@ -<%@ Page Language="c#" MasterPageFile="../../masterpages/umbracoPage.Master" Codebehind="editstylesheet.aspx.cs" AutoEventWireup="True" - Inherits="umbraco.cms.presentation.settings.stylesheet.editstylesheet" ValidateRequest="False" %> -<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %> - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file 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 85c7f07b34..30c6f9857b 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,10 +1,11 @@ -using System; +using System; using System.Web.UI; +using Umbraco.Core.IO; +using Umbraco.Web; using umbraco.BasePages; using umbraco.BusinessLogic; using umbraco.cms.businesslogic.web; using umbraco.cms.presentation.Trees; -using umbraco.IO; using umbraco.uicontrols; namespace umbraco.cms.presentation.settings.stylesheet @@ -23,38 +24,30 @@ namespace umbraco.cms.presentation.settings.stylesheet protected void Page_Load(object sender, EventArgs e) { - if (!IsPostBack) - { - // editor source - - if (!UmbracoSettings.ScriptDisableEditor) - { - // TODO: Register the some script editor js file if you can find a good one. - } - - ClientTools + ClientTools .SetActiveTreeType(TreeDefinitionCollection.Instance.FindTree().Tree.Alias) - .SyncTree("-1,init," + helper.Request("id"), false); - } + .SyncTree("-1,init," + Request.GetItemAsString("id"), false); - MenuIconI save = Panel1.Menu.NewIcon(); + var save = Panel1.Menu.NewIcon(); save.ImageURL = SystemDirectories.Umbraco + "/images/editor/save.gif"; - save.OnClickCommand = "doSubmit()"; + + save.OnClickCommand = "Umbraco.Editors.EditStyleSheet.save('" + editorSource.ClientID + "', '" + NameTxt.ClientID + "', '" + NameTxt.Text + "', '" + Request.QueryString["id"] + "')"; + save.AltText = "Save stylesheet"; save.ID = "save"; - Panel1.Text = ui.Text("stylesheet", "editstylesheet", base.getUser()); - pp_name.Text = ui.Text("name", base.getUser()); - pp_path.Text = ui.Text("path", base.getUser()); + Panel1.Text = ui.Text("stylesheet", "editstylesheet", getUser()); + pp_name.Text = ui.Text("name", getUser()); + pp_path.Text = ui.Text("path", getUser()); stylesheet = new StyleSheet(int.Parse(Request.QueryString["id"])); - string appPath = Request.ApplicationPath; + var appPath = Request.ApplicationPath; if (appPath == "/") appPath = ""; lttPath.Text = "" + appPath + - IO.SystemDirectories.Css + "/" + stylesheet.Text + ".css"; + SystemDirectories.Css + "/" + stylesheet.Text + ".css"; - if (!IsPostBack) + if (IsPostBack == false) { NameTxt.Text = stylesheet.Text; editorSource.Text = stylesheet.Content; @@ -68,26 +61,77 @@ namespace umbraco.cms.presentation.settings.stylesheet ScriptManager.GetCurrent(Page).Services.Add(new ServiceReference("../webservices/legacyAjaxCalls.asmx")); } - #region Web Form Designer generated code - - protected override void OnInit(EventArgs e) - { - // - // CODEGEN: This call is required by the ASP.NET Web Form Designer. - // - - InitializeComponent(); - base.OnInit(e); - } + /// + /// Panel1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.UmbracoPanel Panel1; /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. + /// Pane7 control. /// - private void InitializeComponent() - { - } + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.Pane Pane7; + + /// + /// pp_name control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel pp_name; + + /// + /// NameTxt control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox NameTxt; + + /// + /// pp_path control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel pp_path; + + /// + /// lttPath control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Literal lttPath; + + /// + /// pp_source control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel pp_source; + + /// + /// editorSource control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.CodeArea editorSource; - #endregion } } \ No newline at end of file diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/settings/stylesheet/editstylesheet.aspx.designer.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/settings/stylesheet/editstylesheet.aspx.designer.cs deleted file mode 100644 index be8d537c96..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/settings/stylesheet/editstylesheet.aspx.designer.cs +++ /dev/null @@ -1,87 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace umbraco.cms.presentation.settings.stylesheet { - - - public partial class editstylesheet { - - /// - /// Panel1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.UmbracoPanel Panel1; - - /// - /// Pane7 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.Pane Pane7; - - /// - /// pp_name control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel pp_name; - - /// - /// NameTxt control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.TextBox NameTxt; - - /// - /// pp_path control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel pp_path; - - /// - /// lttPath control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Literal lttPath; - - /// - /// pp_source control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.PropertyPanel pp_source; - - /// - /// editorSource control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::umbraco.uicontrols.CodeArea editorSource; - } -} diff --git a/src/umbraco.controls/CodeArea.cs b/src/umbraco.controls/CodeArea.cs index e93022c0bd..b3dd048067 100644 --- a/src/umbraco.controls/CodeArea.cs +++ b/src/umbraco.controls/CodeArea.cs @@ -55,7 +55,7 @@ namespace umbraco.uicontrols { get { - return !UmbracoSettings.ScriptDisableEditor; // && HttpContext.Current.Request.Browser.Browser != "IE"; + return UmbracoSettings.ScriptDisableEditor == false; } } @@ -86,18 +86,6 @@ namespace umbraco.uicontrols ClientDependencyLoader.Instance.RegisterDependency(2, "CodeMirror/js/lib/codemirror.css", "UmbracoClient", ClientDependencyType.Css); ClientDependencyLoader.Instance.RegisterDependency(3, "CodeMirror/css/umbracoCustom.css", "UmbracoClient", ClientDependencyType.Css); ClientDependencyLoader.Instance.RegisterDependency(4, "CodeArea/styles.css", "UmbracoClient", ClientDependencyType.Css); - - - - //if (AutoSuggest && HttpContext.Current.Request.Browser.Browser != "IE") - //{ - // ClientDependencyLoader.Instance.RegisterDependency(3, "CodeMirror/js/lib/util/simple-hint-customized.js", "UmbracoClient", ClientDependencyType.Javascript); - - // ClientDependencyLoader.Instance.RegisterDependency(4, "CodeMirror/js/lib/util/" + CodeBase.ToString().ToLower() + "-hint.js", "UmbracoClient", ClientDependencyType.Javascript); - // ClientDependencyLoader.Instance.RegisterDependency(5, "CodeMirror/js/lib/util/" + CodeBase.ToString().ToLower() + "-hints.js", "UmbracoClient", ClientDependencyType.Javascript); - - // ClientDependencyLoader.Instance.RegisterDependency(4, "CodeMirror/js/lib/util/simple-hint.css", "UmbracoClient", ClientDependencyType.Css); - //} } } @@ -107,16 +95,14 @@ namespace umbraco.uicontrols CodeTextBox = new TextBox(); CodeTextBox.ID = "CodeTextBox"; - if (!CodeMirrorEnabled) + if (CodeMirrorEnabled == false) { CodeTextBox.Attributes.Add("class", "codepress"); CodeTextBox.Attributes.Add("wrap", "off"); } CodeTextBox.TextMode = TextBoxMode.MultiLine; - - //this.CssClass = "codepress"; - + this.Controls.Add(CodeTextBox); } @@ -128,7 +114,7 @@ namespace umbraco.uicontrols { get { - if (!CodeMirrorEnabled) + if (CodeMirrorEnabled == false) return CodeTextBox.ClientID; else return base.ClientID; @@ -142,7 +128,7 @@ namespace umbraco.uicontrols var jsEventCode = ""; - if (!CodeMirrorEnabled) + if (CodeMirrorEnabled == false) { CodeTextBox.RenderControl(writer); jsEventCode = RenderBasicEditor(); @@ -176,7 +162,7 @@ namespace umbraco.uicontrols var UmbEditor; $(document).ready(function () { //create the editor - UmbEditor = new Umbraco.Controls.CodeEditor.UmbracoEditor(" + (!CodeMirrorEnabled).ToString().ToLower() + @", '" + this.ClientID + @"'); + UmbEditor = new Umbraco.Controls.CodeEditor.UmbracoEditor(" + (CodeMirrorEnabled == false).ToString().ToLower() + @", '" + this.ClientID + @"'); var m_textEditor = jQuery('#" + this.ClientID + @"'); //with codemirror adding divs for line numbers, we need to target a different element @@ -185,12 +171,7 @@ namespace umbraco.uicontrols jQuery(window).resize(function(){ resizeTextArea(m_textEditor, " + OffSetX.ToString() + "," + OffSetY.ToString() + @"); }); jQuery(document).ready(function(){ resizeTextArea(m_textEditor, " + OffSetX.ToString() + "," + OffSetY.ToString() + @"); }); });"; - /* - if (!UmbracoSettings.ScriptDisableEditor && HttpContext.Current.Request.Browser.Browser == "IE") - { - jsEventCode += "jQuery('

" + ui.Text("codemirroriewarning").Replace("'", "\\'") + "

').insertAfter('#" + this.ClientID + "');"; - }*/ - + } jsEventCode = string.Format(@"", jsEventCode); @@ -213,18 +194,7 @@ namespace umbraco.uicontrols var extraKeys = ""; var editorMimetype = ""; -// if (AutoSuggest && HttpContext.Current.Request.Browser.Browser != "IE") -// { -// extraKeys = @", -// extraKeys: { -// ""'@'"": function(cm) { CodeMirror.{lang}Hint(cm, '@'); }, -// ""'.'"": function(cm) { CodeMirror.{lang}Hint(cm, '.'); }, -// ""Ctrl-Space"": function(cm) { CodeMirror.{lang}Hint(cm, ''); } -// }".Replace("{lang}", CodeBase.ToString().ToLower()); -// } - - - if (!string.IsNullOrEmpty(EditorMimeType)) + if (string.IsNullOrEmpty(EditorMimeType) == false) editorMimetype = @", mode: """ + EditorMimeType + "\""; @@ -250,61 +220,6 @@ namespace umbraco.uicontrols updateLineInfo(codeEditor); "; - - /* - string[] parserFiles = new string[] { "tokenizejavascript.js", "parsejavascript.js" }; - string[] cssFile = new string[] { "jscolors.css", "umbracoCustom.css" }; - - switch (CodeBase) - { - case EditorType.JavaScript: -parserFiles = new string[] { "tokenizejavascript.js", "parsejavascript.js" }; - cssFile = new string[] { "jscolors.css", "umbracoCustom.css" }; - break; - case EditorType.Css: - parserFiles = new string[] { "parsecss.js" }; - cssFile = new string[] { "csscolors.css", "umbracoCustom.css" }; - break; - case EditorType.Python: - parserFiles = new string[] { "parsepython.js" }; - cssFile = new string[] { "pythoncolors.css", "umbracoCustom.css" }; - break; - case EditorType.XML: - parserFiles = new string[] { "parsexml.js" }; - cssFile = new string[] { "xmlcolors.css", "umbracoCustom.css" }; - break; - case EditorType.HTML: - parserFiles = new string[] { "parsexml.js", "parsecss.js", "tokenizejavascript.js", "parsejavascript.js", "parsehtmlmixed.js" }; - cssFile = new string[] { "xmlcolors.css", "jscolors.css", "csscolors.css", "umbracoCustom.css" }; - break; - } - - var jsEventCode = @" - var textarea = document.getElementById('" + CodeTextBox.ClientID + @"'); - var codeEditor = CodeMirror.fromTextArea(textarea, { - width: ""100%"", - height: ""100%"", - tabMode: ""shift"", - textWrapping: false, - lineNumbers: true, - parserfile: [" + string.Join(",", - parserFiles - .Select(x => string.Format(@"""{0}""", x)) - .ToArray()) + @"], - stylesheet: [" + string.Join(",", - - cssFile - .Select(x => string.Format(@"""{0}""", IOHelper.ResolveUrl(SystemDirectories.Umbraco_client) + @"/CodeMirror/css/" + x)) - .ToArray()) + @"], - path: """ + IOHelper.ResolveUrl(SystemDirectories.Umbraco_client) + @"/CodeMirror/js/"", - content: textarea.value, - autoMatchParens: false," - + (string.IsNullOrEmpty(ClientSaveMethod) ? "" : @"saveFunction: " + ClientSaveMethod + ",") + @" - onChange: function() {}}); - - "; - */ - return jsEventCode; } }