Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Web;
- using System.Web.UI.WebControls;
- using System.Web.UI.HtmlControls;
- using EPiServer;
- using EPiServer.Core;
- using EPiServer.SpecializedProperties;
- using Avantime.Classes;
- using Avantime.Classes.Webapp;
- using netr;
- namespace Avantime.Templates.Campaign.Units
- {
- /// <summary>
- /// Module for displaying text.
- /// </summary>
- public partial class ModuleText : Avantime.Templates.Core.Units.Module.ModuleBase
- {
- /// <summary>
- /// Page load
- /// </summary>
- protected override void OnLoad(System.EventArgs e)
- {
- base.OnLoad(e);
- SetupStyle();
- SetupLink();
- }
- /// <summary>
- /// Setup style for this module.
- /// </summary>
- private void SetupStyle()
- {
- // Inverted module
- if (mPageData["ModuleInverted"] != null)
- {
- DivOuter.Attributes["class"] = "InvertedModule";
- PlaceHolderInvertedTop.Visible = true;
- PlaceHolderInvertedBottom.Visible = true;
- }
- // Backgroundimage
- if (mPageData["ModuleBackgroundImage"] != null)
- {
- DivOuter.Style["background-image"] =
- "url(" + (string)mPageData["ModuleBackgroundImage"] + ")";
- DivOuter.Style["background-repeat"] = "no-repeat";
- if (mPageData["ModuleBackgroundImageAlign"] != null)
- {
- string[] arrValues = ((string)mPageData["ModuleBackgroundImageAlign"]).Split(';');
- string horizontalValue =
- ((arrValues.Length > 0) && (arrValues[0] != "")) ? arrValues[0] : "left";
- string verticalValue =
- ((arrValues.Length > 1) && (arrValues[1] != "")) ? arrValues[1] : "top";
- DivOuter.Style["background-position"] = horizontalValue + " " + verticalValue;
- }
- }
- // Height
- int height = (mPageData["ModuleHeight"] != null) ? (int)mPageData["ModuleHeight"] : 0;
- if (mPageData["ModuleInverted"] != null)
- {
- // Inverted modules add divs for rounded corners at the top and bottom
- // and some additional padding. We need to subtract that here.
- height -= (5 + 5 + 2 + 2);
- }
- if (height > 0)
- {
- DivOuter.Style["height"] = height + "px";
- }
- // Padding
- int paddingTop = (mPageData["MarginTop"] != null) ? (int)mPageData["MarginTop"] : 0;
- int paddingRight = (mPageData["MarginRight"] != null) ? (int)mPageData["MarginRight"] : 0;
- int paddingBottom = (mPageData["MarginBottom"] != null) ? (int)mPageData["MarginBottom"] : 0;
- int paddingLeft = (mPageData["MarginLeft"] != null) ? (int)mPageData["MarginLeft"] : 0;
- if ((paddingTop > 0) || (paddingRight > 0) ||
- (paddingBottom > 0) || (paddingLeft > 0))
- {
- DivPadder.Style["padding"] = string.Format("{0}px {1}px {2}px {3}px",
- paddingTop, paddingRight, paddingBottom, paddingLeft);
- }
- if (height > 0)
- {
- int innerHeight = height - paddingTop - paddingBottom -
- ((mPageData["ModuleLink"] != null) ? 35 : 0);
- DivPadder.Style["height"] = innerHeight + "px";
- }
- }
- /// <summary>
- /// Setup linkbutton at the bottom of the module.
- /// </summary>
- private void SetupLink()
- {
- if (mPageData["ModuleLink"] != null)
- {
- PlaceHolderLink.Visible = true;
- if (mPageData["ModuleInverted"] != null)
- {
- ImageTextManager.SetCampaignInvertedButtonStyle(ImageTextLinkControl);
- }
- else
- {
- PageData startPage = mPageData.TraverseTo(Project.Settings.Instance.CampaignStartPagePageTypeID);
- if (startPage != null &&
- startPage["ButtonImage"] != null &&
- startPage["ButtonImageLeft"] != null &&
- startPage["ButtonImageLeft"] != null)
- {
- ImageTextManager.SetCampaignButtonStyle(ImageTextLinkControl, startPage["ButtonImage"] as string, startPage["ButtonImageLeft"] as string, startPage["ButtonImageRight"] as string);
- }
- else
- {
- ImageTextManager.SetCampaignButtonStyle(ImageTextLinkControl);
- }
- }
- ImageTextLinkControl.ImageItems[0].Text = (mPageData["ModuleLinkText"] != null) ?
- ((string)mPageData["ModuleLinkText"]).ToUpper() : "LÄS MER";
- ImageTextLinkControl.NavigateUrl = (string)mPageData["ModuleLink"];
- ImageTextLinkControl.Target =
- ((PropertyFrame)mPageData.Property["ModuleLinkTarget"]).FrameName;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement