diff --git a/umbraco/presentation/umbraco.presentation.csproj b/umbraco/presentation/umbraco.presentation.csproj index 8e8d1ddfb1..011ce74bf0 100644 --- a/umbraco/presentation/umbraco.presentation.csproj +++ b/umbraco/presentation/umbraco.presentation.csproj @@ -94,6 +94,10 @@ False ..\..\foreign dlls\Examine.dll + + False + ..\..\foreign dlls\HtmlAgilityPack.dll + False ..\..\foreign dlls\ICSharpCode.SharpZipLib.dll @@ -651,6 +655,20 @@ ImageUploader.aspx + + ModuleInjectionMacroRenderer.aspx + ASPXCodeBehind + + + ModuleInjectionMacroRenderer.aspx + + + ModuleInjector.aspx + ASPXCodeBehind + + + ModuleInjector.aspx + SkinCustomizer.ascx ASPXCodeBehind @@ -1651,7 +1669,10 @@ + + + diff --git a/umbraco/presentation/umbraco/LiveEditing/Modules/SkinModule/ModuleInjectionMacroRenderer.aspx b/umbraco/presentation/umbraco/LiveEditing/Modules/SkinModule/ModuleInjectionMacroRenderer.aspx new file mode 100644 index 0000000000..253ce9ead3 --- /dev/null +++ b/umbraco/presentation/umbraco/LiveEditing/Modules/SkinModule/ModuleInjectionMacroRenderer.aspx @@ -0,0 +1 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ModuleInjectionMacroRenderer.aspx.cs" Inherits="umbraco.presentation.umbraco.LiveEditing.Modules.SkinModule.ModuleInjectionMacroRenderer" %> diff --git a/umbraco/presentation/umbraco/LiveEditing/Modules/SkinModule/ModuleInjectionMacroRenderer.aspx.cs b/umbraco/presentation/umbraco/LiveEditing/Modules/SkinModule/ModuleInjectionMacroRenderer.aspx.cs new file mode 100644 index 0000000000..243add8787 --- /dev/null +++ b/umbraco/presentation/umbraco/LiveEditing/Modules/SkinModule/ModuleInjectionMacroRenderer.aspx.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Collections; +using System.Text; +using System.IO; + +namespace umbraco.presentation.umbraco.LiveEditing.Modules.SkinModule +{ + public partial class ModuleInjectionMacroRenderer : UmbracoDefault + { + + + protected override void Render(HtmlTextWriter output) + { + if (!string.IsNullOrEmpty(Request["tag"])) + { + presentation.templateControls.Macro m = new presentation.templateControls.Macro(); + + Hashtable DataValues = helper.ReturnAttributes(Request["tag"]); + + m.Alias = DataValues["alias"].ToString(); + m.MacroAttributes = DataValues; + + StringBuilder sb = new StringBuilder(); + StringWriter tw = new StringWriter(sb); + HtmlTextWriter hw = new HtmlTextWriter(tw); + + m.RenderControl(hw); + + Response.Output.Write(sb.ToString()); + } + } + } +} \ No newline at end of file diff --git a/umbraco/presentation/umbraco/LiveEditing/Modules/SkinModule/ModuleInjectionMacroRenderer.aspx.designer.cs b/umbraco/presentation/umbraco/LiveEditing/Modules/SkinModule/ModuleInjectionMacroRenderer.aspx.designer.cs new file mode 100644 index 0000000000..77d6cd4cdf --- /dev/null +++ b/umbraco/presentation/umbraco/LiveEditing/Modules/SkinModule/ModuleInjectionMacroRenderer.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.presentation.umbraco.LiveEditing.Modules.SkinModule { + + + public partial class ModuleInjectionMacroRenderer { + } +} diff --git a/umbraco/presentation/umbraco/LiveEditing/Modules/SkinModule/ModuleInjector.aspx b/umbraco/presentation/umbraco/LiveEditing/Modules/SkinModule/ModuleInjector.aspx new file mode 100644 index 0000000000..6747d340a9 --- /dev/null +++ b/umbraco/presentation/umbraco/LiveEditing/Modules/SkinModule/ModuleInjector.aspx @@ -0,0 +1,117 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ModuleInjector.aspx.cs" Inherits="umbraco.presentation.umbraco.LiveEditing.Modules.SkinModule.ModuleInjector" %> +<%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %> +<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %> + + + + + + + + + + + + +
+ + + +
+ +
+ + " + onclick="updateMacro()" /> + +
+ + diff --git a/umbraco/presentation/umbraco/LiveEditing/Modules/SkinModule/ModuleInjector.aspx.cs b/umbraco/presentation/umbraco/LiveEditing/Modules/SkinModule/ModuleInjector.aspx.cs new file mode 100644 index 0000000000..f89b5a8c06 --- /dev/null +++ b/umbraco/presentation/umbraco/LiveEditing/Modules/SkinModule/ModuleInjector.aspx.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Reflection; +using umbraco.IO; + +namespace umbraco.presentation.umbraco.LiveEditing.Modules.SkinModule +{ + public partial class ModuleInjector : BasePages.UmbracoEnsuredPage + { + private cms.businesslogic.macro.Macro m; + public string _macroAlias = ""; + + protected void Page_Load(object sender, EventArgs e) + { + renderProperties(); + } + + protected void renderProperties() + { + if (!string.IsNullOrEmpty(Request["macroAlias"])) + { + + + m = cms.businesslogic.macro.Macro.GetByAlias(Request["macroAlias"]); + + String macroAssembly = ""; + String macroType = ""; + + _macroAlias = m.Alias; + + + //If no properties, we will exit now... + if (m.Properties.Length == 0) + { + Literal noProps = new Literal(); + noProps.Text = ""; + macroProperties.Controls.Add(noProps); + } + else + { + //if we have properties, we'll render the controls for them... + foreach (cms.businesslogic.macro.MacroProperty mp in m.Properties) + { + macroAssembly = mp.Type.Assembly; + macroType = mp.Type.Type; + try + { + + Assembly assembly = Assembly.LoadFrom(IOHelper.MapPath(SystemDirectories.Bin + "/" + macroAssembly + ".dll")); + + Type type = assembly.GetType(macroAssembly + "." + macroType); + interfaces.IMacroGuiRendering typeInstance = Activator.CreateInstance(type) as interfaces.IMacroGuiRendering; + if (typeInstance != null) + { + Control control = Activator.CreateInstance(type) as Control; + control.ID = mp.Alias; + + if (!IsPostBack) + { + if (Request["umb_" + mp.Alias] != null) + { + if (Request["umb_" + mp.Alias] != "") + { + type.GetProperty("Value").SetValue(control, Convert.ChangeType(Request["umb_" + mp.Alias], type.GetProperty("Value").PropertyType), null); + } + } + } + + // register alias + uicontrols.PropertyPanel pp = new uicontrols.PropertyPanel(); + pp.Text = mp.Name; + pp.Controls.Add(control); + macroProperties.Controls.Add(pp); + + pp.Controls.Add(new LiteralControl("\n")); + + + + } + else + { + Trace.Warn("umbEditContent", "Type doesn't exist or is not umbraco.interfaces.DataFieldI ('" + macroAssembly + "." + macroType + "')"); + } + + } + catch (Exception fieldException) + { + Trace.Warn("umbEditContent", "Error creating type '" + macroAssembly + "." + macroType + "'", fieldException); + } + } + } + } + else + { + + } + } + } +} \ No newline at end of file diff --git a/umbraco/presentation/umbraco/LiveEditing/Modules/SkinModule/ModuleInjector.aspx.designer.cs b/umbraco/presentation/umbraco/LiveEditing/Modules/SkinModule/ModuleInjector.aspx.designer.cs new file mode 100644 index 0000000000..ab912e99cc --- /dev/null +++ b/umbraco/presentation/umbraco/LiveEditing/Modules/SkinModule/ModuleInjector.aspx.designer.cs @@ -0,0 +1,51 @@ +//------------------------------------------------------------------------------ +// +// 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.LiveEditing.Modules.SkinModule { + + + public partial class ModuleInjector { + + /// + /// ClientLoader control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.UmbracoClientDependencyLoader ClientLoader; + + /// + /// JsInclude1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::ClientDependency.Core.Controls.JsInclude JsInclude1; + + /// + /// 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; + + /// + /// macroProperties control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.PlaceHolder macroProperties; + } +} diff --git a/umbraco/presentation/umbraco/LiveEditing/Modules/SkinModule/SkinModule.cs b/umbraco/presentation/umbraco/LiveEditing/Modules/SkinModule/SkinModule.cs index 598a8cafb2..0158d65e95 100644 --- a/umbraco/presentation/umbraco/LiveEditing/Modules/SkinModule/SkinModule.cs +++ b/umbraco/presentation/umbraco/LiveEditing/Modules/SkinModule/SkinModule.cs @@ -11,11 +11,17 @@ using System.Web.UI; using umbraco.cms.businesslogic.skinning; using ClientDependency.Core.Controls; using umbraco.presentation.umbraco.controls; +using HtmlAgilityPack; +using umbraco.cms.businesslogic.template; +using System.Text; +using System.IO; +using System.Collections; namespace umbraco.presentation.umbraco.LiveEditing.Modules.SkinModule { [ClientDependency(200, ClientDependencyType.Javascript, "modal/modal.js", "UmbracoClient")] [ClientDependency(200, ClientDependencyType.Css, "modal/style.css", "UmbracoClient")] + [ClientDependency(500, ClientDependencyType.Javascript, "LiveEditing/Modules/SkinModule/js/ModuleInjection.js", "UmbracoRoot")] [ClientDependency(800, ClientDependencyType.Javascript, "LiveEditing/Modules/SkinModule/js/disableInstallButtonsOnClick.js", "UmbracoRoot")] public class SkinModule : BaseModule { @@ -75,5 +81,83 @@ namespace umbraco.presentation.umbraco.LiveEditing.Modules.SkinModule ClientDependencyLoader.Instance.RegisterDependency(500, "LiveEditing/Modules/SkinModule/js/SkinModuleShowOnStartup.js", "UmbracoRoot", ClientDependencyType.Javascript); } } + + + + protected override void Manager_MessageReceived(object sender, MesssageReceivedArgs e) + { + switch (e.Type) + { + case "injectmodule": + //update template, insert macro tag + + if (InsertMacroTag(nodeFactory.Node.GetCurrent().template, e.Message.Split(';')[0], e.Message.Split(';')[1], e.Message.Split(';')[2] == "prepend")) + { + //ok + + //presentation.templateControls.Macro m = new presentation.templateControls.Macro(); + + //Hashtable DataValues = helper.ReturnAttributes(e.Message.Split(';')[1]); + + //m.Alias = DataValues["alias"].ToString(); + //m.MacroAttributes = DataValues; + + //StringBuilder sb = new StringBuilder(); + //StringWriter tw = new StringWriter(sb); + //HtmlTextWriter hw = new HtmlTextWriter(tw); + + //m.RenderControl(hw); + + //string macroOutput = sb.ToString(); + + //string placeMacroOutput = string.Format("jQuery('.umbModuleContainerPlaceHolder','#{0}').remove();jQuery('#{0}').{1}(\"{2}\");", e.Message.Split(';')[0], e.Message.Split(';')[2], macroOutput); + + + //ScriptManager.RegisterClientScriptBlock(Page, GetType(), new Guid().ToString(), placeMacroOutput, true); + + } + else + { + //not ok + } + + break; + } + } + + private bool InsertMacroTag(int template, string targetId, string tag, bool prepend) + { + Template t = new Template(template); + + string TargetFile = t.MasterPageFile; + string TargetID = targetId; + + HtmlDocument doc = new HtmlDocument(); + doc.Load(TargetFile); + + if (doc.DocumentNode.SelectNodes(string.Format("//*[@id = '{0}']", TargetID)) != null) + { + foreach (HtmlNode target in doc.DocumentNode.SelectNodes(string.Format("//*[@id = '{0}']", TargetID))) + { + HtmlNode macrotag = HtmlNode.CreateNode(tag); + + if (prepend) + target.PrependChild(macrotag); + else + target.AppendChild(macrotag); + } + doc.Save(TargetFile); + + return true; + } + else + { + //might be on master template + if (t.HasMasterTemplate) + return InsertMacroTag(t.MasterTemplate, targetId, tag, prepend); + else + return false; + } + } } } \ No newline at end of file diff --git a/umbraco/presentation/umbraco/LiveEditing/Modules/SkinModule/js/ModuleInjection.js b/umbraco/presentation/umbraco/LiveEditing/Modules/SkinModule/js/ModuleInjection.js new file mode 100644 index 0000000000..5bdc0fe057 --- /dev/null +++ b/umbraco/presentation/umbraco/LiveEditing/Modules/SkinModule/js/ModuleInjection.js @@ -0,0 +1,43 @@ +function umbShowModuleContainerSelectors() { + + jQuery(".umbModuleContainer").each(function () { + + if (jQuery(this).children().size() > 0) { + jQuery(this).prepend("
Insert module here
"); + } + + jQuery(this).append("
Insert module here
"); + + }); + + jQuery(".umbModuleContainerSelector").click(function () { + + Umbraco.Controls.ModalWindow().open('/umbraco/LiveEditing/Modules/SkinModule/ModuleInjector.aspx?macroAlias=RunwayTopNavigation&target=' + jQuery(this).parent().attr('id') + "&type=" + jQuery(this).attr('rel'), 'Insert module', true, 550, 550, 50, 0, ['.modalbuton'], null); + + }); +} + +function umbRemoveModuleContainerSelectors() { + jQuery(".umbModuleContainerSelector").remove(); +} + +function umbInsertModule(container,macro,type) { + umbRemoveModuleContainerSelectors(); + + + if (type == "append") { + jQuery("#" + container).append("
Working...
"); + } else { + jQuery("#" + container).prepend("
Working...
"); + } + + UmbracoCommunicator.SendClientMessage("injectmodule", container + ";" + macro + ";" + type); + + //need to lose this replace calls + supply current page id; + + jQuery.post("/umbraco/LiveEditing/Modules/SkinModule/ModuleInjectionMacroRenderer.aspx?tag=" + macro.replace('>','').replace('<','').replace('',''), + function (data) { + jQuery(".umbModuleContainerPlaceHolder").html(data); + }); + +} \ No newline at end of file diff --git a/umbraco/presentation/umbraco/dashboard/StartupMediaDashboard.ascx b/umbraco/presentation/umbraco/dashboard/StartupMediaDashboard.ascx index d09d4d0d31..28714b7b3f 100644 --- a/umbraco/presentation/umbraco/dashboard/StartupMediaDashboard.ascx +++ b/umbraco/presentation/umbraco/dashboard/StartupMediaDashboard.ascx @@ -1,5 +1,5 @@ <%@ Control Language="C#" AutoEventWireup="True" CodeBehind="StartupMediaDashboard.ascx.cs" Inherits="dashboardUtilities.StartupMediaDashboard" %> -<%@ Register src="zipupload.ascx" tagname="zipupload" tagprefix="uc1" %> +<%--<%@ Register src="zipupload.ascx" tagname="zipupload" tagprefix="uc1" %>--%> <%@ Register Namespace="umbraco.uicontrols" Assembly="controls" TagPrefix="umb" %> @@ -149,7 +149,7 @@

Upload Files

- + <%-- --%>
diff --git a/umbraco/presentation/umbraco/dashboard/StartupMediaDashboard.ascx.designer.cs b/umbraco/presentation/umbraco/dashboard/StartupMediaDashboard.ascx.designer.cs index 80f33b8319..1d6c8d3b82 100644 --- a/umbraco/presentation/umbraco/dashboard/StartupMediaDashboard.ascx.designer.cs +++ b/umbraco/presentation/umbraco/dashboard/StartupMediaDashboard.ascx.designer.cs @@ -19,7 +19,16 @@ namespace dashboardUtilities { /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::System.Web.UI.WebControls.Panel startPanel; + protected global::umbraco.uicontrols.Pane startPanel; + + /// + /// startPP control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel startPP; /// /// zipUploadPanel control. @@ -28,25 +37,34 @@ namespace dashboardUtilities { /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::System.Web.UI.WebControls.Panel zipUploadPanel; + protected global::umbraco.uicontrols.Pane zipUploadPanel; /// - /// zipupload1 control. + /// zipUploadPP control. /// /// /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::Nibble.Umb.ZipUpload.zipupload zipupload1; + protected global::umbraco.uicontrols.PropertyPanel zipUploadPP; /// - /// learnPanel control. + /// learn control. /// /// /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::System.Web.UI.WebControls.Panel learnPanel; + protected global::umbraco.uicontrols.Pane learn; + + /// + /// learnPP control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel learnPP; /// /// hidePanel control. @@ -55,7 +73,16 @@ namespace dashboardUtilities { /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::System.Web.UI.WebControls.Panel hidePanel; + protected global::umbraco.uicontrols.Pane hidePanel; + + /// + /// hidePP control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::umbraco.uicontrols.PropertyPanel hidePP; /// /// hideCheckBox control. diff --git a/umbraco/presentation/umbraco/templateControls/Macro.cs b/umbraco/presentation/umbraco/templateControls/Macro.cs index f2357d8911..6f9aceb12f 100644 --- a/umbraco/presentation/umbraco/templateControls/Macro.cs +++ b/umbraco/presentation/umbraco/templateControls/Macro.cs @@ -21,6 +21,10 @@ namespace umbraco.presentation.templateControls { // Hashtable attributes = (Hashtable)ViewState["Attributes"]; return m_Attributes; } + set + { + m_Attributes = value; + } }