예제 #1
0
            private string MatchHandler(Match m)
            {
                string strOldTag = m.Groups["tag"].Value + m.Groups["content"].Value + m.Groups["endtag"].Value;
                string strNewTag = strOldTag;

                if (!m.Groups[0].Value.ToLower().Contains("codetype=\"dotnetnuke/client\""))
                {
                    switch (this.ParseOption)
                    {
                    case SkinParser.Localized:
                        if (strNewTag.IndexOf(this.SkinPath) == -1)
                        {
                            strNewTag = m.Groups["tag"].Value + this.SkinPath + m.Groups["content"].Value + m.Groups["endtag"].Value;
                        }
                        break;

                    case SkinParser.Portable:
                        if (strNewTag.ToLower().IndexOf("<%= skinpath %>") == -1)
                        {
                            strNewTag = m.Groups["tag"].Value + "<%= SkinPath %>" + m.Groups["content"].Value + m.Groups["endtag"].Value;
                        }
                        if (strNewTag.IndexOf(this.SkinPath) != -1)
                        {
                            strNewTag = strNewTag.Replace(this.SkinPath, "");
                        }
                        break;
                    }
                }
                m_Messages += SkinController.FormatMessage(SUBST, string.Format(SUBST_DETAIL, System.Web.HttpUtility.HtmlEncode(strOldTag), System.Web.HttpUtility.HtmlEncode(strNewTag)), 2, false);
                return(strNewTag);
            }
예제 #2
0
            public string PrependASCXDirectives(ArrayList Registrations)
            {
                string Messages   = "";
                string Prefix     = "";
                string strPattern = "<\\s*body[^>]*>(?<skin>.*)<\\s*/\\s*body\\s*>";
                Match  objMatch;

                objMatch = Regex.Match(this.Contents, strPattern, RegexOptions.IgnoreCase | RegexOptions.Singleline);
                if (!String.IsNullOrEmpty(objMatch.Groups[1].Value))
                {
                    this.Contents = objMatch.Groups[1].Value;
                }
                if (this.SkinRoot == SkinController.RootSkin)
                {
                    Prefix += "<%@ Control language=\"vb\" AutoEventWireup=\"false\" Explicit=\"True\" Inherits=\"DotNetNuke.UI.Skins.Skin\" %>" + Environment.NewLine;
                }
                else if (this.SkinRoot == SkinController.RootContainer)
                {
                    Prefix += "<%@ Control language=\"vb\" AutoEventWireup=\"false\" Explicit=\"True\" Inherits=\"DotNetNuke.UI.Containers.Container\" %>" + Environment.NewLine;
                }
                Messages += SkinController.FormatMessage(CONTROL_DIR, HttpUtility.HtmlEncode(Prefix), 2, false);
                foreach (string Item in Registrations)
                {
                    Messages += SkinController.FormatMessage(CONTROL_REG, HttpUtility.HtmlEncode(Item), 2, false);
                    Prefix   += Item;
                }
                this.Contents = Prefix + this.Contents;
                return(Messages);
            }
예제 #3
0
        public string ProcessFile(string FileName, UI.Skins.SkinParser ParseOption)
        {
            string   strMessage  = SkinController.FormatMessage(FILE_BEGIN, Path.GetFileName(FileName), 0, false);
            SkinFile objSkinFile = new SkinFile(this.SkinRoot, FileName, this.SkinAttributes);

            switch (objSkinFile.FileExtension)
            {
            case ".htm":
            case ".html":
                string contents = objSkinFile.Contents;
                strMessage          += this.ObjectFactory.Parse(ref contents);
                strMessage          += this.PathFactory.Parse(ref contents, this.PathFactory.HTMLList, objSkinFile.SkinRootPath, ParseOption);
                strMessage          += this.ControlFactory.Parse(ref contents, objSkinFile.Attributes);
                objSkinFile.Contents = contents;
                ArrayList Registrations = new ArrayList();
                Registrations.AddRange(this.ControlFactory.Registrations);
                Registrations.AddRange(this.ObjectFactory.Registrations);
                strMessage += objSkinFile.PrependASCXDirectives(Registrations);
                break;
            }
            objSkinFile.Write();
            strMessage += objSkinFile.Messages;
            strMessage += SkinController.FormatMessage(FILE_END, Path.GetFileName(FileName), 1, false);
            return(strMessage);
        }
예제 #4
0
 public string ProcessList(ArrayList FileList, UI.Skins.SkinParser ParseOption)
 {
     foreach (string FileName in FileList)
     {
         this.Message += ProcessFile(FileName, ParseOption);
     }
     this.Message += SkinController.FormatMessage(FILES_END, this.SkinRoot + " :: " + this.SkinName, 0, false);
     return(this.Message);
 }
예제 #5
0
            public void Write()
            {
                if (File.Exists(this.WriteFileName))
                {
                    File.Delete(this.WriteFileName);
                }
                m_Messages += SkinController.FormatMessage(FILE_WRITE, Path.GetFileName(this.WriteFileName), 2, false);
                StreamWriter objStreamWriter = new StreamWriter(this.WriteFileName);

                objStreamWriter.WriteLine(this.Contents);
                objStreamWriter.Flush();
                objStreamWriter.Close();
            }
예제 #6
0
            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;
                }
            }
예제 #7
0
        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);
        }
예제 #8
0
            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, "&lt;" + SkinControl + " /&gt;", 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, "&lt;" + SkinControl + "&gt;", 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>");
                }
            }
예제 #9
0
            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("\"", "&quot;") + "\"";
                                }
                            }
                        }
                        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, "&lt;" + SkinControl + " /&gt;", 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, "&lt;" + SkinControl + "&gt;", 2, false);
                        SkinControl    = "<" + SkinControl + ">";
                    }
                    return(SkinControl);
                }
                else
                {
                    this.Messages += SkinController.FormatMessage(TOKEN_NOTFOUND, "[" + m.Groups["token"].Value + "]", 2, false);
                    return("[" + m.Groups["token"].Value + "]");
                }
            }