public SkinFile(string SkinRoot, string FileName, XmlDocument SkinAttributes) { m_FileName = FileName; m_FileExtension = Path.GetExtension(FileName); m_SkinRoot = SkinRoot; m_FileAttributes = SkinAttributes; string strTemp = FileName.Replace(Path.GetFileName(FileName), ""); strTemp = strTemp.Replace("\\", "/"); m_SkinRootPath = Common.Globals.ApplicationPath + strTemp.Substring(0, strTemp.ToUpper().IndexOf("/PORTALS")); this.Contents = Read(FileName); switch (this.FileExtension) { case ".htm": case ".html": m_WriteFileName = FileName.Replace(Path.GetExtension(FileName), ".ascx"); Regex PaneCheck1 = new Regex("\\s*id\\s*=\\s*\"" + Common.Globals.glbDefaultPane + "\"", RegexOptions.IgnoreCase); Regex PaneCheck2 = new Regex("\\s*[" + Common.Globals.glbDefaultPane + "]", RegexOptions.IgnoreCase); if (PaneCheck1.IsMatch(this.Contents) == false && PaneCheck2.IsMatch(this.Contents) == false) { m_Messages += SkinController.FormatMessage(FILE_FORMAT_ERROR, string.Format(FILE_FORMAT_ERROR, FileName), 2, true); } if (File.Exists(FileName.Replace(this.FileExtension, ".xml"))) { try { m_FileAttributes.Load(FileName.Replace(this.FileExtension, ".xml")); m_Messages += SkinController.FormatMessage(FILE_LOAD, FileName, 2, false); } catch (Exception ex) { m_FileAttributes = SkinAttributes; m_Messages += SkinController.FormatMessage(FILE_LOAD_ERROR, FileName, 2, true); ex.ToString(); } } break; default: m_WriteFileName = FileName; break; } }
public SkinFileProcessor(string SkinPath, string SkinRoot, string SkinName) { this.Message += SkinController.FormatMessage(INITIALIZE_PROCESSOR, SkinRoot + " :: " + SkinName, 0, false); m_SkinRoot = SkinRoot; m_SkinPath = SkinPath; m_SkinName = SkinName; string FileName = this.SkinPath + this.SkinRoot + "\\" + this.SkinName + "\\" + SkinRoot.Substring(0, SkinRoot.Length - 1) + ".xml"; if (File.Exists(FileName)) { try { this.SkinAttributes.Load(FileName); this.Message += SkinController.FormatMessage(PACKAGE_LOAD, Path.GetFileName(FileName), 2, false); } catch (Exception ex) { this.Message += SkinController.FormatMessage(string.Format(PACKAGE_LOAD_ERROR, ex.Message), Path.GetFileName(FileName), 2, true); } } string Token; foreach (SkinControlInfo objSkinControl in SkinControlController.GetSkinControls().Values) { Token = objSkinControl.ControlKey.ToUpper(); if (m_ControlList.ContainsKey(Token)) { this.Message += SkinController.FormatMessage(string.Format(DUPLICATE_ERROR, objSkinControl.ControlKey.ToString().ToUpper()), string.Format(DUPLICATE_DETAIL, (string)m_ControlList[Token], objSkinControl.ControlSrc.ToString()), 2, true); } else { this.Message += SkinController.FormatMessage(string.Format(LOAD_SKIN_TOKEN, objSkinControl.ControlKey.ToString().ToUpper()), objSkinControl.ControlSrc.ToString(), 2, false); m_ControlList.Add(Token, objSkinControl.ControlSrc); } } m_ControlFactory = new ControlParser(m_ControlList); m_ObjectFactory = new ObjectParser(m_ControlList); }
private string ObjectMatchHandler(Match m) { string OBJECT_PROC = Util.GetLocalizedString("ProcessObject"); string OBJECT_SKIN = Util.GetLocalizedString("SkinObject"); string OBJECT_PANE = Util.GetLocalizedString("PaneObject"); string OBJECT_FOUND = Util.GetLocalizedString("ObjectFound"); string CONTROL_FORMAT = Util.GetLocalizedString("ControlFormat"); string OBJECT_NOTFOUND = Util.GetLocalizedString("ObjectNotFound"); string EmbeddedObjectAttributes = m.Groups["token"].Value.Substring(0, m.Groups["token"].Value.IndexOf(">")); string[] Attributes = EmbeddedObjectAttributes.Split(' '); string AttributeNode = ""; string Token = ""; string ControlName = ""; string[] Attribute; string AttributeName; string AttributeValue; foreach (string strAttribute in Attributes) { if (strAttribute != string.Empty) { Attribute = strAttribute.Split('='); AttributeName = Attribute[0].Trim(); AttributeValue = Attribute[1].Trim().Replace("\"", ""); switch (AttributeName.ToLower()) { case "id": ControlName = AttributeValue; break; case "codetype": AttributeNode = AttributeValue; break; case "codebase": Token = AttributeValue.ToUpper(); break; } } } if (AttributeNode.ToLower() == "dotnetnuke/server") { this.Messages += SkinController.FormatMessage(OBJECT_PROC, Token, 2, false); if (this.ControlList.ContainsKey(Token) == true || Token == "CONTENTPANE") { string SkinControl = ""; if (this.ControlList.ContainsKey(Token)) { this.Messages += SkinController.FormatMessage(OBJECT_SKIN, (string)this.ControlList[Token], 2, false); } else { this.Messages += SkinController.FormatMessage(OBJECT_PANE, Token, 2, false); } string Parameters = m.Groups["token"].Value.Substring(m.Groups["token"].Value.IndexOf(">") + 1); Parameters = Parameters.Replace("<param name=\"", ""); Parameters = Parameters.Replace("\" value", ""); Parameters = Parameters.Replace("/>", ""); Parameters = Regex.Replace(Parameters, "\\s+", " "); if (this.ControlList.ContainsKey(Token)) { SkinControl = "dnn:" + Token + " runat=\"server\" "; if (!String.IsNullOrEmpty(ControlName)) { SkinControl += "id=\"" + ControlName + "\" "; } SkinControl += Parameters; string ControlRegistration = "<%@ Register TagPrefix=\"dnn\" TagName=\"" + Token + "\" Src=\"~/" + (string)this.ControlList[Token] + "\" %>" + Environment.NewLine; if (RegisterList.Contains(ControlRegistration) == false) { RegisterList.Add(ControlRegistration); } this.Messages += SkinController.FormatMessage(CONTROL_FORMAT, "<" + SkinControl + " />", 2, false); SkinControl = "<" + SkinControl + "/>"; } else { SkinControl = "div runat=\"server\" "; if (!String.IsNullOrEmpty(ControlName)) { SkinControl += "id=\"" + ControlName + "\" "; } else { SkinControl += "id=\"ContentPane\" "; } SkinControl += Parameters + "></div"; this.Messages += SkinController.FormatMessage(CONTROL_FORMAT, "<" + SkinControl + ">", 2, false); SkinControl = "<" + SkinControl + ">"; } return(SkinControl); } else { this.Messages += SkinController.FormatMessage(OBJECT_NOTFOUND, Token, 2, false); return("<object" + m.Groups["token"].Value + "</object>"); } } else { return("<object" + m.Groups["token"].Value + "</object>"); } }
private string TokenMatchHandler(Match m) { string TOKEN_PROC = Util.GetLocalizedString("ProcessToken"); string TOKEN_SKIN = Util.GetLocalizedString("SkinToken"); string TOKEN_PANE = Util.GetLocalizedString("PaneToken"); string TOKEN_FOUND = Util.GetLocalizedString("TokenFound"); string TOKEN_FORMAT = Util.GetLocalizedString("TokenFormat"); string TOKEN_NOTFOUND_INFILE = Util.GetLocalizedString("TokenNotFoundInFile"); string CONTROL_FORMAT = Util.GetLocalizedString("ControlFormat"); string TOKEN_NOTFOUND = Util.GetLocalizedString("TokenNotFound"); string Token = m.Groups["token"].Value.ToUpper(); string ControlName = Token + m.Groups["instance"].Value; string AttributeNode = Token + (String.IsNullOrEmpty(m.Groups["instance"].Value) ? "" : ":" + m.Groups["instance"].Value); this.Messages += SkinController.FormatMessage(TOKEN_PROC, "[" + AttributeNode + "]", 2, false); if (this.ControlList.ContainsKey(Token) == true || Token.IndexOf("CONTENTPANE") != -1) { string SkinControl = ""; if (this.ControlList.ContainsKey(Token)) { this.Messages += SkinController.FormatMessage(TOKEN_SKIN, (string)this.ControlList[Token], 2, false); } else { this.Messages += SkinController.FormatMessage(TOKEN_PANE, Token, 2, false); } if (this.Attributes.DocumentElement != null) { XmlNode xmlSkinAttributeRoot = this.Attributes.DocumentElement.SelectSingleNode("descendant::Object[Token='[" + AttributeNode + "]']"); if (xmlSkinAttributeRoot != null) { this.Messages += SkinController.FormatMessage(TOKEN_FOUND, "[" + AttributeNode + "]", 2, false); foreach (XmlNode xmlSkinAttribute in xmlSkinAttributeRoot.SelectNodes(".//Settings/Setting")) { if (!String.IsNullOrEmpty(xmlSkinAttribute.SelectSingleNode("Value").InnerText)) { this.Messages += SkinController.FormatMessage(TOKEN_FORMAT, xmlSkinAttribute.SelectSingleNode("Name").InnerText + "=\"" + xmlSkinAttribute.SelectSingleNode("Value").InnerText + "\"", 2, false); SkinControl += " " + xmlSkinAttribute.SelectSingleNode("Name").InnerText + "=\"" + xmlSkinAttribute.SelectSingleNode("Value").InnerText.Replace("\"", """) + "\""; } } } else { this.Messages += SkinController.FormatMessage(TOKEN_NOTFOUND_INFILE, "[" + AttributeNode + "]", 2, false); } } if (this.ControlList.ContainsKey(Token)) { SkinControl = "dnn:" + Token + " runat=\"server\" id=\"dnn" + ControlName + "\"" + SkinControl; string ControlRegistration = "<%@ Register TagPrefix=\"dnn\" TagName=\"" + Token + "\" Src=\"~/" + (string)this.ControlList[Token] + "\" %>" + Environment.NewLine; if (RegisterList.Contains(ControlRegistration) == false) { RegisterList.Add(ControlRegistration); } this.Messages += SkinController.FormatMessage(CONTROL_FORMAT, "<" + SkinControl + " />", 2, false); SkinControl = "<" + SkinControl + " />"; } else { if (SkinControl.ToLower().IndexOf("id=") == -1) { SkinControl = " id=\"ContentPane\""; } SkinControl = "div runat=\"server\"" + SkinControl + "></div"; this.Messages += SkinController.FormatMessage(CONTROL_FORMAT, "<" + SkinControl + ">", 2, false); SkinControl = "<" + SkinControl + ">"; } return(SkinControl); } else { this.Messages += SkinController.FormatMessage(TOKEN_NOTFOUND, "[" + m.Groups["token"].Value + "]", 2, false); return("[" + m.Groups["token"].Value + "]"); } }
private bool ProcessSlaveModule() { ModuleController objModules = new ModuleController(); ModuleInfo objModule = null; ModuleInfo slaveModule = null; int moduleId = -1; string key = ""; bool bSuccess = true; if (Request.QueryString["mid"] != null) { Int32.TryParse(Request.QueryString["mid"], out moduleId); } if (Request.QueryString["ctl"] != null) { key = Request.QueryString["ctl"]; } if (Request.QueryString["moduleid"] != null && (key.ToLower() == "module" || key.ToLower() == "help")) { Int32.TryParse(Request.QueryString["moduleid"], out moduleId); } if (moduleId != -1) { objModule = objModules.GetModule(moduleId, PortalSettings.ActiveTab.TabID, false); if (objModule != null) { slaveModule = objModule.Clone(); } } if (slaveModule == null) { slaveModule = new ModuleInfo(); slaveModule.ModuleID = moduleId; slaveModule.ModuleDefID = -1; slaveModule.TabID = PortalSettings.ActiveTab.TabID; } if (Request.QueryString["moduleid"] != null && (key.ToLower() == "module" || key.ToLower() == "help")) { slaveModule.ModuleDefID = -1; } if (Request.QueryString["dnnprintmode"] != "true") { slaveModule.ModuleTitle = ""; } slaveModule.Header = ""; slaveModule.Footer = ""; slaveModule.StartDate = DateTime.MinValue; slaveModule.EndDate = DateTime.MaxValue; slaveModule.PaneName = Common.Globals.glbDefaultPane; slaveModule.Visibility = VisibilityState.None; slaveModule.Color = ""; slaveModule.Border = ""; slaveModule.DisplayTitle = true; slaveModule.DisplayPrint = false; slaveModule.DisplaySyndicate = false; slaveModule.ContainerSrc = PortalSettings.ActiveTab.ContainerSrc; if (string.IsNullOrEmpty(slaveModule.ContainerSrc)) { slaveModule.ContainerSrc = PortalSettings.DefaultPortalContainer; } slaveModule.ContainerSrc = SkinController.FormatSkinSrc(slaveModule.ContainerSrc, PortalSettings); slaveModule.ContainerPath = SkinController.FormatSkinPath(slaveModule.ContainerSrc); Pane pane = null; bool bFound = Panes.TryGetValue(Common.Globals.glbDefaultPane.ToLowerInvariant(), out pane); ModuleControlInfo objModuleControl = ModuleControlController.GetModuleControlByControlKey(key, slaveModule.ModuleDefID); if (objModuleControl != null) { slaveModule.ModuleControlId = objModuleControl.ModuleControlID; slaveModule.IconFile = objModuleControl.IconFile; if (ModulePermissionController.HasModuleAccess(slaveModule.ModuleControl.ControlType, Null.NullString, slaveModule)) { bSuccess = InjectModule(pane, slaveModule); } else { Response.Redirect(Common.Globals.AccessDeniedURL(MODULEACCESS_ERROR), true); } } return(bSuccess); }
private Containers.Container LoadModuleContainer(ModuleInfo objModule) { Containers.Container ctlContainer = null; string containerSrc = Null.NullString; HttpRequest Request = PaneControl.Page.Request; int PreviewModuleId = -1; if (Request.QueryString["ModuleId"] != null) { Int32.TryParse(Request.QueryString["ModuleId"], out PreviewModuleId); } if ((Request.QueryString["ContainerSrc"] != null) && (objModule.ModuleID == PreviewModuleId || PreviewModuleId == -1)) { containerSrc = SkinController.FormatSkinSrc(Globals.QueryStringDecode(Request.QueryString["ContainerSrc"]) + ".ascx", PortalSettings); ctlContainer = LoadContainerByPath(containerSrc); } if (ctlContainer == null) { if (Request.Cookies["_ContainerSrc" + PortalSettings.PortalId.ToString()] != null) { if (!String.IsNullOrEmpty(Request.Cookies["_ContainerSrc" + PortalSettings.PortalId.ToString()].Value)) { containerSrc = SkinController.FormatSkinSrc(Request.Cookies["_ContainerSrc" + PortalSettings.PortalId.ToString()].Value + ".ascx", PortalSettings); ctlContainer = LoadContainerByPath(containerSrc); } } } if (ctlContainer == null) { if (objModule.DisplayTitle == false) { bool blnDisplayTitle = ModulePermissionController.CanEditModuleContent(objModule) || Globals.IsAdminSkin(); if (blnDisplayTitle == true) { blnDisplayTitle = (PortalSettings.UserMode != PortalSettings.Mode.View); } if (blnDisplayTitle == false) { containerSrc = SkinController.FormatSkinSrc("[G]" + SkinController.RootContainer + "/_default/No Container.ascx", PortalSettings); ctlContainer = LoadContainerByPath(containerSrc); } } } if (ctlContainer == null) { if (objModule.ContainerSrc == PortalSettings.ActiveTab.ContainerSrc) { if (PaneControl is HtmlControl) { HtmlControl objHtmlControl = (HtmlControl)PaneControl; if ((objHtmlControl.Attributes["ContainerSrc"] != null)) { bool validSrc = false; if ((objHtmlControl.Attributes["ContainerType"] != null) && (objHtmlControl.Attributes["ContainerName"] != null)) { containerSrc = "[" + objHtmlControl.Attributes["ContainerType"] + "]" + SkinController.RootContainer + "/" + objHtmlControl.Attributes["ContainerName"] + "/" + objHtmlControl.Attributes["ContainerSrc"]; validSrc = true; } else { containerSrc = objHtmlControl.Attributes["ContainerSrc"]; if (containerSrc.Contains("/")) { if (!(containerSrc.ToLower().StartsWith("[g]") || containerSrc.ToLower().StartsWith("[l]"))) { if (SkinController.IsGlobalSkin(PortalSettings.ActiveTab.SkinSrc)) { containerSrc = string.Format("[G]containers/{0}", containerSrc.TrimStart('/')); } else { containerSrc = string.Format("[L]containers/{0}", containerSrc.TrimStart('/')); } validSrc = true; } } } if (validSrc) { containerSrc = SkinController.FormatSkinSrc(containerSrc, PortalSettings); ctlContainer = LoadContainerByPath(containerSrc); } } } } } if (ctlContainer == null) { containerSrc = objModule.ContainerSrc; if (!String.IsNullOrEmpty(containerSrc)) { containerSrc = SkinController.FormatSkinSrc(containerSrc, PortalSettings); ctlContainer = LoadContainerByPath(containerSrc); } } if (ctlContainer == null) { containerSrc = SkinController.FormatSkinSrc(SkinController.GetDefaultPortalContainer(), PortalSettings); ctlContainer = LoadContainerByPath(containerSrc); } objModule.ContainerPath = SkinController.FormatSkinPath(containerSrc); ctlContainer.ID = "ctr"; if (objModule.ModuleID > -1) { ctlContainer.ID += objModule.ModuleID.ToString(); } return(ctlContainer); }