/// <summary> /// Called by the framework when the component needs to be rendered as HTML. /// </summary> /// <param name="model">The model being rendered by the component.</param> /// <returns>The component rendered as HTML.</returns> public Task <string> RenderAsync(string model) { HtmlBuilder sb = new HtmlBuilder(); YTagBuilder tagLabel = new YTagBuilder("label"); FieldSetup(tagLabel, FieldType.Anonymous); if (string.IsNullOrEmpty(model)) // we're distinguishing between "" and " " { tagLabel.InnerHtml = " "; } else { tagLabel.SetInnerText(model); } sb.Append(tagLabel.ToString(YTagRenderMode.Normal)); string helpLink; if (TryGetSiblingProperty <string>($"{PropertyName}_HelpLink", out helpLink) && !string.IsNullOrWhiteSpace(helpLink)) { YTagBuilder tagA = new YTagBuilder("a"); tagA.Attributes.Add("href", Utility.UrlEncodePath(helpLink)); tagA.Attributes.Add("target", "_blank"); tagA.MergeAttribute("rel", "noopener noreferrer"); tagA.AddCssClass(Manager.AddOnManager.CheckInvokedCssModule("yt_extlabel_img")); tagA.InnerHtml = ImageHTML.BuildKnownIcon("#Help"); sb.Append(tagA.ToString(YTagRenderMode.Normal)); } return(Task.FromResult(sb.ToString())); }
/// <summary> /// Called by the framework when the component needs to be rendered as HTML. /// </summary> /// <param name="model">The model being rendered by the component.</param> /// <returns>The component rendered as HTML.</returns> public Task <string> RenderAsync(object model) { YTagBuilder tag = new YTagBuilder("span"); FieldSetup(tag, FieldType.Anonymous); tag.InnerHtml = ImageHTML.BuildKnownIcon("#RemoveLight", title: __ResStr("altRemove", "Remove"), name: "DeleteAction"); return(Task.FromResult(tag.ToString(YTagRenderMode.Normal))); }
/// <summary> /// Called by the framework when the component needs to be rendered as HTML. /// </summary> /// <param name="model">The model being rendered by the component.</param> /// <returns>The component rendered as HTML.</returns> public async Task <string> RenderAsync(Guid?model) { HtmlBuilder hb = new HtmlBuilder(); // dropdown List <SelectionItem <string> > list; list = ( from p in await PageDefinition.GetDesignedPagesAsync() orderby p.Url select new SelectionItem <string> { Text = p.Url, Value = p.PageGuid.ToString(), }).ToList <SelectionItem <string> >(); list.Insert(0, new SelectionItem <string> { Text = __ResStr("select", "(select)"), Value = null }); string ddList = await DropDownListComponent.RenderDropDownListAsync(this, (model ?? Guid.Empty).ToString(), list, null); // link YTagBuilder tag = new YTagBuilder("a"); PageDefinition page = null; if (model != null) { page = await PageDefinition.LoadAsync((Guid)model); } tag.MergeAttribute("href", (page != null ? page.EvaluatedCanonicalUrl : "")); tag.MergeAttribute("target", "_blank"); tag.MergeAttribute("rel", "nofollow noopener noreferrer"); tag.Attributes.Add(Basics.CssTooltip, __ResStr("linkTT", "Click to preview the page in a new window - not all pages can be displayed correctly and may require additional parameters")); tag.InnerHtml = tag.InnerHtml + ImageHTML.BuildKnownIcon("#PagePreview", sprites: Info.PredefSpriteIcons); string linkTag = tag.ToString(YTagRenderMode.Normal); hb.Append($@" <div id='{DivId}' class='yt_pageselection t_edit'> <div class='t_select'> {ddList.ToString()} </div> <div class='t_link'> {linkTag} </div> <div class='t_description'> </div> </div>"); Manager.ScriptManager.AddLast($@"new YetaWF_ComponentsHTML.PageSelectionEditComponent('{DivId}');"); return(hb.ToString()); }
/// <summary> /// Called by the framework when the component needs to be rendered as HTML. /// </summary> /// <param name="model">The model being rendered by the component.</param> /// <returns>The component rendered as HTML.</returns> public async Task <string> RenderAsync(object model) { HtmlBuilder hb = new HtmlBuilder(); string text; if (model is MultiString) { text = (MultiString)model; } else { text = (string)model; } bool copy = PropData.GetAdditionalAttributeValue <bool>("Copy", true); if (!string.IsNullOrWhiteSpace(text)) { int emHeight = PropData.GetAdditionalAttributeValue("EmHeight", 10); YTagBuilder tag = new YTagBuilder("textarea"); tag.AddCssClass("yt_textareasourceonly"); tag.AddCssClass("t_display"); tag.AddCssClass("k-textbox"); // USE KENDO style //tag.AddCssClass("k-state-disabled"); // USE KENDO style FieldSetup(tag, FieldType.Anonymous); tag.Attributes.Add("id", ControlId); tag.Attributes.Add("rows", emHeight.ToString()); if (copy) { tag.Attributes.Add("readonly", "readonly"); } else { tag.Attributes.Add("disabled", "disabled"); } tag.SetInnerText(text); hb.Append(tag.ToString(YTagRenderMode.Normal)); if (copy) { hb.Append(ImageHTML.BuildKnownIcon("#TextAreaSourceOnlyCopy", sprites: Info.PredefSpriteIcons, title: __ResStr("ttCopy", "Copy to Clipboard"), cssClass: "yt_textareasourceonly_copy")); } } if (copy) { await Manager.AddOnManager.AddAddOnNamedAsync(Package.AreaName, "clipboardjs.com.clipboard");// add clipboard support } return(hb.ToString()); }
internal string GetModuleLink(Guid?model, bool force = false) { if (!force) { if (model == null || model == Guid.Empty) { return(""); } } YTagBuilder tag = new YTagBuilder("a"); tag.MergeAttribute("href", ModuleDefinition.GetModulePermanentUrl(model ?? Guid.Empty)); tag.MergeAttribute("target", "_blank"); tag.MergeAttribute("rel", "nofollow noopener noreferrer"); tag.Attributes.Add(Basics.CssTooltip, __ResStr("linkTT", "Click to preview the module in a new window - not all modules can be displayed correctly and may require additional parameters")); tag.InnerHtml = tag.InnerHtml + ImageHTML.BuildKnownIcon("#ModulePreview", sprites: Info.PredefSpriteIcons); return(tag.ToString(YTagRenderMode.Normal)); }
/// <summary> /// Renders a complete module menu. /// </summary> /// <param name="mod">The module for which the module menu is rendered.</param> /// <returns>Returns the complete module menu as HTML.</returns> public async Task <string> RenderModuleMenuAsync(ModuleDefinition mod) { HtmlBuilder hb = new HtmlBuilder(); MenuList moduleMenu = await mod.GetModuleMenuListAsync(ModuleAction.RenderModeEnum.NormalMenu, ModuleAction.ActionLocationEnum.ModuleMenu); string menuContents = (await RenderMenuAsync(moduleMenu, null, Globals.CssModuleMenu)); if (!string.IsNullOrWhiteSpace(menuContents)) { //await Manager.ScriptManager.AddKendoUICoreJsFile("kendo.popup.min.js"); // is now a prereq of kendo.window (2017.2.621) await KendoUICore.AddFileAsync("kendo.menu.min.js"); await Manager.AddOnManager.AddAddOnNamedAsync(Package.AreaName, "ModuleMenu"); // module menu support await Manager.AddOnManager.AddAddOnNamedAsync(Package.AreaName, "Modules"); // various module support await Manager.AddOnManager.AddAddOnNamedAsync(Package.AreaName, "jquery-color"); // for color change when entering module edit menu // <div class= > YTagBuilder divTag = new YTagBuilder("div"); divTag.AddCssClass(Manager.AddOnManager.CheckInvokedCssModule(Globals.CssModuleMenuEditIcon)); divTag.Attributes.Add("style", "display:none"); hb.Append(divTag.ToString(YTagRenderMode.StartTag)); hb.Append(ImageHTML.BuildKnownIcon("#ModuleMenuEdit", sprites: Info.PredefSpriteIcons, title: null /*no tooltip here as it's useless */)); // <div> YTagBuilder div2Tag = new YTagBuilder("div"); div2Tag.AddCssClass(Manager.AddOnManager.CheckInvokedCssModule(Globals.CssModuleMenuContainer)); hb.Append(div2Tag.ToString(YTagRenderMode.StartTag)); // <ul><li> menu hb.Append(menuContents); // </div> hb.Append(div2Tag.ToString(YTagRenderMode.EndTag)); // </div> hb.Append(divTag.ToString(YTagRenderMode.EndTag)); } return(hb.ToString()); }
/// <summary> /// Called by the framework when the component needs to be rendered as HTML. /// </summary> /// <param name="model">The model being rendered by the component.</param> /// <returns>The component rendered as HTML.</returns> public async Task <string> RenderAsync(string model) { HtmlBuilder hb = new HtmlBuilder(); bool copy = PropData.GetAdditionalAttributeValue <bool>("Copy", true); bool rdonly = PropData.GetAdditionalAttributeValue <bool>("ReadOnly", false); YTagBuilder tag = new YTagBuilder("input"); tag.AddCssClass(TemplateClass); // adding k-textbox to the control makes it look like a kendo maskedtext box without the overhead of actually calling kendoMaskedTextBox tag.AddCssClass("k-textbox"); tag.AddCssClass("t_display"); tag.AddCssClass("k-state-disabled"); // USE KENDO style FieldSetup(tag, FieldType.Anonymous); tag.MergeAttribute("type", "text"); tag.MergeAttribute("value", model ?? ""); if (copy || rdonly) { tag.MergeAttribute("readonly", "readonly"); } else { tag.MergeAttribute("disabled", "disabled"); } hb.Append(tag.ToString(YTagRenderMode.StartTag)); if (copy) { await Manager.AddOnManager.AddAddOnNamedAsync(Package.AreaName, "clipboardjs.com.clipboard");// add clipboard support hb.Append(ImageHTML.BuildKnownIcon("#TextCopy", sprites: Info.PredefSpriteIcons, title: __ResStr("ttCopy", "Copy to Clipboard"), cssClass: "yt_text_copy")); } //Manager.ScriptManager.AddLast($@"new YetaWF_ComponentsHTML.TextDisplayComponent('{ControlId}');"); return(hb.ToString()); }
/// <summary> /// Called by the framework when the component needs to be rendered as HTML. /// </summary> /// <param name="model">The model being rendered by the component.</param> /// <returns>The component rendered as HTML.</returns> public Task <string> RenderAsync(string model) { if (string.IsNullOrWhiteSpace(model)) { return(Task.FromResult <string>(null)); } HtmlBuilder hb = new HtmlBuilder(); hb.Append("<div class='yt_url t_display'>"); string hrefUrl; if (!TryGetSiblingProperty($"{PropertyName}_Url", out hrefUrl)) { hrefUrl = model; } if (string.IsNullOrWhiteSpace(hrefUrl)) { // no link YTagBuilder tag = new YTagBuilder("span"); FieldSetup(tag, FieldType.Anonymous); string cssClass = PropData.GetAdditionalAttributeValue("CssClass", ""); if (!string.IsNullOrWhiteSpace(cssClass)) { tag.AddCssClass(Manager.AddOnManager.CheckInvokedCssModule(cssClass)); } tag.SetInnerText(model); hb.Append(tag.ToString(YTagRenderMode.Normal)); } else { // link YTagBuilder tag = new YTagBuilder("a"); FieldSetup(tag, FieldType.Anonymous); string cssClass = PropData.GetAdditionalAttributeValue("CssClass", ""); if (!string.IsNullOrWhiteSpace(cssClass)) { tag.AddCssClass(Manager.AddOnManager.CheckInvokedCssModule(cssClass)); } tag.MergeAttribute("href", hrefUrl); tag.MergeAttribute("target", "_blank"); tag.MergeAttribute("rel", "nofollow noopener noreferrer"); string text; if (!TryGetSiblingProperty($"{PropertyName}_Text", out text)) { text = model; } tag.SetInnerText(text); string tooltip = null; TryGetSiblingProperty($"{PropertyName}_ToolTip", out tooltip); if (!string.IsNullOrWhiteSpace(tooltip)) { tag.MergeAttribute(Basics.CssTooltip, tooltip); } // image if (PropData.GetAdditionalAttributeValue("ShowImage", true)) { tag.InnerHtml = tag.InnerHtml + ImageHTML.BuildKnownIcon("#UrlRemote", sprites: Info.PredefSpriteIcons); } hb.Append(tag.ToString(YTagRenderMode.Normal)); } hb.Append("</div>"); return(Task.FromResult(hb.ToString())); }
/// <summary> /// Called by the framework when the component needs to be rendered as HTML. /// </summary> /// <param name="model">The model being rendered by the component.</param> /// <returns>The component rendered as HTML.</returns> public async Task <string> RenderAsync(string model) { HtmlBuilder hb = new HtmlBuilder(); UrlTypeEnum type = PropData.GetAdditionalAttributeValue("UrlType", UrlTypeEnum.Remote); UrlUI ui = new UrlUI { UrlType = type, _Local = model, _Remote = model, }; hb.Append($@" <div id='{ControlId}' class='yt_url t_edit'>"); YTagBuilder tag = new YTagBuilder("input"); tag.AddCssClass("t_hidden"); tag.Attributes["type"] = "hidden"; FieldSetup(tag, FieldType.Validated); tag.MergeAttribute("value", model); hb.Append(tag.ToString(YTagRenderMode.StartTag)); using (Manager.StartNestedComponent(FieldName)) { hb.Append($@" {await HtmlHelper.ForEditAsync(ui, nameof(ui.UrlType), Validation: false)} "); if ((type & UrlTypeEnum.Local) != 0) { hb.Append($@" <div class='t_local'> {await HtmlHelper.ForEditAsync(ui, nameof(ui._Local), Validation: false)} </div>"); } if ((type & UrlTypeEnum.Remote) != 0) { hb.Append($@" <div class='t_remote'> {await HtmlHelper.ForEditAsync(ui, nameof(ui._Remote), Validation: false)} </div>"); } } // link tag = new YTagBuilder("a"); tag.MergeAttribute("href", Utility.UrlEncodePath(model)); tag.MergeAttribute("target", "_blank"); tag.MergeAttribute("rel", "nofollow noopener noreferrer"); tag.InnerHtml = tag.InnerHtml + ImageHTML.BuildKnownIcon("#UrlRemote", sprites: Info.PredefSpriteIcons); string link = tag.ToString(YTagRenderMode.Normal); UrlEditSetup setup = new UrlEditSetup { Type = type, Url = model, }; hb.Append($@" <div class='t_link'> {link} </div> </div>"); Manager.ScriptManager.AddLast($"new YetaWF_ComponentsHTML.UrlEditComponent('{ControlId}', {Utility.JsonSerialize(setup)});"); return(hb.ToString()); }
/// <summary> /// Renders a text input control. /// </summary> /// <param name="component">The current component being rendered.</param> /// <param name="model">The model.</param> /// <param name="templateCssClass">The CSS class to add to the template (starting with yt_).</param> /// <returns>The component rendered as HTML.</returns> public static async Task <string> RenderTextAsync(YetaWFComponent component, string model, string templateCssClass) { await IncludeExplicitAsync(); HtmlBuilder hb = new HtmlBuilder(); component.UseSuppliedIdAsControlId(); YTagBuilder tag = new YTagBuilder("input"); if (!string.IsNullOrWhiteSpace(templateCssClass)) { tag.AddCssClass(templateCssClass); } tag.AddCssClass("yt_text_base"); // adding k-textbox to the control makes it look like a kendo maskedtext box without the overhead of actually calling kendoMaskedTextBox tag.AddCssClass("k-textbox"); tag.AddCssClass("t_edit"); component.FieldSetup(tag, component.Validation ? FieldType.Validated : FieldType.Normal); tag.Attributes.Add("id", component.ControlId); //string id = null; //if (!string.IsNullOrWhiteSpace(mask)) { // id = component.MakeId(tag); //} if (Manager.CurrentModule != null && Manager.CurrentModule.FormAutoComplete) { tag.MergeAttribute("autocomplete", "on", replaceExisting: false); } else { tag.MergeAttribute("autocomplete", "new-password", replaceExisting: false); } bool copy = component.PropData.GetAdditionalAttributeValue <bool>("Copy", false); //string mask = component.PropData.GetAdditionalAttributeValue<string>("Mask", null); // handle StringLengthAttribute as maxlength StringLengthAttribute lenAttr = component.PropData.TryGetAttribute <StringLengthAttribute>(); if (lenAttr != null) { #if DEBUG if (tag.Attributes.ContainsKey("maxlength")) { throw new InternalError("Both StringLengthAttribute and maxlength specified - {0}", component.FieldName); } #endif int maxLength = lenAttr.MaximumLength; if (maxLength > 0 && maxLength <= 8000) { tag.MergeAttribute("maxlength", maxLength.ToString()); } } #if DEBUG if (lenAttr == null && !tag.Attributes.ContainsKey("maxlength")) { throw new InternalError("No max string length given using StringLengthAttribute or maxlength - {0}", component.FieldName); } #endif // text tag.MergeAttribute("type", "text"); tag.MergeAttribute("value", model ?? ""); hb.Append($@"{tag.ToString(YTagRenderMode.StartTag)}"); if (copy) { await Manager.AddOnManager.AddAddOnNamedAsync(component.Package.AreaName, "clipboardjs.com.clipboard");// add clipboard support hb.Append(ImageHTML.BuildKnownIcon("#TextCopy", sprites: Info.PredefSpriteIcons, title: __ResStr("ttCopy", "Copy to Clipboard"), cssClass: "yt_text_copy")); } //if (!string.IsNullOrWhiteSpace(mask)) { // // if there is a Mask we need to use the KendoMaskedTextBox // await KendoUICore.AddFileAsync("kendo.maskedtextbox.min.js"); // ScriptBuilder sb = new ScriptBuilder(); // sb.Append("$('#{0}').kendoMaskedTextBox({{ mask: '{1}' }});\n", id, Utility.JserEncode(mask)); // Manager.ScriptManager.AddLastDocumentReady(sb); //} //Manager.ScriptManager.AddLast($@"new YetaWF_ComponentsHTML.TextEditComponent('{component.ControlId}');"); return(hb.ToString()); }
public async Task <string> RenderAsync(int model) { HtmlBuilder hb = new HtmlBuilder(); string type = PropData.GetAdditionalAttributeValue <string>("Force", null); if (type == "Grid" || (await IsLargeUserBaseAsync() && type != "DropDown")) { string hiddenId = UniqueId(); string allId = UniqueId(); string nameId = UniqueId(); string noUser = __ResStr("noUser", "(none)"); bool header = PropData.GetAdditionalAttributeValue("Header", true); UserIdUI ui = new UserIdUI { UserId = model, }; using (UserDefinitionDataProvider userDP = new UserDefinitionDataProvider()) { UserDefinition user = await userDP.GetItemByUserIdAsync(model); if (user == null) { ui.UserName = __ResStr("noUser", "(none)"); } else { ui.UserName = user.UserName; } } ui.AllUsers = GetGridAllUsersModel(header); ui.AllUsers.Id = allId; hb.Append($@" <div class='yt_yetawf_identity_userid t_large t_edit' id='{DivId}'> {await HtmlHelper.ForEditComponentAsync(Container, PropertyName, model, "Hidden", HtmlAttributes: new { id = hiddenId, __NoTemplate = true })}"); using (Manager.StartNestedComponent(FieldName)) { hb.Append($@" <div class='t_name'> {await HtmlHelper.ForDisplayAsync(ui, nameof(ui.UserName), HtmlAttributes: new { id = nameId })} {ImageHTML.BuildKnownIcon("#RemoveLight", title: __ResStr("ttClear", "Clear the current selection"), cssClass: "t_clear")} </div> {await HtmlHelper.ForLabelAsync(ui, nameof(ui.AllUsers))} {await HtmlHelper.ForDisplayAsync(ui, nameof(ui.AllUsers))}"); } hb.Append($@" </div>"); UserIdSetup setup = new UserIdSetup { GridAllId = ui.AllUsers.Id, HiddenId = hiddenId, NameId = nameId, NoUser = noUser, }; Manager.ScriptManager.AddLast($@"new YetaWF_Identity.UserIdEditComponent('{DivId}', {Utility.JsonSerialize(setup)});"); } else { hb.Append($@" <div class='yt_yetawf_identity_userid t_small t_edit'>"); using (UserDefinitionDataProvider userDP = new UserDefinitionDataProvider()) { List <DataProviderSortInfo> sorts = null; DataProviderSortInfo.Join(sorts, new DataProviderSortInfo { Field = nameof(UserDefinition.UserName), Order = DataProviderSortInfo.SortDirection.Ascending }); DataProviderGetRecords <UserDefinition> recs = await userDP.GetItemsAsync(0, MAXUSERS, sorts, null); List <SelectionItem <int> > list = (from u in recs.Data select new SelectionItem <int> { Text = u.UserName, Value = u.UserId, }).ToList(); list.Insert(0, new SelectionItem <int> { Text = __ResStr("select", "(select)"), Value = 0, }); hb.Append(await DropDownListIntComponent.RenderDropDownListAsync(this, model, list, null)); } hb.Append($@" </div>"); } return(hb.ToString()); }
internal static async Task <string> RenderActionAsync(ModuleAction action, ModuleAction.RenderModeEnum mode, string id, ModuleAction.RenderEngineEnum RenderEngine = ModuleAction.RenderEngineEnum.KendoMenu, int BootstrapSmartMenuLevel = 0, bool HasSubmenu = false) { // check if we're in the right mode if (!await action.RendersSomethingAsync()) { return(null); } await Manager.AddOnManager.AddTemplateFromUIHintAsync("ActionIcons");// this is needed because we're not used by templates if (!string.IsNullOrWhiteSpace(action.ConfirmationText) && (action.Style != ModuleAction.ActionStyleEnum.Post && action.Style != ModuleAction.ActionStyleEnum.Nothing)) { throw new InternalError("When using ConfirmationText, the Style property must be set to Post"); } if (!string.IsNullOrWhiteSpace(action.PleaseWaitText) && (action.Style != ModuleAction.ActionStyleEnum.Normal && action.Style != ModuleAction.ActionStyleEnum.Post)) { throw new InternalError("When using PleaseWaitText, the Style property must be set to Normal or Post"); } if (action.CookieAsDoneSignal && action.Style != ModuleAction.ActionStyleEnum.Normal) { throw new InternalError("When using CookieAsDoneSignal, the Style property must be set to Normal"); } ModuleAction.ActionStyleEnum style = action.Style; if (style == ModuleAction.ActionStyleEnum.OuterWindow) { if (!Manager.IsInPopup) { style = ModuleAction.ActionStyleEnum.Normal; } } if (style == ModuleAction.ActionStyleEnum.Popup || style == ModuleAction.ActionStyleEnum.PopupEdit) { if (Manager.IsInPopup) { style = ModuleAction.ActionStyleEnum.NewWindow; } } if (style == ModuleAction.ActionStyleEnum.Popup || style == ModuleAction.ActionStyleEnum.PopupEdit || style == ModuleAction.ActionStyleEnum.ForcePopup) { await YetaWFCoreRendering.Render.AddPopupsAddOnsAsync(); } bool newWindow = false, outerWindow = false; bool popup = false, popupEdit = false; bool nothing = false, post = false; switch (style) { default: case ModuleAction.ActionStyleEnum.Normal: break; case ModuleAction.ActionStyleEnum.NewWindow: newWindow = true; break; case ModuleAction.ActionStyleEnum.Popup: case ModuleAction.ActionStyleEnum.ForcePopup: popup = Manager.CurrentSite.AllowPopups; break; case ModuleAction.ActionStyleEnum.PopupEdit: popup = Manager.CurrentSite.AllowPopups; popupEdit = Manager.CurrentSite.AllowPopups; break; case ModuleAction.ActionStyleEnum.OuterWindow: outerWindow = true; break; case ModuleAction.ActionStyleEnum.Nothing: nothing = true; break; case ModuleAction.ActionStyleEnum.Post: post = true; break; } YTagBuilder tag = new YTagBuilder("a"); if (!string.IsNullOrWhiteSpace(action.Tooltip)) { tag.MergeAttribute(Basics.CssTooltip, action.Tooltip); } if (!string.IsNullOrWhiteSpace(action.Name)) { tag.MergeAttribute("data-name", action.Name); } if (!action.Displayed) { tag.MergeAttribute("style", "display:none"); } if (HasSubmenu) { if (RenderEngine == ModuleAction.RenderEngineEnum.BootstrapSmartMenu) { tag.AddCssClass("dropdown-toggle"); tag.Attributes.Add("data-toggle", "dropdown-toggle"); } tag.Attributes.Add("aria-haspopup", "true"); tag.Attributes.Add("aria-expanded", "false"); } if (RenderEngine == ModuleAction.RenderEngineEnum.BootstrapSmartMenu) { tag.AddCssClass(BootstrapSmartMenuLevel <= 1 ? "nav-link" : "dropdown-item"); } if (!string.IsNullOrWhiteSpace(id)) { tag.Attributes.Add("id", id); } if (!string.IsNullOrWhiteSpace(action.CssClass)) { tag.AddCssClass(Manager.AddOnManager.CheckInvokedCssModule(action.CssClass)); } string extraClass; switch (mode) { default: case ModuleAction.RenderModeEnum.Button: extraClass = "y_act_button"; break; case ModuleAction.RenderModeEnum.ButtonIcon: extraClass = "y_act_buttonicon"; break; case ModuleAction.RenderModeEnum.ButtonOnly: extraClass = "y_act_buttononly"; break; case ModuleAction.RenderModeEnum.IconsOnly: extraClass = "y_act_icon"; break; case ModuleAction.RenderModeEnum.LinksOnly: extraClass = "y_act_link"; break; case ModuleAction.RenderModeEnum.NormalLinks: extraClass = "y_act_normlink"; break; case ModuleAction.RenderModeEnum.NormalMenu: extraClass = "y_act_normmenu"; break; } tag.AddCssClass(Manager.AddOnManager.CheckInvokedCssModule(extraClass)); string url = action.GetCompleteUrl(OnPage: true); if (!string.IsNullOrWhiteSpace(url)) { tag.MergeAttribute("href", Utility.UrlEncodePath(url)); if (Manager.CurrentPage != null) { string currUrl = Manager.CurrentPage.EvaluatedCanonicalUrl; if (!string.IsNullOrWhiteSpace(currUrl) && currUrl != "/") // this doesn't work on home page because everything matches { if (action.Url == currUrl) { tag.AddCssClass("t_currenturl"); } if (currUrl.StartsWith(action.Url)) { tag.AddCssClass("t_currenturlpart"); } } } } else { tag.MergeAttribute("href", "javascript:void(0);"); } if (!string.IsNullOrWhiteSpace(action.ConfirmationText)) { if (action.Category == ModuleAction.ActionCategoryEnum.Delete) { // confirm deletions? if (UserSettings.GetProperty <bool>("ConfirmDelete")) { tag.MergeAttribute(Basics.CssConfirm, action.ConfirmationText); } } else { // confirm actions? if (UserSettings.GetProperty <bool>("ConfirmActions")) { tag.MergeAttribute(Basics.CssConfirm, action.ConfirmationText); } } } if (!string.IsNullOrWhiteSpace(action.PleaseWaitText)) { tag.MergeAttribute(Basics.CssPleaseWait, action.PleaseWaitText); } if (action.CookieAsDoneSignal) { tag.Attributes.Add(Basics.CookieDoneCssAttr, ""); } if (action.SaveReturnUrl) { tag.Attributes.Add(Basics.CssSaveReturnUrl, ""); if (!action.AddToOriginList) { tag.Attributes.Add(Basics.CssDontAddToOriginList, ""); } } if (!string.IsNullOrWhiteSpace(action.ExtraData)) { tag.Attributes.Add(Basics.CssExtraData, action.ExtraData); } if (action.NeedsModuleContext) { tag.Attributes.Add(Basics.CssAddModuleContext, ""); } if (post) { tag.Attributes.Add(Basics.PostAttr, ""); } if (action.DontFollow || action.CookieAsDoneSignal || post || nothing) { tag.MergeAttribute("rel", "nofollow"); // this is so bots don't follow this assuming it's a simple page (Post actions can't be retrieved with GET/HEAD anyway) } if (outerWindow) { tag.Attributes.Add(Basics.CssOuterWindow, ""); } if (!nothing) { tag.AddCssClass(Manager.AddOnManager.CheckInvokedCssModule(Basics.CssActionLink)); } if (newWindow) { tag.MergeAttribute("target", "_blank"); tag.MergeAttribute("rel", "noopener noreferrer"); } if (popup) { tag.AddCssClass(Manager.AddOnManager.CheckInvokedCssModule(Basics.CssPopupLink)); if (popupEdit) { tag.Attributes.Add(Basics.CssAttrDataSpecialEdit, ""); } } if (mode == ModuleAction.RenderModeEnum.Button || mode == ModuleAction.RenderModeEnum.ButtonIcon || mode == ModuleAction.RenderModeEnum.ButtonOnly) { tag.Attributes.Add(Basics.CssAttrActionButton, ""); } bool hasText = false, hasImg = false; string innerHtml = ""; if (mode != ModuleAction.RenderModeEnum.LinksOnly && mode != ModuleAction.RenderModeEnum.ButtonOnly && !string.IsNullOrWhiteSpace(action.ImageUrlFinal)) { string text = mode == ModuleAction.RenderModeEnum.NormalMenu ? action.MenuText : action.LinkText; if (RenderEngine == ModuleAction.RenderEngineEnum.KendoMenu) { innerHtml += ImageHTML.BuildKnownIcon(action.ImageUrlFinal, alt: text, cssClass: Basics.CssNoTooltip + " k-image"); // k-image is needed to align <i> and <img> correctly } else { innerHtml += ImageHTML.BuildKnownIcon(action.ImageUrlFinal, alt: text, cssClass: Basics.CssNoTooltip); } hasImg = true; } if (mode != ModuleAction.RenderModeEnum.IconsOnly && mode != ModuleAction.RenderModeEnum.ButtonIcon) { string text = mode == ModuleAction.RenderModeEnum.NormalMenu ? action.MenuText : action.LinkText; if (!string.IsNullOrWhiteSpace(text)) { innerHtml += Utility.HtmlEncode(text); hasText = true; } } if (hasText) { if (hasImg) { tag.AddCssClass("y_act_textimg"); } else { tag.AddCssClass("y_act_text"); } } else { if (hasImg) { tag.AddCssClass("y_act_img"); } } if (HasSubmenu && RenderEngine == ModuleAction.RenderEngineEnum.BootstrapSmartMenu) { innerHtml += " <span class='caret'></span>"; } tag.AddCssClass(Globals.CssModuleNoPrint); tag.InnerHtml = innerHtml; return(tag.ToString(YTagRenderMode.Normal)); }