Skip to content

Instantly share code, notes, and snippets.

Created July 14, 2010 20:54
Show Gist options
  • Save anonymous/476055 to your computer and use it in GitHub Desktop.
Save anonymous/476055 to your computer and use it in GitHub Desktop.
using System;
using System.Linq;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Security.Permissions;
using DotNetNuke.Services.FileSystem;
using DotNetNuke.UI.Skins;
namespace MyCompany.Controls {
public class DynamicPane : UserControl {
/// <summary>
/// The name of the pane to load (ex: ContentPane)
/// </summary>
public string Pane { get; set; }
/// <summary>
/// The tab id for the tab to load
/// </summary>
public int TabId { get; set; }
/// <summary>
/// The module id for the control hosting this dynamic pane (use -1 if this is not used in a module)
/// </summary>
public int ModuleId { get; set; }
protected override void OnLoad(EventArgs e) {
var control = new HtmlGenericControl("div");
Controls.Add(control);
var pane = new Pane(control);
var desired = new PortalSettings(TabId, PortalSettings.Current.PortalId);
if (desired.ActiveTab.Modules.Count > 0) {
string defaultContainerSrc = PortalSettings.Current.ActiveTab.ContainerSrc;
foreach (ModuleInfo objModule in desired.ActiveTab.Modules.Cast<ModuleInfo>().Where(
m =>
m.PaneName == Pane
&& ModulePermissionController.CanViewModule(m)
&& m.IsDeleted == false
&& m.StartDate < DateTime.Now
&& m.EndDate > DateTime.Now
&& m.ModuleID != ModuleId)) {
if (objModule.IconFile.ToLower().IndexOf("fileid=") >= 0) {
FileInfo fileById = new FileController().GetFileById(int.Parse(objModule.IconFile.ToLower().Replace("fileid=", "")), objModule.PortalID);
string str = fileById.Folder + fileById.FileName;
objModule.IconFile = str;
}
if (objModule.ContainerSrc == "") {
objModule.ContainerSrc = defaultContainerSrc;
}
pane.InjectModule(objModule);
}
}
base.OnLoad(e);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment