void CheckAndDisplayFile() { ResourceFileName.Text = Server.HtmlEncode(SPFile.Name); DocLibLink.NavigateUrl = SPList.DefaultViewUrl; DocLibLink.Text = Server.HtmlEncode(SPList.Title); // Make sure that the package isn't checked out. //Using LoginName instead of Sid as Sid may be empty while using FBA #if SP2007 if (SPFile.CheckOutStatus != SPFile.SPCheckOutStatus.None && SPFile.CheckedOutBy.LoginName.Equals(SPWeb.CurrentUser.LoginName)) #else if (SPFile.CheckOutType != SPFile.SPCheckOutType.None && SPFile.CheckedOutByUser.LoginName.Equals(SPWeb.CurrentUser.LoginName)) #endif { // If it's checked out by the current user, show an error. throw new SafeToDisplayException(PageCulture.Resources.ActionsCheckedOutError); } // no minor versions or limited version number warnings if (!SPList.EnableVersioning || SPList.MajorVersionLimit != 0 || SPList.MajorWithMinorVersionsLimit != 0) { if (SlkStore.Settings.AutoVersionLibrariesIfUnversioned) { SlkStore.VersionLibrary((SPDocumentLibrary)SPList); Response.Redirect(Request.RawUrl, true); } else { errorBanner.AddError(ErrorType.Warning, PageCulture.Format(PageCulture.Resources.ActionsVersioningOff, Server.HtmlEncode(SPList.Title))); } } // If the current file isn't a published version, show a warning. // If the document library doesn't have minor versions, the file is NEVER SPFileLevel.Published if (SPList.EnableMinorVersions) { if (SPFile.Level == SPFileLevel.Draft) { errorBanner.AddError(ErrorType.Warning, PageCulture.Resources.ActionsDraftVersion); } } if (!IsPostBack) { // get information about the package: populate the "Organizations" row // (as applicable) in the UI, and set <title> and <description> to the text // of the title and description to display string title, description; if (NonELearning) { // non-e-learning content... // set <title> and <description> title = SPFile.Title; if (String.IsNullOrEmpty(title)) { title = Path.GetFileNameWithoutExtension(SPFile.Name); } description = string.Empty; // hide the "Organizations" row organizationRow.Visible = false; organizationRowBottomLine.Visible = false; } else { // e-learning content... // set <packageInformation> to refer to information about the package title = package.Title; description = package.Description; // populate the drop-down list of organizations; hide the entire row containing that drop-down if there's only one organization if (package.Organizations.Count <= 1) { organizationRow.Visible = false; organizationRowBottomLine.Visible = false; } else { foreach (OrganizationNodeReader nodeReader in package.Organizations) { string id = nodeReader.Id; organizationList.Items.Add(new ListItem(Server.HtmlEncode(GetDefaultTitle(nodeReader.Title, id)), id)); } ListItem defaultOrganization = organizationList.Items.FindByValue(package.DefaultOrganizationId.ToString(CultureInfo.InvariantCulture)); if (defaultOrganization != null) { defaultOrganization.Selected = true; } } } // copy <title> to the UI lblTitle.Text = Server.HtmlEncode(title); lblDescription.Text = SlkUtilities.GetCrlfHtmlEncodedText(description); } // if the package has warnings, tell the user if (package.Warnings != null) { StringBuilder sb = new StringBuilder(); sb.Append(PageCulture.Resources.ActionsWarning); sb.AppendLine("<br />"); sb.Append("<a href=\"javascript: __doPostBack('showWarnings','');\">"); if (ShowWarnings) { sb.Append(PageCulture.Resources.ActionsHideDetails); } else { sb.Append(PageCulture.Resources.ActionsShowDetails); } sb.AppendLine("</a>"); if (ShowWarnings) { sb.AppendLine("<ul style=\"margin-top:0;margin-bottom:0;margin-left:24;\">"); using (XmlReader xmlReader = package.Warnings.CreateReader()) { XPathNavigator root = new XPathDocument(xmlReader).CreateNavigator(); foreach (XPathNavigator error in root.Select("/Warnings/Warning")) { sb.Append("<li>"); sb.Append(Server.HtmlEncode(error.Value)); sb.AppendLine("</li>"); } } sb.Append("</ul>\n"); } errorBanner.AddHtmlErrorText(ErrorType.Warning, sb.ToString()); } }