PageRenderTime 21ms CodeModel.GetById 15ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/projects/PigeonCms.Core/BLL/StaticPage.cs

http://pigeoncms.googlecode.com/
C# | 193 lines | 145 code | 20 blank | 28 comment | 4 complexity | e65fea382697ccf6b0074cd53d2c5272 MD5 | raw file
  1using System;
  2using System.Data;
  3using System.Configuration;
  4using System.Web;
  5using System.Web.Security;
  6using System.Web.UI;
  7using System.Web.UI.WebControls;
  8using System.Web.UI.WebControls.WebParts;
  9using System.Web.UI.HtmlControls;
 10using System.Diagnostics;
 11using System.ComponentModel;
 12using System.Collections.Generic;
 13using System.Threading;
 14
 15namespace PigeonCms
 16{
 17    public class StaticPage: ITable
 18    {
 19        private string pageName = "";
 20        private bool visible = true;
 21        private bool showPageTitle = true;
 22        private Dictionary<string, string> pageTitleTranslations = new Dictionary<string, string>();
 23        private Dictionary<string, string> pageContentTranslations = new Dictionary<string, string>();
 24
 25        public StaticPage()
 26        {
 27        }
 28
 29        /// <summary>
 30        /// Name or achronim of the Page used as primary key
 31        /// </summary>
 32        [DataObjectField(true)]
 33        public string PageName
 34        {
 35            [DebuggerStepThrough()]
 36            get { return pageName; }
 37            [DebuggerStepThrough()]
 38            set { pageName = value; }
 39        }
 40
 41        /// <summary>
 42        /// Title of the static page in current culture
 43        /// </summary>
 44        [DataObjectField(false)]
 45        public string PageTitle
 46        {
 47            get 
 48            {
 49                string pageTitle = "";
 50                PageTitleTranslations.TryGetValue(Thread.CurrentThread.CurrentCulture.Name, out pageTitle);
 51                if (Utility.IsEmptyFckField(pageTitle))
 52                    PageTitleTranslations.TryGetValue(Config.CultureDefault, out pageTitle);
 53                return pageTitle;
 54            }
 55        }
 56
 57        /// <summary>
 58        /// html content of the static page in current culture
 59        /// </summary>
 60        [DataObjectField(false)]
 61        public string PageContent
 62        {
 63            get 
 64            {
 65                string pageContent = "";
 66                PageContentTranslations.TryGetValue(Thread.CurrentThread.CurrentCulture.Name, out pageContent);
 67                if (Utility.IsEmptyFckField(pageContent))
 68                    PageContentTranslations.TryGetValue(Config.CultureDefault, out pageContent);
 69                return pageContent;
 70            }
 71        }
 72
 73        /// <summary>
 74        /// content parsed
 75        /// </summary>
 76        [DataObjectField(false)]
 77        public string PageContentParsed
 78        {
 79            get
 80            {
 81                string res = this.PageContent;
 82                res = Utility.Html.FillPlaceholders(res);
 83                return res;
 84            }
 85        }
 86        
 87
 88        /// <summary>
 89        /// Show or not the the content
 90        /// </summary>
 91        public bool Visible
 92        {
 93            [DebuggerStepThrough()]
 94            get { return visible; }
 95            [DebuggerStepThrough()]
 96            set { visible = value; }
 97        }
 98
 99        /// <summary>
100        /// Show or not the page title
101        /// </summary>
102        public bool ShowPageTitle
103        {
104            [DebuggerStepThrough()]
105            get { return showPageTitle; }
106            [DebuggerStepThrough()]
107            set { showPageTitle = value; }
108        }
109
110        /// <summary>
111        /// Title of the static page in different culture
112        /// </summary>
113        [DataObjectField(false)]
114        public Dictionary<string, string> PageTitleTranslations
115        {
116            [DebuggerStepThrough()]
117            get { return pageTitleTranslations; }
118            [DebuggerStepThrough()]
119            set { pageTitleTranslations = value; }
120        }
121
122        /// <summary>
123        /// Content of the static page in different culture
124        /// </summary>
125        [DataObjectField(false)]
126        public Dictionary<string, string> PageContentTranslations
127        {
128            [DebuggerStepThrough()]
129            get { return pageContentTranslations; }
130            [DebuggerStepThrough()]
131            set { pageContentTranslations = value; }
132        }
133
134        public bool IsPageTitleTranslated
135        {
136            get
137            {
138                bool res = true;
139                string val = "";
140                PageTitleTranslations.TryGetValue(Thread.CurrentThread.CurrentCulture.Name, out val);
141                if (Utility.IsEmptyFckField(val))
142                    res = false;
143                return res;
144            }
145        }
146
147        public bool IsPageContentTranslated
148        {
149            get
150            {
151                bool res = true;
152                string val = "";
153                PageContentTranslations.TryGetValue(Thread.CurrentThread.CurrentCulture.Name, out val);
154                if (Utility.IsEmptyFckField(val))
155                    res = false;
156                return res;
157            }
158        }
159    }
160
161    /// <summary>
162    /// Filter used in search
163    /// </summary>
164    /// <remarks></remarks>
165    [Serializable]
166    public class StaticPageFilter
167    {
168        #region fields definition
169
170        private string pageName = "";
171        private Utility.TristateBool visible = Utility.TristateBool.NotSet;
172
173        public string PageName
174        {
175            [DebuggerStepThrough()]
176            get { return pageName; }
177            [DebuggerStepThrough()]
178            set { pageName = value; }
179        }
180
181        public Utility.TristateBool Visible
182        {
183            [DebuggerStepThrough()]
184            get { return visible; }
185            [DebuggerStepThrough()]
186            set { visible = value; }
187        }
188
189        #endregion
190
191    }
192
193}