WIP installer refactor, work on skinning engine

[TFS Changeset #78244]
This commit is contained in:
starfighter83
2010-10-11 15:06:16 +00:00
parent c0942cdf6b
commit 8a0a33870b
12 changed files with 513 additions and 9 deletions

View File

@@ -94,6 +94,10 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\foreign dlls\Examine.dll</HintPath>
</Reference>
<Reference Include="HtmlAgilityPack, Version=1.4.0.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\foreign dlls\HtmlAgilityPack.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.SharpZipLib, Version=0.83.1.0, Culture=neutral, PublicKeyToken=1b03e6acf1164f73">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\foreign dlls\ICSharpCode.SharpZipLib.dll</HintPath>
@@ -651,6 +655,20 @@
<Compile Include="umbraco\LiveEditing\Modules\SkinModule\ImageUploader.aspx.designer.cs">
<DependentUpon>ImageUploader.aspx</DependentUpon>
</Compile>
<Compile Include="umbraco\LiveEditing\Modules\SkinModule\ModuleInjectionMacroRenderer.aspx.cs">
<DependentUpon>ModuleInjectionMacroRenderer.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="umbraco\LiveEditing\Modules\SkinModule\ModuleInjectionMacroRenderer.aspx.designer.cs">
<DependentUpon>ModuleInjectionMacroRenderer.aspx</DependentUpon>
</Compile>
<Compile Include="umbraco\LiveEditing\Modules\SkinModule\ModuleInjector.aspx.cs">
<DependentUpon>ModuleInjector.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="umbraco\LiveEditing\Modules\SkinModule\ModuleInjector.aspx.designer.cs">
<DependentUpon>ModuleInjector.aspx</DependentUpon>
</Compile>
<Compile Include="umbraco\LiveEditing\Modules\SkinModule\SkinCustomizer.ascx.cs">
<DependentUpon>SkinCustomizer.ascx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
@@ -1651,7 +1669,10 @@
<Content Include="umbraco\images\umbraco\settingSkin.gif" />
<Content Include="umbraco\LiveEditing\Modules\SkinModule\ImageUploader.aspx" />
<Content Include="umbraco\LiveEditing\Modules\SkinModule\js\disableInstallButtonsOnClick.js" />
<Content Include="umbraco\LiveEditing\Modules\SkinModule\js\ModuleInjection.js" />
<Content Include="umbraco\LiveEditing\Modules\SkinModule\js\SkinModuleShowOnStartup.js" />
<Content Include="umbraco\LiveEditing\Modules\SkinModule\ModuleInjectionMacroRenderer.aspx" />
<Content Include="umbraco\LiveEditing\Modules\SkinModule\ModuleInjector.aspx" />
<Content Include="umbraco\LiveEditing\Modules\SkinModule\skin.png" />
<Content Include="umbraco\LiveEditing\Modules\SkinModule\SkinCustomizer.ascx" />
<Content Include="umbraco\LiveEditing\Modules\SkinModule\SkinModule.js" />

View File

@@ -0,0 +1 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ModuleInjectionMacroRenderer.aspx.cs" Inherits="umbraco.presentation.umbraco.LiveEditing.Modules.SkinModule.ModuleInjectionMacroRenderer" %>

View File

@@ -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());
}
}
}
}

View File

@@ -0,0 +1,15 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace umbraco.presentation.umbraco.LiveEditing.Modules.SkinModule {
public partial class ModuleInjectionMacroRenderer {
}
}

View File

@@ -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" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<cc1:UmbracoClientDependencyLoader runat="server" id="ClientLoader" />
<umb:JsInclude ID="JsInclude1" runat="server" FilePath="ui/jquery.js" PathNameAlias="UmbracoClient"
Priority="0" />
<script type="text/javascript">
var macroAliases = new Array();
var macroAlias = '<%= _macroAlias %>';
<%if (umbraco.UmbracoSettings.UseAspNetMasterPages) { %>
var macroElement = "umbraco:Macro";
<%}else{ %>
var macroElement = "?UMBRACO_MACRO";
<%}%>
function registerAlias(alias, pAlias) {
var macro = new Array();
macro[0] = alias;
macro[1] = pAlias;
macroAliases[macroAliases.length] = macro;
}
function updateMacro() {
var macroString = '<' + macroElement + ' ';
for (i=0; i<macroAliases.length; i++) {
var controlId = macroAliases[i][0];
var propertyName = macroAliases[i][1];
var control = jQuery("#" + controlId);
if (control == null || (!control.is('input') && !control.is('select'))) {
// hack for tree based macro parameter types
var picker = Umbraco.Controls.TreePicker.GetPickerById(controlId);
if (picker != undefined) {
macroString += propertyName + "=\"" + picker.GetValue() + "\" ";
}
} else {
if (control.is(':checkbox')) {
if (control.is(':checked'))
macroString += propertyName + "=\"1\" ";
else
macroString += propertyName + "=\"0\" ";
} else if (control[0].tagName.toLowerCase() == 'select') {
var tempValue = '';
control.find(':selected').each(function(i, selected) {
tempValue += jQuery(this).attr('value') + ', ';
});
/*
for (var j=0; j<document.forms[0][controlId].length;j++) {
if (document.forms[0][controlId][j].selected)
tempValue += document.forms[0][controlId][j].value + ', ';
}
*/
if (tempValue.length > 2)
tempValue = tempValue.substring(0, tempValue.length-2)
macroString += propertyName + "=\"" + tempValue + "\" ";
}else {
macroString += propertyName + "=\"" + pseudoHtmlEncode(document.forms[0][controlId].value) + "\" ";
}
}
}
if (macroString.length > 1)
macroString = macroString.substr(0, macroString.length-1);
<%if (!umbraco.UmbracoSettings.UseAspNetMasterPages){ %>
macroString += " macroAlias=\"" + macroAlias + "\"";
<%} %>
<%if (umbraco.UmbracoSettings.UseAspNetMasterPages){ %>
macroString += " Alias=\"" + macroAlias + "\" runat=\"server\"></" + macroElement + ">";
<%} else { %>
macroString += "></" + macroElement + ">";
<%} %>
top.jQuery('.umbModalBoxIframe').closest(".umbModalBox").ModalWindowAPI().close();
top.umbInsertModule('<%=umbraco.helper.Request("target")%>',macroString,'<%=umbraco.helper.Request("type")%>');
}
function pseudoHtmlEncode(text) {
return text.replace(/\"/gi,"&amp;quot;").replace(/\</gi,"&amp;lt;").replace(/\>/gi,"&amp;gt;");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div style="height: 420px; overflow: auto;">
<asp:PlaceHolder ID="macroProperties" runat="server" />
</div>
<input type="button" value="<%=umbraco.ui.Text("general", "ok", this.getUser())%>"
onclick="updateMacro()" />
</form>
</body>
</html>

View File

@@ -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 = "<script type='text/javascript'>updateMacro()</script>";
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("<script type=\"text/javascript\"> registerAlias('" + control.ClientID + "','" + mp.Alias + "'); </script>\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
{
}
}
}
}

View File

@@ -0,0 +1,51 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace umbraco.presentation.umbraco.LiveEditing.Modules.SkinModule {
public partial class ModuleInjector {
/// <summary>
/// ClientLoader control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.UmbracoClientDependencyLoader ClientLoader;
/// <summary>
/// JsInclude1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::ClientDependency.Core.Controls.JsInclude JsInclude1;
/// <summary>
/// form1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
/// <summary>
/// macroProperties control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.PlaceHolder macroProperties;
}
}

View File

@@ -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;
}
}
}
}

View File

@@ -0,0 +1,43 @@
function umbShowModuleContainerSelectors() {
jQuery(".umbModuleContainer").each(function () {
if (jQuery(this).children().size() > 0) {
jQuery(this).prepend("<div class='umbModuleContainerSelector' rel='prepend'>Insert module here</div>");
}
jQuery(this).append("<div class='umbModuleContainerSelector' rel='append'>Insert module here</div>");
});
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("<div class='umbModuleContainerPlaceHolder'>Working...</div>");
} else {
jQuery("#" + container).prepend("<div class='umbModuleContainerPlaceHolder'>Working...</div>");
}
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('</umbraco:Macro>',''),
function (data) {
jQuery(".umbModuleContainerPlaceHolder").html(data);
});
}

View File

@@ -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" %>
<script type="text/javascript" src="/umbraco/dashboard/scripts/jquery.jfeed.pack.js"></script>
<link href="/umbraco_client/propertypane/style.css" rel="stylesheet" />
@@ -149,7 +149,7 @@
<umb:Pane runat="server" ID="zipUploadPanel">
<umb:PropertyPanel runat="server" ID="zipUploadPP">
<h2>Upload Files</h2>
<uc1:zipupload ID="zipupload1" runat="server" />
<%-- <uc1:zipupload ID="zipupload1" runat="server" />--%>
</umb:PropertyPanel>
</umb:Pane>

View File

@@ -19,7 +19,16 @@ namespace dashboardUtilities {
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Panel startPanel;
protected global::umbraco.uicontrols.Pane startPanel;
/// <summary>
/// startPP control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.PropertyPanel startPP;
/// <summary>
/// zipUploadPanel control.
@@ -28,25 +37,34 @@ namespace dashboardUtilities {
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Panel zipUploadPanel;
protected global::umbraco.uicontrols.Pane zipUploadPanel;
/// <summary>
/// zipupload1 control.
/// zipUploadPP control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::Nibble.Umb.ZipUpload.zipupload zipupload1;
protected global::umbraco.uicontrols.PropertyPanel zipUploadPP;
/// <summary>
/// learnPanel control.
/// learn control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Panel learnPanel;
protected global::umbraco.uicontrols.Pane learn;
/// <summary>
/// learnPP control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.PropertyPanel learnPP;
/// <summary>
/// hidePanel control.
@@ -55,7 +73,16 @@ namespace dashboardUtilities {
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Panel hidePanel;
protected global::umbraco.uicontrols.Pane hidePanel;
/// <summary>
/// hidePP control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::umbraco.uicontrols.PropertyPanel hidePP;
/// <summary>
/// hideCheckBox control.

View File

@@ -21,6 +21,10 @@ namespace umbraco.presentation.templateControls {
// Hashtable attributes = (Hashtable)ViewState["Attributes"];
return m_Attributes;
}
set
{
m_Attributes = value;
}
}