/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

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