WIP installer refactor, updates to skin module, adds rollback active skin option

[TFS Changeset #77218]
This commit is contained in:
starfighter83
2010-09-16 08:17:32 +00:00
parent bb0a4eb023
commit e7c8be2d51
3 changed files with 69 additions and 25 deletions

View File

@@ -94,6 +94,16 @@ namespace umbraco.cms.businesslogic.skinning
return CreateFromFile(manifest);
}
public static Skin CreateFromName(string name)
{
foreach (Skin s in Skinning.GetAllSkins())
{
if (s.Name == name)
return s;
}
return null;
}
public bool OverridesTemplates()
{
return (System.IO.Directory.GetFiles(IO.IOHelper.MapPath(SkinFolder), "*.master").Count() > 0);

View File

@@ -44,8 +44,9 @@
<span><%# ((Skin)Container.DataItem).Text %></span>
<br />
<asp:Button ID="Button1" runat="server" Text="Install" CommandArgument="<%# ((Skin)Container.DataItem).RepoGuid %>" OnClick="SelectStarterKitDesign"/>
<asp:Button ID="Button1" runat="server" Text="Install" CommandArgument="<%# ((Skin)Container.DataItem).RepoGuid %>" OnClick="SelectStarterKitDesign" CommandName="<%# ((Skin)Container.DataItem).Text %>"/>
</li>
</ItemTemplate>
@@ -56,7 +57,12 @@
</div>
<p runat="server" id="pCustomizeSkin">... or <a href="#" onclick="jQuery('#changeSkin').hide();jQuery('#costumizeSkin').show();">customize</a> current skin</p>
<p runat="server" id="pCustomizeSkin">
... or <a href="#" onclick="jQuery('#changeSkin').hide();jQuery('#costumizeSkin').show();">customize</a> current skin</p>
<button type="button" class="modalbuton" id="cancelSkinInstall">Cancel</button>

View File

@@ -9,6 +9,7 @@ using System.Xml;
using System.Text;
using umbraco.interfaces.skinning;
using umbraco.IO;
using umbraco.cms.businesslogic.template;
namespace umbraco.presentation.umbraco.LiveEditing.Modules.SkinModule
{
@@ -94,10 +95,19 @@ namespace umbraco.presentation.umbraco.LiveEditing.Modules.SkinModule
if (Skinning.IsSkinInstalled(s.RepoGuid))
{
Button inst = (Button)e.Item.FindControl("Button1");
inst.Text = "Already downloaded";
inst.Enabled = false;
inst.Text = "Apply (already downloaded)";
inst.CommandName = "apply";
inst.CommandArgument = s.Text;
}
if (ActiveSkin.Name == s.Text)
{
Button inst = (Button)e.Item.FindControl("Button1");
inst.Text = "Rollback (active skin)";
inst.CommandName = "remove";
inst.CommandArgument = s.Text;
}
}
}
@@ -210,36 +220,54 @@ namespace umbraco.presentation.umbraco.LiveEditing.Modules.SkinModule
protected void SelectStarterKitDesign(object sender, EventArgs e)
{
Guid kitGuid = new Guid(((Button)sender).CommandArgument);
cms.businesslogic.packager.Installer installer = new cms.businesslogic.packager.Installer();
if (repo.HasConnection())
if (((Button)sender).CommandName == "apply")
{
cms.businesslogic.packager.Installer p = new cms.businesslogic.packager.Installer();
Skin s = Skin.CreateFromName(((Button)sender).CommandArgument);
Skinning.ActivateAsCurrentSkin(s);
string tempFile = p.Import(repo.fetch(kitGuid.ToString()));
p.LoadConfig(tempFile);
int pID = p.CreateManifest(tempFile, kitGuid.ToString(), repoGuid);
p.InstallFiles(pID, tempFile);
p.InstallBusinessLogic(pID, tempFile);
p.InstallCleanUp(pID, tempFile);
library.RefreshContent();
if (cms.businesslogic.skinning.Skinning.GetAllSkins().Count > 0)
{
cms.businesslogic.skinning.Skinning.ActivateAsCurrentSkin(cms.businesslogic.skinning.Skinning.GetAllSkins()[0]);
}
Page.Response.Redirect(library.NiceUrl(int.Parse(UmbracoContext.Current.PageId.ToString())));
}
else if (((Button)sender).CommandName == "remove")
{
nodeFactory.Node n = nodeFactory.Node.GetCurrent();
Template t = new Template(n.template);
Skinning.RollbackSkin(t.Id);
Page.Response.Redirect(library.NiceUrl(int.Parse(UmbracoContext.Current.PageId.ToString())));
}
else
{
//ShowConnectionError();
Guid kitGuid = new Guid(((Button)sender).CommandArgument);
cms.businesslogic.packager.Installer installer = new cms.businesslogic.packager.Installer();
if (repo.HasConnection())
{
cms.businesslogic.packager.Installer p = new cms.businesslogic.packager.Installer();
string tempFile = p.Import(repo.fetch(kitGuid.ToString()));
p.LoadConfig(tempFile);
int pID = p.CreateManifest(tempFile, kitGuid.ToString(), repoGuid);
p.InstallFiles(pID, tempFile);
p.InstallBusinessLogic(pID, tempFile);
p.InstallCleanUp(pID, tempFile);
library.RefreshContent();
Skin s = Skin.CreateFromName(((Button)sender).CommandName);
Skinning.ActivateAsCurrentSkin(s);
Page.Response.Redirect(library.NiceUrl(int.Parse(UmbracoContext.Current.PageId.ToString())));
}
else
{
//ShowConnectionError();
}
}
}
}
}