From 3319ded749026dfa92e9fbce0765787a25797ae1 Mon Sep 17 00:00:00 2001 From: PerPloug Date: Tue, 14 Sep 2010 07:14:24 +0000 Subject: [PATCH] template dialog for skinning (WIP) [TFS Changeset #77161] --- umbraco.sln | 2 - .../cms/businesslogic/skinning/Skinning.cs | 11 ++- .../presentation/umbraco.presentation.csproj | 8 ++ .../umbraco/dialogs/TemplateSkinning.aspx | 30 +++++++ .../umbraco/dialogs/TemplateSkinning.aspx.cs | 66 ++++++++++++++ .../dialogs/TemplateSkinning.aspx.designer.cs | 87 +++++++++++++++++++ .../umbraco/settings/editTemplate.aspx.cs | 11 +++ 7 files changed, 211 insertions(+), 4 deletions(-) create mode 100644 umbraco/presentation/umbraco/dialogs/TemplateSkinning.aspx create mode 100644 umbraco/presentation/umbraco/dialogs/TemplateSkinning.aspx.cs create mode 100644 umbraco/presentation/umbraco/dialogs/TemplateSkinning.aspx.designer.cs diff --git a/umbraco.sln b/umbraco.sln index d4c25628fe..e8be50c7cc 100644 --- a/umbraco.sln +++ b/umbraco.sln @@ -17,7 +17,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "StandardConfig", "StandardConfig", "{B8ECDB8B-BF44-462C-B6DA-22421B3EC4D7}" ProjectSection(SolutionItems) = preProject - config templates\access.xml = config templates\access.xml aspnet35.config = aspnet35.config config templates\config\UI.xml = config templates\config\UI.xml config templates\umbraco.config = config templates\umbraco.config @@ -71,7 +70,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DLLs", "DLLs", "{F06D18F6-C foreign dlls\IronPython.dll = foreign dlls\IronPython.dll foreign dlls\IronRuby.dll = foreign dlls\IronRuby.dll License.txt = License.txt - foreign dlls\Lucene.Net.dll = foreign dlls\Lucene.Net.dll foreign dlls\Microsoft.ApplicationBlocks.Data.dll = foreign dlls\Microsoft.ApplicationBlocks.Data.dll foreign dlls\MySql.Data.dll = foreign dlls\MySql.Data.dll foreign dlls\TidyNet.dll = foreign dlls\TidyNet.dll diff --git a/umbraco/cms/businesslogic/skinning/Skinning.cs b/umbraco/cms/businesslogic/skinning/Skinning.cs index 0f1d8aa87a..afefe5c6f0 100644 --- a/umbraco/cms/businesslogic/skinning/Skinning.cs +++ b/umbraco/cms/businesslogic/skinning/Skinning.cs @@ -225,6 +225,13 @@ namespace umbraco.cms.businesslogic.skinning return IsSkinnable(template.Alias); } + + public static Dictionary AllowedSkins(int templateID) + { + Template template = new Template(templateID); + return AllowedSkins(template.Alias); + } + public static Dictionary AllowedSkins(Template template) { return AllowedSkins(template.Alias); @@ -268,8 +275,8 @@ namespace umbraco.cms.businesslogic.skinning installed.Load(IO.IOHelper.MapPath(SystemDirectories.Packages) + "/installed/installedPackages.config"); XmlNode starterKit = installed.SelectSingleNode( - string.Format("//templates [contains (., '{0}') ]//ancestor::package",template)); - + string.Format("//package [@enableSkins = 'True' and contains(./templates, '{0}')]", template)); + if (starterKit != null) return new Guid(starterKit.Attributes["packageGuid"].Value); else diff --git a/umbraco/presentation/umbraco.presentation.csproj b/umbraco/presentation/umbraco.presentation.csproj index f3292d1832..d3321d4306 100644 --- a/umbraco/presentation/umbraco.presentation.csproj +++ b/umbraco/presentation/umbraco.presentation.csproj @@ -565,6 +565,13 @@ Preview.aspx + + TemplateSkinning.aspx + ASPXCodeBehind + + + TemplateSkinning.aspx + endPreview.aspx ASPXCodeBehind @@ -1574,6 +1581,7 @@ + diff --git a/umbraco/presentation/umbraco/dialogs/TemplateSkinning.aspx b/umbraco/presentation/umbraco/dialogs/TemplateSkinning.aspx new file mode 100644 index 0000000000..66627a817f --- /dev/null +++ b/umbraco/presentation/umbraco/dialogs/TemplateSkinning.aspx @@ -0,0 +1,30 @@ +<%@ Page Language="C#" MasterPageFile="../masterpages/umbracoDialog.Master" AutoEventWireup="true" CodeBehind="TemplateSkinning.aspx.cs" Inherits="umbraco.presentation.umbraco.dialogs.TemplateSkinning" %> +<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %> +<%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %> + + + + + + + Download more skins + + + + +
+ + + + + or Rollback current skin + + +
+
+ + + ...connect to repo and list all skins available, mark those already installed... + + +
diff --git a/umbraco/presentation/umbraco/dialogs/TemplateSkinning.aspx.cs b/umbraco/presentation/umbraco/dialogs/TemplateSkinning.aspx.cs new file mode 100644 index 0000000000..f934bff993 --- /dev/null +++ b/umbraco/presentation/umbraco/dialogs/TemplateSkinning.aspx.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using umbraco.cms.businesslogic.skinning; +using umbraco.cms.businesslogic.template; +using umbraco.cms.businesslogic; + +namespace umbraco.presentation.umbraco.dialogs +{ + public partial class TemplateSkinning : System.Web.UI.Page + { + private int templateID = 0; + + protected void Page_Load(object sender, EventArgs e) + { + templateID = int.Parse(Request["id"]); + Template t = new Template(templateID); + + if (Skinning.StarterKitGuid(templateID).HasValue) + { + p_apply.Visible = true; + + string currentSkin = Skinning.GetCurrentSkinAlias(templateID); + int templateRoot = FindTemplateRoot((CMSNode)t); + + dd_skins.Items.Add("Choose..."); + foreach (KeyValuePair kvp in Skinning.AllowedSkins(templateRoot)) + { + ListItem li = new ListItem(kvp.Value, kvp.Key); + if (kvp.Key == currentSkin) + li.Selected = true; + + dd_skins.Items.Add(li); + } + + if (!string.IsNullOrEmpty(Skinning.GetCurrentSkinAlias(templateID))) + { + ph_rollback.Visible = true; + } + } + } + + private int FindTemplateRoot(CMSNode t) + { + if (t.ParentId < 0) + return t.Id; + else + return FindTemplateRoot(t.Parent); + } + + protected void openRepo(object sender, EventArgs e) { } + protected void apply(object sender, EventArgs e) { + + if (dd_skins.SelectedIndex > 0) + { + Skinn + + } + + } + protected void rollback(object sender, EventArgs e) { } + } +} \ No newline at end of file diff --git a/umbraco/presentation/umbraco/dialogs/TemplateSkinning.aspx.designer.cs b/umbraco/presentation/umbraco/dialogs/TemplateSkinning.aspx.designer.cs new file mode 100644 index 0000000000..4d777f54ef --- /dev/null +++ b/umbraco/presentation/umbraco/dialogs/TemplateSkinning.aspx.designer.cs @@ -0,0 +1,87 @@ +//------------------------------------------------------------------------------ +// +// 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.presentation.umbraco.dialogs { + + + public partial class TemplateSkinning { + + /// + /// p_apply control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.Pane p_apply; + + /// + /// PropertyPanel1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel PropertyPanel1; + + /// + /// dd_skins control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.DropDownList dd_skins; + + /// + /// PropertyPanel2 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel PropertyPanel2; + + /// + /// Button1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button Button1; + + /// + /// ph_rollback control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.PlaceHolder ph_rollback; + + /// + /// lb_rollback control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.LinkButton lb_rollback; + + /// + /// p_download control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.Pane p_download; + } +} diff --git a/umbraco/presentation/umbraco/settings/editTemplate.aspx.cs b/umbraco/presentation/umbraco/settings/editTemplate.aspx.cs index f76feae4dd..0c48d2757c 100644 --- a/umbraco/presentation/umbraco/settings/editTemplate.aspx.cs +++ b/umbraco/presentation/umbraco/settings/editTemplate.aspx.cs @@ -11,6 +11,7 @@ using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using umbraco.cms.presentation.Trees; using umbraco.IO; +using umbraco.cms.businesslogic.skinning; namespace umbraco.cms.presentation.settings @@ -124,6 +125,16 @@ namespace umbraco.cms.presentation.settings umbContent.OnClickCommand = umbraco.BasePages.ClientTools.Scripts.OpenModalWindow(umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) + "/dialogs/insertMasterpageContent.aspx?id=" + _template.Id.ToString(), ui.Text("template", "insertContentArea"), 470, 300); } + if (Skinning.StarterKitGuid(_template.Id).HasValue) + { + Panel1.Menu.InsertSplitter(); + uicontrols.MenuIconI umbContainer = Panel1.Menu.NewIcon(); + umbContainer.ImageURL = UmbracoPath + "/images/editor/masterpagePlaceHolder.gif"; + umbContainer.AltText = ui.Text("template", "modifyTemplateSkin"); + umbContainer.OnClickCommand = umbraco.BasePages.ClientTools.Scripts.OpenModalWindow(umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) + "/dialogs/TemplateSkinning.aspx?&id=" + _template.Id.ToString(), ui.Text("template", "modifyTemplateSkin"), 570, 420); + } + + // Help Panel1.Menu.InsertSplitter();