using System;
using System.Data;
using System.Xml;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.Web;
using IlgharCMS;
using IlgharCMS.ArticleModule;
public partial class CArticleCategory : IlgharCMS.Page
{
public CArticleCategory()
: base("article_category.dwt.aspx")
{}
protected XmlDocument _xmlTemplate;
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
_xmlTemplate = XmlData.GetXmlDocument();
if (!String.IsNullOrEmpty(Request.QueryString["GetPageCount"]))
                            {
                                Response.Write(t4155);
                                Response.End();
                            }
                        
Response.AddCacheItemDependency("ClearAllCache");
}

                                protected DataRow ShopChannel
                                {
                                    get
                                    {
                                        if (_ShopChannel == null)
                                            _ShopChannel = Manager.GetExtraInstance(Channel, "Shop");

                                        return _ShopChannel;
                                    }
                                }
                                private DataRow _ShopChannel;

                            protected string MetaKeywords
                                            {
                                                get
                                                {
                                                    StringBuilder result = new StringBuilder();
                                                    
                                                    if (!String.IsNullOrEmpty(ArticleCategory[IlgharCMS.ArticleModule.Alias.ArticleCategory.MetaKeywords].ToString()))
                                                        result.Append(ArticleCategory[IlgharCMS.ArticleModule.Alias.ArticleCategory.MetaKeywords].ToString());
                                                    else
                                                    result.Append(ArticleCategory[IlgharCMS.ArticleModule.Alias.ArticleCategory.Name]);
                                    if (!String.IsNullOrEmpty(Channel[IlgharCMS.SystemModule.Alias.Channel.MetaKeywords].ToString()))
                                        result.Append(" - " + Channel[IlgharCMS.SystemModule.Alias.Channel.MetaKeywords]);

                                    if (!String.IsNullOrEmpty(Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.MetaKeywords + PageLang].ToString()))
                                        result.Append(" - " + Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.MetaKeywords + PageLang]);
                                    
                                                    return result.ToString();
                                                }
                                            }
                            protected string MetaDescription
                                            {
                                                get
                                                {
                                                    StringBuilder result = new StringBuilder();
                                                    
                                                    if (!String.IsNullOrEmpty(ArticleCategory[IlgharCMS.ArticleModule.Alias.ArticleCategory.MetaDescription].ToString()))
                                                        result.Append(ArticleCategory[IlgharCMS.ArticleModule.Alias.ArticleCategory.MetaDescription].ToString());
                                                    else
                                                    result.Append(ArticleCategory[IlgharCMS.ArticleModule.Alias.ArticleCategory.Name]);
                                    if (!String.IsNullOrEmpty(Channel[IlgharCMS.SystemModule.Alias.Channel.MetaDescription].ToString()))
                                        result.Append(" - " + Channel[IlgharCMS.SystemModule.Alias.Channel.MetaDescription]);

                                    if (!String.IsNullOrEmpty(Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.MetaDescription + PageLang].ToString()))
                                        result.Append(" - " + Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.MetaDescription + PageLang]);
                                    
                                                    return result.ToString();
                                                }
                                            }
                            protected string Footer
                                            {
                                                get
                                                {
                                                    if (String.IsNullOrEmpty(Channel[IlgharCMS.SystemModule.Alias.Channel.Footer].ToString()))
                                                        return Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.Footer + PageLang].ToString();
                                                    else
                                                        return Channel[IlgharCMS.SystemModule.Alias.Channel.Footer].ToString();
                                                }
                                            }
                            protected string StatisticsCode
                                            {
                                                get
                                                {
                                                    if (String.IsNullOrEmpty(Channel[IlgharCMS.SystemModule.Alias.Channel.StatisticsCode].ToString()))
                                                        return Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.StatisticsCode + PageLang].ToString();
                                                    else
                                                        return Channel[IlgharCMS.SystemModule.Alias.Channel.StatisticsCode].ToString();
                                                }
                                            }
                            
                            protected Dictionary<string, object> ArticleCategory
                            {
                                get
                                {
                                    object id = null;
                                    id = Convert.ToString(Request.QueryString["ID"]);
                                    if (_ArticleCategoryID != null && _ArticleCategoryID == id)
                                        return _ArticleCategory;

                                    int instanceID;
instanceID = InstanceID;

                                    using (IlgharCMS.ArticleModule.IArticleCategory bll = (IlgharCMS.ArticleModule.IArticleCategory)Manager.CreateObject("ArticleCategory", instanceID, PageLang, false))
                                    {
                                        _ArticleCategoryID = id;
                                        _ArticleCategory = bll.Get(id);
                                    }

                                    return _ArticleCategory;
                                }
                            }
                            private Dictionary<string, object> _ArticleCategory;
                            private object _ArticleCategoryID;
                            
                            protected string t1035Default
                            {
                                get
                                {
                                    StringBuilder result = new StringBuilder(_xmlTemplate.SelectSingleNode("//t1035").InnerText);
                                    object t1137 = ImagePath;
result.Replace("{#t1137#}",t1137 == null ? "" : t1137.ToString());

                                    return result.ToString();
                                }
                            }
                            protected string t1035
                            {
                                get
                                {
                                    int instanceID;
                                    DataRow[] rows = Manager.Instances.Select(IlgharCMS.SystemModule.Alias.Module.Namespace + "='IlgharCMS.AdModule'");if (rows.Length == 0)
{instanceID = 0;}
else
{instanceID = (int)rows[0][IlgharCMS.SystemModule.Alias.Instance.InnerID];}
                                    if (instanceID == 0)
                                        return t1035Default;

                                    string path = String.Empty;
                                    int id = -1;
                                    
                            using (IlgharCMS.AdModule.IPosition bll = (IlgharCMS.AdModule.IPosition)Manager.CreateObject("Position", instanceID, PageLang, false))
                            {
                                id = bll.GetInnerIDFromGuid(new Guid("{099A2FEC-2278-4b03-BC08-A3C1FC3ADC66}"));
                                path = Manager.GetCachePath() + "ad/" + instanceID + "_" + PageLang + "_" + id + ".js";
                                if (id > 0 && !System.IO.File.Exists(Manager.MapPath(path)))
                                {
                                    path = bll.GenerateCacheFile(id);
                                    if (String.IsNullOrEmpty(path))
                                        id = -1;
                                }
                            }
                            

                                    if (id <= 0)
                                        return t1035Default;
                                    else
                                        return "<script type=\"text/javascript\" src=\"" + path + "\"></script>";
                                }
                            }
                            
                            private string t1498BuildUrl(DataRow record)
                            {
                                string url = record[IlgharCMS.SystemModule.Alias.Menu.Path].ToString();
                                if (url.StartsWith("http://") || url.StartsWith("/"))
                                {
                                    if (url.StartsWith("/") && (Convert.ToBoolean(Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.Fake404]) || Request.RawUrl.IndexOf("/ilghar.aspx?/") != -1))
                                        return Manager.GetWebPath() + "ilghar.aspx?" + url;
                                    else
                                        return url;
                                }

                                DataRow[] rows = Manager.Channels.Select(IlgharCMS.SystemModule.Alias.Channel.ID + "='" + record[IlgharCMS.SystemModule.Alias.Menu.ChannelID] + "'");
                                if (rows.Length == 0)
                                    return url;

                                DataRow channel = rows[0];
                                if (!Convert.IsDBNull(Channel[IlgharCMS.SystemModule.Alias.Channel.TranslateLang]))
                                {
                                    string instance = null;
                                    if (Convert.IsDBNull(channel[IlgharCMS.SystemModule.Alias.Instance.ID]))
                                        instance = IlgharCMS.SystemModule.Alias.Instance.ID + " IS NULL AND ";
                                    else
                                        instance = IlgharCMS.SystemModule.Alias.Instance.ID + "='" + channel[IlgharCMS.SystemModule.Alias.Instance.ID] + "' AND ";
                                    rows = Manager.Channels.Select(IlgharCMS.SystemModule.Alias.Channel.ID + " IS NOT NULL AND " + instance + IlgharCMS.SystemModule.Alias.Channel.TemplateLang + "='" + Channel[IlgharCMS.SystemModule.Alias.Channel.TemplateLang] + "' AND " + IlgharCMS.SystemModule.Alias.Channel.TranslateLang + "='" + Channel[IlgharCMS.SystemModule.Alias.Channel.TranslateLang] + "'");
                                    if (rows.Length > 0)
                                        channel = rows[0];
                                }

                                string content = record[IlgharCMS.SystemModule.Alias.Menu.Content].ToString();
                                if (!String.IsNullOrEmpty(content))
                                {
                                    if (!Convert.IsDBNull(record[IlgharCMS.SystemModule.Alias.Menu.PageTemplate]))
                                    {
                                        if (record[IlgharCMS.SystemModule.Alias.Menu.PageExtension].ToString() == String.Empty)
                                            url = BuildUrl(channel, record[IlgharCMS.SystemModule.Alias.Menu.PageTemplate].ToString(), "ID=" + record[IlgharCMS.SystemModule.Alias.Menu.PageID] + "&Ext=" + channel[IlgharCMS.SystemModule.Alias.Channel.Extension]);
                                        else
                                            url = BuildUrl(channel, record[IlgharCMS.SystemModule.Alias.Menu.PageTemplate].ToString(), "ID=" + record[IlgharCMS.SystemModule.Alias.Menu.PageID] + "&Ext=" + record[IlgharCMS.SystemModule.Alias.Menu.PageExtension]);
                                    }
                                    else
                                    {
                                        rows = Manager.Pages.Select(IlgharCMS.SystemModule.Alias.Template.Page.TemplatePath + "='" + channel[IlgharCMS.SystemModule.Alias.Channel.TemplatePath] + "' AND " + IlgharCMS.SystemModule.Alias.Template.Page.Mark + "='System' AND " + IlgharCMS.SystemModule.Alias.Template.Page.Object + "='Menu'");
                                        if (rows.Length == 0)
                                        {
                                            url = String.Empty;
                                        }
                                        else
                                        {
                                            if (record[IlgharCMS.SystemModule.Alias.Menu.PageExtension].ToString() == String.Empty)
                                                url = BuildUrl(channel, rows[0][IlgharCMS.SystemModule.Alias.Template.Page.PathInTemplate].ToString(), "ID=" + record[IlgharCMS.SystemModule.Alias.Menu.PageID] + "&Ext=" + channel[IlgharCMS.SystemModule.Alias.Channel.Extension]);
                                            else
                                                url = BuildUrl(channel, rows[0][IlgharCMS.SystemModule.Alias.Template.Page.PathInTemplate].ToString(), "ID=" + record[IlgharCMS.SystemModule.Alias.Menu.PageID] + "&Ext=" + record[IlgharCMS.SystemModule.Alias.Menu.PageExtension]);
                                        }
                                    }
                                }
                                else
                                {
                                    string channelPath = String.Empty;
                                    if (!String.IsNullOrEmpty(channel[IlgharCMS.SystemModule.Alias.Channel.Domain].ToString()))
                                    {
                                        Uri domain = new Uri(channel[IlgharCMS.SystemModule.Alias.Channel.Domain].ToString().Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries)[0]);
                                        if (channel == Channel)
                                            channelPath = domain.LocalPath;
                                        else
                                            channelPath = domain.ToString();
                                    }
                                    else if (!String.IsNullOrEmpty(Channel[IlgharCMS.SystemModule.Alias.Channel.Domain].ToString()))
                                    {
                                       channelPath = Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.Domain].ToString() + channel[IlgharCMS.SystemModule.Alias.Channel.Path].ToString().TrimStart('/');
                                    }
                                    else
                                    {
                                        channelPath = channel[IlgharCMS.SystemModule.Alias.Channel.Path].ToString();
                                        
                                    }
                                    if (!String.IsNullOrEmpty(url))
                                    {
                                        url = channelPath + url;
                                        url = url.Replace(".ext", channel[IlgharCMS.SystemModule.Alias.Channel.Extension].ToString());
                                    }
                                    else
                                    {
                                        url = channelPath + channel[IlgharCMS.SystemModule.Alias.Channel.DefaultDocument].ToString() + channel[IlgharCMS.SystemModule.Alias.Channel.Extension];
                                    }

                                    if (Convert.ToBoolean(Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.Fake404]) || Request.RawUrl.IndexOf("/ilghar.aspx?/") != -1)
                                        url = Manager.GetWebPath() + "ilghar.aspx?" + url;
                                }

                                return url;
                            }

                            private int t1498IDCounter = 0;
                            private object t1498IDRecord = null;
                            private DataTable t1498ID;
                            private DataTable t1498ID_
                            {
                                get
                                {
                                    string condition = null;
condition += "P2131_24_403=";
condition += "true";
condition += " and P2131_24_264 IS ";
condition += "NULL";
condition += " and P2131_24_263 IS ";
condition += "NULL";


                                    string sort = null;

                                    using (IlgharCMS.SystemModule.IMenu bll = (IlgharCMS.SystemModule.IMenu)Manager.CreateObject("Menu", SystemInstanceID, PageLang, false))
                                    {
                                        t1498ID = bll.List(-1, -1, condition, sort);
                                    }

                                    return t1498ID;
                                }
                            }
                            protected string t1498
                            {
                                get
                                {
                                    XmlNode node = _xmlTemplate.SelectSingleNode("//t1498");
                                    Dictionary<string, object> replacementPair = new Dictionary<string, object>();
                                    
                                        replacementPair["{#URL#}"] = new CustomBuild(
                                                                        delegate(DataRow record, int index)
                                                                        {
                                                                            return t1498BuildUrl(record);
                                                                        }
                                                                        );
                                                replacementPair["{#Target#}"] = IlgharCMS.SystemModule.Alias.Menu.Target;replacementPair["{#Name#}"] = IlgharCMS.SystemModule.Alias.Menu.Name;
                                    StringBuilder all = Manager.Build(node, t1498ID_, replacementPair, ref t1498IDRecord, ref t1498IDCounter);
                                    
                                    
                                    
                                    return all.ToString();
                                }
                            }
                          
                        protected int t1990IDRecordCount
                        {
                            get
                            {
                                int instanceID;
instanceID = InstanceID;
                                using (IlgharCMS.ArticleModule.IArticleCategory bll = (IlgharCMS.ArticleModule.IArticleCategory)Manager.CreateObject("ArticleCategory", instanceID, PageLang, false))
                                {
                                    string condition = null;
condition += "P2194_1_104=";
condition += "true";
condition += " and P2194_1_3 IS ";
condition += "NULL";


                                    return bll.GetRecordCount(condition);
                                }
                            }
                        }
                        
                            protected int t1990IDCounter = 0;
                            protected object t1990IDRecord = null;
                            private DataTable t1990IDData;
                            protected DataTable t1990ID
                            {
                                get
                                {
                                    if (t1990IDData != null)
                                        return t1990IDData;

                                    t1990IDData = t1990ID_;
                                    return t1990IDData;
                                }
                            }
                        
                                private DataTable t1990ID_
                                {
                                    get
                                    {
                                        string condition = null;
condition += "P2194_1_104=";
condition += "true";
condition += " and P2194_1_3 IS ";
condition += "NULL";


                                        string sort = null;

                                        int instanceID;
instanceID = InstanceID;

                                        using (IlgharCMS.ArticleModule.IArticleCategory bll = (IlgharCMS.ArticleModule.IArticleCategory)Manager.CreateObject("ArticleCategory", instanceID, PageLang, false))
                                        {
                                            t1990IDData = bll.List(-1, -1, condition, sort);
                                        }

                                        return t1990IDData;
                                    }
                                }
                            
                            protected string t1990
                            {
                                get
                                {
                                    XmlNode node = _xmlTemplate.SelectSingleNode("//t1990");
                                    Dictionary<string, object> replacementPair = new Dictionary<string, object>();
                                    
                                        replacementPair[@"{#BuildUrl()#}"] = new CustomBuild(
                                                                        delegate(DataRow record, int index)
                                                                        {
                                                                            object t2133 = BuildUrl(Channel,"article_category","ID=" + t1990ID.Rows[t1990IDCounter]["P2194_1_101"] + "&Ext=" + t1990ID.Rows[t1990IDCounter]["P2194_1_102"] + "&PageTemplate=" + t1990ID.Rows[t1990IDCounter]["P2194_1_100"] + "&PageUrl=" + HttpUtility.UrlEncode(t1990ID.Rows[t1990IDCounter]["P2194_1_103"].ToString()));
                                                                            if (t2133 != null)
                                                                                return t2133.ToString();
                                                                            else
                                                                                return String.Empty;
                                                                        }
                                                                        );
                                                replacementPair["{#Name#}"] = IlgharCMS.ArticleModule.Alias.ArticleCategory.Name;
                                    StringBuilder all = Manager.Build(node, t1990ID_, replacementPair, ref t1990IDRecord, ref t1990IDCounter);
                                    
                                    
                                    
                                    return all.ToString();
                                }
                            }
                          
                        protected int t2309IDRecordCount
                        {
                            get
                            {
                                int instanceID;
instanceID = (int)ShopChannel[IlgharCMS.SystemModule.Alias.Instance.InnerID];
                                using (IlgharCMS.ShopModule.IGoods bll = (IlgharCMS.ShopModule.IGoods)Manager.CreateObject("Goods", instanceID, PageLang, false))
                                {
                                    string condition = null;
condition += "P1896_2_64=";
condition += "false";
condition += " and P1896_2_63=";
condition += "true";


                                    return bll.GetRecordCount(condition);
                                }
                            }
                        }
                        
                            protected int t2309IDCounter = 0;
                            protected object t2309IDRecord = null;
                            private DataTable t2309IDData;
                            protected DataTable t2309ID
                            {
                                get
                                {
                                    if (t2309IDData != null)
                                        return t2309IDData;

                                    t2309IDData = t2309ID_;
                                    return t2309IDData;
                                }
                            }
                        
                                private DataTable t2309ID_
                                {
                                    get
                                    {
                                        string condition = null;
condition += "P1896_2_64=";
condition += "false";
condition += " and P1896_2_63=";
condition += "true";


                                        string sort = null;sort = "P1896_2_57 DESC";

                                        int instanceID;
instanceID = (int)ShopChannel[IlgharCMS.SystemModule.Alias.Instance.InnerID];

                                        using (IlgharCMS.ShopModule.IGoods bll = (IlgharCMS.ShopModule.IGoods)Manager.CreateObject("Goods", instanceID, PageLang, false))
                                        {
                                            t2309IDData = bll.List(1, 10, condition, sort);
                                        }

                                        return t2309IDData;
                                    }
                                }
                            
                            protected string t2309
                            {
                                get
                                {
                                    XmlNode node = _xmlTemplate.SelectSingleNode("//t2309");
                                    Dictionary<string, object> replacementPair = new Dictionary<string, object>();
                                    
                                        replacementPair[@"{#BuildUrl()#}"] = new CustomBuild(
                                                                        delegate(DataRow record, int index)
                                                                        {
                                                                            object t2525 = BuildUrl(ShopChannel,"goods","ID=" + t2309ID.Rows[t2309IDCounter]["P1896_2_415"] + "&Ext=" + t2309ID.Rows[t2309IDCounter]["P1896_2_416"] + "&PageTemplate=" + t2309ID.Rows[t2309IDCounter]["P1896_2_414"]);
                                                                            if (t2525 != null)
                                                                                return t2525.ToString();
                                                                            else
                                                                                return String.Empty;
                                                                        }
                                                                        );
                                                replacementPair["{#Name#}"] = IlgharCMS.ShopModule.Alias.Goods.Name;replacementPair["{#Thumbnail#}"] = IlgharCMS.ShopModule.Alias.Goods.Thumbnail;
                                    StringBuilder all = Manager.Build(node, t2309ID_, replacementPair, ref t2309IDRecord, ref t2309IDCounter);
                                    
                                    
                                    
                                    return all.ToString();
                                }
                            }
                          
                        protected int t2857IDRecordCount
                        {
                            get
                            {
                                int instanceID;
instanceID = (int)SystemChannel[IlgharCMS.SystemModule.Alias.Instance.InnerID];
                                using (IlgharCMS.SystemModule.ILink bll = (IlgharCMS.SystemModule.ILink)Manager.CreateObject("Link", instanceID, PageLang, false))
                                {
                                    string condition = null;
condition += "P2131_46_402=";
condition += "true";


                                    return bll.GetRecordCount(condition);
                                }
                            }
                        }
                        
                            protected int t2857IDCounter = 0;
                            protected object t2857IDRecord = null;
                            private DataTable t2857IDData;
                            protected DataTable t2857ID
                            {
                                get
                                {
                                    if (t2857IDData != null)
                                        return t2857IDData;

                                    t2857IDData = t2857ID_;
                                    return t2857IDData;
                                }
                            }
                        
                                private DataTable t2857ID_
                                {
                                    get
                                    {
                                        string condition = null;
condition += "P2131_46_402=";
condition += "true";


                                        string sort = null;

                                        int instanceID;
instanceID = (int)SystemChannel[IlgharCMS.SystemModule.Alias.Instance.InnerID];

                                        using (IlgharCMS.SystemModule.ILink bll = (IlgharCMS.SystemModule.ILink)Manager.CreateObject("Link", instanceID, PageLang, false))
                                        {
                                            t2857IDData = bll.List(-1, -1, condition, sort);
                                        }

                                        return t2857IDData;
                                    }
                                }
                            
                            protected string t2857
                            {
                                get
                                {
                                    XmlNode node = _xmlTemplate.SelectSingleNode("//t2857");
                                    Dictionary<string, object> replacementPair = new Dictionary<string, object>();
                                    replacementPair["{#URL#}"] = IlgharCMS.SystemModule.Alias.Link.URL;replacementPair["{#Name#}"] = IlgharCMS.SystemModule.Alias.Link.Name;replacementPair["{#Logo#}"] = IlgharCMS.SystemModule.Alias.Link.Logo;
                                    StringBuilder all = Manager.Build(node, t2857ID_, replacementPair, ref t2857IDRecord, ref t2857IDCounter);
                                    
                                    
                                    
                                    return all.ToString();
                                }
                            }
                          
                            private int t3292IDCounter = 0;
                            private object t3292IDRecord = null;
                            private DataTable t3292ID_;
                            private DataTable t3292ID
                            {
                                get
                                {
                                    if (t3292ID_ != null)
                                        return t3292ID_;

                                    t3292ID_ = new DataTable();
                                    t3292ID_.Columns.Add("Name", typeof(string));
                                    t3292ID_.Columns.Add("URL", typeof(string));

                                    DataRow newRow = null;

                                    
                                newRow = t3292ID_.NewRow();
                                newRow["Name"] = Channel[IlgharCMS.SystemModule.Alias.Channel.Name + PageLang];
                                if (!String.IsNullOrEmpty(Channel[IlgharCMS.SystemModule.Alias.Channel.Domain].ToString()))
                                {
                                    newRow["URL"] = "/";
                                }
                                else
                                {
                                    newRow["URL"] = Channel[IlgharCMS.SystemModule.Alias.Channel.Path] + Channel[IlgharCMS.SystemModule.Alias.Channel.DefaultDocument].ToString()  + Channel[IlgharCMS.SystemModule.Alias.Channel.Extension];
                                    
                                }
                                if (Convert.ToBoolean(Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.Fake404]) || Request.RawUrl.IndexOf("/ilghar.aspx?/") != -1)
                                    newRow["URL"] = Manager.GetWebPath() + "ilghar.aspx?" + newRow["URL"];
                                t3292ID_.Rows.Add(newRow);

                    

                                    Guid parentID = (Guid)Channel[IlgharCMS.SystemModule.Alias.Channel.ParentID];
                                    while (parentID != Guid.Empty)
                                    {
                                        DataRow row = Manager.Channels.Select(IlgharCMS.SystemModule.Alias.Channel.ID + "='" + parentID + "'")[0];

                                        newRow = t3292ID_.NewRow();
                                        newRow["Name"] = row[IlgharCMS.SystemModule.Alias.Channel.Name + PageLang];
                                        string path = row[IlgharCMS.SystemModule.Alias.Channel.Path].ToString();
                                        if (Convert.IsDBNull(row[IlgharCMS.SystemModule.Alias.Channel.TemplatePath]))
                                            newRow["URL"] = path;
                                        else if (!String.IsNullOrEmpty(row[IlgharCMS.SystemModule.Alias.Channel.Domain].ToString()))
                                            newRow["URL"] = row[IlgharCMS.SystemModule.Alias.Channel.Domain].ToString().Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries) + row[IlgharCMS.SystemModule.Alias.Channel.DefaultDocument].ToString() + row[IlgharCMS.SystemModule.Alias.Channel.Extension];
                                        else if (!String.IsNullOrEmpty(Channel[IlgharCMS.SystemModule.Alias.Channel.Domain].ToString()))
                                            newRow["URL"] = Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.Domain] + path.TrimStart('/') + row[IlgharCMS.SystemModule.Alias.Channel.DefaultDocument].ToString() + row[IlgharCMS.SystemModule.Alias.Channel.Extension];
                                        else
                                            newRow["URL"] = Manager.GetWebPath() + path.TrimStart('/') + row[IlgharCMS.SystemModule.Alias.Channel.DefaultDocument].ToString() + row[IlgharCMS.SystemModule.Alias.Channel.Extension];
                                        if (newRow["URL"].ToString().StartsWith("/") && (Convert.ToBoolean(Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.Fake404]) || Request.RawUrl.IndexOf("/ilghar.aspx?/") != -1))
                                            newRow["URL"] = Manager.GetWebPath() + "ilghar.aspx?" + newRow["URL"];
                                        t3292ID_.Rows.InsertAt(newRow, 0);

                                        parentID = (Guid)row[IlgharCMS.SystemModule.Alias.Channel.ParentID];
                                    }

                                    
                            int instanceID;
instanceID = InstanceID;
                            using (IlgharCMS.ArticleModule.IArticleCategory bll = (IlgharCMS.ArticleModule.IArticleCategory)Manager.CreateObject("ArticleCategory", instanceID, PageLang, false))
                            {
                                string condition = null;
                                condition = IlgharCMS.ArticleModule.Alias.ArticleCategory.ID + "={" + (ArticleCategory==null?null:ArticleCategory[IlgharCMS.ArticleModule.Alias.ArticleCategory.ParentID]) + "}";


                                DataTable table = bll.List(1, 1, condition, null);
                                if (table.Rows.Count == 0)
                                    return t3292ID_;

                                int pos = t3292ID_.Rows.Count;

                                newRow = t3292ID_.NewRow();
                                newRow["Name"] = table.Rows[0][IlgharCMS.ArticleModule.Alias.ArticleCategory.Name].ToString();
                                newRow["URL"] = BuildUrl(Channel, "article_category", "ID=" + table.Rows[0][IlgharCMS.ArticleModule.Alias.ArticleCategory.InnerID]);
                                t3292ID_.Rows.InsertAt(newRow, pos);

                                while (!Guid.Equals(table.Rows[0][IlgharCMS.ArticleModule.Alias.ArticleCategory.ParentID], Guid.Empty))
                                {
                                    table = bll.List(1, 1, IlgharCMS.ArticleModule.Alias.ArticleCategory.ID + "=" + table.Rows[0][IlgharCMS.ArticleModule.Alias.ArticleCategory.ParentID], null);

                                    newRow = t3292ID_.NewRow();
                                    newRow["Name"] = table.Rows[0][IlgharCMS.ArticleModule.Alias.ArticleCategory.Name].ToString();
                                    newRow["URL"] = BuildUrl(Channel, "article_category", "ID=" + table.Rows[0][IlgharCMS.ArticleModule.Alias.ArticleCategory.InnerID]);
                                    t3292ID_.Rows.InsertAt(newRow, pos);
                                }
                            }
                            

                                    return t3292ID_;
                                }
                            }
                            protected string t3292
                            {
                                get
                                {
                                    XmlNode node = _xmlTemplate.SelectSingleNode("//t3292");
                                    Dictionary<string, object> replacementPair = new Dictionary<string, object>();
                                    replacementPair["{#URL#}"] = "URL";replacementPair["{#Name#}"] = "Name";
                                    StringBuilder all = Manager.Build(node, t3292ID, replacementPair, ref t3292IDRecord, ref t3292IDCounter);
                                    
                                    
                                    
                                    return all.ToString();
                                }
                            }
                          
                        protected int ListRecordCount
                        {
                            get
                            {
                                int instanceID;
instanceID = InstanceID;
                                using (IlgharCMS.ArticleModule.IArticle bll = (IlgharCMS.ArticleModule.IArticle)Manager.CreateObject("Article", instanceID, PageLang, false))
                                {
                                    string condition = null;
condition += "P2194_2_42=";
condition += "false";
condition += " and P2194_2_41=";
condition += "true";
condition += " and P2194_2_51=";
condition += (ArticleCategory==null?null:ArticleCategory[IlgharCMS.ArticleModule.Alias.ArticleCategory.ID]);


                                    return bll.GetRecordCount(condition);
                                }
                            }
                        }
                        
                            protected int ListCounter = 0;
                            protected object ListRecord = null;
                            private DataTable ListData;
                            protected DataTable List
                            {
                                get
                                {
                                    if (ListData != null)
                                        return ListData;

                                    ListData = List_;
                                    return ListData;
                                }
                            }
                        
                                private DataTable List_
                                {
                                    get
                                    {
                                        string condition = null;
condition += "P2194_2_42=";
condition += "false";
condition += " and P2194_2_41=";
condition += "true";
condition += " and P2194_2_51=";
condition += (ArticleCategory==null?null:ArticleCategory[IlgharCMS.ArticleModule.Alias.ArticleCategory.ID]);


                                        string sort = null;sort = "P2194_2_46 DESC";

                                        int instanceID;
instanceID = InstanceID;

                                        using (IlgharCMS.ArticleModule.IArticle bll = (IlgharCMS.ArticleModule.IArticle)Manager.CreateObject("Article", instanceID, PageLang, false))
                                        {
                                            ListData = bll.List(Convert.ToInt32(PageNumber), 20, condition, sort);
                                        }

                                        return ListData;
                                    }
                                }
                            
                            protected string t3657
                            {
                                get
                                {
                                    XmlNode node = _xmlTemplate.SelectSingleNode("//t3657");
                                    Dictionary<string, object> replacementPair = new Dictionary<string, object>();
                                    
                                        replacementPair[@"{#BuildUrl()#}"] = new CustomBuild(
                                                                        delegate(DataRow record, int index)
                                                                        {
                                                                            object t3909 = BuildUrl(Channel,"article","ID=" + List.Rows[ListCounter]["P2194_2_89"] + "&Ext=" + List.Rows[ListCounter]["P2194_2_90"] + "&PageTemplate=" + List.Rows[ListCounter]["P2194_2_88"] + "&PageUrl=" + HttpUtility.UrlEncode(List.Rows[ListCounter]["P2194_2_91"].ToString()));
                                                                            if (t3909 != null)
                                                                                return t3909.ToString();
                                                                            else
                                                                                return String.Empty;
                                                                        }
                                                                        );
                                                replacementPair["{#Title#}"] = IlgharCMS.ArticleModule.Alias.Article.Title;replacementPair["{#UpdateTime#}"] = IlgharCMS.ArticleModule.Alias.Article.UpdateTime;
                                    StringBuilder all = Manager.Build(node, List_, replacementPair, ref ListRecord, ref ListCounter);
                                    
                                    
                                    
                                    return all.ToString();
                                }
                            }
                          
                            
                        private string t4155URL_ = null;
                        private string t4155URL
                        {
                            get
                            {
                                if (t4155URL_ != null)
                                    return t4155URL_;

                                t4155URL_ = BuildUrl(null, null, "Page={Page}");
                                return t4155URL_;
                            }
                        }
                        
                            private int t4155Page;
                            private int t4155PageCount;
                            private int t4155RecordCount;
                            private int t4155PageSize;
                            private int t4155Index;
                            protected string t4155
                            {
                                get
                                {
                                    t4155Page = Convert.ToInt32(PageNumber);
                                    if (t4155Page <= 0)
                                        t4155Page = 1;
                                    t4155PageSize = 20;
                                    t4155RecordCount = Convert.ToInt32(ListRecordCount);

                                    XmlNode node = _xmlTemplate.SelectSingleNode("//t4155");

                                    StringBuilder all = new StringBuilder(node.SelectSingleNode("All").InnerText);

                                    t4155PageCount = t4155RecordCount / t4155PageSize;
                                    if (t4155RecordCount % t4155PageSize > 0)
                                        t4155PageCount += 1;

                                    if (!String.IsNullOrEmpty(Request.QueryString["GetPageCount"]))
                                        return t4155PageCount.ToString();

                                    //--------------------------------------
                                    //Start : FirstPage
                                    StringBuilder firstPage = new StringBuilder();
                                    string firstPageYesTpl = node.SelectSingleNode("FirstPage/Yes").InnerText;
                                    string firstPageNoTpl = node.SelectSingleNode("FirstPage/No").InnerText;
                                    if (t4155Page > 1)
                                    {
                                        firstPage.Append(firstPageNoTpl);
                                        object t4473 = t4155URL.Replace("{Page}", "1");
firstPage.Replace("{#t4473#}", t4473 == null ? "" : t4473.ToString());
object t4520 = t4155URL.Replace("{Page}", Convert.ToString(t4155Page - 1));
firstPage.Replace("{#t4520#}", t4520 == null ? "" : t4520.ToString());

                                    }
                                    else
                                    {
                                        firstPage.Append(firstPageYesTpl);
                                        
                                    }
                                    all.Replace("{#FirstPage#}", firstPage.ToString());
                                    //End : FirstPage
                                    //--------------------------------------

                                    //--------------------------------------
                                    //Start : CurrentPage
                                    StringBuilder currentPage = new StringBuilder();

                                    if (t4155PageCount > 1)
                                    {
                                        string currentPageYesTpl = node.SelectSingleNode("CurrentPage/Yes").InnerText;
                                        string currentPageNoTpl = node.SelectSingleNode("CurrentPage/No").InnerText;

                                        bool isAll = false;
                                        int pageEnd = 0;
                                        if (isAll)
                                        {
                                            t4155Index = 1;
                                            pageEnd = t4155PageCount;
                                        }
                                        else
                                        {
                                            t4155Index = t4155Page - 5;
                                            if (t4155Index <= 0)
                                                t4155Index = 1;

                                            pageEnd = t4155Page + 5;
                                            if (pageEnd > t4155PageCount)
                                                pageEnd = t4155PageCount;
                                        }

                                        while (t4155Index <= pageEnd)
                                        {
                                            if (t4155Index == t4155Page)
                                            {
                                                currentPage.Append(currentPageYesTpl);
                                                object t4677 = t4155Index;
currentPage.Replace("{#t4677#}", t4677 == null ? "" : t4677.ToString());

                                            }
                                            else
                                            {
                                                currentPage.Append(currentPageNoTpl);
                                                object t4749 = t4155URL.Replace("{Page}", Convert.ToString(t4155Index));
currentPage.Replace("{#t4749#}", t4749 == null ? "" : t4749.ToString());
object t4759 = t4155Index;
currentPage.Replace("{#t4759#}", t4759 == null ? "" : t4759.ToString());

                                            }
                                            t4155Index++;
                                        }
                                    }
                                    all.Replace("{#CurrentPage#}", currentPage.ToString());
                                    //End : CurrentPage
                                    //--------------------------------------

                                    //--------------------------------------
                                    //Start : LastPage
                                    StringBuilder lastPage = new StringBuilder();

                                    string lastPageYesTpl = node.SelectSingleNode("LastPage/Yes").InnerText;
                                    string lastPageNoTpl = node.SelectSingleNode("LastPage/No").InnerText;

                                    if (t4155Page < t4155PageCount)
                                    {
                                        lastPage.Append(lastPageNoTpl);
                                        object t5008 = t4155URL.Replace("{Page}", Convert.ToString(t4155Page + 1));
lastPage.Replace("{#t5008#}", t5008 == null ? "" : t5008.ToString());
object t5050 = t4155URL.Replace("{Page}", Convert.ToString(t4155PageCount));
lastPage.Replace("{#t5050#}", t5050 == null ? "" : t5050.ToString());

                                    }
                                    else
                                    {
                                        lastPage.Append(lastPageYesTpl);
                                        
                                    }
                                    all.Replace("{#LastPage#}", lastPage.ToString());
                                    //End : LastPage
                                    //--------------------------------------

                                    

                                    return all.ToString();
                                }
                            }
                          
                            private string t5275BuildUrl(DataRow record)
                            {
                                string url = record[IlgharCMS.SystemModule.Alias.Menu.Path].ToString();
                                if (url.StartsWith("http://") || url.StartsWith("/"))
                                {
                                    if (url.StartsWith("/") && (Convert.ToBoolean(Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.Fake404]) || Request.RawUrl.IndexOf("/ilghar.aspx?/") != -1))
                                        return Manager.GetWebPath() + "ilghar.aspx?" + url;
                                    else
                                        return url;
                                }

                                DataRow[] rows = Manager.Channels.Select(IlgharCMS.SystemModule.Alias.Channel.ID + "='" + record[IlgharCMS.SystemModule.Alias.Menu.ChannelID] + "'");
                                if (rows.Length == 0)
                                    return url;

                                DataRow channel = rows[0];
                                if (!Convert.IsDBNull(Channel[IlgharCMS.SystemModule.Alias.Channel.TranslateLang]))
                                {
                                    string instance = null;
                                    if (Convert.IsDBNull(channel[IlgharCMS.SystemModule.Alias.Instance.ID]))
                                        instance = IlgharCMS.SystemModule.Alias.Instance.ID + " IS NULL AND ";
                                    else
                                        instance = IlgharCMS.SystemModule.Alias.Instance.ID + "='" + channel[IlgharCMS.SystemModule.Alias.Instance.ID] + "' AND ";
                                    rows = Manager.Channels.Select(IlgharCMS.SystemModule.Alias.Channel.ID + " IS NOT NULL AND " + instance + IlgharCMS.SystemModule.Alias.Channel.TemplateLang + "='" + Channel[IlgharCMS.SystemModule.Alias.Channel.TemplateLang] + "' AND " + IlgharCMS.SystemModule.Alias.Channel.TranslateLang + "='" + Channel[IlgharCMS.SystemModule.Alias.Channel.TranslateLang] + "'");
                                    if (rows.Length > 0)
                                        channel = rows[0];
                                }

                                string content = record[IlgharCMS.SystemModule.Alias.Menu.Content].ToString();
                                if (!String.IsNullOrEmpty(content))
                                {
                                    if (!Convert.IsDBNull(record[IlgharCMS.SystemModule.Alias.Menu.PageTemplate]))
                                    {
                                        if (record[IlgharCMS.SystemModule.Alias.Menu.PageExtension].ToString() == String.Empty)
                                            url = BuildUrl(channel, record[IlgharCMS.SystemModule.Alias.Menu.PageTemplate].ToString(), "ID=" + record[IlgharCMS.SystemModule.Alias.Menu.PageID] + "&Ext=" + channel[IlgharCMS.SystemModule.Alias.Channel.Extension]);
                                        else
                                            url = BuildUrl(channel, record[IlgharCMS.SystemModule.Alias.Menu.PageTemplate].ToString(), "ID=" + record[IlgharCMS.SystemModule.Alias.Menu.PageID] + "&Ext=" + record[IlgharCMS.SystemModule.Alias.Menu.PageExtension]);
                                    }
                                    else
                                    {
                                        rows = Manager.Pages.Select(IlgharCMS.SystemModule.Alias.Template.Page.TemplatePath + "='" + channel[IlgharCMS.SystemModule.Alias.Channel.TemplatePath] + "' AND " + IlgharCMS.SystemModule.Alias.Template.Page.Mark + "='System' AND " + IlgharCMS.SystemModule.Alias.Template.Page.Object + "='Menu'");
                                        if (rows.Length == 0)
                                        {
                                            url = String.Empty;
                                        }
                                        else
                                        {
                                            if (record[IlgharCMS.SystemModule.Alias.Menu.PageExtension].ToString() == String.Empty)
                                                url = BuildUrl(channel, rows[0][IlgharCMS.SystemModule.Alias.Template.Page.PathInTemplate].ToString(), "ID=" + record[IlgharCMS.SystemModule.Alias.Menu.PageID] + "&Ext=" + channel[IlgharCMS.SystemModule.Alias.Channel.Extension]);
                                            else
                                                url = BuildUrl(channel, rows[0][IlgharCMS.SystemModule.Alias.Template.Page.PathInTemplate].ToString(), "ID=" + record[IlgharCMS.SystemModule.Alias.Menu.PageID] + "&Ext=" + record[IlgharCMS.SystemModule.Alias.Menu.PageExtension]);
                                        }
                                    }
                                }
                                else
                                {
                                    string channelPath = String.Empty;
                                    if (!String.IsNullOrEmpty(channel[IlgharCMS.SystemModule.Alias.Channel.Domain].ToString()))
                                    {
                                        Uri domain = new Uri(channel[IlgharCMS.SystemModule.Alias.Channel.Domain].ToString().Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries)[0]);
                                        if (channel == Channel)
                                            channelPath = domain.LocalPath;
                                        else
                                            channelPath = domain.ToString();
                                    }
                                    else if (!String.IsNullOrEmpty(Channel[IlgharCMS.SystemModule.Alias.Channel.Domain].ToString()))
                                    {
                                       channelPath = Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.Domain].ToString() + channel[IlgharCMS.SystemModule.Alias.Channel.Path].ToString().TrimStart('/');
                                    }
                                    else
                                    {
                                        channelPath = channel[IlgharCMS.SystemModule.Alias.Channel.Path].ToString();
                                        
                                    }
                                    if (!String.IsNullOrEmpty(url))
                                    {
                                        url = channelPath + url;
                                        url = url.Replace(".ext", channel[IlgharCMS.SystemModule.Alias.Channel.Extension].ToString());
                                    }
                                    else
                                    {
                                        url = channelPath + channel[IlgharCMS.SystemModule.Alias.Channel.DefaultDocument].ToString() + channel[IlgharCMS.SystemModule.Alias.Channel.Extension];
                                    }

                                    if (Convert.ToBoolean(Manager.Site[IlgharCMS.SystemModule.Alias.InstanceConfig.Fake404]) || Request.RawUrl.IndexOf("/ilghar.aspx?/") != -1)
                                        url = Manager.GetWebPath() + "ilghar.aspx?" + url;
                                }

                                return url;
                            }

                            private int t5275IDCounter = 0;
                            private object t5275IDRecord = null;
                            private DataTable t5275ID;
                            private DataTable t5275ID_
                            {
                                get
                                {
                                    string condition = null;
condition += "P2131_24_264=";
condition += "{BAC035A8-F6BB-4772-8D51-A7F4F3AB7AD3}";


                                    string sort = null;

                                    using (IlgharCMS.SystemModule.IMenu bll = (IlgharCMS.SystemModule.IMenu)Manager.CreateObject("Menu", SystemInstanceID, PageLang, false))
                                    {
                                        t5275ID = bll.List(-1, -1, condition, sort);
                                    }

                                    return t5275ID;
                                }
                            }
                            protected string t5275
                            {
                                get
                                {
                                    XmlNode node = _xmlTemplate.SelectSingleNode("//t5275");
                                    Dictionary<string, object> replacementPair = new Dictionary<string, object>();
                                    
                                        replacementPair["{#URL#}"] = new CustomBuild(
                                                                        delegate(DataRow record, int index)
                                                                        {
                                                                            return t5275BuildUrl(record);
                                                                        }
                                                                        );
                                                replacementPair["{#Target#}"] = IlgharCMS.SystemModule.Alias.Menu.Target;replacementPair["{#Name#}"] = IlgharCMS.SystemModule.Alias.Menu.Name;
                                    StringBuilder all = Manager.Build(node, t5275ID_, replacementPair, ref t5275IDRecord, ref t5275IDCounter);
                                    
                                    
                                    
                                    return all.ToString();
                                }
                            }
                          }
