/// <summary> /// Initializes menu. /// </summary> protected void InitalizeMenu() { if (!String.IsNullOrEmpty(widgetId) || !String.IsNullOrEmpty(widgetName)) { WidgetInfo wi = null; // Get page info PageInfo pi = CMSWebPartPropertiesPage.GetPageInfo(aliasPath, templateId, culture); if (pi == null) { Visible = false; return; } // Get template instance PageTemplateInstance templateInstance = CMSPortalManager.GetTemplateInstanceForEditing(pi); if (templateInstance != null) { // Get zone type WebPartZoneInstance zoneInstance = templateInstance.GetZone(zoneId); if (zoneInstance != null) { zoneType = zoneInstance.WidgetZoneType; } if (!isNewWidget) { // Get web part WebPartInstance widget = templateInstance.GetWebPart(instanceGuid, widgetId); if ((widget != null) && widget.IsWidget) { // WebPartType = codename, get widget by codename wi = WidgetInfoProvider.GetWidgetInfo(widget.WebPartType); // Set the variant mode (MVT/Content personalization) variantMode = widget.VariantMode; } } } // New widget if (isNewWidget) { int id = ValidationHelper.GetInteger(widgetId, 0); if (id > 0) { wi = WidgetInfoProvider.GetWidgetInfo(id); } else if (!String.IsNullOrEmpty(widgetName)) { wi = WidgetInfoProvider.GetWidgetInfo(widgetName); } } // Get widget info from name if not found yet if ((wi == null) && (!String.IsNullOrEmpty(widgetName))) { wi = WidgetInfoProvider.GetWidgetInfo(widgetName); } if (wi != null) { pageTitle.TitleText = GetString("Widgets.Properties.Title") + " (" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(wi.WidgetDisplayName)) + ")"; } // Use live or non live dialogs string documentationUrl = String.Empty; // If no zone type defined or not inline => do not show documentation switch (zoneType) { case WidgetZoneTypeEnum.Dashboard: case WidgetZoneTypeEnum.Editor: case WidgetZoneTypeEnum.Group: case WidgetZoneTypeEnum.User: documentationUrl = ResolveUrl("~/CMSModules/Widgets/Dialogs/WidgetDocumentation.aspx"); break; // If no zone set => do not create documentation link default: if (inline) { documentationUrl = ResolveUrl("~/CMSModules/Widgets/Dialogs/WidgetDocumentation.aspx"); } else { return; } break; } // Generate documentation link Literal ltr = new Literal(); pageTitle.RightPlaceHolder.Controls.Add(ltr); // Ensure correct parameters in documentation URL documentationUrl += URLHelper.GetQuery(RequestContext.CurrentURL); if (wi != null) { documentationUrl = URLHelper.UpdateParameterInUrl(documentationUrl, "widgetid", wi.WidgetID.ToString()); } string docScript = "NewWindow('" + ScriptHelper.GetString(documentationUrl, encapsulate: false) + "', 'WebPartPropertiesDocumentation', 800, 800); return false;"; string tooltip = GetString("help.tooltip"); ltr.Text += String.Format ("<div class=\"action-button\"><a onclick=\"{0}\" href=\"#\"><span class=\"sr-only\">{1}</span><i class=\"icon-modal-question cms-icon-80\" title=\"{1}\" aria-hidden=\"true\"></i></a></div>", HTMLHelper.EncodeForHtmlAttribute(docScript), tooltip); } }
/// <summary> /// External data binding handler. /// </summary> protected object gridDocuments_OnExternalDataBound(object sender, string sourceName, object parameter) { int currentNodeId; sourceName = sourceName.ToLowerCSafe(); switch (sourceName) { case "view": { // Dialog view item DataRowView data = ((DataRowView)((GridViewRow)parameter).DataItem); CMSGridActionButton btn = ((CMSGridActionButton)sender); // Current row is the Root document isRootDocument = (ValidationHelper.GetInteger(data["NodeParentID"], 0) == 0); currentNodeId = ValidationHelper.GetInteger(data["NodeID"], 0); isCurrentDocument = (currentNodeId == WOpenerNodeID); string culture = ValidationHelper.GetString(data["DocumentCulture"], string.Empty); // Existing document culture if (culture.ToLowerCSafe() == CultureCode.ToLowerCSafe()) { string className = ValidationHelper.GetString(data["ClassName"], string.Empty); if (DataClassInfoProvider.GetDataClassInfo(className).ClassHasURL) { var relativeUrl = isRootDocument ? "~/" : DocumentUIHelper.GetPageHandlerPreviewPath(currentNodeId, culture, CurrentUser.UserName); string url = ResolveUrl(relativeUrl); btn.OnClientClick = "ViewItem(" + ScriptHelper.GetString(url) + "); return false;"; } else { btn.Enabled = false; btn.Style.Add(HtmlTextWriterStyle.Cursor, "default"); } } // New culture version else { btn.OnClientClick = "wopener.NewDocumentCulture(" + currentNodeId + ", '" + CultureCode + "'); CloseDialog(); return false;"; } } break; case "edit": { CMSGridActionButton btn = ((CMSGridActionButton)sender); if (IsEditVisible) { DataRowView data = ((DataRowView)((GridViewRow)parameter).DataItem); string culture = ValidationHelper.GetString(data["DocumentCulture"], string.Empty); currentNodeId = ValidationHelper.GetInteger(data["NodeID"], 0); int nodeParentId = ValidationHelper.GetInteger(data["NodeParentID"], 0); if (!RequiresDialog || (culture.ToLowerCSafe() == CultureCode.ToLowerCSafe())) { // Go to the selected document or create a new culture version when not used in a dialog btn.OnClientClick = "EditItem(" + currentNodeId + ", " + nodeParentId + "); return false;"; } else { // New culture version in a dialog btn.OnClientClick = "wopener.NewDocumentCulture(" + currentNodeId + ", '" + CultureCode + "'); CloseDialog(); return false;"; } } else { btn.Visible = false; } } break; case "delete": { // Delete button CMSGridActionButton btn = ((CMSGridActionButton)sender); // Hide the delete button for the root document btn.Visible = !isRootDocument; } break; case "contextmenu": { // Dialog context menu item CMSGridActionButton btn = ((CMSGridActionButton)sender); // Hide the context menu for the root document btn.Visible = !isRootDocument && !ShowAllLevels; } break; case "versionnumber": { // Version number if (parameter == DBNull.Value) { parameter = "-"; } parameter = HTMLHelper.HTMLEncode(parameter.ToString()); return(parameter); } case "documentname": { // Document name DataRowView data = (DataRowView)parameter; string className = ValidationHelper.GetString(data["ClassName"], string.Empty); string classDisplayName = ValidationHelper.GetString(data["classdisplayname"], null); string name = ValidationHelper.GetString(data["DocumentName"], string.Empty); string culture = ValidationHelper.GetString(data["DocumentCulture"], string.Empty); string cultureString = null; currentNodeId = ValidationHelper.GetInteger(data["NodeID"], 0); int nodeParentId = ValidationHelper.GetInteger(data["NodeParentID"], 0); if (isRootDocument) { // User site name for the root document name = SiteContext.CurrentSiteName; } // Default culture if (culture.ToLowerCSafe() != CultureCode.ToLowerCSafe()) { cultureString = " (" + culture + ")"; } StringBuilder sb = new StringBuilder(); if (ShowDocumentTypeIcon) { // Prepare tooltip for document type icon string iconTooltip = ""; if (ShowDocumentTypeIconTooltip && (classDisplayName != null)) { string safeClassName = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(classDisplayName)); iconTooltip = string.Format("onmouseout=\"UnTip()\" onmouseover=\"Tip('{0}')\"", HTMLHelper.EncodeForHtmlAttribute(safeClassName)); } var dataClass = DataClassInfoProvider.GetDataClassInfo(className); if (dataClass != null) { var iconClass = (string)dataClass.GetValue("ClassIconClass"); sb.Append(UIHelper.GetDocumentTypeIcon(Page, className, iconClass, additionalAttributes: iconTooltip)); } } string safeName = HTMLHelper.HTMLEncode(TextHelper.LimitLength(name, 50)); if (DocumentNameAsLink && !isRootDocument) { string tooltip = UniGridFunctions.DocumentNameTooltip(data); string selectFunction = SelectItemJSFunction + "(" + currentNodeId + ", " + nodeParentId + ");"; sb.Append("<a href=\"javascript: ", selectFunction, "\""); sb.Append(" onmouseout=\"UnTip()\" onmouseover=\"Tip('", HTMLHelper.EncodeForHtmlAttribute(tooltip), "')\">", safeName, cultureString, "</a>"); } else { sb.Append(safeName, cultureString); } // Show document marks only if method is not called from grid export and document marks are allowed if ((sender != null) && ShowDocumentMarks) { // Prepare parameters int workflowStepId = ValidationHelper.GetInteger(DataHelper.GetDataRowViewValue(data, "DocumentWorkflowStepID"), 0); WorkflowStepTypeEnum stepType = WorkflowStepTypeEnum.Undefined; if (workflowStepId > 0) { WorkflowStepInfo stepInfo = WorkflowStepInfo.Provider.Get(workflowStepId); if (stepInfo != null) { stepType = stepInfo.StepType; } } // Create data container IDataContainer container = new DataRowContainer(data); // Add icons and use current culture of processed node because of 'Not translated document' icon sb.Append(" ", DocumentUIHelper.GetDocumentMarks(Page, currentSiteName, ValidationHelper.GetString(container.GetValue("DocumentCulture"), string.Empty), stepType, container)); } return(sb.ToString()); } case "documentculture": { DocumentFlagsControl ucDocFlags = null; if (OnDocumentFlagsCreating != null) { // Raise event for obtaining custom DocumentFlagControl object result = OnDocumentFlagsCreating(this, sourceName, parameter); ucDocFlags = result as DocumentFlagsControl; // Check if something other than DocumentFlagControl was returned if ((ucDocFlags == null) && (result != null)) { return(result); } } // Dynamically load document flags control when not created if (ucDocFlags == null) { ucDocFlags = LoadUserControl("~/CMSAdminControls/UI/DocumentFlags.ascx") as DocumentFlagsControl; } // Set document flags properties if (ucDocFlags != null) { DataRowView data = (DataRowView)parameter; // Get node ID currentNodeId = ValidationHelper.GetInteger(data["NodeID"], 0); if (!string.IsNullOrEmpty(SelectLanguageJSFunction)) { ucDocFlags.SelectJSFunction = SelectLanguageJSFunction; } ucDocFlags.ID = "docFlags" + currentNodeId; ucDocFlags.SiteCultures = SiteCultures; ucDocFlags.NodeID = currentNodeId; ucDocFlags.StopProcessing = true; // Keep the control for later usage FlagsControls.Add(ucDocFlags); return(ucDocFlags); } } break; case "modifiedwhen": case "modifiedwhentooltip": // Modified when if (string.IsNullOrEmpty(parameter.ToString())) { return(string.Empty); } DateTime modifiedWhen = ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME); currentUserInfo = currentUserInfo ?? MembershipContext.AuthenticatedUser; currentSiteInfo = currentSiteInfo ?? SiteContext.CurrentSite; return(sourceName.EqualsCSafe("modifiedwhen", StringComparison.InvariantCultureIgnoreCase) ? TimeZoneHelper.ConvertToUserTimeZone(modifiedWhen, true, currentUserInfo, currentSiteInfo) : TimeZoneHelper.GetUTCLongStringOffset(currentUserInfo, currentSiteInfo)); default: if (OnExternalAdditionalDataBound != null) { return(OnExternalAdditionalDataBound(sender, sourceName, parameter)); } break; } return(parameter); }
/// <summary> /// Renders HTML5 version of Twitter plugin on the page. /// </summary> private void RenderPluginHTML5() { string serviceUrl = null; string url = UrlToShare; url = URLHelper.GetAbsoluteUrl(String.IsNullOrEmpty(url) ? RequestContext.CurrentURL : ResolveUrl(url)); url = HTMLHelper.EncodeForHtmlAttribute(url); StringBuilder sb = new StringBuilder(); switch (Type.ToLowerCSafe()) { case "share": serviceUrl = "https://twitter.com/share"; sb.Append("<a href=\"", serviceUrl, "\" class=\"twitter-share-button\" data-count=\"", ShowCount ? "horizontal" : "none", "\""); if (!string.IsNullOrEmpty(CountUrl)) { sb.Append(" data-counturl=\"", HTMLHelper.EncodeForHtmlAttribute(CountUrl), "\""); } sb.Append(" data-url=\"", url, "\""); break; // If type is hashtag case "hashtag": serviceUrl = "https://twitter.com/intent/tweet"; serviceUrl = URLHelper.AddUrlParameter(serviceUrl, "button_hashtag", ButtonHashtag); serviceUrl = HTMLHelper.EncodeForHtmlAttribute(serviceUrl); sb.Append("<a href=\"", serviceUrl, "\" class=\"twitter-hashtag-button\""); break; // If type is mention case "mention": serviceUrl = "https://twitter.com/intent/tweet"; serviceUrl = URLHelper.AddUrlParameter(serviceUrl, "screen_name", URLHelper.URLEncode(UserToMention)); serviceUrl = HTMLHelper.EncodeForHtmlAttribute(serviceUrl); sb.Append("<a href=\"", serviceUrl, "\" class=\"twitter-mention-button\""); break; } if (!string.IsNullOrEmpty(TweetText)) { sb.Append(" data-text=\"", HTMLHelper.EncodeForHtmlAttribute(TweetText), "\""); } sb.Append(" data-lang=\"", HTMLHelper.EncodeForHtmlAttribute(Language), "\" data-width=\"", Width, "px\" data-size=\"", (Size.EqualsCSafe("m") ? "medium" : "large"), "\""); if (!string.IsNullOrEmpty(Via)) { sb.Append(" data-via=\"", HTMLHelper.EncodeForHtmlAttribute(Via), "\""); } if (!string.IsNullOrEmpty(RelatedAccounts)) { sb.Append(" data-related=\"", HTMLHelper.EncodeForHtmlAttribute(RelatedAccounts), "\""); } if (!string.IsNullOrEmpty(Hashtags)) { sb.Append(" data-hashtags=\"", HTMLHelper.EncodeForHtmlAttribute(Hashtags), "\""); } sb.Append("></a>"); // Register Twitter widget API ltlTweetButtonCode.Text = sb.ToString(); ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "TwitterWidgetsAPI", "<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=\"http://platform.twitter.com/widgets.js\";fjs.parentNode.insertBefore(js,fjs);}}(document,\"script\",\"twitter-wjs\");</script>"); }
private object GetDocumentNameColumnMarkup(DataRowView data) { var documentName = ValidationHelper.GetString(data["NodeName"], string.Empty); var documentAliasPath = ValidationHelper.GetString(DataHelper.GetDataRowViewValue(data, "NodeAliasPath"), String.Empty); var tooltip = GetTooltip(documentName, documentAliasPath); var pageTypeIcon = GetNodeIcon(Convert.ToString(data["ClassName"])); var sb = new StringBuilder(); sb.Append( "<span style=\"cursor: help \" onmouseout=\"UnTip()\" onmouseover=\"Tip('", HTMLHelper.EncodeForHtmlAttribute(tooltip), "')\" >" + pageTypeIcon + "<span>", HTMLHelper.HTMLEncode(TextHelper.LimitLength(documentName, 50)), "</span></span>" ); return(sb.ToString()); }
/// <summary> /// Initializes the control properties. /// </summary> protected override void SetupControl() { if (StopProcessing) { // Do not process } else { // Default height if nothing additional is shown int height = heightDefault; // If faces and stream are shown if (ShowFaces && ShowStream) { height = heightStreamFaces; } // If only stream is shown else if (ShowStream) { height = heightStream; } // If only faces are shown else if (ShowFaces) { height = heightFaces; } // If stream or faces are shown and header is too if (ShowHeader && (ShowFaces || ShowStream)) { height = height + 35; } if (UseHTML5) { StringBuilder sb = new StringBuilder(); sb.Append("<div class=\"fb-like-box\" data-href=\"", HTMLHelper.EncodeForHtmlAttribute(FBPageUrl), "\" data-width=\"", Width, "\" data-height=\"", height, "\" data-header=\"", ShowHeader, "\" data-stream=\"", ShowStream, "\" data-show-faces=\"", ShowFaces, "\" data-colorscheme=\"", ColorScheme, "\" data-force-wall=\"", ForceWall, "\" data-show-border=\"", ShowBorder, "\""); sb.Append("></div>"); string fbApiKey = FacebookConnectHelper.GetFacebookApiKey(SiteContext.CurrentSiteName); if (String.IsNullOrEmpty(fbApiKey)) { ShowError(lblErrorMessage, "socialnetworking.facebook.apikeynotset"); } // Register Facebook javascript SDK ScriptHelper.RegisterFacebookJavascriptSDK(Page, LocalizationContext.PreferredCultureCode, fbApiKey); ltlLikeBox.Text = sb.ToString(); } else { // Iframe code string src = "http://www.facebook.com/plugins/likebox.php"; string query = URLHelper.AddUrlParameter(null, "href", FBPageUrl); query = URLHelper.AddUrlParameter(query, "header", ShowHeader.ToString()); query = URLHelper.AddUrlParameter(query, "width", Width.ToString()); query = URLHelper.AddUrlParameter(query, "show_faces", ShowFaces.ToString()); query = URLHelper.AddUrlParameter(query, "stream", ShowStream.ToString()); query = URLHelper.AddUrlParameter(query, "colorscheme", ColorScheme); query = URLHelper.AddUrlParameter(query, "height", height.ToString()); query = URLHelper.AddUrlParameter(query, "force_wall", ForceWall.ToString()); query = URLHelper.AddUrlParameter(query, "show_border", ShowBorder.ToString()); src = HTMLHelper.EncodeForHtmlAttribute(URLHelper.AppendQuery(src, query)); ltlLikeBox.Text = "<iframe src=\"" + src + "\""; ltlLikeBox.Text += " scrolling=\"no\" frameborder=\"0\" style=\"border:none; overflow:hidden; width:" + Width + "px; height:" + height + "px;\"></iframe>"; } } }
protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter) { // For all actions if (sourceName.EndsWith("action", StringComparison.OrdinalIgnoreCase)) { var img = sender as CMSGridActionButton; if (img != null) { img.Enabled = !IsRunningThread(); } } switch (sourceName.ToLowerInvariant()) { case "resubmitaction": case "processaction": case "cancelaction": var img = sender as CMSGridActionButton; if (img != null) { img.Enabled &= modifyAllowed; var gvr = parameter as GridViewRow; if (gvr == null) { return(img); } var drv = gvr.DataItem as DataRowView; if (drv == null) { return(img); } var status = (TranslationStatusEnum)ValidationHelper.GetInteger(drv["SubmissionStatus"], 0); switch (sourceName.ToLowerInvariant()) { case "resubmitaction": img.Enabled &= modifyAllowed && ((status == TranslationStatusEnum.WaitingForTranslation) || (status == TranslationStatusEnum.SubmissionError)); break; case "processaction": img.Enabled &= modifyAllowed && ((status == TranslationStatusEnum.TranslationReady) || (status == TranslationStatusEnum.TranslationCompleted) || (status == TranslationStatusEnum.ProcessingError)); break; case "cancelaction": var service = TranslationServiceInfoProvider.GetTranslationServiceInfo(ValidationHelper.GetInteger(drv["SubmissionServiceID"], 0)); if (service != null) { bool serviceSupportsCancel = service.TranslationServiceSupportsCancel; img.Enabled &= modifyAllowed && (status == TranslationStatusEnum.WaitingForTranslation) && serviceSupportsCancel; if (!serviceSupportsCancel) { // Display tooltip for disabled cancel img.ToolTip = String.Format(GetString("translationservice.cancelnotsupported"), service.TranslationServiceDisplayName); } } break; } } return(img); case "submissionstatus": TranslationStatusEnum submissionstatus = (TranslationStatusEnum)ValidationHelper.GetInteger(parameter, 0); return(TranslationServiceHelper.GetFormattedStatusString(submissionstatus)); case "submissionprice": string price = GetString("general.notavailable"); double priceVal = ValidationHelper.GetDouble(parameter, -1); if (priceVal >= 0) { price = priceVal.ToString(); } return(price); case "submissiontargetculture": { string[] cultureCodes = ValidationHelper.GetString(parameter, "").Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); StringBuilder sb = new StringBuilder(); int count = cultureCodes.Length; int counter = 0; foreach (var cultureCode in cultureCodes) { // Limit cultures list if (counter == 5) { sb.Append(" "); sb.AppendFormat(ResHelper.GetString("translationservices.submissionnamesuffix"), count - 5); break; } // Separate cultures by comma if (counter > 0) { sb.Append(", "); } var culture = CultureInfoProvider.GetCultureInfo(cultureCode); if (culture == null) { continue; } sb.AppendFormat("<span title=\"{0}\"><img class=\"cms-icon-80\" src=\"{1}\" alt=\"{2}\" /> {3}</span>", HTMLHelper.EncodeForHtmlAttribute(culture.CultureName), UIHelper.GetFlagIconUrl(null, culture.CultureCode, "16x16"), HTMLHelper.EncodeForHtmlAttribute(culture.CultureName), HTMLHelper.HTMLEncode(culture.CultureShortName)); ++counter; } return(sb.ToString()); } } return(parameter); }
/// <summary> /// Invoked when new tree node is created. /// </summary> /// <param name="itemData">Category data.</param> /// <param name="defaultNode">Default node.</param> protected TreeNode treeElem_OnNodeCreated(DataRow itemData, TreeNode defaultNode) { defaultNode.Selected = false; defaultNode.SelectAction = TreeNodeSelectAction.None; defaultNode.NavigateUrl = ""; if (itemData != null) { CategoryInfo category = new CategoryInfo(itemData); var catLevel = category.CategoryLevel; if ((StartingCategoryObj != null) && (category.CategoryIDPath.StartsWithCSafe(StartingCategoryObj.CategoryIDPath))) { catLevel -= StartingCategoryObj.CategoryLevel - 1; } string cssClass = GetCssClass(catLevel); string caption = category.CategoryDisplayName; if (String.IsNullOrEmpty(caption)) { caption = category.CategoryName; } // Get target URL string url = GetUrl(category); caption = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(caption)); StringBuilder attrs = new StringBuilder(); // Append target attribute if (!string.IsNullOrEmpty(CategoriesPageTarget)) { attrs.Append(" target=\"").Append(CategoriesPageTarget).Append("\""); } // Append title attribute if (RenderLinkTitle) { attrs.Append(" title=\"").Append(caption).Append("\""); } // Append CSS class if (!string.IsNullOrEmpty(cssClass)) { attrs.Append(" class=\"" + cssClass + "\""); } // Append before/after texts caption = (CategoryContentBefore ?? "") + caption; caption += CategoryContentAfter ?? ""; if (category.IsGlobal && !category.CategoryIsPersonal) { caption += " <sup>" + GetString("general.global") + "</sup>"; } // Set caption defaultNode.Text = defaultNode.Text.Replace("##NODECUSTOMNAME##", caption); defaultNode.Text = defaultNode.Text.Replace("##NODECODENAME##", HTMLHelper.HTMLEncode(category.CategoryName)); defaultNode.Text = defaultNode.Text.Replace("##PARENTID##", category.CategoryParentID.ToString()); defaultNode.Text = defaultNode.Text.Replace("##ID##", category.CategoryID.ToString()); defaultNode.Text = defaultNode.Text.Replace("##BEFORENAME##", string.Format("<a href=\"{0}\" {1}>", HTMLHelper.EncodeForHtmlAttribute(url), attrs)); defaultNode.Text = defaultNode.Text.Replace("##AFTERNAME##", "</a>"); // Expand node if all nodes are to be expanded if (ExpandAll) { defaultNode.Expand(); } else { // Check if selected category exists if (Category != null) { if ((Category.CategoryID != category.CategoryID) || RenderSubItems) { // Expand whole path to selected category string strId = category.CategoryID.ToString().PadLeft(CategoryInfoProvider.CategoryIDLength, '0'); if (Category.CategoryIDPath.Contains(strId)) { defaultNode.Expand(); } } } } return(defaultNode); } return(null); }
/// <summary> /// Returns message for user in callback data, that will be shown via alert dialog. /// </summary> /// <param name="messageText">Text to be displayed</param> private void ShowMessageInCallback(string messageText) { callbackResult.Add("message", HTMLHelper.EncodeForHtmlAttribute(messageText)); }
/// <summary> /// Initializes the control properties. /// </summary> protected override void SetupControl() { if (StopProcessing) { // Do not process } else { if (string.IsNullOrEmpty(Domain)) { Domain = SiteContext.CurrentSite.DomainName; } if (UseHTML5) { StringBuilder sb = new StringBuilder(); sb.Append("<div class=\"fb-recommendations\" data-width=\"", Width, "\" data-height=\"", Height, "\" data-site=\"", Domain, "\" data-header=\"", ShowHeader, "\" data-colorscheme=\"", ColorScheme, "\""); if (!string.IsNullOrEmpty(Font)) { sb.Append(" data-font=\"", Font, "\""); } if (!string.IsNullOrEmpty(RefParameter)) { sb.Append(" data-ref=\"", RefParameter, "\""); } sb.Append("></div>"); string fbApiKey = FacebookConnectHelper.GetFacebookApiKey(SiteContext.CurrentSiteName); if (String.IsNullOrEmpty(fbApiKey)) { ShowError(lblErrorMessage, "socialnetworking.facebook.apikeynotset"); } // Register Facebook javascript SDK ScriptHelper.RegisterFacebookJavascriptSDK(Page, LocalizationContext.PreferredCultureCode, fbApiKey); ltlRecommendations.Text = sb.ToString(); } else { // Iframe code string query = null; string src = "http://www.facebook.com/plugins/recommendations.php"; if (!string.IsNullOrEmpty(Font)) { query = URLHelper.AddUrlParameter(query, "font", Font); } if (!string.IsNullOrEmpty(RefParameter)) { query = URLHelper.AddUrlParameter(query, "ref", RefParameter); } query = URLHelper.AddUrlParameter(query, "site", Domain); query = URLHelper.AddUrlParameter(query, "header", ShowHeader.ToString()); query = URLHelper.AddUrlParameter(query, "width", Width.ToString()); query = URLHelper.AddUrlParameter(query, "colorscheme", ColorScheme); query = URLHelper.AddUrlParameter(query, "height", Height.ToString()); src = HTMLHelper.EncodeForHtmlAttribute(URLHelper.AppendQuery(src, query)); ltlRecommendations.Text = "<iframe src=\"" + src + "\""; ltlRecommendations.Text += " scrolling=\"no\" frameborder=\"0\" style=\"border:none; overflow:hidden; width:" + Width + "px; height:" + Height + "px;\"></iframe>"; } } }
/// <summary> /// Initializes the control properties /// </summary> protected void SetupControl() { if (StopProcessing) { // Do not process } else { ScriptHelper.RegisterJQuery(Page); treeElemG.StopProcessing = !DisplayGlobalCategories && !DisplaySiteCategories; treeElemP.StopProcessing = !DisplayPersonalCategories; // Prepare node templates treeElemP.SelectedNodeTemplate = treeElemG.SelectedNodeTemplate = "<span id=\"" + ClientID + "node_##NODECODENAME##\" class=\"CategoryTreeItem " + SelectedItemCSS + "\">##BEFORENAME####ICON##<span class=\"Name\">##NODECUSTOMNAME##</span>##AFTERNAME##</span>"; treeElemP.NodeTemplate = treeElemG.NodeTemplate = "<span id=\"" + ClientID + "node_##NODECODENAME##\" class=\"CategoryTreeItem\">##BEFORENAME####ICON##<span class=\"Name\">##NODECUSTOMNAME##</span>##AFTERNAME##</span>"; // Init tree provider objects treeElemG.ProviderObject = CreateTreeProvider(SiteContext.CurrentSiteID, 0); if (!treeElemP.StopProcessing && (MembershipContext.AuthenticatedUser != null)) { treeElemP.ProviderObject = CreateTreeProvider(0, MembershipContext.AuthenticatedUser.UserID); } // Expand first level by default treeElemP.ExpandPath = treeElemG.ExpandPath = "/"; // Create root node for global and site categories string rootCatName = CategoriesRoot; string rootId = "NULL"; string before = ""; string after = ""; if (StartingCategoryObj != null) { rootId = StartingCategoryObj.CategoryID.ToString(); rootCatName = HTMLHelper.HTMLEncode(StartingCategoryObj.CategoryDisplayName); before = string.Format("<a href=\"{0}\">", HTMLHelper.EncodeForHtmlAttribute(GetUrl(StartingCategoryObj))); after = "</a>"; } string rootName = "<span class=\"TreeRoot\">" + ResHelper.LocalizeString(rootCatName) + "</span>"; string rootText = treeElemG.ReplaceMacros(treeElemG.NodeTemplate, 0, 6, rootName, null, 0, null, null); // Replace macros rootText = rootText.Replace("##NODECUSTOMNAME##", rootName); rootText = rootText.Replace("##NODECODENAME##", "CategoriesRoot"); rootText = rootText.Replace("##PARENTID##", CATEGORIES_ROOT_PARENT_ID.ToString()); rootText = rootText.Replace("##BEFORENAME##", before); rootText = rootText.Replace("##AFTERNAME##", after); string itemImg = CategoriesRootImageUrl; if (!string.IsNullOrEmpty(itemImg) && itemImg.StartsWithCSafe("~/")) { itemImg = ResolveUrl(itemImg); } treeElemG.SetRoot(rootText, rootId, itemImg, null, null); rootName = "<span class=\"TreeRoot\">" + ResHelper.LocalizeString(PersonalCategoriesRoot) + "</span>"; rootText = treeElemP.ReplaceMacros(treeElemP.NodeTemplate, 0, 6, rootName, null, 0, null, null); // Replace macros rootText = rootText.Replace("##NODECUSTOMNAME##", rootName); rootText = rootText.Replace("##NODECODENAME##", "PersonalCategoriesRoot"); rootText = rootText.Replace("##PARENTID##", PERSONAL_CATEGORIES_ROOT_PARENT_ID.ToString()); rootText = rootText.Replace("##BEFORENAME##", ""); rootText = rootText.Replace("##AFTERNAME##", ""); itemImg = PersonalCategoriesRootImageUrl; if (!string.IsNullOrEmpty(itemImg) && itemImg.StartsWithCSafe("~/")) { itemImg = ResolveUrl(itemImg); } treeElemP.SetRoot(rootText, "NULL", itemImg, null, null); } }
protected object gridDocuments_OnExternalDataBound(object sender, string sourceName, object parameter) { sourceName = sourceName.ToLowerCSafe(); DataRowView drv = null; bool modifyPermission = true; string documentCulture = null; switch (sourceName) { case "documentname": drv = parameter as DataRowView; string documentName = null; string encodedDocumentName = null; string documentType = null; documentCulture = ValidationHelper.GetString(drv.Row["DocumentCulture"], string.Empty); string alias = ValidationHelper.GetString(drv.Row["NodeAlias"], string.Empty); int nodeId = ValidationHelper.GetInteger(drv.Row["NodeID"], 0); int documentId = ValidationHelper.GetInteger(drv.Row["DocumentID"], 0); bool isLinked = (ValidationHelper.GetInteger(drv["NodeLinkedNodeID"], 0) != 0); Guid nodeGuid = ValidationHelper.GetGuid(drv.Row["NodeGUID"], Guid.Empty); string fileDescription = ValidationHelper.GetString(drv.Row["FileDescription"], string.Empty); Guid fileAttachment = ValidationHelper.GetGuid(drv.Row["FileAttachment"], Guid.Empty); // Get permissions flags modifyPermission = TreeSecurityProvider.CheckPermission(drv.Row, NodePermissionsEnum.Modify, documentCulture); bool modifyCulturePermission = TreeSecurityProvider.CheckPermission(drv.Row, NodePermissionsEnum.Modify, PreferredCultureCode); bool deletePermission = TreeSecurityProvider.CheckPermission(drv.Row, NodePermissionsEnum.Delete, documentCulture); bool modifyPermissionsPermission = TreeSecurityProvider.CheckPermission(drv.Row, NodePermissionsEnum.ModifyPermissions, documentCulture); bool readPermission = !CheckPermissions || TreeSecurityProvider.CheckPermission(drv.Row, NodePermissionsEnum.Read, documentCulture); if (modifyPermission) { documentName = ValidationHelper.GetString(drv.Row["DocumentName"], string.Empty); documentType = ValidationHelper.GetString(drv.Row["DocumentType"], string.Empty); } else { documentName = ValidationHelper.GetString(drv.Row["PublishedDocumentName"], string.Empty); documentType = ValidationHelper.GetString(drv.Row["PublishedDocumentType"], string.Empty); } encodedDocumentName = HTMLHelper.HTMLEncode(documentName); string fileTypeIcon = UIHelper.GetFileIcon(Page, documentType, tooltip: HTMLHelper.HTMLEncode(documentType)); string flagIcon = null; if (documentCulture.ToLowerCSafe() != PreferredCultureCode.ToLowerCSafe()) { flagIcon = "<img class=\"Icon\" src=\"" + GetFlagIconUrl(documentCulture, "16x16") + "\" alt=\"" + HTMLHelper.HTMLEncode(documentCulture) + "\" />"; } string menuParameter = ScriptHelper.GetString(nodeId + "|" + documentCulture); string attachmentName = encodedDocumentName; string toolTip = UIHelper.GetTooltipAttributes(null, 0, 0, null, null, null, fileDescription, null, 300); // Generate link to open document if (fileAttachment != Guid.Empty) { // Get document URL string attachmentUrl = AuthenticationHelper.ResolveUIUrl(AttachmentURLProvider.GetPermanentAttachmentUrl(nodeGuid, alias)); if (modifyPermission) { attachmentUrl = URLHelper.AddParameterToUrl(attachmentUrl, "latestfordocid", ValidationHelper.GetString(documentId, string.Empty)); attachmentUrl = URLHelper.AddParameterToUrl(attachmentUrl, "hash", ValidationHelper.GetHashString("d" + documentId)); } attachmentUrl = URLHelper.UpdateParameterInUrl(attachmentUrl, "chset", Guid.NewGuid().ToString()); if (!string.IsNullOrEmpty(attachmentUrl)) { attachmentName = "<a href=\"" + HTMLHelper.EncodeForHtmlAttribute(attachmentUrl) + "\" " + toolTip + ">" + encodedDocumentName + "</a> "; } } else { attachmentName = "<span" + toolTip + ">" + encodedDocumentName + "</span>"; } // Add linked flag if (isLinked) { attachmentName += DocumentHelper.GetDocumentMarkImage(Page, DocumentMarkEnum.Link); } bool showContextMenu = readPermission && (modifyPermission || modifyPermissionsPermission || deletePermission || (IsAuthorizedToCreate && modifyCulturePermission)); // Generate row with icons, hover action and context menu StringBuilder contextMenuString = new StringBuilder(); contextMenuString.Append("<table>"); contextMenuString.Append("<tr>"); if (showContextMenu) { contextMenuString.Append(ContextMenuContainer.GetStartTag("libraryMenu_" + arrowContextMenu.ClientID, menuParameter, false, HtmlTextWriterTag.Td, "ArrowIcon", null)); contextMenuString.Append("<a class=\"btn-unigrid-action\"><i class=\"icon-ellipsis\"></i></a>"); contextMenuString.Append(ContextMenuContainer.GetEndTag(HtmlTextWriterTag.Td)); } else { contextMenuString.Append("<td class=\"NoIcon\"> </td>"); } if (showContextMenu) { contextMenuString.Append(ContextMenuContainer.GetStartTag("libraryMenu_" + rowContextMenu.ClientID, menuParameter, true, HtmlTextWriterTag.Td, "FileTypeIcon", null)); } else { contextMenuString.Append("<td class=\"FileTypeIcon\">"); } contextMenuString.Append(fileTypeIcon); contextMenuString.Append(ContextMenuContainer.GetEndTag(HtmlTextWriterTag.Td)); if (showContextMenu) { contextMenuString.Append(ContextMenuContainer.GetStartTag("libraryMenu_" + rowContextMenu.ClientID, menuParameter, true, HtmlTextWriterTag.Td, "RowContent", "width: 100%;")); } else { contextMenuString.Append("<td class=\"RowContent\" style=\"width: 100%;\">"); } contextMenuString.Append(attachmentName); contextMenuString.Append(ContextMenuContainer.GetEndTag(HtmlTextWriterTag.Td)); if (!string.IsNullOrEmpty(flagIcon)) { contextMenuString.Append(ContextMenuContainer.GetStartTag("libraryMenu_" + rowContextMenu.ClientID, menuParameter, true, HtmlTextWriterTag.Td, "FlagIcon", null)); contextMenuString.Append(flagIcon); contextMenuString.Append(ContextMenuContainer.GetEndTag(HtmlTextWriterTag.Td)); } contextMenuString.Append(" </tr>"); contextMenuString.Append("</table>"); return(contextMenuString.ToString()); case "modifiedwhen": case "modifiedwhentooltip": if (string.IsNullOrEmpty(parameter.ToString())) { return(string.Empty); } else { // Handle time zones DateTime modifiedWhen = ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME); if (sourceName == "modifiedwhen") { if (IsLiveSite) { return(TimeZoneMethods.ConvertDateTime(modifiedWhen, this)); } else { return(TimeZoneHelper.GetCurrentTimeZoneDateTimeString(modifiedWhen, CurrentUser, CurrentSite, out usedTimeZone)); } } else { if (!IsLiveSite) { if (TimeZoneHelper.TimeZonesEnabled && (usedTimeZone == null)) { TimeZoneHelper.GetCurrentTimeZoneDateTimeString(modifiedWhen, CurrentUser, CurrentSite, out usedTimeZone); } return(TimeZoneHelper.GetUTCLongStringOffset(usedTimeZone)); } else { return(null); } } } case "status": string stepName = string.Empty; string toReturn = string.Empty; // Extract datarow drv = parameter as DataRowView; stepName = GetString("general.dash"); TreeNode node = DocumentHelper.GetDocument(ValidationHelper.GetInteger(drv["DocumentID"], 0), TreeProvider); if (node != null) { var step = node.WorkflowStep; if (step != null) { stepName = step.StepDisplayName; } } // Gain desired values from datarow view int checkedOutByUserId = ValidationHelper.GetInteger(drv["DocumentCheckedOutByUserID"], 0); documentCulture = ValidationHelper.GetString(drv.Row["DocumentCulture"], string.Empty); modifyPermission = TreeSecurityProvider.CheckPermission(drv.Row, NodePermissionsEnum.Modify, documentCulture); // Add 'checked out' icon if ((checkedOutByUserId > 0) && modifyPermission) { toReturn = " " + DocumentHelper.GetDocumentMarkImage(Page, DocumentMarkEnum.CheckedOut); } toReturn = stepName + toReturn; return(toReturn); } return(parameter); }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { List <string[]> cultures = GetCultures(); if ((cultures != null) && ((cultures.Count > 1) || (HideCurrentCulture && (cultures.Count > 0)))) { // Render the cultures ltlHyperlinks.Text = String.Empty; mLayoutSeparator = DisplayLayout.ToLowerCSafe() == "vertical" ? "<br />" : " "; bool addSeparator = false; // Loop thru all cultures foreach (string[] data in cultures) { string url = data[0]; string code = data[1]; string name = data[2]; // Get flag icon URL imgFlagIcon = UIHelper.GetFlagIconUrl(Page, code, "16x16"); if (addSeparator) { ltlHyperlinks.Text += Separator + mLayoutSeparator; } if (ShowCultureNames) { // Add flag icon before the link text ltlHyperlinks.Text += "<img src=\"" + imgFlagIcon + "\" alt=\"" + HTMLHelper.HTMLEncode(name) + "\" />"; ltlHyperlinks.Text += "<a href=\"" + HTMLHelper.EncodeForHtmlAttribute(URLHelper.ResolveUrl(url)) + "\">"; ltlHyperlinks.Text += HTMLHelper.HTMLEncode(name); // Set surrounding div css class selectionClass = "languageSelectionWithCultures"; } else { ltlHyperlinks.Text += "<a href=\"" + url + "\">" + "<img src=\"" + imgFlagIcon + "\" alt=\"" + HTMLHelper.HTMLEncode(name) + "\" />"; // Set surrounding div css class selectionClass = "languageSelection"; } ltlHyperlinks.Text += "</a>"; addSeparator = true; } } // Hide webpart if there isn't more than one culture else { Visible = false; } if (string.IsNullOrEmpty(selectionClass)) { ltrDivOpen.Text = "<div>"; } else { ltrDivOpen.Text = "<div class=\"" + selectionClass + "\">"; } ltrDivClose.Text = "</div>"; // Check if RTL hack must be applied if (CultureHelper.IsPreferredCultureRTL()) { ltrDivOpen.Text += "<span style=\"visibility:hidden;\">a</span>"; } } }
/// <summary> /// Renders Twitter plugin on the page. /// </summary> private void RenderPlugin() { // Build plugin code string query = null; string src = "http://platform.twitter.com/widgets/tweet_button.html"; int height = (Size.EqualsCSafe("m")) ? 20 : 28; // Check optional parameters if (!string.IsNullOrEmpty(TweetText)) { query = URLHelper.AddUrlParameter(query, "text", URLHelper.URLEncode(TweetText)); } if (!string.IsNullOrEmpty(Via)) { query = URLHelper.AddUrlParameter(query, "via", URLHelper.URLEncode(Via)); } if (!string.IsNullOrEmpty(RelatedAccounts)) { query = URLHelper.AddUrlParameter(query, "related", URLHelper.URLEncode(RelatedAccounts)); } if (!string.IsNullOrEmpty(Hashtags)) { query = URLHelper.AddUrlParameter(query, "hashtags", URLHelper.URLEncode(Hashtags)); } query = URLHelper.AddUrlParameter(query, "lang", Language); query = URLHelper.AddUrlParameter(query, "size", Size); // If type is share if (Type.EqualsCSafe("share")) { query = URLHelper.AddUrlParameter(query, "count", ShowCount ? "horizontal" : "none"); string url = UrlToShare; url = URLHelper.GetAbsoluteUrl(string.IsNullOrEmpty(url) ? RequestContext.CurrentURL : ResolveUrl(url)); query = URLHelper.AddUrlParameter(query, "url", url); if (!string.IsNullOrEmpty(CountUrl)) { query = URLHelper.AddUrlParameter(query, "counturl", URLHelper.URLEncode(CountUrl)); } } // If type is hashtag if (Type.EqualsCSafe("hashtag")) { query = URLHelper.AddUrlParameter(query, "type", Type); query = URLHelper.AddUrlParameter(query, "button_hashtag", URLHelper.URLEncode(ButtonHashtag)); } // If type is mention if (Type.EqualsCSafe("mention")) { query = URLHelper.AddUrlParameter(query, "type", Type); query = URLHelper.AddUrlParameter(query, "screen_name", URLHelper.URLEncode(UserToMention)); } src = HTMLHelper.EncodeForHtmlAttribute(URLHelper.AppendQuery(src, query)); // Output HTML code string output = "<iframe src=\"{0}\" scrolling=\"no\" frameborder=\"0\" allowtransparency=\"true\" style=\"width: {1}px; height: {2}px;\"></iframe>"; ltlTweetButtonCode.Text = String.Format(output, src, Width, height); }
/// <summary> /// Check that unlock hash is valid /// </summary> /// <param name="checkOnly">Indicates if only check will be performed</param> private bool CheckAndUnlock(bool checkOnly) { if ((UserAccount != null) && !UserAccount.Enabled && (UserAccount.UserInvalidLogOnAttempts > 0)) { if (!checkOnly) { AuthenticationHelper.UnlockUserAccount(UserAccount); // Show information message or redirect to specified URL if (string.IsNullOrEmpty(RedirectionURL)) { btnConfirm.Visible = false; if (!string.IsNullOrEmpty(SuccessfulUnlockText)) { ShowConfirmation(SuccessfulUnlockText); } else { ShowConfirmation(GetString("invalidlogonattempts.unlockaccount.accountunlocked")); lblInfo.Text = String.Format(GetString("invalidlogonattempts.unlockaccount.login"), HTMLHelper.EncodeForHtmlAttribute(returnUrl)); } } else { URLHelper.Redirect(UrlResolver.ResolveUrl(RedirectionURL)); } } } else { DisplayError(DataHelper.GetNotEmpty(UnsuccessfulUnlockText, GetString("invalidlogonattempts.unlockaccount.errortext"))); return(false); } return(true); }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { // If there is only one culture on site and hiding is enabled hide webpart if (HideIfOneCulture && !CultureSiteInfoProvider.IsSiteMultilingual(SiteContext.CurrentSiteName)) { Visible = false; return; } // Get list of cultures List <string[]> cultures = GetCultures(); // Check whether exists more than one culture if ((cultures != null) && ((cultures.Count > 1) || (HideCurrentCulture && (cultures.Count > 0)))) { // Add CSS Stylesheet CSSHelper.RegisterCSSLink(Page, URLHelper.ResolveUrl("~/CMSWebparts/Localization/languageselectiondropdown_files/langselector.css")); string imgFlagIcon = String.Empty; StringBuilder result = new StringBuilder(); result.Append("<ul class=\"langselector\">"); // Set first item to the current language CultureInfo ci = CultureInfoProvider.GetCultureInfo(CultureHelper.GetPreferredCulture()); if (ci != null) { // Drop down imitating icon string dropIcon = ResolveUrl("~/CMSWebparts/Localization/languageselectiondropdown_files/dd_arrow.gif"); // Current language imgFlagIcon = GetImageUrl("Flags/16x16/" + HTMLHelper.HTMLEncode(ci.CultureCode) + ".png"); string currentCultureShortName = String.Empty; if (ShowCultureNames) { currentCultureShortName = HTMLHelper.HTMLEncode(ci.CultureShortName); } result.AppendFormat("<li class=\"lifirst\" style=\"background-image:url('{0}'); background-repeat: no-repeat\"><a class=\"first\" style=\"background-image:url({1}); background-repeat: no-repeat\" href=\"{2}\">{3}</a>", dropIcon, imgFlagIcon, "#", currentCultureShortName); } result.Append("<ul>"); // Loop thru all cultures foreach (string[] data in cultures) { string url = data[0]; string code = data[1]; string name = HTMLHelper.HTMLEncode(data[2]); // Language icon imgFlagIcon = GetImageUrl("Flags/16x16/" + HTMLHelper.HTMLEncode(code) + ".png"); if (!ShowCultureNames) { name = string.Empty; } result.AppendFormat("<li><a style=\"background-image:url({0}); background-repeat: no-repeat\" href=\"{1}\">{2}</a></li>\r\n", imgFlagIcon, HTMLHelper.EncodeForHtmlAttribute(URLHelper.ResolveUrl(url)), name); } result.Append("</ul></li></ul>"); ltlLanguages.Text = result.ToString(); } else if (HideIfOneCulture) { Visible = false; } } }
/// <summary> /// Creates URL for. /// </summary> /// <param name="param">URL paramater</param> /// <param name="number">Value</param> public string CreateUrl(string param, object number) { return(HTMLHelper.EncodeForHtmlAttribute(URLHelper.UpdateParameterInUrl(RequestContext.CurrentURL, param, ValidationHelper.GetString(number, "1")))); }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (!StopProcessing) { bool show = true; TreeNode curDoc = DocumentContext.CurrentDocument; // Check if permissions should be checked if (ShowOnlyWhenAuthorized) { // Check permissions if (!((MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Editor, SiteContext.CurrentSiteName)) && CMSPage.IsUserAuthorizedPerContent() && (MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(curDoc, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Allowed))) { show = false; Visible = false; } } if (show) { // Create edit link StringBuilder sb = new StringBuilder("<a class=\"EditDocumentLink\" href=\""); // On-Site edit if (PreferOnSiteEdit && PortalHelper.IsOnSiteEditingEnabled(CurrentSiteName)) { string onsiteEditUrl = UrlResolver.ResolveUrl(PortalHelper.OnSiteEditRelativeURL); string retUrl = RequestContext.CurrentURL; // handle default alias path if ((ViewMode == CMS.PortalEngine.ViewModeEnum.LiveSite) && (URLRewritingContext.CurrentPageInfoSource == PageInfoSource.DefaultAliasPath)) { string aliasPath = PageInfoProvider.GetDefaultAliasPath(RequestContext.CurrentDomain, SiteContext.CurrentSiteName); if (!String.IsNullOrEmpty(aliasPath)) { string query = URLHelper.GetQuery(retUrl); retUrl = UrlResolver.ResolveUrl(DocumentURLProvider.GetUrl(aliasPath)); retUrl = URLHelper.AppendQuery(retUrl, query); } } onsiteEditUrl = URLHelper.UpdateParameterInUrl(onsiteEditUrl, "editurl", HttpUtility.UrlEncode(retUrl)); sb.Append(HTMLHelper.EncodeForHtmlAttribute(onsiteEditUrl)); } // Administration edit else { sb.Append("~/Admin/cmsadministration.aspx?action=edit&nodeid="); sb.Append(curDoc.NodeID); sb.Append("&culture="); sb.Append(curDoc.DocumentCulture); sb.Append(ApplicationUrlHelper.GetApplicationHash("cms.content", "content")); } sb.Append("\">"); // Text link if (String.IsNullOrEmpty(ImageURL)) { sb.Append(LinkText); } // Image link else { sb.Append("<img src=\""); sb.Append(UrlResolver.ResolveUrl(ImageURL)); sb.Append("\" alt=\""); sb.Append(HTMLHelper.HTMLEncode(LinkText)); sb.Append("\" title=\""); sb.Append(HTMLHelper.HTMLEncode(LinkText)); sb.Append("\" />"); } sb.Append("</a>"); ltlEditLink.Text = sb.ToString(); } } }
/// <summary> /// Click event of btnOk. /// </summary> /// <param name="sender">Sender</param> /// <param name="e">Arguments</param> protected void btnReset_Click(object sender, EventArgs e) { if ((passStrength.Text.Length > 0) && rfvConfirmPassword.IsValid) { if (passStrength.Text == txtConfirmPassword.Text) { // Check policy if (passStrength.IsValid()) { int userId = GetResetRequestID(); // Check if password expired if (pwdExp > 0) { UserInfo ui = UserInfoProvider.GetUserInfo(userId); if (!UserInfoProvider.IsUserPasswordDifferent(ui, passStrength.Text)) { ShowError(GetString("passreset.newpasswordrequired")); return; } } // Get e-mail address of sender string emailFrom = DataHelper.GetNotEmpty(SendEmailFrom, SettingsKeyInfoProvider.GetValue("CMSSendPasswordEmailsFrom", siteName)); // Try to reset password and show result to user bool success; string resultText = AuthenticationHelper.ResetPassword(hash, time, userId, interval, passStrength.Text, "Reset password control", emailFrom, siteName, null, out success, InvalidRequestText, ExceededIntervalText); // If password reset was successful if (success) { ClearResetRequestID(); // Redirect to specified URL if (!string.IsNullOrEmpty(RedirectUrl)) { URLHelper.Redirect(RedirectUrl); } // Get proper text ShowConfirmation(DataHelper.GetNotEmpty(SuccessText, resultText)); pnlReset.Visible = false; lblLogonLink.Text = String.Format(GetString("memberhsip.logonlink"), HTMLHelper.EncodeForHtmlAttribute(returnUrl)); } else { ShowError(resultText); } } else { ShowError(AuthenticationHelper.GetPolicyViolationMessage(SiteContext.CurrentSiteName)); } } else { ShowError(GetString("passreset.notmatch")); } } else { ShowError(GetString("general.requiresvalue")); } }
/// <summary> /// Sets image url, width and height. /// </summary> protected void SetImage() { Visible = false; // Only if display picture is allowed if (DisplayPicture) { string imageUrl = ResolveUrl("~/CMSPages/GetAvatar.aspx?avatarguid="); bool isGravatar = false; // Is user id set? => Get user info if (mUserId > 0) { // Get user info UserInfo ui = UserInfoProvider.GetUserInfo(mUserId); if (ui != null) { switch (UserAvatarType) { case AvatarInfoProvider.AVATAR: AvatarID = ui.UserAvatarID; if (AvatarID <= 0) // Backward compatibility { if (ui.UserPicture != "") { // Get picture filename string filename = ui.UserPicture.Remove(ui.UserPicture.IndexOfCSafe('/')); string ext = Path.GetExtension(filename); imageUrl += filename.Substring(0, (filename.Length - ext.Length)); imageUrl += "&extension=" + ext; Visible = true; } else if (UseDefaultAvatar) { UserGenderEnum gender = (UserGenderEnum)ValidationHelper.GetInteger(ui.UserSettings.UserGender, 0); AvatarInfo ai = AvatarInfoProvider.GetDefaultAvatar(gender); if (ai != null) { AvatarID = ai.AvatarID; } } } break; case AvatarInfoProvider.GRAVATAR: int sideSize = mWidth > 0 ? mWidth : SettingsKeyInfoProvider.GetIntValue(SiteContext.CurrentSiteName + ".CMSAvatarMaxSideSize"); imageUrl = AvatarInfoProvider.CreateGravatarLink(ui.Email, ui.UserSettings.UserGender, sideSize, SiteContext.CurrentSiteName); isGravatar = true; Visible = true; AvatarID = 0; break; } } } else { // If user is public try get his gravatar if (UserAvatarType == AvatarInfoProvider.GRAVATAR) { int sideSize = mWidth > 0 ? mWidth : SettingsKeyInfoProvider.GetIntValue(SiteContext.CurrentSiteName + ".CMSAvatarMaxSideSize"); imageUrl = AvatarInfoProvider.CreateGravatarLink(UserEmail, (int)UserGenderEnum.Unknown, sideSize, SiteContext.CurrentSiteName); isGravatar = true; Visible = true; AvatarID = 0; } } // Is group id set? => Get group info if (mGroupId > 0) { // Get group info trough module commands GeneralizedInfo gi = ModuleCommands.CommunityGetGroupInfo(mGroupId); if (gi != null) { AvatarID = ValidationHelper.GetInteger(gi.GetValue("GroupAvatarID"), 0); } if ((AvatarID <= 0) && UseDefaultAvatar) { AvatarInfo ai = AvatarInfoProvider.GetDefaultAvatar(DefaultAvatarTypeEnum.Group); if (ai != null) { AvatarID = ai.AvatarID; } } } if (AvatarID > 0) { AvatarInfo ai = AvatarInfoProvider.GetAvatarInfoWithoutBinary(AvatarID); if (ai != null) { imageUrl += ai.AvatarGUID.ToString(); imageUrl = URLHelper.AppendQuery(imageUrl, "lastModified=" + SecurityHelper.GetSHA2Hash(ai.AvatarLastModified.ToString())); Visible = true; } } // If item was found if (Visible) { if (!isGravatar) { if (KeepAspectRatio) { imageUrl += "&maxsidesize=" + (Width > Height ? Width : Height); } else { imageUrl += "&width=" + Width + "&height=" + Height; } } imageUrl = HTMLHelper.EncodeForHtmlAttribute(imageUrl); ltlImage.Text = "<img alt=\"" + GetString("general.avatar") + "\" src=\"" + imageUrl + "\" />"; // Render outer div with specific CSS class if (RenderOuterDiv) { ltlImage.Text = "<div class=\"" + OuterDivCSSClass + "\">" + ltlImage.Text + "</div>"; } } } }
/// <summary> /// Initializes the control properties. /// </summary> protected override void SetupControl() { if (StopProcessing) { // Do not process } else { StringBuilder sb = new StringBuilder(); //Configure widget sb.Append("<a class=\"twitter-timeline\" href=\"https://twitter.com/", HTMLHelper.EncodeForHtmlAttribute(URLHelper.URLEncode(Username)), "\" data-widget-id=\"", HTMLHelper.EncodeForHtmlAttribute(WidgetID)); //Chrome setup StringBuilder chromeString = new StringBuilder(); chromeString.Append(Transparent ? "transparent " : ""); chromeString.Append(!DisplayBorders ? "noborders " : ""); chromeString.Append(!DisplayHeader ? "noheader " : ""); chromeString.Append(!DisplayFooter ? "nofooter " : ""); chromeString.Append(!Scrollbar ? "noscrollbar " : ""); if (!String.IsNullOrEmpty(chromeString.ToString())) { sb.Append("\" data-chrome=\"", chromeString.ToString().Trim()); } sb.Append("\" width=\"", Width, "\" height=\"", Height); if (NumberOfTweets > 0) { sb.Append("\" data-tweet-limit=\"", NumberOfTweets); } if (!String.IsNullOrEmpty(Theme)) { sb.Append("\" data-theme=\"", Theme.ToLowerCSafe()); } if (!String.IsNullOrEmpty(LinkColor)) { sb.Append("\" data-link-color=\"", LinkColor.ToLowerCSafe()); } if (!String.IsNullOrEmpty(BorderColor)) { sb.Append("\" data-border-color=\"", BorderColor.ToLowerCSafe()); } sb.Append("\">Tweets by @", HTMLHelper.HTMLEncode(Username), "</a>\n"); //widhet generating script sb.Append("<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+\"://platform.twitter.com/widgets.js\";fjs.parentNode.insertBefore(js,fjs);}}(document,\"script\",\"twitter-wjs\");</script>"); // Set plugin code ltlPluginCode.Text = sb.ToString(); } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do not process } else { var uinfo = MembershipContext.AuthenticatedUser; if (uinfo.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin) || !DisplayOnlyToGlobalAdministrator) { // Create new string builder for links StringBuilder sb = new StringBuilder(); // Store current site name string curSiteName = SiteContext.CurrentSiteName; // Get default user name string queryStringKey = (string.IsNullOrEmpty(DefaultUserName)) ? null : "?username="******"~/Admin/"); if (!string.IsNullOrEmpty(DefaultUserName)) { url = URLHelper.AddParameterToUrl(url, "username", DefaultUserName); } sb.AppendFormat(CMSDeskText, string.Concat("<a href=\"", HTMLHelper.EncodeForHtmlAttribute(url), "\">", CMSDeskLinkText, "</a>")); separatorNeeded = true; } // If edit document link is shown if (ShowEditDocumentLink && (!CheckPermissions || (uinfo.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Editor, curSiteName) && CMSPage.IsUserAuthorizedPerContent() && (uinfo.IsAuthorizedPerDocument(DocumentContext.CurrentDocument, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Allowed)))) { // Check if separator needed if (separatorNeeded) { sb.Append(" " + Separator + " "); } string url = HTMLHelper.EncodeForHtmlAttribute(DocumentUIHelper.GetDocumentEditUrl(DocumentContext.CurrentDocument.NodeID, DocumentContext.CurrentDocumentCulture.CultureCode)); if (PreferOnSiteEdit && PortalHelper.IsOnSiteEditingEnabled(CurrentSiteName)) { url = UrlResolver.ResolveUrl(PortalHelper.OnSiteEditRelativeURL); string retUrl = RequestContext.CurrentURL; // handle default alias path if ((ViewMode == CMS.PortalEngine.ViewModeEnum.LiveSite) && (URLRewritingContext.CurrentPageInfoSource == PageInfoSource.DefaultAliasPath)) { string aliasPath = PageInfoProvider.GetDefaultAliasPath(RequestContext.CurrentDomain, SiteContext.CurrentSiteName); if (!String.IsNullOrEmpty(aliasPath)) { string query = URLHelper.GetQuery(retUrl); retUrl = UrlResolver.ResolveUrl(DocumentURLProvider.GetUrl(aliasPath)); retUrl = URLHelper.AppendQuery(retUrl, query); } } url = URLHelper.UpdateParameterInUrl(url, "editurl", HttpUtility.UrlEncode(retUrl)); } sb.AppendFormat(EditDocumentText, string.Concat("<a href=\"", HTMLHelper.EncodeForHtmlAttribute(url), "\">", EditDocumentLinkText, "</a>")); } ltlAdminActions.Text = sb.ToString(); } } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { GroupInfo group = null; // Try to get group information from query string int groupId = QueryHelper.GetInteger("groupid", 0); group = (groupId > 0) ? GroupInfoProvider.GetGroupInfo(groupId) : CommunityContext.CurrentGroup; if (group != null) { // Check whether group is approved if (!group.GroupApproved) { lblAccessInfo.Text = GetString("group.groupnotavailable"); } else { // Check permissions for current user switch (group.GroupAccess) { // Anybody can view the content default: case SecurityAccessEnum.AllUsers: // If content for selected group is available for all users redirect back to group page RedirectToGroupPage(group); break; // Site members can view the content case SecurityAccessEnum.AuthenticatedUsers: if (!AuthenticationHelper.IsAuthenticated()) { lblAccessInfo.Text = String.Format(SiteMembersOnlyText, "<a title=\"Sign in\" href=\"" + URLHelper.UpdateParameterInUrl(LoginURL, "returnurl", HTMLHelper.EncodeForHtmlAttribute(RequestContext.CurrentURL)) + "\">", "</a>"); } else { RedirectToGroupPage(group); } break; // Only group members can view the content case SecurityAccessEnum.GroupMembers: if (!MembershipContext.AuthenticatedUser.IsGroupMember(group.GroupID)) { // If current user is public show text with sign in link if (!AuthenticationHelper.IsAuthenticated()) { lblAccessInfo.Text = String.Format(GroupMembersOnlyText, "<a title=\"Sign in\" href=\"" + URLHelper.UpdateParameterInUrl(LoginURL, "returnurl", HTMLHelper.EncodeForHtmlAttribute(RequestContext.CurrentURL)) + "\">", "</a>"); } else { // For authenticate users display text with join the group text string link = string.Empty; // If join group path is defined use it, otherwise display join the group dialog if (String.IsNullOrEmpty(JoinGroupPath)) { // Register the dialog script ScriptHelper.RegisterDialogScript(Page); string script = ScriptHelper.GetScript("function JoinToGroupAccessRequest() {\n" + "modalDialog('" + AuthenticationHelper.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/JoinTheGroup.aspx") + "?groupid=" + group.GroupID + "','requestJoinToGroup', 500, 180); \n" + " } \n"); ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "JoinToGroupAccessRequest", script); link = "<a title=\"" + GetString("group.joingroup") + "\" href=\"" + HTMLHelper.EncodeForHtmlAttribute(RequestContext.CurrentURL) + "\" onclick=\"JoinToGroupAccessRequest(); return false;\">"; } else { link = "<a title=\"" + GetString("group.joingroup") + "\" href=\"" + JoinGroupPath + "\">"; } lblAccessInfo.Text = String.Format(GroupMembersOnlyAuthenticatedText, link, "</a>"); } } else { RedirectToGroupPage(group); } break; } } } else { Visible = false; } } }
protected void Page_Load(object sender, EventArgs e) { ScriptHelper.RegisterDialogScript(Page); if (SelectedSite == null) { lnkGenerate.Enabled = lnkInvalidate.Enabled = false; return; } lnkGenerate.OnClientClick = "modalDialog('" + UrlResolver.ResolveUrl("~/CMSModules/REST/FormControls/GenerateHash.aspx") + "' , 'GenerateAuthHash', 800, 410); return false;"; lnkInvalidate.OnClientClick = $"return confirm('{ResHelper.GetStringFormat("rest.invalidatehash.confirmation", HTMLHelper.EncodeForHtmlAttribute(SelectedSite.DisplayName))}');"; lnkInvalidate.Click += (s, args) => { SettingsKeyInfoProvider.SetValue("CMSRESTUrlHashSalt", SelectedSite.SiteName, Guid.NewGuid()); lblInvalidate.Visible = true; }; lblInvalidate.Text = ResHelper.GetStringFormat("rest.invalidatehash.message", HTMLHelper.HTMLEncode(SelectedSite.DisplayName)); }