private void SetTabPrivate(string resourceString, string url, string helpTopic) { // Resolve macros in url url = CMSContext.ResolveMacros(url); SetTab(GetNextTabID(), ResHelper.GetString(resourceString), ResolveUrl(url), string.Format("SetHelpTopic('helpBreadcrumbs', '{0}');", helpTopic)); }
/// <summary> /// Fills dropdown list with document types. /// </summary> private void FillDocumentTypesDDL() { drpDocTypes.Items.Clear(); // Add (All) record drpDocTypes.Items.Add(new ListItem(GetString("general.selectall"), "0")); // Select only document types from current site marked as product string where = "ClassIsDocumentType = 1 AND ClassIsProduct = 1 AND ClassID IN (SELECT ClassID FROM CMS_ClassSite WHERE SiteID = " + CMSContext.CurrentSiteID + ")"; DataSet ds = DataClassInfoProvider.GetClasses("ClassID, ClassDisplayName", where, "ClassDisplayName", 0); if (!DataHelper.DataSourceIsEmpty(ds)) { foreach (DataRow dr in ds.Tables[0].Rows) { string name = ValidationHelper.GetString(dr["ClassDisplayName"], ""); int id = ValidationHelper.GetInteger(dr["ClassID"], 0); if (!string.IsNullOrEmpty(name) && (id > 0)) { // Handle document name name = ResHelper.LocalizeString(CMSContext.ResolveMacros(name)); drpDocTypes.Items.Add(new ListItem(name, id.ToString())); } } } }
protected void Page_Load(object sender, EventArgs e) { // Try skip IIS http errors Response.TrySkipIisCustomErrors = true; // Set service unavailable state Response.StatusCode = 503; // Set title titleElem.TitleText = GetString("Error.SiteOffline"); titleElem.TitleImage = GetImageUrl("Others/Messages/warning.png"); SiteInfo currentSite = CMSContext.CurrentSite; if (currentSite != null) { if (currentSite.SiteIsOffline) { // Site is offline if (!String.IsNullOrEmpty(currentSite.SiteOfflineMessage)) { lblInfo.Text = CMSContext.ResolveMacros(currentSite.SiteOfflineMessage); } else { lblInfo.Text = ResHelper.GetString("error.siteisoffline"); } } else { // Redirect to the root Response.Redirect("~/"); } } }
protected void Page_Load(object sender, EventArgs e) { // Set title this.titleElem.TitleText = GetString("Error.SiteOffline"); this.titleElem.TitleImage = GetImageUrl("Others/Messages/warning.png"); SiteInfo currentSite = CMSContext.CurrentSite; if (currentSite != null) { if (currentSite.SiteIsOffline) { // Site is offline if (!String.IsNullOrEmpty(currentSite.SiteOfflineMessage)) { lblInfo.Text = CMSContext.ResolveMacros(currentSite.SiteOfflineMessage); } else { lblInfo.Text = ResHelper.GetString("error.siteisoffline"); } } else { // Redirect to the root Response.Redirect("~/"); } } }
/// <summary> /// Ensures graph HTML code. /// </summary> protected void EnsureGraph() { ItemType = ReportItemType.HtmlGraph; // Get html graph content string content = Generate(); // If graph is not defined display info message if (String.IsNullOrEmpty(content)) { // Check whether no data text is defiend if (!String.IsNullOrEmpty(ReportSettings["QueryNoRecordText"])) { // Display no data text plcInfo.Visible = true; lblInfo.Text = HTMLHelper.HTMLEncode(CMSContext.ResolveMacros(ReportSettings["QueryNoRecordText"])); EnableExport = false; } } // Display graph else { // Set generated HTML to the literal control ltlGraph.Text = content; } if (EmailMode) { menuCont.Visible = false; ltlEmail.Text = content; ltlEmail.Visible = true; } }
/// <summary> /// Get completly resolved url (resolve macros, hash, url) /// </summary> private string GetUrl(string url) { url = CMSContext.ResolveMacros(url); url = URLHelper.EnsureHashToQueryParameters(url); url = URLHelper.ResolveUrl(url); return(url); }
/// <summary> /// Mass action 'ok' button clicked. /// </summary> protected void btnOk_Click(object sender, EventArgs e) { Action action = (Action)ValidationHelper.GetInteger(drpAction.SelectedItem.Value, 0); What what = (What)ValidationHelper.GetInteger(drpWhat.SelectedItem.Value, 0); string where = string.Empty; switch (what) { // All items case What.All: where = CMSContext.ResolveMacros("ContactGroupMemberContactGroupID = " + cgi.ContactGroupID); break; // Selected items case What.Selected: // Convert array to integer values to make sure no sql injection is possible (via string values) where = SqlHelperClass.GetWhereCondition <int>("ContactGroupMemberRelatedID", gridElem.SelectedItems, false); where = SqlHelperClass.AddWhereCondition(where, "ContactGroupMemberContactGroupID = " + cgi.ContactGroupID); break; default: return; } // Set constraint for account relations only where = SqlHelperClass.AddWhereCondition(where, "(ContactGroupMemberType = 1)"); switch (action) { // Action 'Remove' case Action.Remove: // Delete the relations between contact group and accounts ContactGroupMemberInfoProvider.DeleteContactGroupMembers(where, cgi.ContactGroupID, true, true); // Show result message if (what == What.Selected) { ShowConfirmation(GetString("om.account.massaction.removed")); } else { ShowConfirmation(GetString("om.account.massaction.removedall")); } break; default: return; } // Reload unigrid gridElem.ClearSelectedItems(); gridElem.ReloadData(); pnlUpdate.Update(); }
protected void btnOk_Click(object sender, EventArgs e) { string resultMessage = string.Empty; Action action = (Action)ValidationHelper.GetInteger(drpAction.SelectedItem.Value, 0); What what = (What)ValidationHelper.GetInteger(drpWhat.SelectedItem.Value, 0); string where = string.Empty; switch (what) { // All items case What.All: where = CMSContext.ResolveMacros("ContactGroupMemberContactGroupID = " + cgi.ContactGroupID); break; // Selected items case What.Selected: where = SqlHelperClass.GetWhereCondition <int>("ContactGroupMemberRelatedID", ContactHelper.GetSafeArray(gridElem.SelectedItems), false); where = SqlHelperClass.AddWhereCondition(where, "ContactGroupMemberContactGroupID = " + cgi.ContactGroupID); break; default: return; } // Set constraint for contact relations only where = SqlHelperClass.AddWhereCondition(where, "(ContactGroupMemberType = 0)"); switch (action) { // Action 'Remove' case Action.Remove: // Delete the relations between contact group and contacts ContactGroupMemberInfoProvider.DeleteContactGroupMembers(where, cgi.ContactGroupID, false, false); resultMessage = GetString("om.contact.massaction.removed"); break; default: return; } if (!string.IsNullOrEmpty(resultMessage)) { lblInfo.Text = resultMessage; lblInfo.Visible = true; } // Reload unigrid gridElem.ClearSelectedItems(); gridElem.ReloadData(); pnlUpdate.Update(); }
protected void btnOk_Click(object sender, EventArgs e) { if (AccountHelper.AuthorizedModifyAccount(SiteID, true)) { string resultMessage = string.Empty; Action action = (Action)ValidationHelper.GetInteger(drpAction.SelectedItem.Value, 0); What what = (What)ValidationHelper.GetInteger(drpWhat.SelectedItem.Value, 0); string where = string.Empty; switch (what) { // All items case What.All: where = CMSContext.ResolveMacros(gridElem.WhereCondition); break; // Selected items case What.Selected: where = SqlHelperClass.GetWhereCondition <int>("AccountID", gridElem.SelectedItems, false); break; default: return; } switch (action) { // Action 'Remove' case Action.Remove: // Clear HQ ID of selected accounts AccountInfoProvider.UpdateAccountHQ(0, where); resultMessage = GetString("om.account.massaction.removed"); break; default: return; } if (!string.IsNullOrEmpty(resultMessage)) { lblInfo.Text = resultMessage; lblInfo.Visible = true; } // Reload UniGrid gridElem.ClearSelectedItems(); gridElem.ReloadData(); pnlUpdate.Update(); } }
protected void Page_Load(object sender, EventArgs e) { InitTabs("Content"); SetTab(0, GetString("general.general"), CMSContext.ResolveMacros("NewsletterTemplate_Edit.aspx?templateid={%EditedObject.TemplateID%}&tabmode={?tabmode?}"), "SetHelpTopic('helpTopic','newsletter_template_general')"); // Add newsletter - template binding tab for ordinary newsletter template EmailTemplateInfo emailTemplate = (EmailTemplateInfo)EditedObject; if ((emailTemplate != null) && (emailTemplate.TemplateType == EmailTemplateType.Issue)) { SetTab(1, GetString("newsletter.templatenewsletter"), CMSContext.ResolveMacros("Tab_Newsletters.aspx?templateid={%EditedObject.TemplateID%}&tabmode={?tabmode?}"), "SetHelpTopic('helpTopic','template_newsletters')"); } }
/// <summary> /// Returns safe and localized tooltip from the given source column. /// </summary> /// <param name="dr">Data row with the tooltip column</param> /// <param name="columnName">Name of the tooltip source column</param> private string GetTooltip(DataRow dr, string columnName) { // Get tooltip string string tooltip = ValidationHelper.GetString(DataHelper.GetDataRowValue(dr, columnName), ""); // Get safe an localized tooltip if (!string.IsNullOrEmpty(tooltip)) { return(HTMLHelper.HTMLEncode(CMSContext.ResolveMacros(tooltip))); } return(""); }
protected void Page_Load(object sender, EventArgs e) { if (!((ViewMode == ViewModeEnum.LiveSite) || (ViewMode == ViewModeEnum.Preview))) { return; } // Registration to chat webservice AbstractCMSPage cmsPage = Page as AbstractCMSPage; if (cmsPage != null) { ChatHelper.RegisterChatAJAXProxy(cmsPage); } // Script references insertion ScriptHelper.RegisterJQuery(Page); ScriptHelper.RegisterJQueryCookie(Page); ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Chat/CMSPages/ChatSettings.ashx", false); ScriptHelper.RegisterScriptFile(Page, "jquery/jquery-tmpl.js"); ScriptHelper.RegisterScriptFile(Page, "~/CMSWebParts/Chat/AutoInitiatedChat_files/AutoInitiatedChat.js"); int optID = ChatPopupWindowSettingsHelper.Store(ChatMessageTransformationName, ChatRoomUserTransformationName, ChatErrorTransformationName, ChatErrorDeleteAllButtonTransformationName); // Run script JavaScriptSerializer sr = new JavaScriptSerializer(); string json = sr.Serialize( new { wpGUID = InstanceGUID, clientID = pnlInitiatedChat.ClientID, contentID = pnlContent.ClientID, pnlErrorID = pnlError.ClientID, lblErrorID = lblError.ClientID, windowURL = ChatHelper.GetChatRoomWindowURL(), trans = ChatHelper.GetWebpartTransformation(TransformationName, "chat.error.transformation.initiatedchat.error"), guid = optID, delay = Delay * 1000, initiatorName = InitiatorName, messages = CMSContext.ResolveMacros(Messages).Split('\n') } ); string startupScript = string.Format("InitAutoInitiatedChat({0});", json); ScriptHelper.RegisterStartupScript(Page, typeof(string), "ChatAutoInitiatedChat_" + ClientID, startupScript, true); }
protected void Page_Load(object sender, EventArgs e) { // Set title CurrentMaster.Title.TitleImage = GetImageUrl("Objects/OM_Score/object.png"); CurrentMaster.Title.TitleText = GetString("om.score.edit"); // Set default help SetHelp("scoring_contacts", "helpTopic"); // register scripts in modal dialog if (isDialogMode) { RegisterModalPageScripts(); } // Modify header appearance in modal dialog (display title instead of breadcrumbs) if (!QueryHelper.GetBoolean("dialogmode", false)) { CurrentPage.InitBreadcrumbs(2); CurrentPage.SetBreadcrumb(0, GetString("om.score.list"), "~/CMSModules/Scoring/Pages/List.aspx", "_parent", null); CurrentPage.SetBreadcrumb(1, CMSContext.ResolveMacros("{%EditedObject.DisplayName%}"), null, null, null); } else { if (EditedObject != null) { // Add score name to title in dialog mode string scoreName = ResHelper.LocalizeString(((ScoreInfo)EditedObject).ScoreDisplayName); CurrentMaster.Title.TitleText += " - " + HTMLHelper.HTMLEncode(scoreName); } } // Initialize tabs InitTabs("content"); SetTab(0, GetString("om.score.contacts"), "Tab_Contacts.aspx", "SetHelpTopic('helpTopic', 'scoring_contacts');"); SetTab(1, GetString("general.general"), "Tab_General.aspx", "SetHelpTopic('helpTopic', 'scoring_general');"); SetTab(2, GetString("om.score.rules"), "Tab_Rules.aspx", "SetHelpTopic('helpTopic', 'scoring_rules');"); if (QueryHelper.GetBoolean("saved", false)) { // Select General tab if new score was created CurrentMaster.Tabs.SelectedTab = 1; CurrentMaster.Title.HelpTopicName = "scoring_general"; } }
protected object gridClasses_OnExternalDataBound(object sender, string sourceName, object parameter) { if (sourceName.ToLower() == "classname") { DataRowView drv = (DataRowView)parameter; // Get properties string className = ValidationHelper.GetString(drv["ClassName"], ""); string classDisplayName = ResHelper.LocalizeString(CMSContext.ResolveMacros(ValidationHelper.GetString(drv["ClassDisplayName"], ""))); string classId = ValidationHelper.GetString(drv["ClassId"], ""); // Format items to output return("<a class=\"ContentNewClass\" href=\"../Edit/EditFrameset.aspx?action=new&nodeid=" + nodeId + "&classid=" + classId + "\">" + "<img style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px;\" " + "src=\"" + ResolveUrl(GetDocumentTypeIconUrl(className)) + "\" />" + HTMLHelper.HTMLEncode(classDisplayName) + "</a>" + GenerateSpaceAfter(className)); } return(HTMLHelper.HTMLEncode(parameter.ToString())); }
protected void Page_Load(object sender, EventArgs e) { string url = ResolveUrl("~/CMSModules/ContactManagement/Pages/Tools/ContactGroup/List.aspx"); url = URLHelper.AddParameterToUrl(url, "siteid", SiteID.ToString()); // Check if running under site manager (and distribute "site manager" flag to other tabs) if (IsSiteManager) { url = URLHelper.AddParameterToUrl(url, "issitemanager", "1"); // Hide title CurrentMaster.Title.TitleText = CurrentMaster.Title.TitleImage = string.Empty; } CurrentPage.InitBreadcrumbs(2); CurrentPage.SetBreadcrumb(0, GetString("om.contactgroup.list"), url, "_parent", null); CurrentPage.SetBreadcrumb(1, CMSContext.ResolveMacros("{%EditedObject.DisplayName%}"), null, null, null); }
protected object gridClasses_OnExternalDataBound(object sender, string sourceName, object parameter) { if (sourceName.ToLowerCSafe() == "classname") { DataRowView drv = (DataRowView)parameter; // Get properties string className = ValidationHelper.GetString(drv["ClassName"], string.Empty); string classDisplayName = ResHelper.LocalizeString(CMSContext.ResolveMacros(ValidationHelper.GetString(drv["ClassDisplayName"], string.Empty))); int classId = ValidationHelper.GetInteger(drv["ClassId"], 0); string nameFormat = "<img style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px;\" src=\"{0}\" />{1}"; // Append link if url specified if (!string.IsNullOrEmpty(SelectionUrl)) { string url = GetSelectionUrl(classId); if (IsInDialog) { url = URLHelper.UpdateParameterInUrl(url, "dialog", "1"); url = URLHelper.UpdateParameterInUrl(url, "reloadnewpage", "1"); } // Prepare attributes string attrs = ""; if (!string.IsNullOrEmpty(ClientTypeClick)) { attrs = string.Format("onclick=\"{0}\"", ClientTypeClick); } nameFormat = string.Format("<a class=\"ContentNewClass\" href=\"{0}\" {2}>{1}</a>", url, nameFormat, attrs); } // Format items to output return(string.Format(nameFormat, ResolveUrl(GetDocumentTypeIconUrl(className)), HTMLHelper.HTMLEncode(classDisplayName)) + GenerateSpaceAfter(className)); } return(HTMLHelper.HTMLEncode(parameter.ToString())); }
/// <summary> /// Loads users and roles listed in the ACL of the selected document and displays them in the listbox. /// </summary> /// <param name="reload">Forces reload of listbox</param> public void LoadOperators(bool reload) { if (!StopProcessing) { string lastOperator = ""; StringBuilder roles = new StringBuilder(); StringBuilder users = new StringBuilder(); StringBuilder disabledRoles = new StringBuilder(); StringBuilder disabledUsers = new StringBuilder(); if (reload) { lstOperators.Items.Clear(); } LoadACLItems(); if ((dsAclItems != null) && (dsAclItems.Tables.Count > 0)) { foreach (DataRow drAclItem in dsAclItems.Tables[0].Rows) { int nodeID = ValidationHelper.GetInteger(drAclItem["ACLOwnerNodeID"], 0); string op = ValidationHelper.GetString(drAclItem["Operator"], ""); if (op != lastOperator) { lastOperator = op; string operName = ValidationHelper.GetString(drAclItem["OperatorName"], String.Empty); operName = CMSContext.ResolveMacros(operName); if (!String.IsNullOrEmpty(op)) { switch (op[0]) { // Operator starts with 'R' - indicates role case 'R': string role = op.Substring(1) + ";"; roles.Append(role); // Test whether ACL owner node id is current node id, if not this ACL is inherited => disable in selector if (nodeID != NodeID) { disabledRoles.Append(role); } if (ValidationHelper.GetInteger(drAclItem["RoleGroupID"], 0) > 0) { operName += " " + GetString("security.grouprole"); } // Add global postfix if (ValidationHelper.GetInteger(drAclItem["SiteID"], 0) == 0) { operName += " " + GetString("general.global"); } break; // Operator starts with 'U' - indicates user case 'U': string user = op.Substring(1) + ";"; users.Append(user); // Test whether ACL owner node id is current node id, if not this ACL is inherited => disable in selector if (nodeID != NodeID) { disabledUsers.Append(user); } string fullName = ValidationHelper.GetString(drAclItem["OperatorFullName"], String.Empty); operName = Functions.GetFormattedUserName(operName, fullName); break; } } if (reload) { lstOperators.Items.Add(new ListItem(operName, op)); } } } } if (reload) { if (lstOperators.Items.Count > 0) { lstOperators.SelectedIndex = 0; DisplayOperatorPermissions(lstOperators.SelectedValue); } else { ResetPermissions(); DisableAllCheckBoxes(); } // Update selector values on full reload addRoles.CurrentSelector.Value = roles.ToString(); addUsers.CurrentSelector.Value = users.ToString(); } // Set values to selectors (to be able to distinguish new and old items for add/remove action) addRoles.CurrentValues = roles.ToString(); addUsers.CurrentValues = users.ToString(); DisabledRoles = disabledRoles.ToString(); DisabledUsers = disabledUsers.ToString(); } }
protected void Page_Load(object sender, EventArgs e) { string bannerCategoryCodeName = ValidationHelper.GetString(GetValue("BannerCategoryCodeName"), ""); BannerCategoryInfo bannerCategory = BannerCategoryInfoProvider.GetBannerCategoryInfoFromSiteOrGlobal(bannerCategoryCodeName, CMSContext.CurrentSiteID); if ((bannerCategory == null) || (bannerCategory.BannerCategoryEnabled == false)) { Visible = !HideIfBannerNotFound; return; } if (URLHelper.IsPostback() && KeepPreviousBannerOnPostBack && BannerIDViewState.HasValue) { bannerReused = true; banner = BannerInfoProvider.GetBannerInfo(BannerIDViewState.Value); } // If random banner should be picked or banner from viewstate was not found if (banner == null) { bannerReused = false; // Get random banner from selected category. Decrement hits left for this banner only if page is displayed on the live site. banner = BannerInfoProvider.GetRandomValidBanner(bannerCategory.BannerCategoryID, (currentViewMode == ViewModeEnum.LiveSite)); } // Exits if no banner was found if (banner == null) { Visible = !HideIfBannerNotFound; return; } // Store banner id in the viewstate if the same banner should be used if request is postback if (KeepPreviousBannerOnPostBack) { BannerIDViewState = banner.BannerID; } string width = ValidationHelper.GetString(GetValue("Width"), ""); string height = ValidationHelper.GetString(GetValue("Height"), ""); string anchorClass = ValidationHelper.GetString(GetValue("AnchorClass"), ""); bool fakeLink = ValidationHelper.GetBoolean(GetValue("FakeLink"), true); if (width != "") { lnkBanner.Style["width"] = width; } if (height != "") { lnkBanner.Style["height"] = height; } lnkBanner.CssClass = string.Format("CMSBanner {0}", anchorClass).Trim(); lnkBanner.Visible = true; // Do not set link if we are not on the live site. if ((currentViewMode == ViewModeEnum.LiveSite) || (currentViewMode == ViewModeEnum.Preview)) { // Link pointing to our custum handler which logs click and redirects string bannerRedirectURL = string.Format( "{0}?bannerID={1}&redirectURL={2}", URLHelper.ResolveUrl("~/CMSModules/BannerManagement/CMSPages/BannerRedirect.ashx"), banner.BannerID, HttpUtility.UrlEncode(URLHelper.ResolveUrl(banner.BannerURL)) ); if (fakeLink) { // Defaultly href attribute will be set to 'nice' URL lnkBanner.Attributes.Add("href", URLHelper.ResolveUrl(banner.BannerURL)); // After clicking href will be set to URL pointing to custom handler which counts clicks lnkBanner.Attributes.Add("onclick", string.Format("this.href='{0}';", bannerRedirectURL)); // GECKO doesn't count middle mouse click as click, so onmouseup (or down) needs to be added lnkBanner.Attributes.Add("onmouseup", string.Format("this.href='{0}';", bannerRedirectURL)); } else { // If faking links is disabled, set href to redirect url lnkBanner.Attributes.Add("href", bannerRedirectURL); } // Add target="_blank" attribute if link should be opened in new window if (banner.BannerBlank) { lnkBanner.Target = "_blank"; } } if (banner.BannerType == BannerTypeEnum.Image) { BannerImageAttributes bannerImageAttributes = BannerManagementHelper.DeserializeBannerImageAttributes(banner.BannerContent); imgBanner.AlternateText = bannerImageAttributes.Alt; imgBanner.ToolTip = bannerImageAttributes.Title; imgBanner.CssClass = bannerImageAttributes.Class; imgBanner.Style.Value = HTMLHelper.HTMLEncode(bannerImageAttributes.Style); imgBanner.ImageUrl = URLHelper.ResolveUrl(bannerImageAttributes.Src); imgBanner.Visible = true; ltrBanner.Visible = false; } else { string text = CMSContext.ResolveMacros(banner.BannerContent); ltrBanner.Text = HTMLHelper.ResolveUrls(text, null, false); imgBanner.Visible = false; ltrBanner.Visible = true; if (banner.BannerType == BannerTypeEnum.HTML) { ControlsHelper.ResolveDynamicControls(this); } } }
/// <summary> /// Generates panel with buttons loaded from given UI Element. /// </summary> /// <param name="uiElementId">ID of the UI Element</param> protected Panel GetButtons(int uiElementId) { const int bigButtonMinimalWidth = 40; const int smallButtonMinimalWidth = 66; Panel pnlButtons = null; // Load the buttons manually from UI Element DataSet ds = UIElementInfoProvider.GetChildUIElements(uiElementId); // When no child found if (DataHelper.DataSourceIsEmpty(ds)) { // Try to use group element as button ds = UIElementInfoProvider.GetUIElements("ElementID = " + uiElementId, null); if (!DataHelper.DataSourceIsEmpty(ds)) { DataRow dr = ds.Tables[0].Rows[0]; string url = ValidationHelper.GetString(dr["ElementTargetURL"], ""); // Use group element as button only if it has URL specified if (string.IsNullOrEmpty(url)) { ds = null; } } } if (!DataHelper.DataSourceIsEmpty(ds)) { // Filter the dataset according to UI Profile FilterElements(ds); int small = 0; int count = ds.Tables[0].Rows.Count; // No buttons, render nothing if (count == 0) { return(null); } // Prepare the panel pnlButtons = new Panel(); pnlButtons.CssClass = "ActionButtons"; // Prepare the table Table tabGroup = new Table(); TableRow tabGroupRow = new TableRow(); tabGroup.CellPadding = 0; tabGroup.CellSpacing = 0; tabGroup.EnableViewState = false; tabGroupRow.EnableViewState = false; tabGroup.Rows.Add(tabGroupRow); List <Panel> panels = new List <Panel>(); for (int i = 0; i < count; i++) { // Get current and next button UIElementInfo uiElement = new UIElementInfo(ds.Tables[0].Rows[i]); UIElementInfo uiElementNext = null; if (i < count - 1) { uiElementNext = new UIElementInfo(ds.Tables[0].Rows[i + 1]); } // Set the first button if (mFirstUIElement == null) { mFirstUIElement = uiElement; } // Get the sizes of current and next button. Button is large when it is the only in the group bool isSmall = (uiElement.ElementSize == UIElementSizeEnum.Regular) && (count > 1); bool isResized = (uiElement.ElementSize == UIElementSizeEnum.Regular) && (!isSmall); bool isNextSmall = (uiElementNext != null) && (uiElementNext.ElementSize == UIElementSizeEnum.Regular); // Set the CSS class according to the button size string cssClass = (isSmall ? "SmallButton" : "BigButton"); string elementName = uiElement.ElementName; // Create main button panel CMSPanel pnlButton = new CMSPanel() { ID = "pnlButton" + elementName, ShortID = "b" + elementName }; pnlButton.Attributes.Add("name", elementName); pnlButton.CssClass = cssClass; // Remember the first button if (firstPanel == null) { firstPanel = pnlButton; } // Remember the selected button if ((preselectedPanel == null) && elementName.Equals(HighlightItem, StringComparison.InvariantCultureIgnoreCase)) { preselectedPanel = pnlButton; // Set the selected button if (mHighlightedUIElement == null) { mHighlightedUIElement = uiElement; } } // URL or behavior string url = uiElement.ElementTargetURL; if (!string.IsNullOrEmpty(url) && url.StartsWith("javascript:", StringComparison.InvariantCultureIgnoreCase)) { pnlButton.Attributes["onclick"] = url.Substring("javascript:".Length); } else if (!string.IsNullOrEmpty(url) && !url.StartsWith("javascript:", StringComparison.InvariantCultureIgnoreCase)) { string buttonSelection = (RememberSelectedItem ? "SelectButton(this);" : ""); // Ensure hash code if required string targetUrl = CMSContext.ResolveMacros(URLHelper.EnsureHashToQueryParameters(url)); if (!String.IsNullOrEmpty(TargetFrameset)) { pnlButton.Attributes["onclick"] = String.Format("{0}parent.frames['{1}'].location.href = '{2}';", buttonSelection, TargetFrameset, URLHelper.ResolveUrl(targetUrl)); } else { pnlButton.Attributes["onclick"] = String.Format("{0}self.location.href = '{1}';", buttonSelection, URLHelper.ResolveUrl(targetUrl)); } if (OnButtonCreated != null) { OnButtonCreated(uiElement, targetUrl); } } // Tooltip if (!string.IsNullOrEmpty(uiElement.ElementDescription)) { pnlButton.ToolTip = ResHelper.LocalizeString(uiElement.ElementDescription); } else { pnlButton.ToolTip = ResHelper.LocalizeString(uiElement.ElementCaption); } pnlButton.EnableViewState = false; // Ensure correct grouping of small buttons if (isSmall && (small == 0)) { small++; Panel pnlSmallGroup = new Panel() { ID = "pnlGroupSmall" + uiElement.ElementName }; if (IsRTL) { pnlSmallGroup.Style.Add("float", "right"); pnlSmallGroup.Style.Add("text-align", "right"); } else { pnlSmallGroup.Style.Add("float", "left"); pnlSmallGroup.Style.Add("text-align", "left"); } pnlSmallGroup.EnableViewState = false; pnlSmallGroup.Controls.Add(pnlButton); panels.Add(pnlSmallGroup); } // Generate button image Image buttonImage = new Image() { ID = "imgButton" + uiElement.ElementName, ImageAlign = (isSmall ? ImageAlign.AbsMiddle : ImageAlign.Top) }; if (!string.IsNullOrEmpty(uiElement.ElementIconPath)) { string iconPath = GetImageUrl(uiElement.ElementIconPath); // Check if element size was changed if (isResized) { // Try to get larger icon string largeIconPath = iconPath.Replace("list.png", "module.png"); try { if (CMS.IO.File.Exists(MapPath(largeIconPath))) { iconPath = largeIconPath; } } catch { } } buttonImage.ImageUrl = iconPath; } else { // Load defaul module icon if ElementIconPath is not specified buttonImage.ImageUrl = GetImageUrl("CMSModules/module.png"); } buttonImage.EnableViewState = false; // Generate button text Literal captionLiteral = new Literal() { ID = "ltlCaption" + uiElement.ElementName, Text = (isSmall ? "\n" : "<br />") + ResHelper.LocalizeString(uiElement.ElementCaption), EnableViewState = false }; // Generate button link HyperLink buttonLink = new HyperLink() { ID = "lnkButton" + uiElement.ElementName }; buttonLink.Controls.Add(buttonImage); buttonLink.Controls.Add(captionLiteral); buttonLink.EnableViewState = false; //Generate button table (IE7 issue) Table tabButton = new Table(); TableRow tabRow = new TableRow(); TableCell tabCellLeft = new TableCell(); TableCell tabCellMiddle = new TableCell(); TableCell tabCellRight = new TableCell(); tabButton.CellPadding = 0; tabButton.CellSpacing = 0; tabButton.EnableViewState = false; tabRow.EnableViewState = false; tabCellLeft.EnableViewState = false; tabCellMiddle.EnableViewState = false; tabCellRight.EnableViewState = false; tabButton.Rows.Add(tabRow); tabRow.Cells.Add(tabCellLeft); tabRow.Cells.Add(tabCellMiddle); tabRow.Cells.Add(tabCellRight); // Generate left border Panel pnlLeft = new Panel() { ID = "pnlLeft" + uiElement.ElementName, CssClass = "Left" + cssClass, EnableViewState = false }; // Generate middle part of button Panel pnlMiddle = new Panel() { ID = "pnlMiddle" + uiElement.ElementName, CssClass = "Middle" + cssClass }; pnlMiddle.Controls.Add(buttonLink); Panel pnlMiddleTmp = new Panel() { EnableViewState = false }; if (isSmall) { pnlMiddle.Style.Add("min-width", smallButtonMinimalWidth + "px"); // IE7 issue with min-width pnlMiddleTmp.Style.Add("width", smallButtonMinimalWidth + "px"); pnlMiddle.Controls.Add(pnlMiddleTmp); } else { pnlMiddle.Style.Add("min-width", bigButtonMinimalWidth + "px"); // IE7 issue with min-width pnlMiddleTmp.Style.Add("width", bigButtonMinimalWidth + "px"); pnlMiddle.Controls.Add(pnlMiddleTmp); } pnlMiddle.EnableViewState = false; // Generate right border Panel pnlRight = new Panel() { ID = "pnlRight" + uiElement.ElementName, CssClass = "Right" + cssClass, EnableViewState = false }; // Add inner controls tabCellLeft.Controls.Add(pnlLeft); tabCellMiddle.Controls.Add(pnlMiddle); tabCellRight.Controls.Add(pnlRight); pnlButton.Controls.Add(tabButton); // If there were two small buttons in a row end the grouping div if ((small == 2) || (isSmall && !isNextSmall)) { small = 0; // Add the button to the small buttons grouping panel panels[panels.Count - 1].Controls.Add(pnlButton); } else { if (small == 0) { // Add the generated button into collection panels.Add(pnlButton); } } if (small == 1) { small++; } } // Add all panels to control foreach (Panel panel in panels) { TableCell tabGroupCell = new TableCell() { VerticalAlign = VerticalAlign.Top, EnableViewState = false }; tabGroupCell.Controls.Add(panel); tabGroupRow.Cells.Add(tabGroupCell); } pnlButtons.Controls.Add(tabGroup); } return(pnlButtons); }
/// <summary> /// Retrieves the specified resources and wraps them in an data container. /// </summary> /// <param name="settings">CSS settings</param> /// <param name="name">Resource name</param> /// <param name="cached">If true, the result will be cached</param> /// <returns>The data container with the resulting stylesheet data</returns> private static CMSOutputResource GetResource(CMSCssSettings settings, string name, bool cached) { List <CMSOutputResource> resources = new List <CMSOutputResource>(); // Add files if (settings.Files != null) { foreach (string item in settings.Files) { // Get the resource CMSOutputResource resource = GetFile(item, CSS_FILE_EXTENSION); resources.Add(resource); } } // Add stylesheets if (settings.Stylesheets != null) { foreach (string item in settings.Stylesheets) { // Get the resource CMSOutputResource resource = GetStylesheet(item); resources.Add(resource); } } // Add web part containers if (settings.Containers != null) { foreach (string item in settings.Containers) { // Get the resource CMSOutputResource resource = GetContainer(item); resources.Add(resource); } } // Add web parts if (settings.WebParts != null) { foreach (string item in settings.WebParts) { // Get the resource CMSOutputResource resource = GetWebPart(item); resources.Add(resource); } } // Add templates if (settings.Templates != null) { foreach (string item in settings.Templates) { // Get the resource CMSOutputResource resource = GetTemplate(item); resources.Add(resource); } } // Add layouts if (settings.Layouts != null) { foreach (string item in settings.Layouts) { // Get the resource CMSOutputResource resource = GetLayout(item); resources.Add(resource); } } // Add transformation containers if (settings.Transformations != null) { foreach (string item in settings.Transformations) { // Get the resource CMSOutputResource resource = GetTransformation(item); resources.Add(resource); } } // Add web part layouts if (settings.WebPartLayouts != null) { foreach (string item in settings.WebPartLayouts) { // Get the resource CMSOutputResource resource = GetWebPartLayout(item); resources.Add(resource); } } // Combine to a single output CMSOutputResource result = CombineResources(resources); // Resolve the macros if (CSSHelper.ResolveMacrosInCSS) { MacroContext context = new MacroContext() { TrackCacheDependencies = cached }; if (cached) { // Add the default dependencies context.AddCacheDependencies(settings.GetCacheDependencies()); context.AddFileCacheDependencies(settings.GetFileCacheDependencies()); } result.Data = CMSContext.ResolveMacros(result.Data, context); if (cached) { // Add cache dependency result.CacheDependency = CacheHelper.GetCacheDependency(context.FileCacheDependencies, context.CacheDependencies); } } else if (cached) { // Only the cache dependency from settings result.CacheDependency = settings.GetCacheDependency(); } // Minify MinifyResource(result, mCssMinifier, CSSHelper.StylesheetMinificationEnabled && settings.EnableMinification, settings.EnableMinification); return(result); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> protected void Page_Load(object sender, EventArgs e) { // Do not process control by default StopProcessing = true; // Keep frequent objects cui = CMSContext.CurrentUser; PageInfo pi = CMSContext.CurrentPageInfo; if (pi == null) { IsPageNotFound = true; pi = OnSiteEditHelper.PageInfoForPageNotFound; } ucUIToolbar.StopProcessing = true; largeCMSDeskButton = !cui.UserSiteManagerAdmin; // Check whether user is authorized to edit page if ((pi != null) && cui.IsAuthenticated() && cui.IsEditor && ((IsPageNotFound && pi.NodeID == 0) || cui.IsAuthorizedPerTreeNode(pi.NodeID, NodePermissionsEnum.Read) == AuthorizationResultEnum.Allowed)) { // Enable processing StopProcessing = false; // Check whether the preferred culture is RTL isRTL = CultureHelper.IsUICultureRTL(); // Add link to CSS file CSSHelper.RegisterCSSLink(Page, "Design", "OnSiteEdit.css"); // Filter UI element buttons ucUIToolbar.OnButtonFiltered += ucUIToolbar_OnButtonFiltered; ucUIToolbar.OnButtonCreated += ucUIToolbar_OnButtonCreated; ucUIToolbar.OnButtonCreating += ucUIToolbar_OnButtonCreating; ucUIToolbar.OnGroupsCreated += ucUIToolbar_OnGroupsCreated; ucUIToolbar.IsRTL = isRTL; // Register edit script file RegisterEditScripts(pi); if (ViewMode == ViewModeEnum.EditLive) { popupHandler.Visible = true; IsLiveSite = false; MessagesPlaceHolder.IsLiveSite = false; MessagesPlaceHolder.Opacity = 100; // Display warning in the Safe mode if (PortalHelper.SafeMode) { string safeModeText = GetString("onsiteedit.safemode") + "<br/><a href=\"" + URLHelper.RawUrl.Replace("safemode=1", "safemode=0") + "\">" + GetString("general.close") + "</a> " + GetString("contentedit.safemode2"); string safeModeDescription = GetString("onsiteedit.safemode") + "<br/>" + GetString("general.seeeventlog"); // Display the warning message ShowWarning(safeModeText, safeModeDescription, ""); } ucUIToolbar.StopProcessing = false; // Ensure document redirection if (!String.IsNullOrEmpty(pi.DocumentMenuRedirectUrl)) { string redirectUrl = CMSContext.ResolveMacros(pi.DocumentMenuRedirectUrl); redirectUrl = URLHelper.ResolveUrl(redirectUrl); ShowInformation(GetString("onsiteedit.redirectinfo") + " <a href=\"" + redirectUrl + "\">" + redirectUrl + "</a>"); } } // Mode menu on live site else if (ViewMode == ViewModeEnum.LiveSite) { // Hide the edit panel, show only slider button pnlToolbarSpace.Visible = false; pnlToolbar.Visible = false; pnlSlider.Visible = true; imgSliderButton.ImageUrl = GetImageUrl("CMSModules/CMS_PortalEngine/OnSiteEdit/edit.png"); imgSliderButton.ToolTip = GetString("onsiteedit.editmode"); imgSliderButton.AlternateText = GetString("onsitedit.editmode"); pnlButton.Attributes.Add("onclick", "OnSiteEdit_ChangeEditMode();"); imgMaximize.Style.Add("display", "none"); imgMaximize.AlternateText = GetString("general.maximize"); imgMaximize.ImageUrl = GetImageUrl("CMSModules/CMS_PortalEngine/OnSiteEdit/ArrowDown.png"); imgMinimize.ImageUrl = GetImageUrl("CMSModules/CMS_PortalEngine/OnSiteEdit/ArrowUp.png"); imgMinimize.AlternateText = GetString("general.minimize"); pnlMinimize.Attributes.Add("onclick", "OESlideSideToolbar();"); // Hide the OnSite edit button when displayed in CMSDesk pnlSlider.Style.Add("display", "none"); } } // Hide control actions for unauthorized users else { plcEdit.Visible = false; } }
object Grid_OnExternalDataBound(object sender, string sourceName, object parameter) { string name = sourceName.ToLowerCSafe(); switch (name) { case "chatmessageauthor": { DataRowView row = (DataRowView)parameter; if (row["AuthorNickname"] == DBNull.Value) { return("<span style=\"color: #777777; font-style: italic;\">" + GetString("chat.system") + "</span>"); } int chatUserID = ValidationHelper.GetInteger(row["ChatMessageUserID"], 0); string nickname = ValidationHelper.GetString(row["AuthorNickname"], "AuthorNickname"); bool isAnonymous = ValidationHelper.GetBoolean(row["AuthorIsAnonymous"], true); return(ChatHelper.GetCMSDeskChatUserField(this, chatUserID, nickname, isAnonymous)); } case "edit": case "reject": case "delete": { DataRowView row = (DataRowView)((GridViewRow)parameter).DataItem; // Whisper message is consider as system here - it can't be rejected or edited ChatMessageTypeEnum msgType = (ChatMessageTypeEnum)ValidationHelper.GetInteger(row["ChatMessageSystemMessageType"], 0); bool isSystem = ((msgType != ChatMessageTypeEnum.ClassicMessage) && (msgType != ChatMessageTypeEnum.Announcement)); bool enabled = true; string iconName = ""; string toolTipResourceString = null; if (name == "edit") { iconName = "Edit"; } else if (name == "reject") { iconName = "Reject"; } else if (name == "delete") { iconName = "Delete"; } if (isSystem) { if (name == "edit" || name == "reject") { // Disable edit and reject buttons for system messages enabled = false; } } else { if (name == "reject") { bool isRejected = ValidationHelper.GetBoolean(row["ChatMessageRejected"], false); if (isRejected) { iconName = "Approve"; toolTipResourceString = "general.approve"; } else { iconName = "Reject"; toolTipResourceString = "general.reject"; } } } if (!HasUserModifyPermission && name != "edit") { enabled = false; } ImageButton actionButton = (ImageButton)sender; if (!enabled) { iconName += "disabled"; } actionButton.Enabled = enabled; actionButton.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/" + iconName + ".png"); if (toolTipResourceString != null) { actionButton.ToolTip = GetString(toolTipResourceString); } break; } case "chatmessagesystemmessagetype": { DataRowView row = (DataRowView)parameter; ChatMessageTypeEnum messageType = (ChatMessageTypeEnum)ValidationHelper.GetInteger(row["ChatMessageSystemMessageType"], 0); if (messageType == ChatMessageTypeEnum.Whisper) { ChatUserInfo recipient = ChatUserInfoProvider.GetChatUserInfo(ValidationHelper.GetInteger(row["ChatMessageRecipientID"], 0)); if (recipient != null) { // Set text to the format "Whisper to somebody", where somebody may be link to the user if he is not anonymous return(string.Format(ResHelper.GetString("chat.system.cmsdesk.whisperto"), ChatHelper.GetCMSDeskChatUserField(this, recipient))); } } return(messageType.ToStringValue((int)ChatMessageTypeStringValueUsageEnum.CMSDeskDescription)); } case "chatmessagetext": { DataRowView row = (DataRowView)parameter; ChatMessageTypeEnum messageType = (ChatMessageTypeEnum)ValidationHelper.GetInteger(row["ChatMessageSystemMessageType"], 0); string messageText = ValidationHelper.GetString(row["ChatMessageText"], ""); if (messageType.IsSystemMessage()) { messageText = CMSContext.ResolveMacros(messageText); } return(HTMLHelper.HTMLEncode(messageText)); } } return(parameter); }
/// <summary> /// Sets time controls (dropdown with interval and textbox with interval value). Returns true if time controls are to be hided. /// </summary> private bool SetTimeControls() { HitsIntervalEnum interval = HitsIntervalEnumFunctions.StringToHitsConversion(intervalStr); DateTime from = DateTimeHelper.ZERO_TIME; DateTime to = DateTimeHelper.ZERO_TIME; DataColumn dcFrom = null; DataColumn dcTo = null; if (drParameters != null) { // Load fromdate and todate from report parameters (passed from query string) dcFrom = drParameters.Table.Columns["FromDate"]; dcTo = drParameters.Table.Columns["ToDate"]; if (dcFrom != null) { from = ValidationHelper.GetDateTime(drParameters["FromDate"], DateTimeHelper.ZERO_TIME); } if (dcTo != null) { to = ValidationHelper.GetDateTime(drParameters["ToDate"], DateTimeHelper.ZERO_TIME); } } // If one contains zero time, set all time radio button. In such situation, report can maintain unlimited fromdate or todate. if ((from == DateTimeHelper.ZERO_TIME) || (to == DateTimeHelper.ZERO_TIME)) { checkLast = false; } // If one is not set, hide limitdata panel if ((dcFrom == null) || (dcTo == null)) { ucInterval.DefaultPeriod = SchedulingHelper.PERIOD_DAY; return(true); } int diff = 0; bool noAddToDiff = false; // If interval is not known, but 'from' and 'to' is set (f.e. preview, webpart,..) - compute interval from date values if (interval == HitsIntervalEnum.None) { String sFrom = ValidationHelper.GetString(drParameters["FromDate"], String.Empty).ToLowerCSafe(); String sTo = ValidationHelper.GetString(drParameters["ToDate"], String.Empty).ToLowerCSafe(); checkLast = true; if (ValidationHelper.IsMacro(sFrom) && ValidationHelper.IsMacro(sTo)) { if (sFrom.Contains("addhours")) { interval = HitsIntervalEnum.Hour; } else if (sFrom.Contains("adddays")) { interval = HitsIntervalEnum.Day; } else if (sFrom.Contains("addweeks")) { interval = HitsIntervalEnum.Week; } else if (sFrom.Contains("addmonths")) { interval = HitsIntervalEnum.Month; } else if (sFrom.Contains("addyears")) { interval = HitsIntervalEnum.Year; } to = DateTime.Now; from = ValidationHelper.GetDateTime(CMSContext.ResolveMacros(sFrom), DateTime.Now); noAddToDiff = true; } else if ((from != DateTimeHelper.ZERO_TIME) && (to != DateTimeHelper.ZERO_TIME)) { // Set interval as greatest possible interval (365+ days -> years, 30+days->months ,...) diff = (int)(to - from).TotalDays; if (diff >= 365) { interval = HitsIntervalEnum.Year; } else if (diff >= 30) { interval = HitsIntervalEnum.Month; } else if (diff >= 7) { interval = HitsIntervalEnum.Week; } else if (diff >= 1) { interval = HitsIntervalEnum.Day; } else { interval = HitsIntervalEnum.Hour; } } } // Set default period and diff based on interval switch (interval) { case HitsIntervalEnum.Year: diff = to.Year - from.Year; ucInterval.DefaultPeriod = SchedulingHelper.PERIOD_MONTH; break; case HitsIntervalEnum.Month: diff = ((to.Year - from.Year) * 12) + to.Month - from.Month; ucInterval.DefaultPeriod = SchedulingHelper.PERIOD_MONTH; break; case HitsIntervalEnum.Week: diff = (int)(to - from).TotalDays / 7; ucInterval.DefaultPeriod = SchedulingHelper.PERIOD_WEEK; break; case HitsIntervalEnum.Day: diff = (int)(to - from).TotalDays; ucInterval.DefaultPeriod = SchedulingHelper.PERIOD_DAY; break; case HitsIntervalEnum.Hour: diff = (int)(to - from).TotalHours; ucInterval.DefaultPeriod = SchedulingHelper.PERIOD_HOUR; break; case HitsIntervalEnum.None: checkLast = false; break; } // Add current if (!noAddToDiff) { diff++; } if (interval != HitsIntervalEnum.None) { drpLast.SelectedValue = HitsIntervalEnumFunctions.HitsConversionToString(interval); } if (!checkLast) { // Defaul settings for no time ucInterval.DefaultPeriod = SchedulingHelper.PERIOD_DAY; } if (diff != 0) { txtLast.Text = diff.ToString(); } return(false); }
/// <summary> /// Reloads the control data. /// </summary> /// <param name="forceReload">Force the reload of the control</param> public override void ReloadData(bool forceReload) { if (StopProcessing) { plcPager.Visible = false; ltlBeforeRows.Visible = false; } else { base.ReloadData(forceReload); SetPageSize(forceReload); // Clear filter if forced reload if (forceReload) { this.txtFilter.Text = ""; this.FilterWhere = null; } if (forceReload || (!mLoaded && !this.StopProcessing)) { StringBuilder sb = new StringBuilder(); // Prepare the order by string orderBy = this.OrderBy; if (orderBy == null) { orderBy = this.RowItemDisplayNameColumn + " ASC"; // Add additional sorting by codename for equal displaynames if (!String.IsNullOrEmpty(this.RowItemCodeNameColumn)) { orderBy += ", " + this.RowItemCodeNameColumn; } if (this.ColumnsCount > 1) { orderBy += ", " + this.ColumnItemDisplayNameColumn + " ASC"; } } int currentPage = pagerElem.UniPager.CurrentPage; string where = SqlHelperClass.AddWhereCondition(this.WhereCondition, this.FilterWhere); bool headersOnly = false; bool hasData = false; mTotalRows = 0; ArrayList columns = null; // Load the data while (true) { // Get specific page int pageItems = this.ColumnsCount * this.pagerElem.UniPager.PageSize; ds = ConnectionHelper.ExecuteQuery(this.QueryName, this.QueryParameters, where, orderBy, 0, null, (currentPage - 1) * pageItems, pageItems, ref mTotalRows); hasData = !DataHelper.DataSourceIsEmpty(ds); // If no records found, get the records for the original dataset if (!hasData && !String.IsNullOrEmpty(FilterWhere)) { // Get only first line ds = ConnectionHelper.ExecuteQuery(this.QueryName, this.QueryParameters, this.WhereCondition, orderBy, this.ColumnsCount); hasData = !DataHelper.DataSourceIsEmpty(ds); headersOnly = true; } // Load the list of columns if (hasData) { if (DataLoaded != null) { DataLoaded(ds); } columns = DataHelper.GetUniqueRows(ds.Tables[0], this.ColumnItemIDColumn); ColumnOrderIndex = GetColumnIndexes(columns, ColumnsPreferedOrder); // If more than current columns count found, and there is more data, get the correct data again if ((columns.Count <= this.ColumnsCount) || (mTotalRows < pageItems)) { break; } else { this.ColumnsCount = columns.Count; } } else { break; } } if (hasData) { bool manyColumns = columns.Count >= 10; string imagesUrl = GetImageUrl("Design/Controls/UniMatrix/", IsLiveSite, true); string firstColumnsWidth = (FirstColumnsWidth > 0) ? "width:" + this.FirstColumnsWidth + (UsePercentage ? "%;" : "px;") : ""; if (!headersOnly) { // Register the scripts string script = "var umImagesUrl = '" + GetImageUrl("Design/Controls/UniMatrix/", IsLiveSite, true) + "';" + "function UM_ItemChanged_" + this.ClientID + "(item) {" + this.Page.ClientScript.GetCallbackEventReference(this, "item.id + ':' + (item.src.indexOf('denied.png') >= 0)", "UM_ItemSaved_" + this.ClientID, "item.id") + "; } \n" + "function UM_ItemSaved_" + this.ClientID + "(rvalue, context) { var elem = document.getElementById(context); var values=rvalue.split('|'); \nif (values[0] == 'true') { elem.src = umImagesUrl + 'allowed.png'; } else { elem.src = umImagesUrl + 'denied.png'; } var contentBefore = $j(\"#contentbeforerows_" + ClientID + "\"); if(contentBefore){ contentBefore.empty().append(values[1]);}}"; ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "UniMatrix_" + this.ClientID, ScriptHelper.GetScript(script)); } // Render header this.ltlBeforeFilter.Text = "<tr class=\"UniGridHead\" align=\"left\"><th style=\"" + firstColumnsWidth + "white-space:nowrap;\" scope=\"col\"><div class=\"UniMatrixFilter\">"; StringBuilder headersb = new StringBuilder(); headersb.Append("</div></th>"); string width = (FixedWidth > 0) ? "width:" + FixedWidth.ToString() + (UsePercentage ? "%;" : "px;") : ""; // Render matrix header foreach (int index in ColumnOrderIndex) { DataRow dr = (DataRow)columns[index]; if (this.ShowHeaderRow) { string header = HTMLHelper.HTMLEncode(CMSContext.ResolveMacros(Convert.ToString(dr[this.ColumnItemDisplayNameColumn]))); headersb.Append("<th scope=\"col\" style=\"text-align: center;"); if (!manyColumns) { headersb.Append(" white-space: nowrap;"); header = header.Replace(" ", " ").Replace("-", "−"); } else { headersb.Append(" padding: 2px 7px 2px 5px;"); } headersb.Append(" " + width + "\""); if (this.ColumnItemTooltipColumn != null) { headersb.Append(" title=\"", GetTooltip(dr, this.ItemTooltipColumn), "\""); } // Disabled mark object columnValue = dr[this.ColumnItemIDColumn]; if (!IsColumnEditable(columnValue)) { header += DisabledColumnMark; } headersb.Append(">", header, "</th>\n"); } else { headersb.Append("<th scope=\"col\" style=\"text-align: center; ", width, "\"> </td>"); } } // Set the correct number of columns this.ColumnsCount = columns.Count; mTotalRows = mTotalRows / this.ColumnsCount; if (!manyColumns) { headersb.Append("<th ", (LastColumnFullWidth ? "style=\"width:100%;\" " : ""), "> </th>"); } headersb.Append("</tr>"); ltlAfterFilter.Text = headersb.ToString(); if (!headersOnly) { string lastId = ""; int colIndex = 0; int rowIndex = 0; bool evenRow = true; // Render matrix rows int step = columns.Count; for (int i = 0; i < ds.Tables[0].Rows.Count; i = i + step) { foreach (int index in ColumnOrderIndex) { DataRow dr = (DataRow)ds.Tables[0].Rows[i + index]; string id = ValidationHelper.GetString(dr[this.RowItemIDColumn], ""); if (id != lastId) { if ((ItemsPerPage > 0) && (rowIndex++ >= this.ItemsPerPage)) { break; } // New row if (lastId != "") { // Close the previous row if (!manyColumns) { sb.Append("<td style=\"white-space:nowrap;\"> </td>"); } sb.Append("</tr>"); } sb.Append("<tr class=\"", (evenRow ? "EvenRow" : "OddRow"), GetAdditionalCssClass(dr), "\"><td class=\"MatrixHeader\" style=\"", firstColumnsWidth, "white-space:nowrap;\""); if (this.RowItemTooltipColumn != null) { sb.Append(" title=\"", GetTooltip(dr, this.RowItemTooltipColumn), "\""); } sb.Append(">"); sb.Append(HTMLHelper.HTMLEncode(CMSContext.ResolveMacros(Convert.ToString(dr[this.RowItemDisplayNameColumn])))); // Disabled mark if (!IsRowEditable(id)) { sb.Append(DisabledRowMark); } // Add global suffix if is required if ((index == 0) && (this.AddGlobalObjectSuffix) && (ValidationHelper.GetInteger(dr[this.SiteIDColumnName], 0) == 0)) { sb.Append(" " + GetString("general.global")); } sb.Append("</td>\n"); lastId = id; colIndex = 0; evenRow = !evenRow; } object columnValue = dr[this.ColumnItemIDColumn]; // Render cell sb.Append("<td style=\"white-space:nowrap; text-align: center;\"><img src=\""); sb.Append(imagesUrl); if (!this.Enabled || disabledColumns.Contains(colIndex) || !IsColumnEditable(columnValue) || !IsRowEditable(id) ) { // Disabled if (Convert.ToInt32(dr["Allowed"]) == 1) { sb.Append("alloweddisabled.png"); } else { sb.Append("denieddisabled.png"); } } else { // Enabled if (Convert.ToInt32(dr["Allowed"]) == 1) { sb.Append("allowed.png"); } else { sb.Append("denied.png"); } sb.Append("\" id=\"chk:", id, ":", columnValue, "\" onclick=\"UM_ItemChanged_", this.ClientID, "(this);"); } sb.Append("\" style=\"cursor:pointer;\" title=\""); string tooltip = GetTooltip(dr, this.ItemTooltipColumn); sb.Append(tooltip, "\" alt=\"", tooltip, "\" /></td>\n"); colIndex++; } } // Close the latest row if present if (!manyColumns) { sb.Append("<td> </td>"); } sb.Append("</tr>"); int totalCols = (columns.Count + 2); if (manyColumns) { totalCols--; } this.ltlPagerBefore.Text = "<tr style=\"border:0px none;\"><td style=\"border:0px none;\" colspan=\"" + totalCols + "\">"; this.ltlPagerAfter.Text = "</td></tr>"; } else { lblInfoAfter.Text = this.NoRecordsMessage; lblInfoAfter.Visible = true; } // Show filter / header bool hideFilter = ((this.FilterLimit > 0) && String.IsNullOrEmpty(FilterWhere) && (mTotalRows < this.FilterLimit)); this.pnlFilter.Visible = !hideFilter; // Show label in corner if text given and filter is hidden if (hideFilter && !string.IsNullOrEmpty(this.CornerText)) { this.ltlBeforeFilter.Text += HTMLHelper.HTMLEncode(this.CornerText); } if (this.ShowFilterRow && !hideFilter) { //this.lblFilter.ResourceString = this.ResourcePrefix + ".entersearch"; this.btnFilter.ResourceString = "general.search"; } else if (!ShowHeaderRow) { this.plcFilter.Visible = false; } } else { pnlFilter.Visible = false; // If norecords message set, hide everything and show message if (!String.IsNullOrEmpty(this.NoRecordsMessage)) { lblInfo.Text = this.NoRecordsMessage; lblInfo.Visible = true; ltlMatrix.Visible = false; ltlContentAfter.Visible = false; ltlContentBefore.Visible = false; } } HasData = hasData; this.ltlContentBefore.Text = this.ContentBefore; this.ltlMatrix.Text = sb.ToString(); this.ltlContentAfter.Text = this.ContentAfter; // Show content before rows and pager this.plcBeforeRows.Visible = ShowContentBeforeRows && hasData && !headersOnly; this.plcPager.Visible = hasData && !headersOnly; if (hasData) { // Set correct ID for direct page contol this.pagerElem.DirectPageControlID = ((float)mTotalRows / pagerElem.CurrentPageSize > 20.0f) ? "txtPage" : "drpPage"; } mLoaded = true; // Call page binding event if (OnPageBinding != null) { OnPageBinding(this, null); } } } }
protected void Page_Load(object sender, EventArgs e) { CurrentUserInfo currentUser = CMSContext.CurrentUser; // Fill the menu with UIElement data for specified module if (!String.IsNullOrEmpty(ModuleName) & (currentUser != null)) { DataSet dsModules = UIElementInfoProvider.GetUIMenuElements(ModuleName); List <object[]> categoriesTmp = new List <object[]>(); if (!DataHelper.DataSourceIsEmpty(dsModules)) { foreach (DataRow drModule in dsModules.Tables[0].Rows) { UIElementInfo moduleElement = new UIElementInfo(drModule); // Proceed if user has permissions for this UI element if (currentUser.IsAuthorizedPerUIElement(ModuleName, moduleElement.ElementName)) { // Category title string categoryTitle = ResHelper.LocalizeString(moduleElement.ElementDisplayName); // Category name string categoryName = ResHelper.LocalizeString(moduleElement.ElementName); // Category URL string categoryUrl = CMSContext.ResolveMacros(URLHelper.EnsureHashToQueryParameters(moduleElement.ElementTargetURL)); // Category image URL string categoryImageUrl = GetImagePath(moduleElement.ElementIconPath.Replace("list.png", "module.png")); if (!FileHelper.FileExists(categoryImageUrl)) { categoryImageUrl = GetImagePath("CMSModules/module.png"); } categoryImageUrl = UIHelper.ResolveImageUrl(categoryImageUrl); // Category tooltip string categoryTooltip = ResHelper.LocalizeString(moduleElement.ElementDescription); // Category actions DataSet dsActions = UIElementInfoProvider.GetChildUIElements(moduleElement.ElementID); List <string[]> actionsTmp = new List <string[]>(); foreach (DataRow drAction in dsActions.Tables[0].Rows) { UIElementInfo actionElement = new UIElementInfo(drAction); // Proceed if user has permissions for this UI element if (currentUser.IsAuthorizedPerUIElement(ModuleName, actionElement.ElementName)) { actionsTmp.Add(new string[] { ResHelper.LocalizeString(actionElement.ElementDisplayName), CMSContext.ResolveMacros(URLHelper.EnsureHashToQueryParameters(actionElement.ElementTargetURL)) }); } } int actionsCount = actionsTmp.Count; string[,] categoryActions = new string[actionsCount, 2]; for (int i = 0; i < actionsCount; i++) { categoryActions[i, 0] = actionsTmp[i][0]; categoryActions[i, 1] = actionsTmp[i][1]; } CategoryCreatedEventArgs args = new CategoryCreatedEventArgs(moduleElement, categoryName, categoryTitle, categoryUrl, categoryImageUrl, categoryTooltip, categoryActions); // Raise additional initialization events for this category if (CategoryCreated != null) { CategoryCreated(this, args); } // Add to categories, if further processing of this category was not cancelled if (!args.Cancel) { categoriesTmp.Add(new object[] { args.CategoryTitle, args.CategoryName, args.CategoryURL, args.CategoryImageURL, args.CategoryTooltip, args.CategoryActions }); } } } } int categoriesCount = categoriesTmp.Count; object[,] categories = new object[categoriesCount, 6]; for (int i = 0; i < categoriesCount; i++) { categories[i, 0] = categoriesTmp[i][0]; categories[i, 1] = categoriesTmp[i][1]; categories[i, 2] = categoriesTmp[i][2]; categories[i, 3] = categoriesTmp[i][3]; categories[i, 4] = categoriesTmp[i][4]; categories[i, 5] = categoriesTmp[i][5]; } if (categoriesCount > 0) { panelMenu.Categories = categories; panelMenu.ColumnsCount = ColumnsCount; } else { RedirectToUINotAvailable(); } // Add editing icon in development mode if (SettingsKeyProvider.DevelopmentMode && currentUser.IsGlobalAdministrator) { ResourceInfo ri = ResourceInfoProvider.GetResourceInfo(ModuleName); if (ri != null) { ltlAfter.Text += "<div class=\"AlignRight\">" + UIHelper.GetResourceUIElementsLink(Page, ri.ResourceId) + "</div>"; } } } }
protected void Page_Load(object sender, EventArgs e) { if (EditedObject != null) { // Register script for unimenu button selection AddMenuButtonSelectScript(this, "Accounts", null, "menu"); // Get account info object AccountInfo ai = (AccountInfo)EditedObject; string append = null; // Check permission AccountHelper.AuthorizedReadAccount(ai.AccountSiteID, true); // Check if running under site manager (and distribute "site manager" flag to other tabs) string siteManagerParam = string.Empty; if (IsSiteManager) { siteManagerParam = "&issitemanager=1"; } // Set default help topic SetHelp("onlinemarketing_account_general", "helpTopic"); // register scripts in modal dialog if (isDialogMode) { RegisterModalPageScripts(); } // Append '(merged)' behind account name in breadcrumbs if (ai.AccountMergedWithAccountID != 0) { append = " " + GetString("om.account.mergedsuffix"); } // Append '(global)' else if (ai.AccountSiteID == 0) { append = " " + GetString("om.account.globalsuffix"); } // Modify header appearance in modal dialog (display title instead of breadcrumbs) if (QueryHelper.GetBoolean("dialogmode", false)) { CurrentMaster.Title.TitleText = GetString("om.account.edit") + " - " + HTMLHelper.HTMLEncode(ai.AccountName) + append; CurrentMaster.Title.TitleImage = GetImageUrl("Objects/OM_Account/object.png"); } else { // Get url for breadcrumbs string url = ResolveUrl("~/CMSModules/ContactManagement/Pages/Tools/Account/List.aspx"); url = URLHelper.AddParameterToUrl(url, "siteid", SiteID.ToString()); if (IsSiteManager) { url = URLHelper.AddParameterToUrl(url, "issitemanager", "1"); } CurrentPage.InitBreadcrumbs(2); CurrentPage.SetBreadcrumb(0, GetString("om.account.list"), url, "_parent", null); CurrentPage.SetBreadcrumb(1, HTMLHelper.HTMLEncode(CMSContext.ResolveMacros("{%EditedObject.DisplayName%}")) + append, null, null, null); } // Check if account has any custom fields int i = 0; FormInfo formInfo = FormHelper.GetFormInfo(ai.ClassName, false); if (formInfo.GetFormElements(true, false, true).Any()) { i = 1; } // Initialize tabs InitTabs("content"); SetTab(0, GetString("general.general"), "Tab_General.aspx?accountid=" + ai.AccountID + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_account_general');"); if (i > 0) { // Add tab for custom fields SetTab(1, GetString("general.customfields"), "Tab_CustomFields.aspx?accountid=" + ai.AccountID + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_account_customfields');"); } // Display contacts tab only if user is authorized to read contacts if (ContactHelper.AuthorizedReadContact(ai.AccountSiteID, false) || AccountHelper.AuthorizedReadAccount(ai.AccountSiteID, false)) { SetTab(1 + i, GetString("om.contact.list"), "Tab_Contacts.aspx?accountid=" + ai.AccountID + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_account_contacts');"); } // Hide last 2 tabs if the account is merged if (ai.AccountMergedWithAccountID == 0) { SetTab(2 + i, GetString("om.account.subsidiaries"), "Tab_Subsidiaries.aspx?accountid=" + ai.AccountID + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_account_subsidiaries');"); SetTab(3 + i, GetString("om.account.merge"), "Tab_Merge.aspx?accountid=" + ai.AccountID + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_account_merge');"); } // Data.com SetTab(4 + i, "Data.com", "Tab_DataCom.aspx?accountid=" + ai.AccountID + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_account_datacom');"); } }
/// <summary> /// Reload data. /// </summary> public override void ReloadData(bool forceLoad) { if ((GraphImageWidth != 0) && (ComputedWidth == 0)) { // Graph width is computed no need to create graph return; } Visible = true; errorOccurred = false; try { ReportTableName = Parameter; EnsureTableInfo(); EnsureChildControls(); //Test security if (TableInfo != null) { ri = ReportInfoProvider.GetReportInfo(TableInfo.TableReportID); if (ri != null) { if (ri.ReportAccess != ReportAccessEnum.All) { if (!CMSContext.CurrentUser.IsAuthenticated()) { Visible = false; return; } } EnableSubscription = EnableSubscription && (ValidationHelper.GetBoolean(TableInfo.TableSettings["SubscriptionEnabled"], true) && ri.ReportEnableSubscription); if (EmailMode && !EnableSubscription) { this.Visible = false; return; } //Set default parametrs directly if not set if (ReportParameters == null) { FormInfo fi = new FormInfo(ri.ReportParameters); // Get datarow with required columns ReportParameters = fi.GetDataRow(false); fi.LoadDefaultValues(ReportParameters, true); } ApplyTimeParameters(); } } // Only use base parameters in case of stored procedure if (QueryIsStoredProcedure) { AllParameters = SpecialFunctions.ConvertDataRowToParams(ReportParameters, null); } // Load data DataSet ds = LoadData(); // If no data load, set empty dataset if (DataHelper.DataSourceIsEmpty(ds)) { if (EmailMode && SendOnlyNonEmptyDataSource) { Visible = false; return; } string noRecordText = ValidationHelper.GetString(TableInfo.TableSettings["QueryNoRecordText"], String.Empty); if (noRecordText != String.Empty) { GridViewObject.Visible = false; lblInfo.Text = CMSContext.ResolveMacros(noRecordText); plcInfo.Visible = true; EnableExport = false; return; } if (!EmailMode) { Visible = false; } } else { GridViewObject.Visible = true; // Resolve macros in column names int i = 0; foreach (DataColumn dc in ds.Tables[0].Columns) { if (dc.ColumnName == "Column" + ((int)(i + 1)).ToString()) { dc.ColumnName = ResolveMacros(ds.Tables[0].Rows[0][i].ToString()); } else { dc.ColumnName = ResolveMacros(dc.ColumnName); } i++; } // Resolve macros in dataset foreach (DataRow dr in ds.Tables[0].Rows) { foreach (DataColumn dc in ds.Tables[0].Columns) { if (dc.DataType.FullName.ToLowerCSafe() == "system.string") { dr[dc.ColumnName] = ResolveMacros(ValidationHelper.GetString(dr[dc.ColumnName], "")); } } } if (EmailMode) { // For some email formats, export data in csv format EmailFormatEnum format = EmailHelper.GetEmailFormat(ReportSubscriptionSiteID); if ((format == EmailFormatEnum.Both) || (format == EmailFormatEnum.PlainText)) { using (MemoryStream ms = MemoryStream.New()) { DataExportHelper deh = new DataExportHelper(ds); byte[] data = deh.ExportToCSV(ds, 0, ms, true); ReportSubscriptionSender.AddToRequest(ri.ReportName, "t" + TableInfo.TableName, data); } } // For plain text email show table only as attachment if (format == EmailFormatEnum.PlainText) { menuCont.Visible = false; ltlEmail.Visible = true; ltlEmail.Text = String.Format(GetString("reportsubscription.attachment"), TableInfo.TableName); return; } GenerateTableForEmail(ds); menuCont.Visible = false; return; } } ApplyStyles(); // Databind to gridview control GridViewObject.DataSource = ds; EnsurePageIndex(); GridViewObject.DataBind(); if ((TableFirstColumnWidth != Unit.Empty) && (GridViewObject.Rows.Count > 0)) { GridViewObject.Rows[0].Cells[0].Width = TableFirstColumnWidth; } } catch (Exception ex) { // Display error message, if data load fail lblError.Visible = true; lblError.Text = "[ReportTable.ascx] Error loading the data: " + ex.Message; EventLogProvider ev = new EventLogProvider(); ev.LogEvent("Report table", "E", ex); errorOccurred = true; } }
protected TreeNode treeElem_OnNodeCreated(DataRow itemData, TreeNode defaultNode) { if (itemData != null) { CurrentUserInfo currentUser = CMSContext.CurrentUser; if (currentUser != null) { // Check permissions string elemName = ValidationHelper.GetString(itemData["ElementName"], ""); if (currentUser.IsAuthorizedPerUIElement(this.ModuleName, elemName, this.ModuleAvailabilityForSiteRequired)) { // Ensure element caption string caption = ValidationHelper.GetString(itemData["ElementCaption"], ""); if (String.IsNullOrEmpty(caption)) { caption = ValidationHelper.GetString(itemData["ElementDisplayName"], ""); } // Set caption string text = defaultNode.Text; text = text.Replace("##NODECUSTOMNAME##", ResHelper.LocalizeString(caption)); text = text.Replace("##NODECODENAME##", elemName); if (!String.IsNullOrEmpty(JavaScriptHandler)) { defaultNode.SelectAction = TreeNodeSelectAction.None; } // Set URL string url = CMSContext.ResolveMacros(ValidationHelper.GetString(itemData["ElementTargetURL"], "")); url = URLHelper.EnsureHashToQueryParameters(url); if (String.IsNullOrEmpty(url)) { return(null); } url = ScriptHelper.GetString(URLHelper.ResolveUrl(url), false); text = text.Replace("##NODETARGETURL##", url); defaultNode.Text = text; totalNodes++; // Raise the node created handler if (OnNodeCreated != null) { defaultNode = OnNodeCreated(new UIElementInfo(itemData), defaultNode); } // Handle the preselection if (defaultNode != null) { if (preselectedItem.Equals(elemName, StringComparison.InvariantCultureIgnoreCase)) { ScriptHelper.RegisterStartupScript(this, typeof(string), "UIMenu_Preselection", ScriptHelper.GetScript("redirectUrl('" + elemName + "','" + url + "'," + ScriptHelper.GetString(elemName) + ")")); } string targetURL = ValidationHelper.GetString(itemData["ElementTargetURL"], ""); // If url is '@' dont redirect, only collapse children if (targetURL == "@") { // Set text manualy, dont't use template string imageUrl = ValidationHelper.GetString(itemData["ElementIconPath"], ""); // Get image URL imageUrl = GetImageUrl(imageUrl); // Try to get default icon if requested icon not found if (!FileHelper.FileExists(imageUrl)) { imageUrl = GetImageUrl("CMSModules/list.png"); } // Onclick simulates click on '+' or '-' button string onClick = "onClick=\"var js = $j(this).parents('tr').find('a').attr('href');eval(js); \""; // Insert image manually - (some IE issues) defaultNode.Text = "<table class=\"TreeNodeTable\" cellspacing=\"0\" cellpadding=\"0\"><tr><td><img src='" + imageUrl + "'/></td><td><span id=\"node_" + elemName + "\" class=\"ContentTreeItem \" name=\"treeNode\" " + onClick + " ><span class=\"NodeName\">" + ResHelper.LocalizeString(caption) + "</span></span></td></tr></table>"; } } return(defaultNode); } } } return(null); }
/// <summary> /// Returns initialized array list with guide item parameters. /// </summary> /// <param name="elementName">UI element data</param> private object[] GetGuideItemParameters(UIElementInfo uiElement) { // Ensure item caption string itemCaption = uiElement.ElementCaption; if (string.IsNullOrEmpty(itemCaption)) { itemCaption = uiElement.ElementDisplayName; } itemCaption = ResHelper.LocalizeString(itemCaption); // Ensure item description string itemDescription = ""; if (!String.IsNullOrEmpty(uiElement.ElementDescription)) { itemDescription = ResHelper.LocalizeString(uiElement.ElementDescription); } else { string moduleName = this.ModuleName; if (moduleName.ToLower().StartsWith("cms.")) { moduleName = moduleName.Remove(0, 4); } itemDescription = GetString(String.Format("{0}.{1}.Description", moduleName, uiElement.ElementName)); } // Ensure item URL string itemUrl = CMSContext.ResolveMacros(uiElement.ElementTargetURL); itemUrl = URLHelper.ResolveUrl(itemUrl); if (String.IsNullOrEmpty(itemUrl)) { return(null); } // Ensure item icon path string itemBigIcon = ""; string itemIcon = uiElement.ElementIconPath; if (!string.IsNullOrEmpty(itemIcon)) { if (!ValidationHelper.IsURL(itemIcon)) { int slashIndex = itemIcon.Replace('\\', '/').LastIndexOf('/'); if ((slashIndex != -1) && (slashIndex < itemIcon.Length)) { // Trim file name of the small icon from the path itemIcon = itemIcon.Remove(slashIndex); // Get file name of the big icon itemBigIcon = UIHelper.GetImagePath(this.Page, itemIcon + "/module.png", false, false); // Check if exists if (!FileHelper.FileExists(itemBigIcon)) { itemBigIcon = UIHelper.GetImagePath(this.Page, itemIcon + "/object.png", false, false); if (!File.Exists(Server.MapPath(itemBigIcon))) { // Use default big icon itemBigIcon = ""; } } } } else { itemBigIcon = itemIcon; } } // Use default big icon if (itemBigIcon == "") { itemBigIcon = GetImageUrl("CMSModules/module.png"); } object[] parameters = new object[5]; // Initialize guide item parameters[0] = itemBigIcon; parameters[1] = itemCaption; parameters[2] = itemUrl; parameters[3] = itemDescription; parameters[4] = uiElement.ElementName; // Handle additional initialization of the guide item if (OnGuideItemCreated != null) { parameters = OnGuideItemCreated(uiElement, parameters); } return(parameters); }
/// <summary> /// Prepares the layout of the web part. /// </summary> protected override void PrepareLayout() { StartLayout(); if (IsDesign) { Append("<table class=\"LayoutTable\" cellspacing=\"0\" style=\"width: 100%;\">"); if (this.ViewMode == ViewModeEnum.Design) { Append("<tr><td class=\"LayoutHeader\">"); // Add header container AddHeaderContainer(); Append("</td></tr>"); } Append("<tr><td>"); } // Content before zones Append(this.BeforeZones); string separator = this.Separator; string before = this.BeforeZone; string after = this.AfterZone; string zoneclass = this.ZoneCSSClass; string zonewidth = this.ZoneWidth; // Render the zones for (int i = 1; i <= this.Zones; i++) { if (i > 1) { Append(separator); } Append("<div"); // Zone class if (!String.IsNullOrEmpty(zoneclass)) { Append(" class=\"", zoneclass, "\""); } // Zone width if (!String.IsNullOrEmpty(zonewidth)) { Append(" style=\"width: ", zonewidth, "\";"); } Append(">", before); // Add the zone CMSWebPartZone zone = AddZone(this.ID + "_" + i, "[" + i + "]"); Append(after, "</div>"); } // Content after zones Append(this.AfterZones); if (IsDesign) { Append("</td></tr>"); // Footer if (AllowDesignMode) { Append("<tr><td class=\"LayoutFooter\" colspan=\"2\"><div class=\"LayoutFooterContent\">"); // Zone actions AppendRemoveAction(ResHelper.GetString("Layout.RemoveZone"), "Zones"); Append(" "); AppendAddAction(ResHelper.GetString("Layout.AddZone"), "Zones"); Append("</div></td></tr>"); } Append("</table>"); } // Register jQuery if (this.IncludeJQuery) { ScriptHelper.RegisterJQuery(this.Page); } // Register scripts string[] scripts = this.ScriptFiles.Split('\r', '\n'); foreach (string script in scripts) { // Register the script file string sfile = script.Trim(); if (!String.IsNullOrEmpty(sfile)) { ScriptHelper.RegisterScriptFile(this.Page, sfile); } } // Add init script string resolvedInitScript = CMSContext.ResolveMacros(this.InitScript); if (!string.IsNullOrEmpty(resolvedInitScript)) { ScriptHelper.RegisterStartupScript(this, typeof(string), ShortClientID + "_Init", ScriptHelper.GetScript(resolvedInitScript)); } // Register CSS files string[] cssFiles = this.CSSFiles.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); Array.ForEach(cssFiles, cssFile => CSSHelper.RegisterCSSLink(this.Page, cssFile.Trim())); // Add inline CSS string inlinecss = CMSContext.ResolveMacros(this.InlineCSS); if (!string.IsNullOrEmpty(inlinecss)) { // Add css to page header CSSHelper.RegisterCSSBlock(this.Page, inlinecss); } FinishLayout(); }