/// <summary> /// External data binding handler. /// </summary> protected object gridDocuments_OnExternalDataBound(object sender, string sourceName, object parameter) { DataRowView data; switch (sourceName.ToLowerCSafe()) { case "documentname": { data = (DataRowView)parameter; string name = ValidationHelper.GetString(data["NodeAliasPath"], ""); string siteName = SiteInfoProvider.GetSiteName(ValidationHelper.GetInteger(data["NodeSiteID"], 0)); int currentNodeId = ValidationHelper.GetInteger(data["NodeID"], 0); int currentNodeParentId = ValidationHelper.GetInteger(data["NodeParentID"], 0); string result; if (currentSiteName == siteName.ToLowerCSafe()) { result = "<a href=\"javascript: SelectItem(" + currentNodeId + ", " + currentNodeParentId + ");\">" + HTMLHelper.HTMLEncode(TextHelper.LimitLength(name, 50)) + "</a>"; } else { result = "<span>" + HTMLHelper.HTMLEncode(TextHelper.LimitLength(name, 50)) + "</span>"; } // Show document mark only if method is not called from grid export bool isLink = (data["NodeLinkedNodeID"] != DBNull.Value); if ((sender != null) && isLink) { result += DocumentUIHelper.GetDocumentMarkImage(this, DocumentMarkEnum.Link); } return(result); } case "documentnametooltip": data = (DataRowView)parameter; return(UniGridFunctions.DocumentNameTooltip(data)); case "deleteaction": { GridViewRow container = (GridViewRow)parameter; int currentNodeId = ValidationHelper.GetInteger(((DataRowView)container.DataItem)["NodeID"], 0); bool current = (Node.NodeID == currentNodeId); ((Control)sender).Visible = ((((DataRowView)container.DataItem)["NodeLinkedNodeID"] != DBNull.Value) && !current); ((CMSGridActionButton)sender).CommandArgument = currentNodeId.ToString(); break; } } return(parameter); }
protected object uniGrid_OnExternalDataBound(object sender, string sourceName, object parameter) { DataRowView data = null; switch (sourceName.ToLowerCSafe()) { case "select": ImageButton btnImg = (ImageButton)sender; btnImg.OnClientClick = "parent.frames['tasksHeader'].selectDocuments = false;parent.frames['tasksTree'].SelectTree(" + btnImg.CommandArgument + ");window.location.href='" + ResolveUrl("~/CMSModules/Staging/Tools/Tasks/Tasks.aspx?serverid=") + serverId + "&nodeid=" + btnImg.CommandArgument + "'; return false;"; return(btnImg); case "showsubdocuments": ImageButton btnSubImg = (ImageButton)sender; int childNodesCount = ValidationHelper.GetInteger(((DataRowView)((GridViewRow)parameter).DataItem).Row["NodeChildNodesCount"], 0); if (childNodesCount > 0) { btnSubImg.OnClientClick = "parent.frames['tasksTree'].RefreshNode(" + btnSubImg.CommandArgument + "," + btnSubImg.CommandArgument + ");window.location.href='" + ResolveUrl("~/CMSModules/Staging/Tools/Tasks/DocumentsList.aspx?serverid=") + serverId + "&nodeid=" + btnSubImg.CommandArgument + "'; return false;"; } else { string noSubDocuments = GetString("synchronization.nosubdocuments"); btnSubImg.ToolTip = noSubDocuments; btnSubImg.ImageUrl = uniGrid.DefaultImageDirectoryPath + "subdocumentdisabled.png"; btnSubImg.AlternateText = noSubDocuments; 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); }
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> /// External data binding handler. /// </summary> protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter) { // Prepare variables int nodeId = 0; string culture = string.Empty; DataRowView data = null; sourceName = sourceName.ToLowerCSafe(); SiteInfo site = null; switch (sourceName) { // Edit button case EXTERNALSOURCE_EDIT: if (sender is ImageButton) { ImageButton editButton = (ImageButton)sender; data = UniGridFunctions.GetDataRowView(editButton.Parent as DataControlFieldCell); site = GetSiteFromRow(data); nodeId = ValidationHelper.GetInteger(data[SOURCE_NODEID], 0); culture = ValidationHelper.GetString(data[SOURCE_DOCUMENTCULTURE], string.Empty); string type = ValidationHelper.GetString(DataHelper.GetDataRowViewValue(data, SOURCE_TYPE), string.Empty); // Check permissions if ((site.Status != SiteStatusEnum.Running) || (!CMSMyDeskPage.IsUserAuthorizedPerContent(site.SiteName) || ((ListingType == ListingTypeEnum.All) && (type == LISTINGTYPE_RECYCLEBIN)))) { editButton.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/Editdisabled.png"); editButton.OnClientClick = "return false"; editButton.Style.Add(HtmlTextWriterStyle.Cursor, "default"); } else { editButton.OnClientClick = "return SelectItem(" + nodeId + ", '" + culture + "','" + ResolveSiteUrl(site) + "');"; } return(editButton); } return(sender); // Preview button case EXTERNALSOURCE_PREVIEW: if (sender is ImageButton) { ImageButton previewButton = (ImageButton)sender; data = UniGridFunctions.GetDataRowView(previewButton.Parent as DataControlFieldCell); site = GetSiteFromRow(data); string type = ValidationHelper.GetString(DataHelper.GetDataRowViewValue(data, SOURCE_TYPE), string.Empty); if ((site.Status != SiteStatusEnum.Running) || ((ListingType == ListingTypeEnum.All) && (type == LISTINGTYPE_RECYCLEBIN))) { previewButton.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/Viewdisabled.png"); previewButton.OnClientClick = "return false"; previewButton.Style.Add(HtmlTextWriterStyle.Cursor, "default"); } else { nodeId = ValidationHelper.GetInteger(data[SOURCE_NODEID], 0); culture = ValidationHelper.GetString(data[SOURCE_DOCUMENTCULTURE], string.Empty); string nodeAliasPath = ValidationHelper.GetString(data[SOURCE_NODEALIASPATH], string.Empty); // Generate preview URL string url = CMSContext.GetUrl(nodeAliasPath, null, site.SiteName); url = URLHelper.AddParameterToUrl(url, "viewmode", "2"); url = URLHelper.AddParameterToUrl(url, URLHelper.LanguageParameterName, culture); previewButton.OnClientClick = "window.open('" + URLHelper.ResolveUrl(url) + "','LiveSite');return false;"; } return(previewButton); } return(sender); // Document name column case EXTERNALSOURCE_DOCUMENTNAME: data = (DataRowView)parameter; string name = ValidationHelper.GetString(data[SOURCE_DOCUMENTNAME], string.Empty); nodeId = ValidationHelper.GetInteger(data[SOURCE_NODEID], 0); culture = ValidationHelper.GetString(data[SOURCE_DOCUMENTCULTURE], string.Empty); string className = ValidationHelper.GetString(data[SOURCE_CLASSNAME], string.Empty); site = GetSiteFromRow(data); if (name == string.Empty) { name = GetString("general.notspecified"); } // Add document type icon string result = string.Empty; switch (ListingType) { case ListingTypeEnum.DocTypeDocuments: break; default: result = "<img src=\"" + UIHelper.GetDocumentTypeIconUrl(Parent.Page, className, String.Empty, true) + "\" class=\"UnigridActionButton\" />"; break; } result += "<span style=\"vertical-align: bottom;\">" + HTMLHelper.HTMLEncode(TextHelper.LimitLength(name, 50)) + "</span>"; if (ListingType != ListingTypeEnum.All) { bool isLink = (data.Row.Table.Columns.Contains(SOURCE_NODELINKEDNODEID) && (data[SOURCE_NODELINKEDNODEID] != DBNull.Value)); if (isLink) { // Add link icon result += UIHelper.GetDocumentMarkImage(Parent.Page, DocumentMarkEnum.Link); } } return(result); // Class name column case EXTERNALSOURCE_CLASSDISPLAYNAME: string displayName = ValidationHelper.GetString(parameter, string.Empty); if (sourceName.ToLowerCSafe() == EXTERNALSOURCE_CLASSDISPLAYNAMETOOLTIP) { displayName = TextHelper.LimitLength(displayName, 50); } if (displayName == string.Empty) { displayName = "-"; } return(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(displayName))); case EXTERNALSOURCE_DOCUMENTNAMETOOLTIP: data = (DataRowView)parameter; return(UniGridFunctions.DocumentNameTooltip(data)); case EXTERNALSOURCE_STEPDISPLAYNAME: // Step display name string stepName = ValidationHelper.GetString(parameter, string.Empty); if (stepName == string.Empty) { stepName = "-"; } return(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(stepName))); case EXTERNALSOURCE_STEPNAME: // Step display name from ID int stepId = ValidationHelper.GetInteger(parameter, 0); if (stepId > 0) { WorkflowStepInfo wsi = WorkflowStepInfoProvider.GetWorkflowStepInfo(stepId); if (wsi != null) { return(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(wsi.StepDisplayName))); } } return("-"); case EXTERNALSOURCE_CULTURE: data = (DataRowView)parameter; culture = ValidationHelper.GetString(data[SOURCE_DOCUMENTCULTURE], string.Empty); // Add icon if (culture != String.Empty) { return(UniGridFunctions.DocumentCultureFlag(data, Page)); } return("-"); // Version column case EXTERNALSOURCE_VERSION: if (parameter == DBNull.Value) { parameter = "-"; } parameter = HTMLHelper.HTMLEncode(parameter.ToString()); return(parameter); // Site name column case EXTERNALSOURCE_SITENAME: string siteName = ValidationHelper.GetString(parameter, string.Empty); siteInfo = SiteInfoProvider.GetSiteInfo(siteName); return(HTMLHelper.HTMLEncode(siteInfo.DisplayName)); case EXTERNALSOURCE_SITEID: int siteId = ValidationHelper.GetInteger(parameter, 0); siteInfo = SiteInfoProvider.GetSiteInfo(siteId); return(HTMLHelper.HTMLEncode(siteInfo.DisplayName)); // Document timestamp column case EXTERNALSOURCE_MODIFIEDWHEN: case EXTERNALSOURCE_MODIFIEDWHENTOOLTIP: if (string.IsNullOrEmpty(parameter.ToString())) { return(string.Empty); } else { if (currentSiteInfo == null) { currentSiteInfo = CMSContext.CurrentSite; } bool displayGMT = (sourceName == EXTERNALSOURCE_MODIFIEDWHENTOOLTIP); DateTime time = ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME); return(TimeZoneHelper.ConvertToUserTimeZone(time, displayGMT, currentUserInfo, currentSiteInfo)); } } return(parameter); }
/// <summary> /// External data binding handler. /// </summary> protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter) { // Prepare variables string culture; DataRowView data; sourceName = sourceName.ToLowerCSafe(); SiteInfo site; switch (sourceName) { // Edit button case EXTERNALSOURCE_EDIT: if (sender is CMSGridActionButton) { var editButton = (CMSGridActionButton)sender; data = UniGridFunctions.GetDataRowView(editButton.Parent as DataControlFieldCell); site = GetSiteFromRow(data); int nodeId = ValidationHelper.GetInteger(data[SOURCE_NODEID], 0); culture = ValidationHelper.GetString(data[SOURCE_DOCUMENTCULTURE], string.Empty); string type = ValidationHelper.GetString(DataHelper.GetDataRowViewValue(data, SOURCE_TYPE), string.Empty); // Check permissions if ((site.Status != SiteStatusEnum.Running) || (!CMSPage.IsUserAuthorizedPerContent(site.SiteName) || ((ListingType == ListingTypeEnum.All) && (type == LISTINGTYPE_RECYCLEBIN)))) { editButton.Enabled = false; editButton.Style.Add(HtmlTextWriterStyle.Cursor, "default"); } else { editButton.Attributes.Add("data-site-url", ResolveSiteUrl(site)); editButton.Attributes.Add("data-node-id", nodeId.ToString()); editButton.Attributes.Add("data-document-culture", culture); } editButton.OnClientClick = "return false"; return(editButton); } return(sender); // Preview button case EXTERNALSOURCE_PREVIEW: if (sender is CMSGridActionButton) { var previewButton = (CMSGridActionButton)sender; data = UniGridFunctions.GetDataRowView(previewButton.Parent as DataControlFieldCell); site = GetSiteFromRow(data); string type = ValidationHelper.GetString(DataHelper.GetDataRowViewValue(data, SOURCE_TYPE), string.Empty); if ((site.Status != SiteStatusEnum.Running) || ((ListingType == ListingTypeEnum.All) && (type == LISTINGTYPE_RECYCLEBIN))) { previewButton.Enabled = false; previewButton.Style.Add(HtmlTextWriterStyle.Cursor, "default"); } else { culture = ValidationHelper.GetString(data[SOURCE_DOCUMENTCULTURE], string.Empty); var nodeID = ValidationHelper.GetInteger(data[SOURCE_NODEID], 0); // Generate preview URL var query = QueryHelper.BuildQuery("viewmode", ((int)ViewModeEnum.Preview).ToString(), URLHelper.LanguageParameterName, culture); string url = DocumentURLProvider.GetPresentationUrlHandlerPath(culture, nodeID, query); previewButton.Attributes.Add("data-preview-url", URLHelper.GetAbsoluteUrl(url, site.DomainName)); } previewButton.OnClientClick = "return false"; return(previewButton); } return(sender); // Document name column case EXTERNALSOURCE_DOCUMENTNAME: data = (DataRowView)parameter; string name = ValidationHelper.GetString(data[SOURCE_DOCUMENTNAME], string.Empty); string className = ValidationHelper.GetString(data[SOURCE_CLASSNAME], string.Empty); if (name == string.Empty) { name = GetString("general.root"); } // Add document type icon string result = string.Empty; switch (ListingType) { case ListingTypeEnum.DocTypeDocuments: break; default: var dataClass = DataClassInfoProvider.GetDataClassInfo(className); if (dataClass != null) { var iconClass = (string)dataClass.GetValue(SOURCE_CLASSICONCLASS); result = UIHelper.GetDocumentTypeIcon(Page, className, iconClass); } break; } result += "<span>" + HTMLHelper.HTMLEncode(TextHelper.LimitLength(name, 50)) + "</span>"; // Show document marks only if method is not called from grid export if ((sender != null) && (ListingType != ListingTypeEnum.All)) { bool isLink = (data.Row.Table.Columns.Contains(SOURCE_NODELINKEDNODEID) && (data[SOURCE_NODELINKEDNODEID] != DBNull.Value)); if (isLink) { // Add link icon result += DocumentUIHelper.GetDocumentMarkImage(Parent.Page, DocumentMarkEnum.Link); } } return(result); // Class name column case EXTERNALSOURCE_CLASSDISPLAYNAME: string displayName = ValidationHelper.GetString(parameter, string.Empty); if (sourceName.ToLowerCSafe() == EXTERNALSOURCE_CLASSDISPLAYNAMETOOLTIP) { displayName = TextHelper.LimitLength(displayName, 50); } if (displayName == string.Empty) { displayName = "-"; } return(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(displayName))); case EXTERNALSOURCE_DOCUMENTNAMETOOLTIP: data = (DataRowView)parameter; return(UniGridFunctions.DocumentNameTooltip(data)); case EXTERNALSOURCE_STEPDISPLAYNAME: // Step display name int stepId = ValidationHelper.GetInteger(parameter, 0); if (stepId > 0) { return(new ObjectTransformation(WorkflowStepInfo.OBJECT_TYPE, stepId) { Transformation = "{%stepdisplayname|(encode)%}" }); } return("-"); // Version column case EXTERNALSOURCE_VERSION: if (parameter == DBNull.Value) { parameter = "-"; } parameter = HTMLHelper.HTMLEncode(parameter.ToString()); return(parameter); // Document timestamp column case EXTERNALSOURCE_MODIFIEDWHEN: case EXTERNALSOURCE_MODIFIEDWHENTOOLTIP: if (String.IsNullOrEmpty(parameter.ToString())) { return(String.Empty); } if (currentSiteInfo == null) { currentSiteInfo = SiteContext.CurrentSite; } if (sourceName.EqualsCSafe(EXTERNALSOURCE_MODIFIEDWHEN, StringComparison.InvariantCultureIgnoreCase)) { DateTime time = ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME); return(TimeZoneHelper.ConvertToUserTimeZone(time, true, currentUserInfo, currentSiteInfo)); } return(mGMTTooltip ?? (mGMTTooltip = TimeZoneHelper.GetUTCLongStringOffset(currentUserInfo, currentSiteInfo))); } 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> /// External data binding handler. /// </summary> protected object gridDocuments_OnExternalDataBound(object sender, string sourceName, object parameter) { int currentNodeId; sourceName = sourceName.ToLowerCSafe(); switch (sourceName) { case "view": { // Dialog view item DataRowView data = ((DataRowView)((GridViewRow)parameter).DataItem); CMSGridActionButton btn = ((CMSGridActionButton)sender); // Current row is the Root document isRootDocument = (ValidationHelper.GetInteger(data["NodeParentID"], 0) == 0); currentNodeId = ValidationHelper.GetInteger(data["NodeID"], 0); isCurrentDocument = (currentNodeId == WOpenerNodeID); string culture = ValidationHelper.GetString(data["DocumentCulture"], string.Empty); // Existing document culture if (culture.ToLowerCSafe() == CultureCode.ToLowerCSafe()) { string className = ValidationHelper.GetString(data["ClassName"], string.Empty); if (DataClassInfoProvider.GetDataClassInfo(className).ClassHasURL) { var relativeUrl = isRootDocument ? "~/" : DocumentUIHelper.GetPageHandlerPreviewPath(currentNodeId, culture, CurrentUser.UserName); string url = ResolveUrl(relativeUrl); btn.OnClientClick = "ViewItem(" + ScriptHelper.GetString(url) + "); return false;"; } else { btn.Enabled = false; btn.Style.Add(HtmlTextWriterStyle.Cursor, "default"); } } // New culture version else { btn.OnClientClick = "wopener.NewDocumentCulture(" + currentNodeId + ", '" + CultureCode + "'); CloseDialog(); return false;"; } } break; case "edit": { CMSGridActionButton btn = ((CMSGridActionButton)sender); if (IsEditVisible) { DataRowView data = ((DataRowView)((GridViewRow)parameter).DataItem); string culture = ValidationHelper.GetString(data["DocumentCulture"], string.Empty); currentNodeId = ValidationHelper.GetInteger(data["NodeID"], 0); int nodeParentId = ValidationHelper.GetInteger(data["NodeParentID"], 0); if (!RequiresDialog || (culture.ToLowerCSafe() == CultureCode.ToLowerCSafe())) { // Go to the selected document or create a new culture version when not used in a dialog btn.OnClientClick = "EditItem(" + currentNodeId + ", " + nodeParentId + "); return false;"; } else { // New culture version in a dialog btn.OnClientClick = "wopener.NewDocumentCulture(" + currentNodeId + ", '" + CultureCode + "'); CloseDialog(); return false;"; } } else { btn.Visible = false; } } break; case "delete": { // Delete button CMSGridActionButton btn = ((CMSGridActionButton)sender); // Hide the delete button for the root document btn.Visible = !isRootDocument; } break; case "contextmenu": { // Dialog context menu item CMSGridActionButton btn = ((CMSGridActionButton)sender); // Hide the context menu for the root document btn.Visible = !isRootDocument && !ShowAllLevels; } break; case "versionnumber": { // Version number if (parameter == DBNull.Value) { parameter = "-"; } parameter = HTMLHelper.HTMLEncode(parameter.ToString()); return(parameter); } case "documentname": { // Document name DataRowView data = (DataRowView)parameter; string className = ValidationHelper.GetString(data["ClassName"], string.Empty); string classDisplayName = ValidationHelper.GetString(data["classdisplayname"], null); string name = ValidationHelper.GetString(data["DocumentName"], string.Empty); string culture = ValidationHelper.GetString(data["DocumentCulture"], string.Empty); string cultureString = null; currentNodeId = ValidationHelper.GetInteger(data["NodeID"], 0); int nodeParentId = ValidationHelper.GetInteger(data["NodeParentID"], 0); if (isRootDocument) { // User site name for the root document name = SiteContext.CurrentSiteName; } // Default culture if (culture.ToLowerCSafe() != CultureCode.ToLowerCSafe()) { cultureString = " (" + culture + ")"; } StringBuilder sb = new StringBuilder(); if (ShowDocumentTypeIcon) { // Prepare tooltip for document type icon string iconTooltip = ""; if (ShowDocumentTypeIconTooltip && (classDisplayName != null)) { string safeClassName = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(classDisplayName)); iconTooltip = string.Format("onmouseout=\"UnTip()\" onmouseover=\"Tip('{0}')\"", HTMLHelper.EncodeForHtmlAttribute(safeClassName)); } var dataClass = DataClassInfoProvider.GetDataClassInfo(className); if (dataClass != null) { var iconClass = (string)dataClass.GetValue("ClassIconClass"); sb.Append(UIHelper.GetDocumentTypeIcon(Page, className, iconClass, additionalAttributes: iconTooltip)); } } string safeName = HTMLHelper.HTMLEncode(TextHelper.LimitLength(name, 50)); if (DocumentNameAsLink && !isRootDocument) { string tooltip = UniGridFunctions.DocumentNameTooltip(data); string selectFunction = SelectItemJSFunction + "(" + currentNodeId + ", " + nodeParentId + ");"; sb.Append("<a href=\"javascript: ", selectFunction, "\""); sb.Append(" onmouseout=\"UnTip()\" onmouseover=\"Tip('", HTMLHelper.EncodeForHtmlAttribute(tooltip), "')\">", safeName, cultureString, "</a>"); } else { sb.Append(safeName, cultureString); } // Show document marks only if method is not called from grid export and document marks are allowed if ((sender != null) && ShowDocumentMarks) { // Prepare parameters int workflowStepId = ValidationHelper.GetInteger(DataHelper.GetDataRowViewValue(data, "DocumentWorkflowStepID"), 0); WorkflowStepTypeEnum stepType = WorkflowStepTypeEnum.Undefined; if (workflowStepId > 0) { WorkflowStepInfo stepInfo = WorkflowStepInfo.Provider.Get(workflowStepId); if (stepInfo != null) { stepType = stepInfo.StepType; } } // Create data container IDataContainer container = new DataRowContainer(data); // Add icons and use current culture of processed node because of 'Not translated document' icon sb.Append(" ", DocumentUIHelper.GetDocumentMarks(Page, currentSiteName, ValidationHelper.GetString(container.GetValue("DocumentCulture"), string.Empty), stepType, container)); } return(sb.ToString()); } case "documentculture": { DocumentFlagsControl ucDocFlags = null; if (OnDocumentFlagsCreating != null) { // Raise event for obtaining custom DocumentFlagControl object result = OnDocumentFlagsCreating(this, sourceName, parameter); ucDocFlags = result as DocumentFlagsControl; // Check if something other than DocumentFlagControl was returned if ((ucDocFlags == null) && (result != null)) { return(result); } } // Dynamically load document flags control when not created if (ucDocFlags == null) { ucDocFlags = LoadUserControl("~/CMSAdminControls/UI/DocumentFlags.ascx") as DocumentFlagsControl; } // Set document flags properties if (ucDocFlags != null) { DataRowView data = (DataRowView)parameter; // Get node ID currentNodeId = ValidationHelper.GetInteger(data["NodeID"], 0); if (!string.IsNullOrEmpty(SelectLanguageJSFunction)) { ucDocFlags.SelectJSFunction = SelectLanguageJSFunction; } ucDocFlags.ID = "docFlags" + currentNodeId; ucDocFlags.SiteCultures = SiteCultures; ucDocFlags.NodeID = currentNodeId; ucDocFlags.StopProcessing = true; // Keep the control for later usage FlagsControls.Add(ucDocFlags); return(ucDocFlags); } } break; case "modifiedwhen": case "modifiedwhentooltip": // Modified when if (string.IsNullOrEmpty(parameter.ToString())) { return(string.Empty); } DateTime modifiedWhen = ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME); currentUserInfo = currentUserInfo ?? MembershipContext.AuthenticatedUser; currentSiteInfo = currentSiteInfo ?? SiteContext.CurrentSite; return(sourceName.EqualsCSafe("modifiedwhen", StringComparison.InvariantCultureIgnoreCase) ? TimeZoneHelper.ConvertToUserTimeZone(modifiedWhen, true, currentUserInfo, currentSiteInfo) : TimeZoneHelper.GetUTCLongStringOffset(currentUserInfo, currentSiteInfo)); default: if (OnExternalAdditionalDataBound != null) { return(OnExternalAdditionalDataBound(sender, sourceName, parameter)); } break; } return(parameter); }
/// <summary> /// External data binding handler. /// </summary> protected object gridDocuments_OnExternalDataBound(object sender, string sourceName, object parameter) { DataRowView data = null; switch (sourceName.ToLowerCSafe()) { case "documentname": { data = (DataRowView)parameter; string name = ValidationHelper.GetString(data["NodeAliasPath"], ""); string siteName = ValidationHelper.GetString(data["SiteName"], ""); int currentNodeId = ValidationHelper.GetInteger(data["NodeID"], 0); int currentNodeParentId = ValidationHelper.GetInteger(data["NodeParentID"], 0); string result = null; if (currentSiteName == siteName.ToLowerCSafe()) { result = "<a href=\"javascript: SelectItem(" + currentNodeId + ", " + currentNodeParentId + ");\">" + HTMLHelper.HTMLEncode(TextHelper.LimitLength(name, 50)) + "</a>"; } else { result = "<span>" + HTMLHelper.HTMLEncode(TextHelper.LimitLength(name, 50)) + "</span>"; } bool isLink = (data["NodeLinkedNodeID"] != DBNull.Value); if (isLink) { result += UIHelper.GetDocumentMarkImage(this, DocumentMarkEnum.Link); } return(result); } case "documentnametooltip": data = (DataRowView)parameter; return(UniGridFunctions.DocumentNameTooltip(data)); case "type": { data = (DataRowView)parameter; int currentNodeId = ValidationHelper.GetInteger(data["NodeID"], 0); int linkedNodeId = ValidationHelper.GetInteger(data["NodeLinkedNodeID"], 0); if (linkedNodeId == 0) { return(GetString("LinkedDocs.Original")); } else if (currentNodeId == Node.NodeID) { return(GetString("LinkedDocs.Current")); } else { return(string.Empty); } } case "sitename": { string siteName = (string)parameter; SiteInfo si = SiteInfoProvider.GetSiteInfo(siteName); if (si != null) { return(HTMLHelper.HTMLEncode(si.DisplayName)); } else { return(parameter); } } case "deleteaction": { GridViewRow container = (GridViewRow)parameter; int currentNodeId = ValidationHelper.GetInteger(((DataRowView)container.DataItem)["NodeID"], 0); bool current = (Node.NodeID == currentNodeId); ((Control)sender).Visible = ((((DataRowView)container.DataItem)["NodeLinkedNodeID"] != DBNull.Value) && !current); ((ImageButton)sender).CommandArgument = currentNodeId.ToString(); break; } } return(parameter); }
/// <summary> /// External data binding handler. /// </summary> protected object gridDocuments_OnExternalDataBound(object sender, string sourceName, object parameter) { int currentNodeId = 0; sourceName = sourceName.ToLower(); switch (sourceName) { case "published": { // Published state bool published = ValidationHelper.GetBoolean(parameter, true); if (published) { return("<span class=\"DocumentPublishedYes\">" + GetString("General.Yes") + "</span>"); } else { return("<span class=\"DocumentPublishedNo\">" + GetString("General.No") + "</span>"); } } 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 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); string preferredCulture = CMSContext.PreferredCultureCode; // Default culture if (culture.ToLower() != preferredCulture.ToLower()) { cultureString = " (" + culture + ")"; } string tooltip = UniGridFunctions.DocumentNameTooltip(data); string imageUrl = null; if (className.Equals("cms.file", StringComparison.InvariantCultureIgnoreCase)) { string extension = ValidationHelper.GetString(data["DocumentType"], ""); imageUrl = GetFileIconUrl(extension, "List"); } // Use class icons else { imageUrl = ResolveUrl(GetDocumentTypeIconUrl(className)); } StringBuilder sb = new StringBuilder(); sb.Append( "<img src=\"", imageUrl, "\" class=\"UnigridActionButton\" /> ", "<a href=\"javascript: SelectItem(", currentNodeId, ", ", nodeParentId, ");\" ", "onmouseout=\"UnTip()\" onmouseover=\"Tip('", tooltip, "')\">", HTMLHelper.HTMLEncode(TextHelper.LimitLength(name, 50)), cultureString, "</a>" ); // Prepare parameters int workflowStepId = ValidationHelper.GetInteger(DataHelper.GetDataRowViewValue(data, "DocumentWorkflowStepID"), 0); string stepName = null; if (workflowStepId > 0) { WorkflowStepInfo stepInfo = WorkflowStepInfoProvider.GetWorkflowStepInfo(workflowStepId); if (stepInfo != null) { stepName = stepInfo.StepName; } } // Create data container IDataContainer container = new DataRowContainer(data); // Add icons sb.Append(" ", UIHelper.GetDocumentMarks(Page, currentSiteName, preferredCulture, stepName, container)); return(sb.ToString()); } case "documentculture": { // Dynamically load document flags control DocumentFlagsControl ucDocFlags = Page.LoadControl("~/CMSAdminControls/UI/DocumentFlags.ascx") as DocumentFlagsControl; // Set document flags properties if (ucDocFlags != null) { // Get node ID currentNodeId = ValidationHelper.GetInteger(parameter, 0); 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(""); } else { DateTime modifiedWhen = ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME); if (currentUserInfo == null) { currentUserInfo = CMSContext.CurrentUser; } if (currentSiteInfo == null) { currentSiteInfo = CMSContext.CurrentSite; } bool displayGMT = (sourceName == "modifiedwhentooltip"); return(TimeZoneHelper.ConvertToUserTimeZone(modifiedWhen, displayGMT, currentUserInfo, currentSiteInfo)); } case "classdisplayname": case "classdisplaynametooltip": // Localize class display name if (!string.IsNullOrEmpty(parameter.ToString())) { return(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(parameter.ToString()))); } return(""); } return(parameter); }
/// <summary> /// Handles data bound event. /// </summary> protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter) { string result = string.Empty; DataRowView data = null; switch (sourceName.ToLower()) { // Create link to event document case "documentname": { data = (DataRowView)parameter; string siteName = ValidationHelper.GetString(data["SiteName"], String.Empty); string documentName = ValidationHelper.GetString(data["DocumentName"], String.Empty); string culture = ValidationHelper.GetString(data["DocumentCulture"], String.Empty); int nodeID = ValidationHelper.GetInteger(data["NodeID"], 0); SiteInfo si = SiteInfoProvider.GetSiteInfo(siteName); if (si != null) { // Get current app path string appPath = URLHelper.ApplicationPath.TrimEnd('/'); string domain = si.DomainName; // If domain contains app path donnt add it if (domain.Contains("/")) { appPath = null; } string path = URLHelper.ResolveUrl("~/CMSDesk/default.aspx?section=content&action=edit&nodeid=" + nodeID + "&culture=" + culture); return("<a target=\"_top\" href=\'" + path + "'\" >" + HTMLHelper.HTMLEncode(documentName) + "</a>"); } } return(HTMLHelper.HTMLEncode(parameter.ToString())); 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 (currentUserInfo == null) { currentUserInfo = CMSContext.CurrentUser; } if (currentSiteInfo == null) { currentSiteInfo = CMSContext.CurrentSite; } bool displayGMT = sourceName.EndsWith("tooltip"); DateTime time = ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME); return(TimeZoneHelper.ConvertToUserTimeZone(time, displayGMT, 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 (currentUserInfo == null) { currentUserInfo = CMSContext.CurrentUser; } if (currentSiteInfo == null) { currentSiteInfo = CMSContext.CurrentSite; } bool displayGMT = sourceName.EndsWith("tooltip"); DateTime time = ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME); return(TimeZoneHelper.ConvertToUserTimeZone(time, displayGMT, currentUserInfo, currentSiteInfo)); } return(result); } return(parameter); }