Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
int32at committed Jul 20, 2013
2 parents ea37e07 + 1d722a3 commit 14b3bd9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
5 changes: 5 additions & 0 deletions lib/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,8 @@ install-spsolution -Identity "$wspFileName" -gacdeployment
wait4timer($wspFileName)
write-host "Done adding"

$ca = Get-SPWebApplication -IncludeCentralAdministration | where {$_.DisplayName -eq "SharePoint Central Administration v4"} | select Url
$url = $ca.Url + "Sponge/default.aspx"

Start-Process $url

28 changes: 25 additions & 3 deletions src/Sponge/Features/Sponge.Feature/Sponge.EventReceiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebPartPages;
using Sponge.Common.Models;
using Sponge.Common.Utilities;

Expand Down Expand Up @@ -53,6 +55,8 @@ private void UpdateLists(SPManager mgr)
CreateConfigItems(mgr);
//CreateLogAppenders(mgr);
//CreateLogConfigs(mgr);

CreateWebParts(mgr);
}

private void CreateConfigItems(SPManager mgr)
Expand All @@ -76,11 +80,9 @@ private void CreateConfigItems(SPManager mgr)
ct.FieldLinks.Reorder(new string[] { "Application", "Key", "Value" });
}




var title = list.Fields["Title"];
title.Title = "Key";
title.Description = "Do not use blanks or special characters here!";
title.Update();

SPView view = list.DefaultView;
Expand Down Expand Up @@ -117,5 +119,25 @@ private SPList CreateList(SPManager mgr, string listName)

return list;
}

private void CreateWebParts(SPManager mgr)
{
var configItems = new XsltListViewWebPart();
configItems.ListId = mgr.ParentWeb.Lists[Constants.SPONGE_LIST_CONFIGITEMS].ID;

var configApps = new XsltListViewWebPart();
configApps.ListId = mgr.ParentWeb.Lists[Constants.SPONGE_LIST_CONFIGAPPLICATIONS].ID;

AddWebPart(mgr.ParentWeb, "default.aspx", configApps, "left", 1);
AddWebPart(mgr.ParentWeb, "default.aspx", configItems, "left", 2);
}

private void AddWebPart(SPWeb web, string pageURL, System.Web.UI.WebControls.WebParts.WebPart webPart, string zoneID, int zoneIndex)
{
SPLimitedWebPartManager webPartManager = web.GetLimitedWebPartManager(pageURL, PersonalizationScope.Shared);
webPartManager.AddWebPart(webPart, zoneID, zoneIndex);
webPartManager.SaveChanges(webPart);
web.Update();
}
}
}

0 comments on commit 14b3bd9

Please sign in to comment.