/// <summary> /// Gets the cancel action for the thread. /// </summary> /// <param name="threadGuid">Thread GUID</param> /// <param name="status">Status</param> protected string GetCancelAction(object threadGuid, object status) { string result = null; if (ValidationHelper.GetString(status, null) != "AbortRequested") { var button = new CMSGridActionButton { IconCssClass = "icon-times-circle", IconStyle = GridIconStyle.Critical, ToolTip = GetString("General.Cancel"), OnClientClick = "CancelThread('" + threadGuid + "'); return false;" }; result = button.GetRenderedHTML(); } return result; }
/// <summary> /// Gets the actions for the thread. /// </summary> /// <param name="hasLog">Log presence</param> /// <param name="threadGuid">Thread GUID</param> /// <param name="status">Status</param> protected string GetActions(object hasLog, object threadGuid, object status) { string result = null; bool logAvailable = ValidationHelper.GetBoolean(hasLog, false); if (logAvailable) { string url = URLHelper.ResolveUrl("~/CMSModules/System/Debug/System_ViewLog.aspx"); url = URLHelper.UpdateParameterInUrl(url, "threadGuid", threadGuid.ToString()); if (WebFarmHelper.WebFarmEnabled) { url = URLHelper.UpdateParameterInUrl(url, "serverName", WebFarmHelper.ServerName); } var button = new CMSGridActionButton { IconCssClass = "icon-eye", IconStyle = GridIconStyle.Allow, ToolTip = GetString("General.View"), OnClientClick = "modalDialog('" + url + "', 'ThreadProgress', '1000', '700'); return false;" }; result += button.GetRenderedHTML(); } if (ValidationHelper.GetString(status, null) != "AbortRequested") { var button = new CMSGridActionButton { IconCssClass = "icon-times-circle", IconStyle = GridIconStyle.Critical, ToolTip = GetString("General.Cancel"), OnClientClick = "CancelThread('" + threadGuid + "'); return false;" }; result += button.GetRenderedHTML(); } return result; }
protected object uniGrid_OnExternalDataBound(object sender, string sourceName, object parameter) { DataRowView data = null; switch (sourceName.ToLowerCSafe()) { case "select": CMSGridActionButton btnImg = (CMSGridActionButton)sender; btnImg.OnClientClick = "parent.frames['tasksContent'].selectDocuments = false;parent.frames['tasksTree'].SelectTree(" + btnImg.CommandArgument + ");window.location.href='" + ResolveUrl("~/CMSModules/Staging/Tools/Tasks/Tasks.aspx?serverid=") + serverId + "&stagingnodeid=" + btnImg.CommandArgument + "'; return false;"; return(btnImg); case "showsubdocuments": CMSGridActionButton btnSubImg = (CMSGridActionButton)sender; bool hasChildren = ValidationHelper.GetBoolean(((DataRowView)((GridViewRow)parameter).DataItem).Row["NodeHasChildren"], false); if (hasChildren) { btnSubImg.OnClientClick = "parent.frames['tasksTree'].RefreshNode(" + btnSubImg.CommandArgument + "," + btnSubImg.CommandArgument + ");window.location.href='" + ResolveUrl("~/CMSModules/Staging/Tools/Tasks/DocumentsList.aspx?serverid=") + serverId + "&stagingnodeid=" + btnSubImg.CommandArgument + "'; return false;"; } else { string noSubDocuments = GetString("synchronization.nosubdocuments"); btnSubImg.ToolTip = noSubDocuments; btnSubImg.Enabled = false; btnSubImg.OnClientClick = "return false;"; } return(btnSubImg); case "documentname": data = (DataRowView)parameter; string name = ValidationHelper.GetString(data["DocumentName"], string.Empty); return("<span>" + HTMLHelper.HTMLEncode(name) + "</span>"); case "documentnametooltip": data = (DataRowView)parameter; return(UniGridFunctions.DocumentNameTooltip(data)); } return(parameter); }
/// <summary> /// Returns SKU edit action HTML. /// </summary> protected string GetSKUEditAction(object skuId, object skuSiteId, object skuParentSkuId, object isProductOption) { var editSKUElemHtml = ""; if (!ValidationHelper.GetBoolean(isProductOption, false) && ShoppingCartControl.IsInternalOrder) { // Do not render product detail link, when not authorized if (!CanReadProducts) { return(editSKUElemHtml); } // Show variants tab for product variant, otherwise general tab int parentSkuId = ValidationHelper.GetInteger(skuParentSkuId, 0); string productIdParam = (parentSkuId == 0) ? skuId.ToString() : parentSkuId.ToString(); string tabParam = (parentSkuId == 0) ? "Products.General" : "Products.Variants"; var query = URLHelper.AddParameterToUrl("", "productid", productIdParam); query = URLHelper.AddParameterToUrl(query, "tabName", tabParam); query = URLHelper.AddParameterToUrl(query, "siteid", skuSiteId.ToString()); query = URLHelper.AddParameterToUrl(query, "dialog", "1"); var url = ApplicationUrlHelper.GetElementDialogUrl(ModuleName.ECOMMERCE, "Products.Properties", additionalQuery: query); // Different tooltip for product than for product variant string tooltip = (parentSkuId == 0) ? GetString("shoppingcart.editproduct") : GetString("shoppingcart.editproductvariant"); var priceDetailButton = new CMSGridActionButton { IconCssClass = "icon-box", ToolTip = tooltip, OnClientClick = ScriptHelper.GetModalDialogScript(url, "SKUEdit", "95%", "95%"), }; editSKUElemHtml = priceDetailButton.GetRenderedHTML(); } return(editSKUElemHtml); }
/// <summary> /// Returns price detail link. /// </summary> protected string GetPriceDetailLink(object value) { var priceDetailElemHtml = ""; if (ShoppingCartControl.EnableProductPriceDetail) { Guid cartItemGuid = ValidationHelper.GetGuid(value, Guid.Empty); if (cartItemGuid != Guid.Empty) { var query = "itemguid=" + cartItemGuid + GetCMSDeskShoppingCartSessionNameQuery(); if (IsLiveSite) { string liveSiteUrl = UrlResolver.ResolveUrl("~/CMSModules/Ecommerce/CMSPages/ShoppingCartSKUPriceDetail.aspx?" + query); priceDetailElemHtml = string.Format("<img src=\"{0}\" onclick=\"{1}\" alt=\"{2}\" class=\"ProductPriceDetailImage\" style=\"cursor:pointer;\" />", GetImageUrl("Design/Controls/UniGrid/Actions/detail.png"), ScriptHelper.GetModalDialogScript(liveSiteUrl, "ProductPriceDetail", 750, 570), GetString("shoppingcart.productpricedetail")); } else { string adminUrl = ApplicationUrlHelper.GetElementDialogUrl(ModuleName.ECOMMERCE, "order.productpricedetail", 0, query); var priceDetailButton = new CMSGridActionButton { IconCssClass = "icon-eye", ToolTip = GetString("shoppingcart.productpricedetail"), OnClientClick = ScriptHelper.GetModalDialogScript(adminUrl, "ProductPriceDetail", 750, 570) }; priceDetailElemHtml = priceDetailButton.GetRenderedHTML(); } } } return(priceDetailElemHtml); }
/// <summary> /// Display chat button. /// </summary> private object ModifyChatButton(object sender, object parameter) { CMSGridActionButton button = ((CMSGridActionButton)sender); if (!isInitiateChatEnabled) { button.Visible = false; } else { DataRow row = ((DataRowView)((GridViewRow)parameter).DataItem).Row; int contactID; int userID; if (DisplayContacts) { contactID = ValidationHelper.GetInteger(row["SessionContactID"], 0); userID = ValidationHelper.GetInteger(row["SessionUserID"], 0); } else { contactID = 0; userID = ValidationHelper.GetInteger(row["UserID"], 0); } // If userID and contactID are not known (can happen if online marketing is turned off), hide initiate chat button if ((userID <= 0) && (contactID <= 0)) { button.Visible = false; } else { button.OnClientClick = string.Format("if (window.top.ChatSupportManager) {{window.top.ChatSupportManager.initiateChat({0}, {1});}} return false;", userID, contactID); } } return(""); }
/// <summary> /// Callback event for create calendar icon. /// </summary> /// <param name="sender">Sender object</param> /// <param name="sourceName">Event source name</param> /// <param name="parameter">Event parameter</param> /// <param name="val">Value from basic external data bound event</param> private object usMemberships_OnAdditionalDataBound(object sender, string sourceName, object parameter, object val) { switch (sourceName.ToLowerCSafe()) { case "calendar": DataRowView drv = (parameter as DataRowView); string itemID = drv[usRoles.ReturnColumnName].ToString(); string iconID = "icon_" + itemID; string date = drv["ValidTo"].ToString(); string postback = ControlsHelper.GetPostBackEventReference(ucCalendar.DateTimeTextBox, "#").Replace("'#'", "$cmsj('#" + ucCalendar.DateTimeTextBox.ClientID + "').val()"); string onClick = String.Empty; ucCalendar.DateTimeTextBox.Attributes["OnChange"] = postback; if (!ucCalendar.UseCustomCalendar) { onClick = "$cmsj('#" + hdnDate.ClientID + "').val('" + itemID + "');" + ucCalendar.GenerateNonCustomCalendarImageEvent(); } else { onClick = "$cmsj('#" + hdnDate.ClientID + "').val('" + itemID + "'); var dt = $cmsj('#" + ucCalendar.DateTimeTextBox.ClientID + "'); dt.val('" + date + "'); dt.cmsdatepicker('setLocation','" + iconID + "'); dt.cmsdatepicker('show');"; } var button = new CMSGridActionButton { ToolTip = GetString("membership.changevalidity"), IconCssClass = "icon-calendar", OnClientClick = onClick + "return false;", ID = iconID }; val = button.GetRenderedHTML(); break; } return(val); }
private object gridViews_OnExternalDataBound(object sender, string sourceName, object parameter) { switch (sourceName.ToLowerCSafe()) { case "iscustom": bool isCustom = ValidationHelper.GetBoolean(parameter, false); return(UniGridFunctions.ColoredSpanYesNo(isCustom)); case "delete": if (!SystemContext.DevelopmentMode) { // Disable "delete" button for system objects bool delete = ValidationHelper.GetBoolean(((DataRowView)((GridViewRow)parameter).DataItem).Row["IsCustom"], false); if (!delete) { CMSGridActionButton button = ((CMSGridActionButton)sender); button.Enabled = false; } } break; } return(sender); }
protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter) { switch (sourceName.ToLowerCSafe()) { case "approved": return(UniGridFunctions.ColoredSpanYesNo(parameter, true)); case "approve": CMSGridActionButton button = ((CMSGridActionButton)sender); if (button != null) { bool isApproved = ValidationHelper.GetBoolean(((DataRowView)((GridViewRow)parameter).DataItem).Row["SubscriptionApproved"], true); if (isApproved) { button.Visible = false; } } break; } return(HTMLHelper.HTMLEncode(Convert.ToString(parameter))); }
private object gridBannerManagement_OnExternalDataBound(object sender, string sourceName, object parameter) { sourceName = sourceName.ToLowerCSafe(); switch (sourceName) { case "delete": DataRow row = ((DataRowView)((GridViewRow)parameter).DataItem).Row; int?siteID = row.IsNull("BannerCategorySiteID") ? (int?)null : ValidationHelper.GetInteger(row["BannerCategorySiteID"], 0); CMSGridActionButton button = ((CMSGridActionButton)sender); if (!HasUserModifyPermission(siteID)) { button.Enabled = false; } break; } return(parameter); }
/// <summary> /// Returns order item edit action HTML. /// </summary> protected string GetOrderItemEditAction(object value) { var editOrderItemElemHtml = ""; Guid itemGuid = ValidationHelper.GetGuid(value, Guid.Empty); if (itemGuid != Guid.Empty) { var query = "itemguid=" + itemGuid + GetCMSDeskShoppingCartSessionNameQuery(); var editItemUrl = UIContextHelper.GetElementDialogUrl(ModuleName.ECOMMERCE, "order.OrderItemProperties", 0, query); var priceDetailButton = new CMSGridActionButton { IconCssClass = "icon-edit", IconStyle = GridIconStyle.Allow, ToolTip = GetString("shoppingcart.editorderitem"), OnClientClick = ScriptHelper.GetModalDialogScript(editItemUrl, "OrderItemEdit", 720, 420) }; editOrderItemElemHtml = priceDetailButton.GetRenderedHTML(); } return(editOrderItemElemHtml); }
protected object ugRecycleBin_OnExternalDataBound(object sender, string sourceName, object parameter) { sourceName = sourceName != null?sourceName.ToLowerInvariant() : null; switch (sourceName) { case "view": CMSGridActionButton btnView = sender as CMSGridActionButton; if (btnView != null) { GridViewRow row = (GridViewRow)parameter; object siteId = DataHelper.GetDataRowViewValue((DataRowView)row.DataItem, "NodeSiteID"); SiteInfo siteInfo = SiteInfoProvider.GetSiteInfo(ValidationHelper.GetInteger(siteId, 0)); if (siteInfo != null) { if (siteInfo.Status == SiteStatusEnum.Stopped) { btnView.Enabled = false; } } } break; case "nodesiteid": { int siteId = ValidationHelper.GetInteger(parameter, 0); SiteInfo siteInfo = SiteInfoProvider.GetSiteInfo(siteId); return((siteInfo != null) ? HTMLHelper.HTMLEncode(siteInfo.DisplayName) : string.Empty); } case "documentname": string documentName = ValidationHelper.GetString(parameter, null); return(string.IsNullOrEmpty(documentName) ? GetString("general.na") : HTMLHelper.HTMLEncode(documentName)); } return(parameter); }
protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter) { switch (sourceName) { case "view": CMSGridActionButton viewBtn = (CMSGridActionButton)sender; viewBtn.OnClientClick = string.Format("dialogParams_{0} = '{1}';{2};return false;", ClientID, viewBtn.CommandArgument, Page.ClientScript.GetCallbackEventReference(this, "dialogParams_" + ClientID, "ViewDetails", null)); break; case "delete": CMSGridActionButton deleteBtn = (CMSGridActionButton)sender; if (!ShowRemoveButton || !modifyPermission) { deleteBtn.Enabled = false; } deleteBtn.Visible = ShowRemoveButton; break; case "acttypedesc": var activityTypeDescription = GetActivityTypeDescription(parameter); return(HTMLHelper.HTMLEncode(activityTypeDescription)); case "acttype": var activityTypeInfo = GetActivityTypeByCodeName(parameter); var activityTypeName = GetActivityTypeName(parameter, activityTypeInfo); var activityTypeColor = activityTypeInfo?.ActivityTypeColor; return(new Tag { Text = activityTypeName, Color = activityTypeColor }); } return(null); }
/// <summary> /// OnExternalDataBound event handler /// </summary> protected object OnExternalDataBound(object sender, string sourceName, object parameter) { WorkflowStepTypeEnum stepType; GridViewRow container; switch (sourceName.ToLowerCSafe()) { case "allowaction": container = (GridViewRow)parameter; stepType = (WorkflowStepTypeEnum)ValidationHelper.GetInteger(DataHelper.GetDataRowViewValue((DataRowView)container.DataItem, "StepType"), 3); switch (stepType) { case WorkflowStepTypeEnum.DocumentEdit: case WorkflowStepTypeEnum.DocumentPublished: case WorkflowStepTypeEnum.DocumentArchived: ((CMSGridActionButton)sender).Visible = false; break; } break; case "steptype": stepType = (WorkflowStepTypeEnum)ValidationHelper.GetInteger(parameter, 3); WorkflowNode node = WorkflowNode.GetInstance(stepType); return(HTMLHelper.HTMLEncode(node.Name)); case "#objectmenu": container = (GridViewRow)parameter; WorkflowStepInfo step = new WorkflowStepInfo(((DataRowView)container.DataItem).Row); if (step.StepIsDefault) { CMSGridActionButton button = ((CMSGridActionButton)sender); button.Visible = false; } break; } return(parameter); }
protected object ugRecycleBin_OnExternalDataBound(object sender, string sourceName, object parameter) { sourceName = sourceName.ToLowerCSafe(); switch (sourceName) { case "view": CMSGridActionButton imgView = (CMSGridActionButton)sender; if (imgView != null) { GridViewRow gvr = (GridViewRow)parameter; DataRowView data = (DataRowView)gvr.DataItem; string viewVersionUrl = ResolveUrl("~/CMSModules/Objects/Dialogs/ViewObjectVersion.aspx?showall=1&nocompare=1&versionhistoryid=" + ValidationHelper.GetInteger(data["VersionID"], 0)); viewVersionUrl = URLHelper.AddParameterToUrl(viewVersionUrl, "hash", QueryHelper.GetHash(viewVersionUrl)); imgView.OnClientClick = "window.open(" + ScriptHelper.GetString(viewVersionUrl) + ");return false;"; } break; case "deletedwhen": case "deletedwhentooltip": if (sourceName.EqualsCSafe("deletedwhen", StringComparison.InvariantCultureIgnoreCase)) { DateTime deletedWhen = ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME); return(TimeZoneHelper.ConvertToUserTimeZone(deletedWhen, true, CurrentUser, CurrentSite)); } else { return(mGMTTooltip ?? (mGMTTooltip = TimeZoneHelper.GetUTCLongStringOffset(CurrentUser, CurrentSite))); } case "versionobjecttype": string objType = ValidationHelper.GetString(parameter, ""); return(HTMLHelper.HTMLEncode(GetString("ObjectType." + objType.Replace(".", "_")))); } return((parameter != null) ? HTMLHelper.HTMLEncode(parameter.ToString()) : null); }
protected object gridData_OnExternalDataBound(object sender, string sourceName, object parameter) { CMSGridActionButton button = sender as CMSGridActionButton; GridViewRow grv = parameter as GridViewRow; if (grv != null) { DataRowView drv = (DataRowView)grv.DataItem; switch (sourceName.ToLowerCSafe()) { case "edit": if (button != null) { if (!isDialog) { button.OnClientClick = "EditRecord(" + formId + ", " + drv[primaryColumn] + "); return false;"; } else { button.Visible = false; } } break; case "delete": if (button != null) { button.CommandArgument = Convert.ToString(drv[primaryColumn]); } break; } } return(parameter); }
/// <summary> /// Gets the log action for the thread. /// </summary> /// <param name="hasLog">Log presence</param> /// <param name="threadGuid">Thread GUID</param> protected string GetLogAction(object hasLog, object threadGuid) { string result = null; bool logAvailable = ValidationHelper.GetBoolean(hasLog, false); if (logAvailable) { string url = URLHelper.ResolveUrl("~/CMSModules/System/Debug/System_ViewLog.aspx"); url = URLHelper.UpdateParameterInUrl(url, "threadGuid", threadGuid.ToString()); if (WebFarmHelper.WebFarmEnabled) { url = URLHelper.UpdateParameterInUrl(url, "serverName", WebFarmHelper.ServerName); } var button = new CMSGridActionButton { IconCssClass = "icon-eye", IconStyle = GridIconStyle.Allow, ToolTip = GetString("General.View"), OnClientClick = "modalDialog('" + url + "', 'ThreadProgress'); return false;" }; result = button.GetRenderedHTML(); } return result; }
/// <summary> /// Unigrid OnExternalDataBound event. /// </summary> protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter) { GroupMemberStatus status = GroupMemberStatus.Approved; DataRowView drv = null; GridViewRow gvr = null; bool current = false; switch (sourceName.ToLowerCSafe()) { case "memberapprovedwhen": case "memberrejectedwhen": if (parameter != DBNull.Value) { // Get current dateTime return(TimeZoneUIMethods.ConvertDateTime(Convert.ToDateTime(parameter), this)); } break; case "approve": gvr = parameter as GridViewRow; if (gvr != null) { drv = gvr.DataItem as DataRowView; if (drv != null) { // Check for current user if (IsLiveSite && (MembershipContext.AuthenticatedUser.UserID == ValidationHelper.GetInteger(drv["MemberUserID"], 0))) { current = true; } // Do not allow approve hidden or disabled users bool hiddenOrDisabled = IsUserHiddenOrDisabled(drv); status = (GroupMemberStatus)ValidationHelper.GetInteger(drv["MemberStatus"], 0); // Enable or disable Approve button if (!current && (status != GroupMemberStatus.Approved) && !hiddenOrDisabled) { CMSGridActionButton button = ((CMSGridActionButton)sender); button.IconCssClass = "icon-check-circle"; button.IconStyle = GridIconStyle.Allow; button.ToolTip = GetString("general.approve"); button.Enabled = true; } else { CMSGridActionButton button = ((CMSGridActionButton)sender); button.IconCssClass = "icon-check-circle"; button.IconStyle = GridIconStyle.Allow; button.ToolTip = GetString("general.approve"); button.Enabled = false; } } } break; case "reject": gvr = parameter as GridViewRow; if (gvr != null) { drv = gvr.DataItem as DataRowView; if (drv != null) { // Check for current user if (IsLiveSite && (MembershipContext.AuthenticatedUser.UserID == ValidationHelper.GetInteger(drv.Row["MemberUserID"], 0))) { current = true; } status = (GroupMemberStatus)ValidationHelper.GetInteger(drv["MemberStatus"], 0); // Enable or disable Reject button if (!current && (status != GroupMemberStatus.Rejected)) { CMSGridActionButton button = ((CMSGridActionButton)sender); button.IconCssClass = "icon-times-circle"; button.IconStyle = GridIconStyle.Critical; button.ToolTip = GetString("general.reject"); button.Enabled = true; } else { CMSGridActionButton button = ((CMSGridActionButton)sender); button.IconCssClass = "icon-times-circle"; button.IconStyle = GridIconStyle.Critical; button.ToolTip = GetString("general.reject"); button.Enabled = false; } } } break; case "formattedusername": // Format username return(HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(Convert.ToString(parameter), IsLiveSite))); case "edit": gvr = parameter as GridViewRow; if (gvr != null) { drv = gvr.DataItem as DataRowView; if (drv != null) { // Do not allow approve hidden or disabled users bool hiddenOrDisabled = IsUserHiddenOrDisabled(drv); // Enable or disable Edit button if (!hiddenOrDisabled) { CMSGridActionButton button = ((CMSGridActionButton)sender); button.IconCssClass = "icon-edit"; button.IconStyle = GridIconStyle.Allow; button.ToolTip = GetString("general.edit"); button.Enabled = true; } else { CMSGridActionButton button = ((CMSGridActionButton)sender); button.IconCssClass = "icon-edit"; button.IconStyle = GridIconStyle.Allow; button.ToolTip = GetString("general.edit"); button.Enabled = false; } } } break; } return(parameter); }
/// <summary> /// Returns price detail link. /// </summary> protected string GetPriceDetailLink(object value) { var priceDetailElemHtml = ""; if ((ShoppingCartControl.EnableProductPriceDetail) && (ShoppingCart.ContentTable != null)) { Guid cartItemGuid = ValidationHelper.GetGuid(value, Guid.Empty); if (cartItemGuid != Guid.Empty) { var query = "itemguid=" + cartItemGuid + GetCMSDeskShoppingCartSessionNameQuery(); if (IsLiveSite) { string liveSiteUrl = URLHelper.ResolveUrl("~/CMSModules/Ecommerce/CMSPages/ShoppingCartSKUPriceDetail.aspx?" + query); priceDetailElemHtml = string.Format("<img src=\"{0}\" onclick=\"{1}\" alt=\"{2}\" class=\"ProductPriceDetailImage\" style=\"cursor:pointer;\" />", GetImageUrl("Design/Controls/UniGrid/Actions/detail.png"), ScriptHelper.GetModalDialogScript(liveSiteUrl, "ProductPriceDetail", 750, 570), GetString("shoppingcart.productpricedetail")); } else { string adminUrl = UIContextHelper.GetElementDialogUrl(ModuleName.ECOMMERCE, "order.productpricedetail", 0, query); var priceDetailButton = new CMSGridActionButton { IconCssClass = "icon-eye", ToolTip = GetString("shoppingcart.productpricedetail"), OnClientClick = ScriptHelper.GetModalDialogScript(adminUrl, "ProductPriceDetail", 750, 570) }; priceDetailElemHtml = priceDetailButton.GetRenderedHTML(); } } } return priceDetailElemHtml; }
protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter) { switch (sourceName) { case "remove": if (sender is CMSGridActionButton) { // Get action button CMSGridActionButton deleteBtn = (CMSGridActionButton)sender; deleteBtn.Enabled = friendsManagePermission; return(deleteBtn); } else { return(string.Empty); } case "reject": if (sender is CMSGridActionButton) { // Get action button CMSGridActionButton rejectBtn = (CMSGridActionButton)sender; // Get full row view DataRowView drv = UniGridFunctions.GetDataRowView((DataControlFieldCell)rejectBtn.Parent); // Add custom reject action if (friendsManagePermission) { rejectBtn.OnClientClick = "return FM_Reject_" + ClientID + "('" + drv["FriendID"] + "',null,'" + DialogUrl + "');"; } else { rejectBtn.Enabled = false; } return(rejectBtn); } else { return(string.Empty); } case "friendapprovedwhen": if (currentUserInfo == null) { currentUserInfo = MembershipContext.AuthenticatedUser; } if (currentSiteInfo == null) { currentSiteInfo = SiteContext.CurrentSite; } DateTime currentDateTime = ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME); if (IsLiveSite) { return(TimeZoneUIMethods.ConvertDateTime(currentDateTime, this)); } else { return(TimeZoneHelper.ConvertToUserTimeZone(currentDateTime, true, currentUserInfo, currentSiteInfo)); } case "formattedusername": return(HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(Convert.ToString(parameter), IsLiveSite))); } return(parameter); }
/// <summary> /// Gets the debug action. /// </summary> /// <param name="key">Cache key</param> private string GetDebugAction(string key) { var button = new CMSGridActionButton { IconCssClass = "icon-bug", ToolTip = GetString("General.Debug"), OnClientClick = String.Format("Debug('{0}'); return false;", Server.UrlEncode(ScriptHelper.GetString(key, false))) }; return button.GetRenderedHTML(); }
protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter) { DataRowView drv; switch (sourceName.ToLowerInvariant()) { case "result": { drv = parameter as DataRowView; if (drv != null) { string errorMsg = ValidationHelper.GetString(drv["SynchronizationErrorMessage"], string.Empty); if (!string.IsNullOrEmpty(errorMsg)) { int synchronizationId = ValidationHelper.GetInteger(drv["SynchronizationID"], 0); string logUrl = ResolveUrl("~/CMSModules/Integration/Pages/Administration/Log.aspx?synchronizationid=") + synchronizationId; return(String.Format("<a target=\"_blank\" href=\"{0}\" onclick=\"modalDialog('{0}', 'tasklog', 1400, 1200); return false;\">{1}</a>", logUrl, GetString("Tasks.ResultFailed"))); } } return(string.Empty); } case "view": if (sender is CMSGridActionButton) { CMSGridActionButton viewButton = sender as CMSGridActionButton; drv = UniGridFunctions.GetDataRowView(viewButton.Parent as DataControlFieldCell); int taskId = ValidationHelper.GetInteger(drv["TaskID"], 0); string detailUrl = ResolveUrl("~/CMSModules/Integration/Pages/Administration/View.aspx?taskid=") + taskId; viewButton.OnClientClick = "modalDialog('" + detailUrl + "', 'tasklog', 1400, 1200); return false;"; return(viewButton); } return(parameter); case "run": if (sender is CMSGridActionButton) { CMSGridActionButton runButton = sender as CMSGridActionButton; drv = UniGridFunctions.GetDataRowView(runButton.Parent as DataControlFieldCell); int connectorId = ValidationHelper.GetInteger(drv["SynchronizationConnectorID"], 0); var connector = IntegrationConnectorInfoProvider.GetIntegrationConnectorInfo(connectorId); bool processingDisabled = TasksAreInbound ? !IntegrationHelper.IntegrationProcessExternal : !IntegrationHelper.IntegrationProcessInternal; if (processingDisabled || (connector == null) || !connector.ConnectorEnabled) { // Set appropriate tooltip if (processingDisabled) { runButton.ToolTip = GetString("integration.processingdisabled"); } else { if ((connector != null) && !connector.ConnectorEnabled) { runButton.ToolTip = String.Format(GetString("integration.connectordisabled"), HTMLHelper.HTMLEncode(connector.ConnectorDisplayName)); } else { runButton.ToolTip = GetString("integration.connectorunavailable"); } } runButton.Enabled = false; runButton.OnClientClick = "return false;"; runButton.Style.Add(HtmlTextWriterStyle.Cursor, "default"); return(runButton); } } break; } return(parameter); }
protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter) { switch (sourceName.ToLowerCSafe()) { case "resubmitaction": case "processaction": case "cancelaction": CMSGridActionButton img = sender as CMSGridActionButton; if (img != null) { img.Enabled = modifyAllowed; GridViewRow gvr = parameter as GridViewRow; if (gvr == null) { return(img); } DataRowView drv = gvr.DataItem as DataRowView; if (drv == null) { return(img); } TranslationStatusEnum status = (TranslationStatusEnum)ValidationHelper.GetInteger(drv["SubmissionStatus"], 0); switch (sourceName.ToLowerCSafe()) { 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": TranslationServiceInfo 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); } return(parameter); }
protected object gridFile_OnExternalDataBound(object sender, string sourceName, object parameter) { GridViewRow gvr; DataRowView drv; string fileGuid; switch (sourceName.ToLowerCSafe()) { case "edit": if (sender is CMSAccessibleButton) { gvr = (GridViewRow)parameter; drv = (DataRowView)gvr.DataItem; fileGuid = ValidationHelper.GetString(drv["MetaFileGUID"], ""); string fileExtension = ValidationHelper.GetString(drv["MetaFileExtension"], ""); // Initialize properties CMSGridActionButton btnImageEditor = (CMSGridActionButton)sender; btnImageEditor.Visible = true; // Display button only if 'Modify' is allowed if (AllowModify) { string query = String.Format("?refresh=1&metafileguid={0}&clientid={1}", fileGuid, ClientID); query = URLHelper.AddUrlParameter(query, "hash", QueryHelper.GetHash(query)); // Display button only if metafile is in supported image format if (ImageHelper.IsSupportedByImageEditor(fileExtension)) { // Initialize button with script btnImageEditor.OnClientClick = String.Format("OpenImageEditor({0}); return false;", ScriptHelper.GetString(query)); } // Non-image metafile else { // Initialize button with script btnImageEditor.OnClientClick = String.Format("OpenEditor({0}); return false;", ScriptHelper.GetString(query)); } } else { btnImageEditor.Enabled = false; } } break; case "delete": if (sender is CMSGridActionButton) { CMSGridActionButton btnDelete = ((CMSGridActionButton)sender); btnDelete.Enabled = AllowModify; } break; case "name": drv = (DataRowView)parameter; string fileName = ValidationHelper.GetString(DataHelper.GetDataRowViewValue(drv, "MetaFileName"), string.Empty); fileGuid = ValidationHelper.GetString(DataHelper.GetDataRowViewValue(drv, "MetaFileGUID"), string.Empty); string fileExt = ValidationHelper.GetString(DataHelper.GetDataRowViewValue(drv, "MetaFileExtension"), string.Empty); bool isImage = ImageHelper.IsImage(fileExt); string fileUrl = String.Format("{0}?fileguid={1}&chset={2}", URLHelper.GetAbsoluteUrl("~/CMSPages/GetMetaFile.aspx"), fileGuid, Guid.NewGuid()); // Tooltip string title = ValidationHelper.GetString(DataHelper.GetDataRowViewValue(drv, "MetaFileTitle"), string.Empty); string description = ValidationHelper.GetString(DataHelper.GetDataRowViewValue(drv, "MetaFileDescription"), string.Empty); int imageWidth = ValidationHelper.GetInteger(DataHelper.GetDataRowViewValue(drv, "MetaFileImageWidth"), 0); int imageHeight = ValidationHelper.GetInteger(DataHelper.GetDataRowViewValue(drv, "MetaFileImageHeight"), 0); string tooltip = UIHelper.GetTooltipAttributes(fileUrl, imageWidth, imageHeight, title, fileName, fileExt, description, null, 300); // Icon string iconTag = UIHelper.GetFileIcon(Page, fileExt, tooltip: fileName); if (isImage) { return(String.Format("<a href=\"#\" onclick=\"javascript: window.open('{0}'); return false;\" class=\"cms-icon-link\"><span id=\"{1}\" {2}>{3}{4}</span></a>", fileUrl, fileGuid, tooltip, iconTag, fileName)); } else { return(String.Format("<a href=\"{0}\" class=\"cms-icon-link\"><span id=\"{1}\" {2}>{3}{4}</span></a>", fileUrl, fileGuid, tooltip, iconTag, fileName)); } case "size": return(DataHelper.GetSizeString(ValidationHelper.GetLong(parameter, 0))); case "update": { drv = (DataRowView)parameter; Panel pnlBlock = new Panel { ID = "pnlBlock" }; string siteName = null; if (SiteID > 0) { SiteInfo si = SiteInfoProvider.GetSiteInfo(SiteID); if (si != null) { siteName = si.SiteName; } } else { siteName = SiteContext.CurrentSiteName; } // Add update control // Dynamically load uploader control var dfuElem = Page.LoadUserControl("~/CMSModules/Content/Controls/Attachments/DirectFileUploader/DirectFileUploader.ascx") as DirectFileUploader; if (dfuElem != null) { dfuElem.ID = "dfuElem" + ObjectID; dfuElem.SourceType = MediaSourceEnum.MetaFile; dfuElem.ControlGroup = "Uploader_" + ObjectID; dfuElem.DisplayInline = true; dfuElem.ForceLoad = true; dfuElem.MetaFileID = ValidationHelper.GetInteger(drv["MetaFileID"], 0); dfuElem.ObjectID = ObjectID; dfuElem.ObjectType = ObjectType; dfuElem.Category = Category; dfuElem.ParentElemID = ClientID; dfuElem.ShowIconMode = true; dfuElem.InsertMode = false; dfuElem.ParentElemID = ClientID; dfuElem.IncludeNewItemInfo = true; dfuElem.SiteID = SiteID; dfuElem.IsLiveSite = IsLiveSite; // Setting of the direct single mode dfuElem.UploadMode = MultifileUploaderModeEnum.DirectSingle; dfuElem.Width = 16; dfuElem.Height = 16; dfuElem.MaxNumberToUpload = 1; if (AllowedExtensions != null) { dfuElem.AllowedExtensions = AllowedExtensions; } pnlBlock.Controls.Add(dfuElem); } // Setup external edit ExternalEditHelper.LoadExternalEditControl(pnlBlock, FileTypeEnum.MetaFile, siteName, new DataRowContainer(drv), IsLiveSite); return(pnlBlock); } } return(parameter); }
/// <summary> /// Generates row with textboxes for new values /// </summary> private void GenerateNewRow() { // New Item tab TableRow trNew = new TableRow(); // Actions TableCell tnew = new TableCell(); tnew.CssClass = "unigrid-actions"; var imgNew = new CMSGridActionButton(); imgNew.OnClientClick = String.Format("addNewRow('{0}'); return false;", ClientID); imgNew.IconCssClass = "icon-plus"; imgNew.IconStyle = GridIconStyle.Allow; imgNew.ToolTip = GetString("xmleditor.createitem"); imgNew.ID = "add"; var imgOK = new CMSGridActionButton(); imgOK.IconCssClass = "icon-check-circle"; imgOK.IconStyle = GridIconStyle.Allow; imgOK.ID = "newok"; imgOK.ToolTip = GetString("xmleditor.additem"); var imgDelete = new CMSGridActionButton(); imgDelete.OnClientClick = String.Format("if (confirm('" + GetString("xmleditor.confirmcancel") + "')) cancelNewRow('{0}'); return false;", ClientID); imgDelete.IconCssClass = "icon-bin"; imgDelete.IconStyle = GridIconStyle.Critical; imgDelete.ID = "newcancel"; imgDelete.ToolTip = GetString("xmleditor.cancelnewitem"); tnew.Controls.Add(imgNew); tnew.Controls.Add(imgOK); tnew.Controls.Add(imgDelete); // Textboxes CMSTextBox txtNewName = new CMSTextBox(); txtNewName.ID = "utk_newkey"; CMSTextBox txtNewValue = new CMSTextBox(); txtNewValue.ID = "utv_newvalue"; txtNewValue.Width = Unit.Pixel(490); TableCell tcnew = new TableCell(); tcnew.Controls.Add(txtNewName); TableCell tcvnew = new TableCell(); tcvnew.Controls.Add(txtNewValue); trNew.Cells.Add(tnew); trNew.Cells.Add(tcnew); trNew.Cells.Add(tcvnew); tblData.Rows.Add(trNew); imgOK.OnClientClick = "if (validateCustomProperties($cmsj('#" + txtNewName.ClientID + "').val(),null))" + ControlsHelper.GetPostBackEventReference(tblData, "add") + " ;return false"; // Prevent load styles from control state imgDelete.AddCssClass("hidden"); imgOK.AddCssClass("hidden"); txtNewName.AddCssClass("hidden"); txtNewValue.AddCssClass("hidden"); txtNewValue.Text = String.Empty; txtNewName.Text = String.Empty; if (!isNewValid && RequestHelper.IsPostBack()) { txtNewName.Text = Request.Form[UniqueID + "$utk_newkey"]; txtNewValue.Text = Request.Form[UniqueID + "$utv_newvalue"]; txtNewValue.CssClass = String.Empty; txtNewName.CssClass = String.Empty; imgOK.RemoveCssClass("hidden"); imgDelete.RemoveCssClass("hidden"); imgNew.AddCssClass("hidden"); RegisterEnableScript(false); } }
/// <summary> /// Generates tables /// </summary> private void GenerateTable() { tblData.Controls.Clear(); Hashtable ht = data.ConvertToHashtable(); TableHeaderRow th = new TableHeaderRow() { TableSection = TableRowSection.TableHeader }; TableHeaderCell ha = new TableHeaderCell(); TableHeaderCell hn = new TableHeaderCell(); TableHeaderCell hv = new TableHeaderCell(); th.CssClass = "unigrid-head"; ha.Text = GetString("unigrid.actions"); ha.CssClass = "unigrid-actions-header"; hn.Text = GetString("xmleditor.propertyname"); hn.Width = Unit.Pixel(180); hv.Text = GetString("xmleditor.propertyvalue"); hv.Width = Unit.Pixel(500); th.Cells.Add(ha); th.Cells.Add(hn); th.Cells.Add(hv); tblData.Rows.Add(th); ArrayList keys = new ArrayList(ht); keys.Sort(new CustomStringComparer()); foreach (DictionaryEntry okey in keys) { String key = ValidationHelper.GetString(okey.Key, String.Empty); String value = ValidationHelper.GetString(okey.Value, String.Empty); bool isInvalid = (key == INVALIDTOKEN); key = isInvalid ? invalidKey : key; if (value == String.Empty) { continue; } TableRow tr = new TableRow(); // Actions TableCell tna = new TableCell(); tna.CssClass = "unigrid-actions"; var imgEdit = new CMSGridActionButton(); imgEdit.OnClientClick = String.Format("displayEdit('{1}','{0}'); return false; ", key, ClientID); imgEdit.IconCssClass = "icon-edit"; imgEdit.IconStyle = GridIconStyle.Allow; imgEdit.ID = key + "_edit"; imgEdit.ToolTip = GetString("xmleditor.edititem"); var imgOK = new CMSGridActionButton(); imgOK.IconCssClass = "icon-check"; imgOK.IconStyle = GridIconStyle.Allow; imgOK.OnClientClick = String.Format("approveCustomChanges('{0}','{1}');return false;", ClientID, key); imgOK.ID = key + "_ok"; imgOK.ToolTip = GetString("xmleditor.approvechanges"); var imgDelete = new CMSGridActionButton(); imgDelete.OnClientClick = " if (confirm('" + GetString("xmleditor.deleteconfirm") + "')) {" + ControlsHelper.GetPostBackEventReference(tblData, "delete_" + key) + "} ;return false;"; imgDelete.IconCssClass = "icon-bin"; imgDelete.IconStyle = GridIconStyle.Critical; imgDelete.ID = key + "_del"; imgDelete.ToolTip = GetString("xmleditor.deleteitem"); var imgUndo = new CMSGridActionButton(); imgUndo.OnClientClick = String.Format("if (confirm('" + GetString("xmleditor.confirmcancel") + "')) undoCustomChanges('{0}','{1}'); return false;", ClientID, key); imgUndo.IconCssClass = "icon-arrow-crooked-left"; imgUndo.ID = key + "_undo"; imgUndo.ToolTip = GetString("xmleditor.undochanges"); tna.Controls.Add(imgEdit); tna.Controls.Add(imgOK); tna.Controls.Add(imgDelete); tna.Controls.Add(imgUndo); value = MacroSecurityProcessor.RemoveSecurityParameters(value, false, null); // Labels Label lblName = new Label(); lblName.ID = "sk" + key; lblName.Text = key; Label lblValue = new Label(); lblValue.ID = "sv" + key; lblValue.Text = value; // Textboxes CMSTextBox txtName = new CMSTextBox(); txtName.Text = key; txtName.ID = "tk" + key; txtName.CssClass = "XmlEditorTextbox"; CMSTextBox txtValue = new CMSTextBox(); txtValue.Text = value; txtValue.ID = "tv" + key; txtValue.CssClass = "XmlEditorTextbox"; txtValue.Width = Unit.Pixel(490); labels.Add(lblName); labels.Add(lblValue); textboxes.Add(txtName); textboxes.Add(txtValue); TableCell tcn = new TableCell(); tcn.Controls.Add(lblName); tcn.Controls.Add(txtName); TableCell tcv = new TableCell(); tcv.Controls.Add(lblValue); tcv.Controls.Add(txtValue); tr.Cells.Add(tna); tr.Cells.Add(tcn); tr.Cells.Add(tcv); tblData.Rows.Add(tr); lblValue.CssClass = String.Empty; lblName.CssClass = "CustomEditorKeyClass"; if (isInvalid) { imgDelete.AddCssClass("hidden"); imgEdit.AddCssClass("hidden"); lblName.AddCssClass("hidden"); lblValue.AddCssClass("hidden"); RegisterEnableScript(false); } else { imgOK.AddCssClass("hidden"); imgUndo.AddCssClass("hidden"); txtName.CssClass += " hidden"; txtValue.CssClass += " hidden"; } } }
/// <summary> /// Disables the action buttons. /// </summary> /// <param name="imageButton">The image button</param> /// <param name="sourceName">Name of the source</param> /// <param name="parameter">The parameter</param> private void DisableActionButtons(CMSGridActionButton imageButton, string sourceName, object parameter) { int status = ValidationHelper.GetInteger((object)((DataRowView)((GridViewRow)parameter).DataItem).Row["EmailStatus"], -1); bool sending = EmailHelper.Queue.SendingInProgess; // Disable action buttons (and image) if e-mail status is 'created' or 'sending' if (sending || (status == (int)EmailStatusEnum.Created) || (status == (int)EmailStatusEnum.Sending)) { imageButton.OnClientClick = null; imageButton.Enabled = false; } }
/// <summary> /// UniGrid external data bound. /// </summary> private object GridDocsOnExternalDataBound(object sender, string sourceName, object parameter) { if (String.IsNullOrEmpty(sourceName)) { return(parameter); } switch (sourceName.ToLowerInvariant()) { case "update": { var drv = parameter as DataRowView; var plcUpd = new PlaceHolder { ID = "plcUdateAction" }; var pnlBlock = new Panel { ID = "pnlBlock" }; plcUpd.Controls.Add(pnlBlock); CreateUploaderControl(drv, pnlBlock); CreateExternalEditControl(drv, pnlBlock); return(plcUpd); } case "edit": { var row = ((DataRowView)((GridViewRow)parameter).DataItem).Row; // Get file extension string extension = ValidationHelper.GetString(row["AttachmentExtension"], string.Empty) .ToLowerInvariant(); // Get attachment GUID attachmentGuid = ValidationHelper.GetGuid(row["AttachmentGUID"], Guid.Empty); var img = sender as CMSGridActionButton; if (img != null) { if (createTempAttachment) { img.Visible = false; } else { img.ScreenReaderDescription = extension; img.ToolTip = attachmentGuid.ToString(); img.PreRender += img_PreRender; } } return(parameter); } case "delete": CMSGridActionButton imgDelete = sender as CMSGridActionButton; if (imgDelete != null) { // Turn off validation imgDelete.CausesValidation = false; imgDelete.PreRender += imgDelete_PreRender; } return(parameter); case "attachment": case "attachmentsize": { var id = ValidationHelper.GetInteger(parameter, 0); var fileName = (sourceName == "attachment") ? "Attachment.ascx" : "AttachmentSize.ascx"; return(new ObjectTransformation(AttachmentInfo.OBJECT_TYPE, id) { DataProvider = VariantsProvider, TransformationName = "~/CMSModules/Content/Controls/Attachments/DocumentAttachments/Transformations/" + fileName, NoDataTransformation = ResHelper.GetString("Attachment.NotAvailable") }); } default: return(parameter); } }
protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter) { DataRowView drv; bool taskEnabled; switch (sourceName.ToLowerCSafe()) { case "useexternalservice": // Use external service { CMSGridActionButton imgButton = sender as CMSGridActionButton; if (imgButton != null) { bool visible = false; // Only if setting 'Use external service' is allowed if (SchedulingHelper.UseExternalService) { drv = UniGridFunctions.GetDataRowView(imgButton.Parent as DataControlFieldCell); if (drv != null) { // Indicates whether the task is processed by an external service bool taskUseExternalService = ValidationHelper.GetBoolean(drv["TaskUseExternalService"], false); // Indicates whether the task is enabled taskEnabled = ValidationHelper.GetBoolean(drv["TaskEnabled"], false); if (taskUseExternalService && taskEnabled) { DateTime taskLastRunTime = ValidationHelper.GetDateTime(drv["TaskLastRunTime"], DateTimeHelper.ZERO_TIME); if (taskLastRunTime != DateTimeHelper.ZERO_TIME) { // Task period string interval = ValidationHelper.GetString(drv["TaskInterval"], null); DateTime now = DateTime.Now; TimeSpan period = SchedulingHelper.GetNextTime(interval, taskLastRunTime, now).Subtract(now); // Actual different time between now date and last run time TimeSpan actualDifferent = now.Subtract(taskLastRunTime); // Show image if actual different time is three times larger than task period if ((period.TotalSeconds > 0) && (actualDifferent.TotalSeconds > (period.TotalSeconds * 3))) { imgButton.ToolTip = GetString("scheduledtask.useservicewarning"); visible = true; } } } } } imgButton.Visible = visible; if (imgButton.Visible) { imgButton.OnClientClick = "return false;"; imgButton.Style.Add(HtmlTextWriterStyle.Cursor, "default"); } } } break; case "taskexecutions": if (string.IsNullOrEmpty(Convert.ToString(parameter))) { return(0); } break; case "runactions": // Image "run" button CMSGridActionButton runButton = ((CMSGridActionButton)sender); // Data row and task enabled value drv = UniGridFunctions.GetDataRowView(runButton.Parent as DataControlFieldCell); taskEnabled = ValidationHelper.GetBoolean(drv["TaskEnabled"], false); if (!taskEnabled) { // If not enabled add confirmation dialog runButton.OnClientClick = "if (!confirm(" + ScriptHelper.GetLocalizedString("taskdisabled.sure") + ")) return false;" + runButton.OnClientClick; } break; } return(parameter); }
/// <summary> /// Handles data bound event. /// </summary> protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter) { string result = string.Empty; DataRowView data; switch (sourceName.ToLowerCSafe()) { case "view": { CMSGridActionButton editButton = ((CMSGridActionButton)sender); var dataItemRow = ((DataRowView)(((GridViewRow)(parameter)).DataItem)).Row; var nodeID = dataItemRow.Field <Int32>("NodeID"); editButton.Attributes.Add("data-node-id", nodeID.ToString()); break; } // Create link to event document case "documentname": { data = (DataRowView)parameter; string documentName = ValidationHelper.GetString(data["DocumentName"], String.Empty); string culture = ValidationHelper.GetString(data["DocumentCulture"], String.Empty); int nodeID = ValidationHelper.GetInteger(data["NodeID"], 0); return("<a class=\"js-unigrid-action js-edit\" " + "href=\"javascript:void(0)\" " + "data-node-id=\"" + nodeID + "\" " + "data-document-culture=\"" + culture + "\" >" + HTMLHelper.HTMLEncode(documentName) + "</a>"); } case "eventtooltip": data = (DataRowView)parameter; return(UniGridFunctions.DocumentNameTooltip(data)); case "eventdate": case "eventopenfrom": case "eventopento": case "eventdatetooltip": case "eventopenfromtooltip": case "eventopentotooltip": if (!String.IsNullOrEmpty(parameter.ToString())) { if (sourceName.EndsWithCSafe("tooltip")) { return(mGMTTooltip ?? (mGMTTooltip = TimeZoneHelper.GetUTCLongStringOffset(CurrentUserInfo, CurrentSiteInfo))); } DateTime time = ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME); return(TimeZoneHelper.ConvertToUserTimeZone(time, true, CurrentUserInfo, CurrentSiteInfo)); } return(result); case "eventenddate": case "eventenddatetooltip": data = (DataRowView)parameter; try { parameter = data["eventenddate"]; } catch { parameter = null; } if ((parameter != null) && !String.IsNullOrEmpty(parameter.ToString())) { if (sourceName.EndsWithCSafe("tooltip")) { return(mGMTTooltip ?? (mGMTTooltip = TimeZoneHelper.GetUTCLongStringOffset(CurrentUserInfo, CurrentSiteInfo))); } DateTime time = ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME); return(TimeZoneHelper.ConvertToUserTimeZone(time, true, CurrentUserInfo, CurrentSiteInfo)); } return(result); } return(parameter); }
/// <summary> /// Gets the view action. /// </summary> /// <param name="key">Cache key</param> private string GetViewAction(string key) { var button = new CMSGridActionButton { IconCssClass = "icon-eye", IconStyle = GridIconStyle.Allow, ToolTip = GetString("General.View"), OnClientClick = String.Format("Show('{0}'); return false;", Server.UrlEncode(key)) }; return button.GetRenderedHTML(); }
protected object gridComments_OnExternalDataBound(object sender, string sourceName, object parameter) { switch (sourceName.ToLowerCSafe()) { case "commentusername": return(HTMLHelper.HTMLEncode(Convert.ToString(parameter))); case "commenttext": string text = Convert.ToString(parameter); if (text.Length > 50) { text = text.Substring(0, 50) + "..."; } return(HTMLHelper.HTMLEncode(text)); case "commentapproved": return(UniGridFunctions.ColoredSpanYesNo(parameter)); case "commentisspam": return(UniGridFunctions.ColoredSpanYesNoReversed(parameter)); case "approve": bool approve = ValidationHelper.GetBoolean(((DataRowView)((GridViewRow)parameter).DataItem).Row["CommentApproved"], false); if (!approve) { CMSGridActionButton button = ((CMSGridActionButton)sender); button.IconCssClass = "icon-check-circle"; button.IconStyle = GridIconStyle.Allow; button.ToolTip = GetString("general.approve"); } else { CMSGridActionButton button = ((CMSGridActionButton)sender); button.IconCssClass = "icon-times-circle"; button.IconStyle = GridIconStyle.Critical; button.ToolTip = GetString("general.reject"); } break; case "edit": string commentId = ((DataRowView)((GridViewRow)parameter).DataItem).Row["CommentID"].ToString(); CMSGridActionButton editButton = ((CMSGridActionButton)sender); // Get filter query string string queryCondition = ShowFilter ? filterElem.FilterQueryString : FilterQueryString; // If no display use postback for refresh string usePostback = String.Empty; if (!ShowFilter) { usePostback = "&usepostback=true"; } editButton.OnClientClick = "modalDialog('" + ResolveUrl("~/CMSModules/Blogs/Controls/Comment_Edit.aspx") + "?commentID=" + commentId + queryCondition + usePostback + "', 'CommentEdit', 850, 480); return false;"; break; } return(parameter); }
/// <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); }
object Grid_OnExternalDataBound(object sender, string sourceName, object parameter) { sourceName = sourceName.ToLowerCSafe(); switch (sourceName) { case "chatroomcreatedbychatuserid": ChatUserInfo user = ChatUserInfoProvider.GetChatUserInfo(ValidationHelper.GetInteger(parameter, 0)); if (user != null) { return(ChatHelper.GetCMSDeskChatUserField(this, user)); } else { return(GetString("general.na")); } case "approve": case "safedelete": DataRow row = ((DataRowView)((GridViewRow)parameter).DataItem).Row; ChatRoomInfo room = ChatRoomInfoProvider.GetChatRoomInfo(ValidationHelper.GetInteger(row["ChatRoomID"], 0)); if (room == null) { return(null); } bool enabled = ((CMSChatPage)Page).HasUserModifyPermission(room.ChatRoomSiteID); string toolTipResourceString; CMSGridActionButton button = ((CMSGridActionButton)sender); if (sourceName == "approve") { bool approve = ValidationHelper.GetBoolean(row["ChatRoomEnabled"], false); if (!approve) { toolTipResourceString = "general.enable"; button.IconCssClass = "icon-check-circle"; button.IconStyle = GridIconStyle.Allow; } else { toolTipResourceString = "general.disable"; button.IconCssClass = "icon-times-circle"; button.IconStyle = GridIconStyle.Critical; } // Disable 'approve' or 'reject' action if room is one to one support if (room.IsOneToOneSupport) { enabled = false; } } else { toolTipResourceString = "general.delete"; } if (!enabled) { button.Enabled = false; } button.ToolTip = GetString(toolTipResourceString); break; } return(parameter); }
/// <summary> /// Callback event for create calendar icon. /// </summary> /// <param name="sender">Sender object</param> /// <param name="sourceName">Event source name</param> /// <param name="parameter">Event parameter</param> /// <param name="val">Value from basic external data bound event</param> private object usUsers_OnAdditionalDataBound(object sender, string sourceName, object parameter, object val) { DataRowView drv = null; switch (sourceName.ToLowerCSafe()) { // Resolve calendar image case "calendar": drv = (parameter as DataRowView); string itemID = drv[usUsers.ReturnColumnName].ToString(); string iconID = "icon_" + itemID; string date = drv["ValidTo"].ToString(); string postback = ControlsHelper.GetPostBackEventReference(ucCalendar.DateTimeTextBox, "#").Replace("'#'", "$cmsj('#" + ucCalendar.DateTimeTextBox.ClientID + "').val()"); string onClick = String.Empty; ucCalendar.DateTimeTextBox.Attributes["OnChange"] = postback; if (!ucCalendar.UseCustomCalendar) { onClick = "$cmsj('#" + hdnDate.ClientID + "').val('" + itemID + "');" + ucCalendar.GenerateNonCustomCalendarImageEvent(); } else { onClick = "$cmsj('#" + hdnDate.ClientID + "').val('" + itemID + "'); var dt = $cmsj('#" + ucCalendar.DateTimeTextBox.ClientID + "'); dt.val('" + date + "'); dt.cmsdatepicker('setLocation','" + iconID + "'); dt.cmsdatepicker ('show');"; } var button = new CMSGridActionButton { ToolTip = GetString("membership.changevalidity"), IconCssClass = "icon-calendar", OnClientClick = onClick + "return false;", ID = iconID }; val = button.GetRenderedHTML(); break; // Resolve User name case "name": drv = (parameter as DataRowView); string name = ValidationHelper.GetString(drv["UserName"], String.Empty); string fullName = ValidationHelper.GetString(drv["FullName"], String.Empty); val = HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(name, fullName, String.Empty, false)); break; } return val; }
/// <summary> /// Gets the delete action. /// </summary> /// <param name="key">Cache key</param> protected string GetDeleteAction(string key) { var button = new CMSGridActionButton { IconCssClass = "icon-bin", IconStyle = GridIconStyle.Critical, ToolTip = GetString("General.Delete"), OnClientClick = String.Format("DeleteCacheItem({0}); return false;", ScriptHelper.GetString(key)) }; return button.GetRenderedHTML(); }
object categoryGrid_OnExternalDataBound(object sender, string sourceName, object parameter) { OptionCategoryInfo category; // Formatting columns switch (sourceName.ToLowerCSafe()) { case "categorydisplayname": category = OptionCategoryInfo.Provider.Get(ValidationHelper.GetInteger(parameter, 0)); return(HTMLHelper.HTMLEncode(category.CategoryFullName)); case "categorytype": return(EnumStringRepresentationExtensions.ToEnum <OptionCategoryTypeEnum>(ValidationHelper.GetString(parameter, "")).ToLocalizedString("com.optioncategorytype")); case "optionscounts": category = OptionCategoryInfo.Provider.Get(ValidationHelper.GetInteger(parameter, 0)); if (category.CategoryType != OptionCategoryTypeEnum.Text) { var tr = new ObjectTransformation("OptionsCounts", category.CategoryID) { DataProvider = countsDataProvider, Transformation = "{% if(AllowAllOptions) { GetResourceString(\"general.all\") } else { FormatString(GetResourceString(\"com.ProductOptions.availableXOfY\"), SelectedOptions, AllOptions) } %}", NoDataTransformation = "{$com.productoptions.nooptions$}", EncodeOutput = false }; return(tr); } return(""); case "edititem": category = new OptionCategoryInfo(((DataRowView)((GridViewRow)parameter).DataItem).Row); CMSGridActionButton btn = sender as CMSGridActionButton; // Disable edit button if category is global and global categories are NOT allowed if (btn != null) { if (!allowedGlobalCat && category.IsGlobal) { btn.Enabled = false; } var query = QueryHelper.BuildQuery("siteId", category.CategorySiteID.ToString(), "productId", ProductID.ToString()); string redirectUrl = ApplicationUrlHelper.GetElementDialogUrl(ModuleName.ECOMMERCE, "EditProductOptionCategory", category.CategoryID, query); btn.OnClientClick = "modalDialog('" + redirectUrl + "','categoryEdit', '1000', '800');"; } break; case "selectoptions": category = new OptionCategoryInfo(((DataRowView)((GridViewRow)parameter).DataItem).Row); CMSGridActionButton btnSelect = sender as CMSGridActionButton; if (btnSelect != null) { // Disable select button if category is type of Text if (category.CategoryType == OptionCategoryTypeEnum.Text) { btnSelect.Enabled = false; } else { var query = QueryHelper.BuildQuery("productId", ProductID.ToString()); // URL of allowed option selector pop-up string urlSelect = ApplicationUrlHelper.GetElementDialogUrl(ModuleName.ECOMMERCE, "ProductOptions.SelectOptions", category.CategoryID, query); // Open allowed options selection dialog btnSelect.OnClientClick = ScriptHelper.GetModalDialogScript(urlSelect, "selectoptions", 1000, 650); } } break; } return(parameter); }
/// <summary> /// Returns order item edit action HTML. /// </summary> protected string GetOrderItemEditAction(object value) { var editOrderItemElemHtml = ""; Guid itemGuid = ValidationHelper.GetGuid(value, Guid.Empty); if (itemGuid != Guid.Empty) { var query = "itemguid=" + itemGuid + GetCMSDeskShoppingCartSessionNameQuery(); var editItemUrl = UIContextHelper.GetElementDialogUrl(ModuleName.ECOMMERCE, "order.OrderItemProperties", 0, query); var priceDetailButton = new CMSGridActionButton { IconCssClass = "icon-edit", IconStyle = GridIconStyle.Allow, ToolTip = GetString("shoppingcart.editorderitem"), OnClientClick = ScriptHelper.GetModalDialogScript(editItemUrl, "OrderItemEdit", 720, 420) }; editOrderItemElemHtml = priceDetailButton.GetRenderedHTML(); } return editOrderItemElemHtml; }
/// <summary> /// Grid external data bound handler. /// </summary> protected object gridFiles_OnExternalDataBound(object sender, string sourceName, object parameter) { // Get the data row view from parameter DataRowView drv = null; if (parameter is DataRowView) { drv = (DataRowView)parameter; } else if (parameter is GridViewRow) { // Get data from the grid view row GridViewRow gvr = (parameter as GridViewRow); if (gvr != null) { drv = (DataRowView)gvr.DataItem; } } // Get the action button CMSGridActionButton btn = null; if (sender is CMSGridActionButton) { btn = (CMSGridActionButton)sender; } switch (sourceName) { case "delete": { // Delete action int siteId = ValidationHelper.GetInteger(drv["AttachmentSiteID"], 0); string siteName = GetSiteName(siteId); Guid guid = ValidationHelper.GetGuid(drv["AttachmentGUID"], Guid.Empty); string extension = ValidationHelper.GetString(drv["AttachmentExtension"], ""); // Check if the file is in DB bool db = ValidationHelper.GetBoolean(drv["HasBinary"], false); // Check if the file is in the file system bool fs = false; string path = AttachmentInfoProvider.GetFilePhysicalPath(siteName, guid.ToString(), extension); if (File.Exists(path)) { fs = true; } // If the file is present in both file system and database, delete is allowed if (fs && db) { // If the files are stored in file system, delete is allowed in database if (StoreInFileSystem(siteId)) { btn.OnClientClick = btn.OnClientClick.Replace("'delete'", "'deleteindatabase'"); btn.ToolTip = "Delete from database"; return(parameter); } // If the files are stored in database, delete is allowed in file system if (StoreInDatabase(siteId)) { btn.OnClientClick = btn.OnClientClick.Replace("'delete'", "'deleteinfilesystem'"); btn.ToolTip = "Delete from file system"; return(parameter); } } btn.Visible = false; } break; case "copy": { // Delete action int siteId = ValidationHelper.GetInteger(drv["AttachmentSiteID"], 0); string siteName = GetSiteName(siteId); Guid guid = ValidationHelper.GetGuid(drv["AttachmentGUID"], Guid.Empty); string extension = ValidationHelper.GetString(drv["AttachmentExtension"], ""); // Check if the file is in DB bool db = ValidationHelper.GetBoolean(drv["HasBinary"], false); // Check if the file is in the file system bool fs = false; string path = AttachmentInfoProvider.GetFilePhysicalPath(siteName, guid.ToString(), extension); if (File.Exists(path)) { fs = true; } // If the file is stored in file system and the file is not present in database, copy to database is allowed if (fs && !db && StoreInDatabase(siteId) && StoreInFileSystem(siteId)) { btn.OnClientClick = btn.OnClientClick.Replace("'copy'", "'copytodatabase'"); btn.ToolTip = "Copy to database"; //btn.ImageUrl = return(parameter); } // If the file is stored in database and the file is not present in file system, copy to file system is allowed if (db && !fs && StoreInFileSystem(siteId)) { btn.OnClientClick = btn.OnClientClick.Replace("'copy'", "'copytofilesystem'"); btn.ToolTip = "Copy to file system"; //btn.ImageUrl = return(parameter); } btn.Visible = false; } break; case "name": { // Attachment name string name = ValidationHelper.GetString(drv["AttachmentName"], ""); Guid guid = ValidationHelper.GetGuid(drv["AttachmentGUID"], Guid.Empty); int siteId = ValidationHelper.GetInteger(drv["AttachmentSiteID"], 0); string extension = ValidationHelper.GetString(drv["AttachmentExtension"], ""); // File name name = Path.GetFileNameWithoutExtension(name); string url = ResolveUrl("~/CMSPages/GetFile.aspx?guid=") + guid; if (siteId != currentSiteId) { // Add the site name to the URL if not current site SiteInfo si = SiteInfoProvider.GetSiteInfo(siteId); if (si != null) { url += "&sitename=" + si.SiteName; } } string tooltipSpan = name; bool isImage = ImageHelper.IsImage(extension); if (isImage) { int imageWidth = ValidationHelper.GetInteger(DataHelper.GetDataRowViewValue(drv, "AttachmentImageWidth"), 0); int imageHeight = ValidationHelper.GetInteger(DataHelper.GetDataRowViewValue(drv, "AttachmentImageHeight"), 0); string tooltip = UIHelper.GetTooltipAttributes(url, imageWidth, imageHeight, null, name, extension, null, null, 300); tooltipSpan = "<span id=\"" + guid + "\" " + tooltip + ">" + name + "</span>"; } return(UIHelper.GetFileIcon(Page, extension, tooltip: name) + " <a href=\"" + url + "\" target=\"_blank\">" + tooltipSpan + "</a>"); } case "size": // File size return(DataHelper.GetSizeString(ValidationHelper.GetInteger(parameter, 0))); case "yesno": // Yes / No return(UniGridFunctions.ColoredSpanYesNo(parameter)); case "site": { int siteId = ValidationHelper.GetInteger(parameter, 0); if (siteId > 0) { SiteInfo si = SiteInfoProvider.GetSiteInfo(siteId); if (si != null) { return(si.DisplayName); } } return(null); } case "storedinfilesystem": { // Delete action int siteId = ValidationHelper.GetInteger(drv["AttachmentSiteID"], 0); string siteName = GetSiteName(siteId); Guid guid = ValidationHelper.GetGuid(drv["AttachmentGUID"], Guid.Empty); string extension = ValidationHelper.GetString(drv["AttachmentExtension"], ""); // Check if the file is in DB bool db = ValidationHelper.GetBoolean(drv["HasBinary"], false); // Check if the file is in the file system bool fs = false; string path = AttachmentInfoProvider.GetFilePhysicalPath(siteName, guid.ToString(), extension); if (File.Exists(path)) { fs = true; } return(UniGridFunctions.ColoredSpanYesNo(fs)); } } return(parameter); }
/// <summary> /// Returns SKU edit action HTML. /// </summary> protected string GetSKUEditAction(object skuId, object skuSiteId, object skuParentSkuId, object isProductOption, object isBundleItem) { var editSKUElemHtml = ""; if (!ValidationHelper.GetBoolean(isProductOption, false) && !ValidationHelper.GetBoolean(isBundleItem, false) && ShoppingCartControl.IsInternalOrder) { // Do not render product detail link, when not authorized if (!CanReadProducts) { return editSKUElemHtml; } // Show variants tab for product variant, otherwise general tab int parentSkuId = ValidationHelper.GetInteger(skuParentSkuId, 0); string productIdParam = (parentSkuId == 0) ? skuId.ToString() : parentSkuId.ToString(); string tabParam = (parentSkuId == 0) ? "Products.General" : "Products.Variants"; var query = URLHelper.AddParameterToUrl("", "productid", productIdParam); query = URLHelper.AddParameterToUrl(query, "tabName", tabParam); query = URLHelper.AddParameterToUrl(query, "siteid", skuSiteId.ToString()); query = URLHelper.AddParameterToUrl(query, "dialog", "1"); var url = UIContextHelper.GetElementDialogUrl("CMS.ECommerce", "Products.Properties", additionalQuery: query); // Different tooltip for product than for product variant string tooltip = (parentSkuId == 0) ? GetString("shoppingcart.editproduct") : GetString("shoppingcart.editproductvariant"); var priceDetailButton = new CMSGridActionButton { IconCssClass = "icon-box", ToolTip = tooltip, OnClientClick = ScriptHelper.GetModalDialogScript(url, "SKUEdit", "95%", "95%"), }; editSKUElemHtml = priceDetailButton.GetRenderedHTML(); } return editSKUElemHtml; }
private object gridData_OnExternalDataBound(object sender, string sourceName, object parameter) { DataRowView row = parameter as DataRowView; if (DocumentListingDisplayed) { switch (sourceName.ToLowerInvariant()) { case "skunumber": case "skuavailableitems": case "publicstatusid": case "allowforsale": case "skusiteid": case "typename": case "skuprice": if (ShowSections && (row["NodeSKUID"] == DBNull.Value)) { return(NO_DATA_CELL_VALUE); } break; case "edititem": row = ((GridViewRow)parameter).DataItem as DataRowView; if ((row != null) && ((row["NodeSKUID"] == DBNull.Value) || showProductsInTree)) { CMSGridActionButton btn = sender as CMSGridActionButton; if (btn != null) { int currentNodeId = ValidationHelper.GetInteger(row["NodeID"], 0); int nodeParentId = ValidationHelper.GetInteger(row["NodeParentID"], 0); if (row["NodeSKUID"] == DBNull.Value) { btn.IconCssClass = "icon-eye"; btn.IconStyle = GridIconStyle.Allow; btn.ToolTip = GetString("com.sku.viewproducts"); } // Go to the selected document btn.OnClientClick = "EditItem(" + currentNodeId + ", " + nodeParentId + "); return false;"; } } break; } } switch (sourceName.ToLowerInvariant()) { case "skunumber": string skuNumber = ValidationHelper.GetString(row["SKUNumber"], null); return(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(skuNumber) ?? "")); case "skuavailableitems": var sku = new SKUInfo(row.Row); int availableItems = sku.SKUAvailableItems; // Inventory tracked by variants if (sku.SKUTrackInventory == TrackInventoryTypeEnum.ByVariants) { return(GetString("com.inventory.trackedbyvariants")); } // Inventory tracking disabled if (sku.SKUTrackInventory == TrackInventoryTypeEnum.Disabled) { return(GetString("com.inventory.nottracked")); } // Ensure correct values for unigrid export if (sender == null) { return(availableItems); } // Tracking by products var inlineAvailableItems = new InlineEditingTextBox { Text = availableItems.ToString(), DelayedReload = DocumentListingDisplayed, EnableEncode = false }; inlineAvailableItems.Formatting += (s, e) => { var reorderAt = sku.SKUReorderAt; // Emphasize the number when product needs to be reordered if (availableItems <= reorderAt) { // Format message informing about insufficient stock level string reorderMsg = string.Format(GetString("com.sku.reorderatTooltip"), reorderAt); string message = string.Format("<span class=\"alert-status-error\" onclick=\"UnTip()\" onmouseout=\"UnTip()\" onmouseover=\"Tip('{1}')\">{0}</span>", availableItems, reorderMsg); inlineAvailableItems.FormattedText = message; } }; // Unigrid with delayed reload in combination with inline edit control requires additional postback to sort data. // Update data only if external data bound is called for the first time. if (!forceReloadData) { inlineAvailableItems.Update += (s, e) => { var newNumberOfItems = ValidationHelper.GetInteger(inlineAvailableItems.Text, availableItems); if (ValidationHelper.IsInteger(inlineAvailableItems.Text) && (-1000000000 <= newNumberOfItems) && (newNumberOfItems <= 1000000000)) { CheckModifyPermission(sku); // Ensures that grid will display inserted value sku.SKUAvailableItems = newNumberOfItems; // Document list is used to display products -> document has to be updated to ensure correct sku mapping if (DocumentListingDisplayed) { int documentId = ValidationHelper.GetInteger(row.Row["DocumentID"], 0); // Create an instance of the Tree provider and select edited document with coupled data var tree = new TreeProvider(MembershipContext.AuthenticatedUser); var document = tree.SelectSingleDocument(documentId); if (document == null) { return; } document.SetValue("SKUAvailableItems", newNumberOfItems); document.Update(); forceReloadData = true; } // Stand-alone product -> only product has to be updated else { sku.MakeComplete(true); sku.Update(); gridData.ReloadData(); } } else { inlineAvailableItems.ErrorText = GetString("com.productedit.availableitemsinvalid"); } }; } return(inlineAvailableItems); case "skuprice": var product = new SKUInfo(row.Row); var currency = CurrencyInfoProvider.GetMainCurrency(product.SKUSiteID); var formattedValue = CurrencyInfoProvider.GetFormattedValue(product.SKUPrice, currency); // Ensure correct values for unigrid export if (sender == null) { return(formattedValue); } var inlineSkuPrice = new InlineEditingTextBox { Text = formattedValue, FormattedText = CurrencyInfoProvider.GetFormattedPrice(product.SKUPrice, currency), DelayedReload = DocumentListingDisplayed }; // Unigrid with delayed reload in combination with inline edit control requires additional postback to sort data. // Update data only if external data bound is called for the first time. if (!forceReloadData) { inlineSkuPrice.Update += (s, e) => { CheckModifyPermission(product); var price = ValidationHelper.GetDecimal(inlineSkuPrice.Text, -1); var error = ValidatePrice(price, currency, product); if (String.IsNullOrEmpty(error)) { UpdatePrice(product, price, row.Row); } else { inlineSkuPrice.ErrorText = error; } }; } return(inlineSkuPrice); case "publicstatusid": int id = ValidationHelper.GetInteger(row["SKUPublicStatusID"], 0); PublicStatusInfo publicStatus = PublicStatusInfoProvider.GetPublicStatusInfo(id); if (publicStatus != null) { // Localize and encode return(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(publicStatus.PublicStatusDisplayName))); } return(string.Empty); case "allowforsale": // Get "on sale" flag return(UniGridFunctions.ColoredSpanYesNo(ValidationHelper.GetBoolean(row["SKUEnabled"], false))); case "typename": string docTypeName = ValidationHelper.GetString(row["ClassDisplayName"], null); // Localize class display name if (!string.IsNullOrEmpty(docTypeName)) { return(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(docTypeName))); } return(string.Empty); } return(parameter); }
/// <summary> /// Gets the debug action for the thread. /// </summary> /// <param name="requestGuid">Request GUID for the debug</param> protected string GetDebugAction(object requestGuid) { string result = null; if (DebugHelper.AnyDebugEnabled) { var rGuid = ValidationHelper.GetGuid(requestGuid, Guid.Empty); if (rGuid != Guid.Empty) { var logs = DebugHelper.FindRequestLogs(rGuid); if (logs != null) { string url = LogControl.GetLogsUrl(rGuid); var button = new CMSGridActionButton { IconCssClass = "icon-bug", IconStyle = GridIconStyle.Allow, ToolTip = GetString("General.Debug"), OnClientClick = "modalDialog('" + url + "', 'ThreadDebug'); return false;" }; result = button.GetRenderedHTML(); } } } return result; }