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 CArticle : IlgharCMS.Page
{
public CArticle()
: base("article.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(t4138);
                                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(Article[IlgharCMS.ArticleModule.Alias.Article.MetaKeywords].ToString()))
                                                        result.Append(Article[IlgharCMS.ArticleModule.Alias.Article.MetaKeywords].ToString());
                                                    else
                                                    result.Append(Article[IlgharCMS.ArticleModule.Alias.Article.TagNames] + " " + Article[IlgharCMS.ArticleModule.Alias.Article.CategoryName] + " " + Article[IlgharCMS.ArticleModule.Alias.Article.Title]);
                                    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(Article[IlgharCMS.ArticleModule.Alias.Article.MetaDescription].ToString()))
                                                        result.Append(Article[IlgharCMS.ArticleModule.Alias.Article.MetaDescription].ToString());
                                                    else
                                                    result.Append(Article[IlgharCMS.ArticleModule.Alias.Article.TagNames] + " " + Article[IlgharCMS.ArticleModule.Alias.Article.CategoryName] + " " + Article[IlgharCMS.ArticleModule.Alias.Article.Title]);
                                    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> Article
                            {
                                get
                                {
                                    object id = null;
                                    id = Convert.ToString(Request.QueryString["ID"]);
                                    if (_ArticleID != null && _ArticleID == id)
                                        return _Article;

                                    int instanceID;
instanceID = InstanceID;

                                    using (IlgharCMS.ArticleModule.IArticle bll = (IlgharCMS.ArticleModule.IArticle)Manager.CreateObject("Article", instanceID, PageLang, false))
                                    {
                                        _ArticleID = id;
                                        _Article = bll.Get(id);
                                    }

                                    return _Article;
                                }
                            }
                            private Dictionary<string, object> _Article;
                            private object _ArticleID;
                            
                            protected Dictionary<string, object> ArticlePage
                            {
                                get
                                {
                                    return Manager.ParseContent((Article==null?null:Article[IlgharCMS.ArticleModule.Alias.Article.Content]),this);
                                }
                            }
                          
                            protected string t1248Default
                            {
                                get
                                {
                                    StringBuilder result = new StringBuilder(_xmlTemplate.SelectSingleNode("//t1248").InnerText);
                                    object t1350 = ImagePath;
result.Replace("{#t1350#}",t1350 == null ? "" : t1350.ToString());

                                    return result.ToString();
                                }
                            }
                            protected string t1248
                            {
                                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 t1248Default;

                                    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 t1248Default;
                                    else
                                        return "<script type=\"text/javascript\" src=\"" + path + "\"></script>";
                                }
                            }
                            
                            private string t1711BuildUrl(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 t1711IDCounter = 0;
                            private object t1711IDRecord = null;
                            private DataTable t1711ID;
                            private DataTable t1711ID_
                            {
                                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))
                                    {
                                        t1711ID = bll.List(-1, -1, condition, sort);
                                    }

                                    return t1711ID;
                                }
                            }
                            protected string t1711
                            {
                                get
                                {
                                    XmlNode node = _xmlTemplate.SelectSingleNode("//t1711");
                                    Dictionary<string, object> replacementPair = new Dictionary<string, object>();
                                    
                                        replacementPair["{#URL#}"] = new CustomBuild(
                                                                        delegate(DataRow record, int index)
                                                                        {
                                                                            return t1711BuildUrl(record);
                                                                        }
                                                                        );
                                                replacementPair["{#Target#}"] = IlgharCMS.SystemModule.Alias.Menu.Target;replacementPair["{#Name#}"] = IlgharCMS.SystemModule.Alias.Menu.Name;
                                    StringBuilder all = Manager.Build(node, t1711ID_, replacementPair, ref t1711IDRecord, ref t1711IDCounter);
                                    
                                    
                                    
                                    return all.ToString();
                                }
                            }
                          
                        protected int t2203IDRecordCount
                        {
                            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 t2203IDCounter = 0;
                            protected object t2203IDRecord = null;
                            private DataTable t2203IDData;
                            protected DataTable t2203ID
                            {
                                get
                                {
                                    if (t2203IDData != null)
                                        return t2203IDData;

                                    t2203IDData = t2203ID_;
                                    return t2203IDData;
                                }
                            }
                        
                                private DataTable t2203ID_
                                {
                                    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))
                                        {
                                            t2203IDData = bll.List(-1, -1, condition, sort);
                                        }

                                        return t2203IDData;
                                    }
                                }
                            
                            protected string t2203
                            {
                                get
                                {
                                    XmlNode node = _xmlTemplate.SelectSingleNode("//t2203");
                                    Dictionary<string, object> replacementPair = new Dictionary<string, object>();
                                    
                                        replacementPair[@"{#BuildUrl()#}"] = new CustomBuild(
                                                                        delegate(DataRow record, int index)
                                                                        {
                                                                            object t2346 = BuildUrl(Channel,"article_category","ID=" + t2203ID.Rows[t2203IDCounter]["P2194_1_101"] + "&Ext=" + t2203ID.Rows[t2203IDCounter]["P2194_1_102"] + "&PageTemplate=" + t2203ID.Rows[t2203IDCounter]["P2194_1_100"] + "&PageUrl=" + HttpUtility.UrlEncode(t2203ID.Rows[t2203IDCounter]["P2194_1_103"].ToString()));
                                                                            if (t2346 != null)
                                                                                return t2346.ToString();
                                                                            else
                                                                                return String.Empty;
                                                                        }
                                                                        );
                                                replacementPair["{#Name#}"] = IlgharCMS.ArticleModule.Alias.ArticleCategory.Name;
                                    StringBuilder all = Manager.Build(node, t2203ID_, replacementPair, ref t2203IDRecord, ref t2203IDCounter);
                                    
                                    
                                    
                                    return all.ToString();
                                }
                            }
                          
                        protected int t2522IDRecordCount
                        {
                            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 t2522IDCounter = 0;
                            protected object t2522IDRecord = null;
                            private DataTable t2522IDData;
                            protected DataTable t2522ID
                            {
                                get
                                {
                                    if (t2522IDData != null)
                                        return t2522IDData;

                                    t2522IDData = t2522ID_;
                                    return t2522IDData;
                                }
                            }
                        
                                private DataTable t2522ID_
                                {
                                    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))
                                        {
                                            t2522IDData = bll.List(1, 10, condition, sort);
                                        }

                                        return t2522IDData;
                                    }
                                }
                            
                            protected string t2522
                            {
                                get
                                {
                                    XmlNode node = _xmlTemplate.SelectSingleNode("//t2522");
                                    Dictionary<string, object> replacementPair = new Dictionary<string, object>();
                                    
                                        replacementPair[@"{#BuildUrl()#}"] = new CustomBuild(
                                                                        delegate(DataRow record, int index)
                                                                        {
                                                                            object t2738 = BuildUrl(ShopChannel,"goods","ID=" + t2522ID.Rows[t2522IDCounter]["P1896_2_415"] + "&Ext=" + t2522ID.Rows[t2522IDCounter]["P1896_2_416"] + "&PageTemplate=" + t2522ID.Rows[t2522IDCounter]["P1896_2_414"]);
                                                                            if (t2738 != null)
                                                                                return t2738.ToString();
                                                                            else
                                                                                return String.Empty;
                                                                        }
                                                                        );
                                                replacementPair["{#Name#}"] = IlgharCMS.ShopModule.Alias.Goods.Name;replacementPair["{#Thumbnail#}"] = IlgharCMS.ShopModule.Alias.Goods.Thumbnail;
                                    StringBuilder all = Manager.Build(node, t2522ID_, replacementPair, ref t2522IDRecord, ref t2522IDCounter);
                                    
                                    
                                    
                                    return all.ToString();
                                }
                            }
                          
                        protected int t3070IDRecordCount
                        {
                            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 t3070IDCounter = 0;
                            protected object t3070IDRecord = null;
                            private DataTable t3070IDData;
                            protected DataTable t3070ID
                            {
                                get
                                {
                                    if (t3070IDData != null)
                                        return t3070IDData;

                                    t3070IDData = t3070ID_;
                                    return t3070IDData;
                                }
                            }
                        
                                private DataTable t3070ID_
                                {
                                    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))
                                        {
                                            t3070IDData = bll.List(-1, -1, condition, sort);
                                        }

                                        return t3070IDData;
                                    }
                                }
                            
                            protected string t3070
                            {
                                get
                                {
                                    XmlNode node = _xmlTemplate.SelectSingleNode("//t3070");
                                    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, t3070ID_, replacementPair, ref t3070IDRecord, ref t3070IDCounter);
                                    
                                    
                                    
                                    return all.ToString();
                                }
                            }
                          
                            private int t3500IDCounter = 0;
                            private object t3500IDRecord = null;
                            private DataTable t3500ID_;
                            private DataTable t3500ID
                            {
                                get
                                {
                                    if (t3500ID_ != null)
                                        return t3500ID_;

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

                                    DataRow newRow = null;

                                    
                                newRow = t3500ID_.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"];
                                t3500ID_.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 = t3500ID_.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"];
                                        t3500ID_.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 + "={" + (Article==null?null:Article[IlgharCMS.ArticleModule.Alias.Article.CategoryID]) + "}";


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

                                int pos = t3500ID_.Rows.Count;

                                newRow = t3500ID_.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]);
                                t3500ID_.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 = t3500ID_.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]);
                                    t3500ID_.Rows.InsertAt(newRow, pos);
                                }
                            }
                            

                                    return t3500ID_;
                                }
                            }
                            protected string t3500
                            {
                                get
                                {
                                    XmlNode node = _xmlTemplate.SelectSingleNode("//t3500");
                                    Dictionary<string, object> replacementPair = new Dictionary<string, object>();
                                    replacementPair["{#URL#}"] = "URL";replacementPair["{#Name#}"] = "Name";
                                    StringBuilder all = Manager.Build(node, t3500ID, replacementPair, ref t3500IDRecord, ref t3500IDCounter);
                                    
                                    
                                    
                                    return all.ToString();
                                }
                            }
                          
                            
                        private string t4138URL_ = null;
                        private string t4138URL
                        {
                            get
                            {
                                if (t4138URL_ != null)
                                    return t4138URL_;

                                t4138URL_ = BuildUrl(null, null, "Page={Page}");
                                return t4138URL_;
                            }
                        }
                        
                            private int t4138Page;
                            private int t4138PageCount;
                            private int t4138RecordCount;
                            private int t4138PageSize;
                            private int t4138Index;
                            protected string t4138
                            {
                                get
                                {
                                    t4138Page = Convert.ToInt32(PageNumber);
                                    if (t4138Page <= 0)
                                        t4138Page = 1;
                                    t4138PageSize = 1;
                                    t4138RecordCount = Convert.ToInt32(ArticlePage["PageCount"]);

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

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

                                    t4138PageCount = t4138RecordCount / t4138PageSize;
                                    if (t4138RecordCount % t4138PageSize > 0)
                                        t4138PageCount += 1;

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

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

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

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

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

                                        bool isAll = false;
                                        int pageEnd = 0;
                                        if (isAll)
                                        {
                                            t4138Index = 1;
                                            pageEnd = t4138PageCount;
                                        }
                                        else
                                        {
                                            t4138Index = t4138Page - 5;
                                            if (t4138Index <= 0)
                                                t4138Index = 1;

                                            pageEnd = t4138Page + 5;
                                            if (pageEnd > t4138PageCount)
                                                pageEnd = t4138PageCount;
                                        }

                                        while (t4138Index <= pageEnd)
                                        {
                                            if (t4138Index == t4138Page)
                                            {
                                                currentPage.Append(currentPageYesTpl);
                                                object t4680 = t4138Index;
currentPage.Replace("{#t4680#}", t4680 == null ? "" : t4680.ToString());

                                            }
                                            else
                                            {
                                                currentPage.Append(currentPageNoTpl);
                                                object t4755 = t4138URL.Replace("{Page}", Convert.ToString(t4138Index));
currentPage.Replace("{#t4755#}", t4755 == null ? "" : t4755.ToString());
object t4765 = t4138Index;
currentPage.Replace("{#t4765#}", t4765 == null ? "" : t4765.ToString());

                                            }
                                            t4138Index++;
                                        }
                                    }
                                    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 (t4138Page < t4138PageCount)
                                    {
                                        lastPage.Append(lastPageNoTpl);
                                        object t5023 = t4138URL.Replace("{Page}", Convert.ToString(t4138Page + 1));
lastPage.Replace("{#t5023#}", t5023 == null ? "" : t5023.ToString());
object t5066 = t4138URL.Replace("{Page}", Convert.ToString(t4138PageCount));
lastPage.Replace("{#t5066#}", t5066 == null ? "" : t5066.ToString());

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

                                    

                                    return all.ToString();
                                }
                            }
                          
                            private string t5307BuildUrl(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 t5307IDCounter = 0;
                            private object t5307IDRecord = null;
                            private DataTable t5307ID;
                            private DataTable t5307ID_
                            {
                                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))
                                    {
                                        t5307ID = bll.List(-1, -1, condition, sort);
                                    }

                                    return t5307ID;
                                }
                            }
                            protected string t5307
                            {
                                get
                                {
                                    XmlNode node = _xmlTemplate.SelectSingleNode("//t5307");
                                    Dictionary<string, object> replacementPair = new Dictionary<string, object>();
                                    
                                        replacementPair["{#URL#}"] = new CustomBuild(
                                                                        delegate(DataRow record, int index)
                                                                        {
                                                                            return t5307BuildUrl(record);
                                                                        }
                                                                        );
                                                replacementPair["{#Target#}"] = IlgharCMS.SystemModule.Alias.Menu.Target;replacementPair["{#Name#}"] = IlgharCMS.SystemModule.Alias.Menu.Name;
                                    StringBuilder all = Manager.Build(node, t5307ID_, replacementPair, ref t5307IDRecord, ref t5307IDCounter);
                                    
                                    
                                    
                                    return all.ToString();
                                }
                            }
                          }
