Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.19 KB | None | 0 0
  1. using System;
  2. using System.Web;
  3. using System.Web.UI.WebControls;
  4. using System.Web.UI.HtmlControls;
  5. using EPiServer;
  6. using EPiServer.Core;
  7. using EPiServer.SpecializedProperties;
  8. using Avantime.Classes;
  9. using Avantime.Classes.Webapp;
  10. using netr;
  11.  
  12. namespace Avantime.Templates.Campaign.Units
  13. {
  14. /// <summary>
  15. /// Module for displaying text.
  16. /// </summary>
  17. public partial class ModuleText : Avantime.Templates.Core.Units.Module.ModuleBase
  18. {
  19. /// <summary>
  20. /// Page load
  21. /// </summary>
  22. protected override void OnLoad(System.EventArgs e)
  23. {
  24. base.OnLoad(e);
  25.  
  26. SetupStyle();
  27. SetupLink();
  28. }
  29.  
  30. /// <summary>
  31. /// Setup style for this module.
  32. /// </summary>
  33. private void SetupStyle()
  34. {
  35. // Inverted module
  36. if (mPageData["ModuleInverted"] != null)
  37. {
  38. DivOuter.Attributes["class"] = "InvertedModule";
  39. PlaceHolderInvertedTop.Visible = true;
  40. PlaceHolderInvertedBottom.Visible = true;
  41. }
  42.  
  43. // Backgroundimage
  44. if (mPageData["ModuleBackgroundImage"] != null)
  45. {
  46. DivOuter.Style["background-image"] =
  47. "url(" + (string)mPageData["ModuleBackgroundImage"] + ")";
  48. DivOuter.Style["background-repeat"] = "no-repeat";
  49.  
  50. if (mPageData["ModuleBackgroundImageAlign"] != null)
  51. {
  52. string[] arrValues = ((string)mPageData["ModuleBackgroundImageAlign"]).Split(';');
  53. string horizontalValue =
  54. ((arrValues.Length > 0) && (arrValues[0] != "")) ? arrValues[0] : "left";
  55. string verticalValue =
  56. ((arrValues.Length > 1) && (arrValues[1] != "")) ? arrValues[1] : "top";
  57.  
  58. DivOuter.Style["background-position"] = horizontalValue + " " + verticalValue;
  59. }
  60. }
  61.  
  62. // Height
  63. int height = (mPageData["ModuleHeight"] != null) ? (int)mPageData["ModuleHeight"] : 0;
  64. if (mPageData["ModuleInverted"] != null)
  65. {
  66. // Inverted modules add divs for rounded corners at the top and bottom
  67. // and some additional padding. We need to subtract that here.
  68. height -= (5 + 5 + 2 + 2);
  69. }
  70. if (height > 0)
  71. {
  72. DivOuter.Style["height"] = height + "px";
  73. }
  74.  
  75. // Padding
  76. int paddingTop = (mPageData["MarginTop"] != null) ? (int)mPageData["MarginTop"] : 0;
  77. int paddingRight = (mPageData["MarginRight"] != null) ? (int)mPageData["MarginRight"] : 0;
  78. int paddingBottom = (mPageData["MarginBottom"] != null) ? (int)mPageData["MarginBottom"] : 0;
  79. int paddingLeft = (mPageData["MarginLeft"] != null) ? (int)mPageData["MarginLeft"] : 0;
  80.  
  81. if ((paddingTop > 0) || (paddingRight > 0) ||
  82. (paddingBottom > 0) || (paddingLeft > 0))
  83. {
  84. DivPadder.Style["padding"] = string.Format("{0}px {1}px {2}px {3}px",
  85. paddingTop, paddingRight, paddingBottom, paddingLeft);
  86. }
  87.  
  88. if (height > 0)
  89. {
  90. int innerHeight = height - paddingTop - paddingBottom -
  91. ((mPageData["ModuleLink"] != null) ? 35 : 0);
  92. DivPadder.Style["height"] = innerHeight + "px";
  93. }
  94. }
  95.  
  96. /// <summary>
  97. /// Setup linkbutton at the bottom of the module.
  98. /// </summary>
  99. private void SetupLink()
  100. {
  101. if (mPageData["ModuleLink"] != null)
  102. {
  103. PlaceHolderLink.Visible = true;
  104. if (mPageData["ModuleInverted"] != null)
  105. {
  106. ImageTextManager.SetCampaignInvertedButtonStyle(ImageTextLinkControl);
  107. }
  108. else
  109. {
  110. PageData startPage = mPageData.TraverseTo(Project.Settings.Instance.CampaignStartPagePageTypeID);
  111.  
  112. if (startPage != null &&
  113. startPage["ButtonImage"] != null &&
  114. startPage["ButtonImageLeft"] != null &&
  115. startPage["ButtonImageLeft"] != null)
  116. {
  117. ImageTextManager.SetCampaignButtonStyle(ImageTextLinkControl, startPage["ButtonImage"] as string, startPage["ButtonImageLeft"] as string, startPage["ButtonImageRight"] as string);
  118. }
  119. else
  120. {
  121. ImageTextManager.SetCampaignButtonStyle(ImageTextLinkControl);
  122. }
  123. }
  124. ImageTextLinkControl.ImageItems[0].Text = (mPageData["ModuleLinkText"] != null) ?
  125. ((string)mPageData["ModuleLinkText"]).ToUpper() : "LÄS MER";
  126. ImageTextLinkControl.NavigateUrl = (string)mPageData["ModuleLink"];
  127. ImageTextLinkControl.Target =
  128. ((PropertyFrame)mPageData.Property["ModuleLinkTarget"]).FrameName;
  129. }
  130. }
  131. }
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement