/// <summary> /// Sets the value of all subject related controls. /// </summary> private void SetSubjectControlValues(object entity) { _subjectLabel.Text = GlobalResource.AssociationSubjectLabel; if (entity != null) { string title = CoreHelper.UpdateEmptyTitle(CoreHelper.GetTitleByResourceType((Resource)entity)); SubjectDisplayLink.Text = System.Web.HttpUtility.HtmlEncode(CoreHelper.FitString(title, 40)); } }
//Adds resource link to the list. private void AddResourceLinkToList(BulletedList list, Resource res) { string linkText = HttpUtility.HtmlEncode(CoreHelper.FitString(CoreHelper.UpdateEmptyTitle( CoreHelper.GetTitleByResourceType(res)), _maxTitleCharWidth)); string linkUrl = string.Empty; linkUrl = string.Format(CultureInfo.CurrentCulture, ViewUrl, res.Id); ListItem item = new ListItem(linkText, linkUrl); //TODO - The following attribute is added for showing tooltip - but it does not work. item.Attributes.Add("title", linkText); list.Items.Add(new ListItem(linkText, linkUrl)); }
/// <summary> /// Populate tree view from data source. /// </summary> protected override void PopulateTree() { if (!this.Page.IsPostBack) { resource = GetScholarlyWorkItem(); _subjectLabel.Text = GlobalResource.CategoryAssociationSubjectLabel; _subjectLink.Text = HttpUtility.HtmlEncode(CoreHelper.FitString(CoreHelper.UpdateEmptyTitle( CoreHelper.GetTitleByResourceType(resource)), _maxCharShownTree)); _subjectLink.NavigateUrl = string.Format(CultureInfo.CurrentCulture, SubjectNavigationUrl, resource.Id); BindTreeView(true); } }
private void Refresh() { IList <Contact> authors = null; string range = string.Empty; AuthorsListBox.Items.Clear(); //Find selected bucket if (AtoELink.Font.Bold) { range = Constants.A_EAuthors; } else if (FtoJLink.Font.Bold) { range = Constants.F_JAuthors; } else if (KtoOLink.Font.Bold) { range = Constants.K_OAuthors; } else if (PtoTLink.Font.Bold) { range = Constants.P_TAuthors; } else if (UtoZLink.Font.Bold) { range = Constants.U_ZAuthors; } else if (OtherLink.Font.Bold) { range = Constants.OtherAuthors; } int fetchRecordCount = 0; int totalRecords = 0; //Calculate fetched record count if (PageIndex > 0) { fetchRecordCount = PageSize * this.PageIndex; } //Fetch authors using (ResourceDataAccess dataAccess = new ResourceDataAccess(this.CreateContext())) { if (IsSecurityAwareControl) { if (AuthenticatedToken != null) { authors = (IList <Contact>)dataAccess.GetAuthors(this.AuthenticatedToken, range, FilterTextBox.Text.Trim(), PageSize, fetchRecordCount, out totalRecords); } } else { authors = (IList <Contact>)dataAccess.GetAuthors(null, range, FilterTextBox.Text.Trim(), PageSize, fetchRecordCount, out totalRecords); } } //Set Page count. if (totalRecords > 0 && totalRecords > PageSize) { PageCount = Convert.ToInt32(Math.Ceiling((double)totalRecords / PageSize)); } else { PageCount = 0; } //Set status of Next and Previous navigation buttons NextButton.Enabled = PrevButton.Enabled = false; NextButton.Enabled = PageCount == 1 | PageCount <= (PageIndex + 1) ? false : true; PrevButton.Enabled = PageIndex == 0 ? false : true; if (authors != null) { foreach (Contact contact in authors) { string title = contact.Title; contact.Title = HttpUtility.HtmlEncode(CoreHelper.FitString(CoreHelper.GetTitleByResourceType(contact), 30)); Person person = contact as Person; if (person != null) { if (!string.IsNullOrEmpty(person.FirstName) || !string.IsNullOrEmpty(person.LastName)) { contact.Title += "(" + title + ")"; } } } } AuthorsListBox.DataSource = authors; AuthorsListBox.DataBind(); }
private void BindRelatedFiles() { if (DataSource.Files != null && DataSource.Files.Count > 0) { int index = 0; foreach (File file in DataSource.Files) { if (UserPermissions == null || (UserPermissions.Keys.Contains(file.Id) && UserPermissions[file.Id].Contains(UserResourcePermissions.Read))) { HyperLink link = new HyperLink(); link.Text = HttpUtility.HtmlEncode(CoreHelper.FitString(CoreHelper.UpdateEmptyTitle(CoreHelper.GetTitleByResourceType(file)), _maxTitleCharWidth)); if (!string.IsNullOrEmpty(FilesLink)) { link.NavigateUrl = string.Format(CultureInfo.CurrentCulture, FilesLink, file.Id); } this.Files.Controls.Add(link); if (index < (DataSource.Files.Count - 1)) { Label commalbl = new Label(); commalbl.Text = _comma; this.Files.Controls.Add(commalbl); } } if (index >= _maxFilesCount - 1) { if (index < (DataSource.Files.Count - 1)) { Label etcLbl = new Label(); etcLbl.Text = _etc; this.Files.Controls.Add(etcLbl); } break; } index++; } } }
/// <summary> /// Updates the status of controls base on DataSource. /// </summary> public override void DataBind() { base.DataBind(); if (DataSource != null) { this.TitleHeader.Text = GlobalResource.TitleText + _colan; //Set title with link this.ResourceTitle.Text = HttpUtility.HtmlEncode(CoreHelper.FitString(CoreHelper.UpdateEmptyTitle( CoreHelper.GetTitleByResourceType(DataSource)), _maxTitleCharWidth)) + " (" + DataSource.GetType().Name + ")"; if (!string.IsNullOrEmpty(TitleLink) && (UserPermissions == null || (UserPermissions.Keys.Contains(DataSource.Id) && UserPermissions[DataSource.Id].Contains(UserResourcePermissions.Read)))) { this.ResourceTitle.NavigateUrl = string.Format(CultureInfo.CurrentCulture, TitleLink, DataSource.Id); } else { this.ResourceTitle.NavigateUrl = string.Empty; } //Set date based on ShowDate value. if (ShowDate == DateType.DateAdded) { this.DateAddedHeader.Text = GlobalResource.DateAddedText + _colan; this.DateAdded.Text = DataSource.DateAdded != null?DataSource.DateAdded.Value.ToString() : string.Empty; } else { this.DateAddedHeader.Text = GlobalResource.DateModifiedText + _colan; this.DateAdded.Text = DataSource.DateModified != null?DataSource.DateModified.Value.ToString() : string.Empty; } //Set Description. this.Description.Text = HttpUtility.HtmlEncode(CoreHelper.FitString(DataSource.Description, _maxDescriptionCharWidth)); //Set files. BindRelatedFiles(); //set authors. ScholarlyWork resource = DataSource as ScholarlyWork; if (resource != null && resource.Authors != null && resource.Authors.Count > 0) { int index = 0; foreach (Contact author in resource.Authors) { if (UserPermissions == null || (UserPermissions.Keys.Contains(author.Id) && UserPermissions[author.Id].Contains(UserResourcePermissions.Read))) { HyperLink link = new HyperLink(); link.Text = HttpUtility.HtmlEncode(CoreHelper.FitString(CoreHelper.UpdateEmptyTitle(CoreHelper.GetTitleByResourceType(author)), _maxTitleCharWidth)); if (!string.IsNullOrEmpty(AuthorsLink)) { link.NavigateUrl = string.Format(CultureInfo.CurrentCulture, AuthorsLink, author.Id); } this.Authors.Controls.Add(link); if (index < (resource.Authors.Count - 1)) { Label commalbl = new Label(); commalbl.Text = _comma; this.Authors.Controls.Add(commalbl); } } if (index >= _maxAuthorsCount - 1) { if (index < (resource.Authors.Count - 1)) { Label etcLbl = new Label(); etcLbl.Text = _etc; this.Authors.Controls.Add(etcLbl); } break; } index++; } } } }