public override void ReloadData() { // Hide control for one culture version if ((DataSource == null) || DataHelper.DataSourceIsEmpty(SiteCultures) || (SiteCultures.Tables[0].Rows.Count <= 1)) { Visible = false; } else { // Check the data source if (!(DataSource is GroupedDataSource)) { throw new Exception("[DocumentFlags]: Only GroupedDataSource is supported as a data source."); } // Register tooltip script ScriptHelper.RegisterTooltip(Page); // Get appropriate table from the data source GroupedDataSource gDS = (GroupedDataSource)DataSource; DataTable table = gDS.GetGroupDataTable(NodeID); // Get document in the default site culture DateTime defaultLastModification = DateTimeHelper.ZERO_TIME; DateTime defaultLastPublished = DateTimeHelper.ZERO_TIME; bool defaultCultureExists = false; DataRow[] rows = null; if (table != null) { rows = table.Select("DocumentCulture='" + DefaultSiteCulture + "'"); defaultCultureExists = (rows.Length > 0); } if (defaultCultureExists) { defaultLastModification = ValidationHelper.GetDateTime(rows[0]["DocumentModifiedWhen"], DateTimeHelper.ZERO_TIME); defaultLastPublished = ValidationHelper.GetDateTime(rows[0]["DocumentLastPublished"], DateTimeHelper.ZERO_TIME); } // Build the content StringBuilder sb = new StringBuilder(); sb.Append("<div class=\"document-flags\">"); int colsInRow = 0; int cols = 0; int colsCount = SiteCultures.Tables[0].Rows.Count; if (colsCount < RepeatColumns) { RepeatColumns = colsCount; } foreach (DataRow dr in SiteCultures.Tables[0].Rows) { ++cols; ++colsInRow; DateTime lastModification = DateTimeHelper.ZERO_TIME; string versionNumber = null; string className = null; TranslationStatusEnum status = TranslationStatusEnum.NotAvailable; string cultureName = DataHelper.GetStringValue(dr, "CultureName", "-"); string cultureCode = DataHelper.GetStringValue(dr, "CultureCode", "-"); // Get document for given culture if (table != null) { rows = table.Select("DocumentCulture='" + cultureCode + "'"); // Document doesn't exist if (rows.Length != 0) { className = DataHelper.GetStringValue(rows[0], "ClassName", null); versionNumber = DataHelper.GetStringValue(rows[0], "DocumentLastVersionNumber", null); // Check if document is outdated if (versionNumber != null) { lastModification = ValidationHelper.GetDateTime(rows[0]["DocumentLastPublished"], DateTimeHelper.ZERO_TIME); status = (lastModification < defaultLastPublished) ? TranslationStatusEnum.Outdated : TranslationStatusEnum.Translated; } else { lastModification = ValidationHelper.GetDateTime(rows[0]["DocumentModifiedWhen"], DateTimeHelper.ZERO_TIME); status = (lastModification < defaultLastModification) ? TranslationStatusEnum.Outdated : TranslationStatusEnum.Translated; } } } sb.Append("<span class=\"", GetStatusCSSClass(status), "\">"); var itemUrl = (className != null && DataClassInfoProvider.GetDataClassInfo(className).ClassHasURL) ? UrlResolver.ResolveUrl(DocumentUIHelper.GetPageHandlerLivePath(NodeID, cultureCode)) : "#"; sb.Append("<img onmouseout=\"UnTip()\" style=\"cursor:pointer;\" onclick=\"", SelectJSFunction, "('", NodeID, "','", cultureCode, "'," + Convert.ToInt32((status != TranslationStatusEnum.NotAvailable)) + "," + ScriptHelper.GetString(itemUrl) + ")\" onmouseover=\"DF_Tip('", GetFlagIconUrl(cultureCode, "48x48"), "', '", cultureName, "', '", GetStatusString(status), "', '"); sb.Append(versionNumber ?? string.Empty); sb.Append("', '"); sb.Append((lastModification != DateTimeHelper.ZERO_TIME) ? TimeZoneHelper.ConvertToUserTimeZone(lastModification, true, MembershipContext.AuthenticatedUser, SiteContext.CurrentSite) : string.Empty); sb.Append("')\" src=\""); sb.Append(GetFlagIconUrl(cultureCode, "16x16")); sb.Append("\" alt=\""); sb.Append(cultureName); sb.Append("\" /></span>"); // Ensure repeat columns if (((colsInRow % RepeatColumns) == 0) && (cols != colsCount)) { sb.Append("<br />\n"); colsInRow = 0; } } sb.Append("</div>\n"); ltlFlags.Text = sb.ToString(); } }