From f726ec740ae56321e51d30c16679fb3399f89c22 Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Tue, 5 Feb 2013 05:43:38 +0600 Subject: [PATCH] Converted Umbraco.aspx, TreeInit.aspx to have proper web forms classes and obsoletes old ones. Obsoletes umbWindow class as its not used in the codebase whatsoever. --- src/Umbraco.Web.UI/Umbraco.Web.UI.csproj | 2 +- src/Umbraco.Web.UI/umbraco/TreeInit.aspx.cs | 12 +- .../umbraco/TreeInit.aspx.designer.cs | 54 ++++ src/Umbraco.Web.UI/umbraco/Umbraco.aspx.cs | 178 +++++++++++- .../umbraco/Umbraco.aspx.designer.cs | 268 +++++++++++++++++- src/Umbraco.Web.UI/umbraco/umbraco.aspx | 10 +- .../umbraco/create.aspx.cs | 1 + .../umbraco/login.aspx.cs | 1 + .../umbraco/treeInit.aspx.cs | 2 +- .../umbraco.presentation/umbraco/umbWindow.cs | 4 +- .../umbraco/umbraco.aspx.cs | 1 + 11 files changed, 518 insertions(+), 15 deletions(-) diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index d26da3250f..5009072508 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -419,7 +419,7 @@ ASPXCodeBehind - Umbraco.aspx + umbraco.aspx diff --git a/src/Umbraco.Web.UI/umbraco/TreeInit.aspx.cs b/src/Umbraco.Web.UI/umbraco/TreeInit.aspx.cs index d4ecff71eb..0f90e84996 100644 --- a/src/Umbraco.Web.UI/umbraco/TreeInit.aspx.cs +++ b/src/Umbraco.Web.UI/umbraco/TreeInit.aspx.cs @@ -2,10 +2,20 @@ using System.Collections.Generic; using System.Linq; using System.Web; +using umbraco.cms.presentation.Trees; namespace Umbraco.Web.UI.Umbraco { - public partial class TreeInit : global::umbraco.cms.presentation.TreeInit + [Obsolete("Used the TreeControl control instead. This does however get used by the TreeService when requesting the tree init url.")] + public partial class TreeInit : Pages.UmbracoEnsuredPage { + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + TreeParams = TreeRequestParams.FromQueryStrings().CreateTreeService(); + DataBind(); + } + + protected TreeService TreeParams { get; private set; } } } \ No newline at end of file diff --git a/src/Umbraco.Web.UI/umbraco/TreeInit.aspx.designer.cs b/src/Umbraco.Web.UI/umbraco/TreeInit.aspx.designer.cs index 1fd780b875..754bf6ba81 100644 --- a/src/Umbraco.Web.UI/umbraco/TreeInit.aspx.designer.cs +++ b/src/Umbraco.Web.UI/umbraco/TreeInit.aspx.designer.cs @@ -11,5 +11,59 @@ namespace Umbraco.Web.UI.Umbraco { public partial class TreeInit { + + /// + /// Head1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.HtmlControls.HtmlHead Head1; + + /// + /// ClientLoader control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.UmbracoClientDependencyLoader ClientLoader; + + /// + /// CssInclude1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.CssInclude CssInclude1; + + /// + /// form1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// ScriptManager1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.ScriptManager ScriptManager1; + + /// + /// JTree control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.controls.Tree.TreeControl JTree; } } diff --git a/src/Umbraco.Web.UI/umbraco/Umbraco.aspx.cs b/src/Umbraco.Web.UI/umbraco/Umbraco.aspx.cs index 5695bf02cf..a399c8715a 100644 --- a/src/Umbraco.Web.UI/umbraco/Umbraco.aspx.cs +++ b/src/Umbraco.Web.UI/umbraco/Umbraco.aspx.cs @@ -1,11 +1,185 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; +using System.Text; +using System.Text.RegularExpressions; using System.Web; +using System.Web.UI; +using Umbraco.Core.IO; +using umbraco; namespace Umbraco.Web.UI.Umbraco { - public partial class Umbraco : global::umbraco.cms.presentation._umbraco - { + public partial class UmbracoMainPage : Pages.UmbracoEnsuredPage + { + public string DefaultApp { get; private set; } + + protected void Page_Load(object sender, System.EventArgs e) + { + var apps = GetUser().Applications.ToList(); + bool userHasAccesstodefaultApp = apps.Any(x => x.alias == "content"); + + // Load user module icons .. + if (apps.Count() > 1) + { + + var jsEvents = new StringBuilder(); + + PlaceHolderAppIcons.Text = ui.Text("main", "sections", GetUser()); + plcIcons.Text = ""; + foreach (global::umbraco.BusinessLogic.Application a in apps.OrderBy(x => x.sortOrder)) + { + + string appClass = a.icon.StartsWith(".") ? a.icon.Substring(1, a.icon.Length - 1) : a.alias; + + //adds client side event handlers to the icon buttons + jsEvents.Append(@"jQuery('." + appClass + "').click(function() { appClick.call(this, '" + a.alias + "'); } );"); + jsEvents.Append(@"jQuery('." + appClass + "').dblclick(function() { appDblClick.call(this, '" + a.alias + "'); } );"); + + string iconElement = String.Format("
  • ", appClass); + if (a.icon.StartsWith(".")) + iconElement += + "\"\"
  • "; + else + iconElement += "\"""; + plcIcons.Text += iconElement; + + } + + //registers the jquery event handlers. + Page.ClientScript.RegisterStartupScript(this.GetType(), "AppIcons", "jQuery(document).ready(function() { " + jsEvents.ToString() + " } );", true); + + } + else + PlaceHolderAppIcons.Visible = false; + + + //if user does not have access to content (ie, he's probably a translator)... + //then change the default tree app + if (!userHasAccesstodefaultApp) + { + JTree.App = apps[0].alias; + DefaultApp = apps[0].alias; + } + else + { + DefaultApp = "content"; + } + + + // Load globalized labels + treeWindow.Text = ui.Text("main", "tree", GetUser()); + + RenderActionJs(); + + // Version check goes here! + + // zb-00004 #29956 : refactor cookies names & handling + var updChkCookie = new global::umbraco.BusinessLogic.StateHelper.Cookies.Cookie("UMB_UPDCHK", GlobalSettings.VersionCheckPeriod); // was "updateCheck" + string updateCheckCookie = updChkCookie.HasValue ? updChkCookie.GetValue() : ""; + + if (GlobalSettings.VersionCheckPeriod > 0 && String.IsNullOrEmpty(updateCheckCookie) && GetUser().UserType.Alias == "admin") + { + + // Add scriptmanager version check + ScriptManager sm = ScriptManager.GetCurrent(Page); + sm.Scripts.Add(new ScriptReference(SystemDirectories.Umbraco + "/js/umbracoUpgradeChecker.js")); + sm.Services.Add(new ServiceReference(SystemDirectories.WebServices + "/CheckForUpgrade.asmx")); + + Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "upgradeChecker", "jQuery(document).ready(function() {umbraco.presentation.webservices.CheckForUpgrade.CallUpgradeService(umbracoCheckUpgrade);});", true); + + updChkCookie.SetValue("1"); + } + DataBind(); + + AddIe9Meta(); + } + + private void AddIe9Meta() + { + if (Request.Browser.Browser == "IE" && Request.Browser.MajorVersion == 9) + { + var metadata = new StringBuilder(); + metadata.AppendFormat( + @" + + + + + ", + IOHelper.ResolveUrl(SystemDirectories.Umbraco + "/images/pinnedIcons/umb.ico"), + HttpContext.Current.Request.Url.Host.ToLower().Replace("www.", "")); + + var user = GetUser(); + if (user != null && user.Applications != null && user.Applications.Length > 0) + { + foreach (var app in user.Applications) + { + metadata.AppendFormat( + @"", + ui.Text("sections", app.alias, user), + IOHelper.ResolveUrl(string.Format("{0}/umbraco.aspx#{1}", SystemDirectories.Umbraco, app.alias)), + File.Exists( + IOHelper.MapPath( + IOHelper.ResolveUrl( + string.Format("{0}/images/pinnedIcons/task_{1}.ico", SystemDirectories.Umbraco, app.alias)))) + ? "/umbraco/images/pinnedIcons/task_" + app.alias + ".ico" + : "/umbraco/images/pinnedIcons/task_default.ico"); + } + } + + this.Header.Controls.Add(new LiteralControl(metadata.ToString())); + } + } + + /// + /// Renders out all JavaScript references that have bee declared in IActions + /// + private void RenderActionJs() + { + var item = 0; + foreach (var jsFile in global::umbraco.BusinessLogic.Actions.Action.GetJavaScriptFileReferences()) + { + //validate that this is a url, if it is not, we'll assume that it is a text block and render it as a text + //block instead. + var isValid = true; + try + { + var jsUrl = new Uri(jsFile, UriKind.RelativeOrAbsolute); + //ok it validates, but so does alert('hello'); ! so we need to do more checks + + //here are the valid chars in a url without escaping + if (Regex.IsMatch(jsFile, @"[^a-zA-Z0-9-._~:/?#\[\]@!$&'\(\)*\+,%;=]")) + isValid = false; + + //we'll have to be smarter and just check for certain js patterns now too! + var jsPatterns = new string[] { @"\+\s*\=", @"\);", @"function\s*\(", @"!=", @"==" }; + if (jsPatterns.Any(p => Regex.IsMatch(jsFile, p))) + { + isValid = false; + } + + if (isValid) + { + //add to page + Page.ClientScript.RegisterClientScriptInclude(this.GetType(), item.ToString(), jsFile); + } + } + catch (UriFormatException) + { + isValid = false; + } + + if (!isValid) + { + //it is invalid, let's render it as a script block instead as devs may have written real Javascript instead + //of a JS path + Page.ClientScript.RegisterClientScriptBlock(this.GetType(), item.ToString(), jsFile, true); + } + + item++; + } + } } } \ No newline at end of file diff --git a/src/Umbraco.Web.UI/umbraco/Umbraco.aspx.designer.cs b/src/Umbraco.Web.UI/umbraco/Umbraco.aspx.designer.cs index 4b90045f98..9592e4d87b 100644 --- a/src/Umbraco.Web.UI/umbraco/Umbraco.aspx.designer.cs +++ b/src/Umbraco.Web.UI/umbraco/Umbraco.aspx.designer.cs @@ -8,9 +8,46 @@ //------------------------------------------------------------------------------ namespace Umbraco.Web.UI.Umbraco { - - - public partial class Umbraco { + + + public partial class UmbracoMainPage + { + + /// + /// ClientLoader control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.UmbracoClientDependencyLoader ClientLoader; + + /// + /// CssInclude1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.CssInclude CssInclude1; + + /// + /// CssInclude2 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.CssInclude CssInclude2; + + /// + /// JsInclude1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude1; /// /// JSON2 control. @@ -20,5 +57,230 @@ namespace Umbraco.Web.UI.Umbraco { /// To modify move field declaration from designer file to code-behind file. /// protected global::ClientDependency.Core.Controls.JsInclude JSON2; + + /// + /// JsInclude2 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude2; + + /// + /// JsInclude3 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude3; + + /// + /// JsInclude14 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude14; + + /// + /// JsInclude5 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude5; + + /// + /// JsInclude6 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude6; + + /// + /// JsInclude13 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude13; + + /// + /// JsInclude7 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude7; + + /// + /// JsInclude8 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude8; + + /// + /// JsInclude9 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude9; + + /// + /// JsInclude10 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude10; + + /// + /// JsInclude11 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude11; + + /// + /// JsInclude4 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude4; + + /// + /// JsInclude17 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude17; + + /// + /// JsInclude12 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude12; + + /// + /// JsInclude15 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude15; + + /// + /// JsInclude16 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude16; + + /// + /// Form1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.HtmlControls.HtmlForm Form1; + + /// + /// umbracoScriptManager control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.ScriptManager umbracoScriptManager; + + /// + /// FindDocuments control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Panel FindDocuments; + + /// + /// Search control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::Umbraco.Web.UI.Umbraco.Search.QuickSearch Search; + + /// + /// treeWindow control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.UmbracoPanel treeWindow; + + /// + /// JTree control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.controls.Tree.TreeControl JTree; + + /// + /// PlaceHolderAppIcons control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.UmbracoPanel PlaceHolderAppIcons; + + /// + /// plcIcons control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Literal plcIcons; + + /// + /// bubbleText control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.PlaceHolder bubbleText; } } diff --git a/src/Umbraco.Web.UI/umbraco/umbraco.aspx b/src/Umbraco.Web.UI/umbraco/umbraco.aspx index f82b3f8259..1f68f91158 100644 --- a/src/Umbraco.Web.UI/umbraco/umbraco.aspx +++ b/src/Umbraco.Web.UI/umbraco/umbraco.aspx @@ -1,5 +1,5 @@ <%@ Page Trace="false" Language="c#" CodeBehind="umbraco.aspx.cs" AutoEventWireup="True" - Inherits="Umbraco.Web.UI.Umbraco.Umbraco" %> + Inherits="Umbraco.Web.UI.Umbraco.UmbracoMainPage" %> <%@ Import Namespace="System.Web.Script.Serialization" %> @@ -90,12 +90,12 @@
    - + <%=GetUser().Name%>
    @@ -299,13 +299,13 @@ if (password != "") { var data = { - username: <%= new JavaScriptSerializer().Serialize(this.getUser().LoginName) %>, + username: <%= new JavaScriptSerializer().Serialize(GetUser().LoginName) %>, password: password }; jQuery.ajax({ type: "POST", - url: "<%=umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) %>/webservices/legacyAjaxCalls.asmx/ValidateUser", + url: "<%=Umbraco.Core.IO.IOHelper.ResolveUrl(Umbraco.Core.IO.SystemDirectories.Umbraco) %>/webservices/legacyAjaxCalls.asmx/ValidateUser", data: JSON.stringify(data), processData: false, success: function (result) { diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/create.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/create.aspx.cs index 764428c664..802b955839 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/create.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/create.aspx.cs @@ -20,6 +20,7 @@ namespace umbraco.cms.presentation ///
    public partial class Create : BasePages.UmbracoEnsuredPage { + [Obsolete("This property is no longer used")] protected umbWindow createWindow; protected System.Web.UI.WebControls.Label helpText; protected System.Web.UI.WebControls.TextBox rename; diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/login.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/login.aspx.cs index e1b71bab1b..7d9ceb4d1a 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/login.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/login.aspx.cs @@ -24,6 +24,7 @@ namespace umbraco.cms.presentation /// public partial class login : BasePages.BasePage { + [Obsolete("This property is no longer used")] protected umbWindow treeWindow; protected override void OnLoad(EventArgs e) diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/treeInit.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/treeInit.aspx.cs index 618577721a..fe5b33cf34 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/treeInit.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/treeInit.aspx.cs @@ -16,7 +16,7 @@ using System.Web.Services; namespace umbraco.cms.presentation { - [Obsolete("Used the TreeControl control instead. This does however get used by the TreeService when requesting the tree init url.")] + [Obsolete("This class is no longer used and will be removed in future versions. The page that supercedes this is Umbraco.Web.UI.Umbraco.TreeInit")] public partial class TreeInit : UmbracoEnsuredPage { diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/umbWindow.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/umbWindow.cs index edf3d33dcb..4094c4fe2f 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/umbWindow.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/umbWindow.cs @@ -8,8 +8,8 @@ namespace umbraco /// /// Summary description for umbWindow. /// - [DefaultProperty("Text"), - ToolboxData("<{0}:umbWindow runat=server>")] + [DefaultProperty("Text"), ToolboxData("<{0}:umbWindow runat=server>")] + [Obsolete("This class is no longer used and will be removed from the codebase in future versions")] public class umbWindow : System.Web.UI.WebControls.PlaceHolder { private string content; diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/umbraco.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/umbraco.aspx.cs index 167f9c67fe..8fd2a6428f 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/umbraco.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/umbraco.aspx.cs @@ -27,6 +27,7 @@ namespace umbraco.cms.presentation /// public class _umbraco : UmbracoEnsuredPage { + [Obsolete("This property is no longer used")] protected umbWindow UmbWindow1; protected System.Web.UI.WebControls.PlaceHolder bubbleText;