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 + "'."); } lttPath.Text = "<a id=\"" + lttPath.ClientID + "\" target=\"_blank\" href=\"" + stylesheet.VirtualPath + "\">" + stylesheet.VirtualPath + "</a>"; editorSource.Text = stylesheet.Content; TreeSyncPath = DeepLink.GetTreePathFromFilePath(filename).TrimEnd(".css"); // name derives from path, without the .css extension, clean for xss NameTxt.Text = stylesheet.Path.TrimEnd(".css").CleanForXss('\\', '/'); if (IsPostBack == false) { ClientTools .SetActiveTreeType(Constants.Trees.Stylesheets) .SyncTree(TreeSyncPath, false); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string file = Request.QueryString["file"]; string path = DeepLink.GetTreePathFromFilePath(file); ClientTools .SetActiveTreeType(TreeDefinitionCollection.Instance.FindTree <loadXslt>().Tree.Alias) .SyncTree(path, false); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string file = Request.QueryString["file"]; string path = DeepLink.GetTreePathFromFilePath(file, false, true); ClientTools .SetActiveTreeType(Constants.Trees.Xslt) .SyncTree(path, false); } }
public JsonResult SaveStylesheet(string filename, string oldName, string contents) { // sanitize input - stylesheet names have no extension var svce = (FileService)Services.FileService; filename = CleanFilename(filename.CleanForXss()); oldName = CleanFilename(oldName); if (filename != oldName) { var stylesheetExists = svce.GetStylesheetByName(filename); if (stylesheetExists != null) { return(Failed(ui.Text("speechBubbles", "cssErrorText"), "A file named '" + filename + ".css' already exists.")); } } var stylesheet = svce.GetStylesheetByName(oldName); if (stylesheet == null) { stylesheet = new Stylesheet(filename); } else { stylesheet.Path = filename; } stylesheet.Content = contents; try { if (svce.ValidateStylesheet(stylesheet) == false) { return(Failed(ui.Text("speechBubbles", "cssErrorText"), ui.Text("speechBubbles", "cssErrorHeader"), new FileSecurityException("File '" + filename + "' is not a valid stylesheet file."))); } svce.SaveStylesheet(stylesheet); } catch (Exception e) { return(Failed(ui.Text("speechBubbles", "cssErrorText"), ui.Text("speechBubbles", "cssErrorHeader"), e)); } return(Success(ui.Text("speechBubbles", "cssSavedText"), ui.Text("speechBubbles", "cssSavedHeader"), new { path = DeepLink.GetTreePathFromFilePath(stylesheet.Path), name = stylesheet.Path, url = stylesheet.VirtualPath, contents = stylesheet.Content })); }
private void Page_Load(object sender, System.EventArgs e) { UmbracoPanel1.hasMenu = true; if (!IsPostBack) { string file = Request.QueryString["file"]; string path = DeepLink.GetTreePathFromFilePath(file); ClientTools .SetActiveTreeType(TreeDefinitionCollection.Instance.FindTree <loadPython>().Tree.Alias) .SyncTree(path, false); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); UmbracoPanel1.hasMenu = true; if (!IsPostBack) { string file = Request.QueryString["file"]; string path = DeepLink.GetTreePathFromFilePath(file); ClientTools .SetActiveTreeType(TreeDefinitionCollection.Instance.FindTree <loadPython>().Tree.Alias) .SyncTree(path, false); } }
public JsonResult SaveStylesheet(string filename, string oldName, string contents) { // sanitize input - stylesheet names have no extension filename = filename .Replace('\\', '/') .TrimStart('/') .EnsureEndsWith(".css"); var svce = (FileService)Services.FileService; var stylesheet = svce.GetStylesheetByName(oldName); if (stylesheet == null) { stylesheet = new Stylesheet(filename); } else { stylesheet.Path = filename; } stylesheet.Content = contents; try { if (svce.ValidateStylesheet(stylesheet) == false) { return(Failed(ui.Text("speechBubbles", "cssErrorText"), ui.Text("speechBubbles", "cssErrorHeader"), new FileSecurityException("File '" + filename + "' is not a valid stylesheet file."))); } svce.SaveStylesheet(stylesheet); } catch (Exception e) { return(Failed(ui.Text("speechBubbles", "cssErrorText"), ui.Text("speechBubbles", "cssErrorHeader"), e)); } return(Success(ui.Text("speechBubbles", "cssSavedText"), ui.Text("speechBubbles", "cssSavedHeader"), new { path = DeepLink.GetTreePathFromFilePath(stylesheet.Path), name = stylesheet.Path, url = stylesheet.VirtualPath, contents = stylesheet.Content })); }
public JsonResult SaveScript(string filename, string oldName, string contents) { // sanitize input - script names have an extension filename = CleanFilename(filename); var svce = (FileService)Services.FileService; var script = svce.GetScriptByName(oldName); if (script == null) { script = new Script(filename); } else { script.Path = filename; } script.Content = contents; try { if (svce.ValidateScript(script) == false) { return(Failed(ui.Text("speechBubbles", "scriptErrorText"), ui.Text("speechBubbles", "scriptErrorHeader"), new FileSecurityException("File '" + filename + "' is not a valid script file."))); } svce.SaveScript(script); } catch (Exception e) { return(Failed(ui.Text("speechBubbles", "scriptErrorText"), ui.Text("speechBubbles", "scriptErrorHeader"), e)); } return(Success(ui.Text("speechBubbles", "scriptSavedText"), ui.Text("speechBubbles", "scriptSavedHeader"), new { path = DeepLink.GetTreePathFromFilePath(script.Path), name = script.Path, url = script.VirtualPath, contents = script.Content })); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); // get the script, ensure it exists (not null) and validate (because // the file service ensures that it loads scripts from the proper location // but does not seem to validate extensions?) - in case of an error, // throw - that's what we did anyways. // also scrapping the code that added .cshtml and .vbhtml extensions, and // ~/Views directory - we're not using editScript.aspx for views anymore. var svce = ApplicationContext.Current.Services.FileService; var script = svce.GetScriptByName(filename); if (script == null) // not found { throw new FileNotFoundException("Could not find file '" + filename + "'."); } lttPath.Text = "<a id=\"" + lttPath.ClientID + "\" target=\"_blank\" href=\"" + script.VirtualPath + "\">" + script.VirtualPath + "</a>"; editorSource.Text = script.Content; ScriptTreeSyncPath = DeepLink.GetTreePathFromFilePath(filename); // name derives from filename, clean for xss NameTxt.Text = filename.CleanForXss('\\', '/'); Panel1.Text = ui.Text("editscript", base.getUser()); pp_name.Text = ui.Text("name", base.getUser()); pp_path.Text = ui.Text("path", base.getUser()); if (IsPostBack == false) { ClientTools .SetActiveTreeType(TreeDefinitionCollection.Instance.FindTree <loadScripts>().Tree.Alias) .SyncTree(ScriptTreeSyncPath, false); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); NameTxt.Text = file; string path = ""; if (file.StartsWith("~/")) { path = Umbraco.Core.IO.IOHelper.ResolveUrl(file); } else { path = Umbraco.Core.IO.IOHelper.ResolveUrl(Umbraco.Core.IO.SystemDirectories.Scripts + "/" + file); } lttPath.Text = "<a target='_blank' href='" + path + "'>" + path + "</a>"; var exts = UmbracoSettings.ScriptFileTypes.Split(',').ToList(); if (Umbraco.Core.Configuration.UmbracoSettings.DefaultRenderingEngine == RenderingEngine.Mvc) { exts.Add("cshtml"); exts.Add("vbhtml"); } var dirs = Umbraco.Core.IO.SystemDirectories.Scripts; if (Umbraco.Core.Configuration.UmbracoSettings.DefaultRenderingEngine == RenderingEngine.Mvc) { dirs += "," + Umbraco.Core.IO.SystemDirectories.MvcViews; } // validate file Umbraco.Core.IO.IOHelper.ValidateEditPath(Umbraco.Core.IO.IOHelper.MapPath(path), dirs.Split(',')); // validate extension Umbraco.Core.IO.IOHelper.ValidateFileExtension(Umbraco.Core.IO.IOHelper.MapPath(path), exts); StreamReader SR; string S; SR = File.OpenText(Umbraco.Core.IO.IOHelper.MapPath(path)); S = SR.ReadToEnd(); SR.Close(); editorSource.Text = S; Panel1.Text = ui.Text("editscript", base.getUser()); pp_name.Text = ui.Text("name", base.getUser()); pp_path.Text = ui.Text("path", base.getUser()); if (!IsPostBack) { string sPath = DeepLink.GetTreePathFromFilePath(file); ClientTools .SetActiveTreeType(TreeDefinitionCollection.Instance.FindTree <loadScripts>().Tree.Alias) .SyncTree(sPath, false); } }
protected override void OnInit(EventArgs e) { base.OnInit(e); //check if a templateId is assigned, meaning we are editing a template if (!Request.QueryString["templateID"].IsNullOrWhiteSpace()) { _template = new Template(int.Parse(Request.QueryString["templateID"])); TemplateTreeSyncPath = "-1,init," + _template.Path.Replace("-1,", ""); } else if (!Request.QueryString["file"].IsNullOrWhiteSpace()) { //we are editing a view (i.e. partial view) OriginalFileName = HttpUtility.UrlDecode(Request.QueryString["file"]); //TemplateTreeSyncPath = "-1,init," + Path.GetFileName(OriginalFileName); TemplateTreeSyncPath = DeepLink.GetTreePathFromFilePath(OriginalFileName.TrimStart("MacroPartials/").TrimStart("Partials/")); } else { throw new InvalidOperationException("Cannot render the editor without a supplied templateId or a file"); } Panel1.hasMenu = true; var editor = Panel1.NewTabPage(ui.Text("template")); editor.Controls.Add(Pane8); var props = Panel1.NewTabPage(ui.Text("properties")); props.Controls.Add(Pane7); SaveButton = Panel1.Menu.NewButton(); SaveButton.Text = ui.Text("save"); SaveButton.ButtonType = MenuButtonType.Primary; SaveButton.ID = "save"; SaveButton.CssClass = "client-side"; Panel1.Text = ui.Text("edittemplate"); pp_name.Text = ui.Text("name", base.getUser()); pp_alias.Text = ui.Text("alias", base.getUser()); pp_masterTemplate.Text = ui.Text("mastertemplate", base.getUser()); // Editing buttons MenuIconI umbField = editorSource.Menu.NewIcon(); umbField.ImageURL = UmbracoPath + "/images/editor/insField.gif"; umbField.OnClickCommand = ClientTools.Scripts.OpenModalWindow( IOHelper.ResolveUrl(SystemDirectories.Umbraco) + "/dialogs/umbracoField.aspx?objectId=" + editorSource.ClientID + "&tagName=UMBRACOGETDATA&mvcView=true", ui.Text("template", "insertPageField"), 640, 550); umbField.AltText = ui.Text("template", "insertPageField"); // TODO: Update icon MenuIconI umbDictionary = editorSource.Menu.NewIcon(); umbDictionary.ImageURL = GlobalSettings.Path + "/images/editor/dictionaryItem.gif"; umbDictionary.OnClickCommand = ClientTools.Scripts.OpenModalWindow( IOHelper.ResolveUrl(SystemDirectories.Umbraco) + "/dialogs/umbracoField.aspx?objectId=" + editorSource.ClientID + "&tagName=UMBRACOGETDICTIONARY&mvcView=true", ui.Text("template", "insertDictionaryItem"), 640, 550); umbDictionary.AltText = "Insert umbraco dictionary item"; var macroSplitButton = new InsertMacroSplitButton { ClientCallbackInsertMacroMarkup = "function(alias) {editViewEditor.insertMacroMarkup(alias);}", ClientCallbackOpenMacroModel = "function(alias) {editViewEditor.openMacroModal(alias);}" }; editorSource.Menu.InsertNewControl(macroSplitButton, 40); MenuIconI umbTemplateQueryBuilder = editorSource.Menu.NewIcon(); umbTemplateQueryBuilder.ImageURL = UmbracoPath + "/images/editor/inshtml.gif"; umbTemplateQueryBuilder.OnClickCommand = "editViewEditor.openQueryModal()"; umbTemplateQueryBuilder.AltText = "Open query builder"; if (_template == null) { InitializeEditorForPartialView(); } else { InitializeEditorForTemplate(); } }