private void InitPageData() { if (isByUser || isShowNew || isShowFresh) { List <Page> dataSource; var emptyScreenCaption = string.Empty; var emptyScreenText = string.Empty; if (isByUser) { dataSource = Wiki.GetPages(byUserID); } else if (isShowNew) { dataSource = Wiki.GetNewPages(MaxNewResults); emptyScreenCaption = WikiResource.EmptyScreenWikiNewPagesCaption; emptyScreenText = WikiResource.EmptyScreenWikiNewPagesText; } else { dataSource = Wiki.GetRecentEditedPages(MaxNewResults); emptyScreenCaption = WikiResource.EmptyScreenWikiRecentlyEditedCaption; emptyScreenText = WikiResource.EmptyScreenWikiRecentlyEditedText; } Page.RegisterInlineScript(String.Format(" wikiPages = {0}; ASC.Community.Wiki.InitListPages();", JsonConvert.SerializeObject(dataSource.ConvertAll(p => new { PageName = GetPageName(p), ID = p.ID, PageLink = GetPageViewLink(p), Author = CoreContext.UserManager.GetUsers(p.UserID).RenderCustomProfileLink("", "linkMedium"), PageDate = GetDate(p) })) ), onReady: true); var emptyScreenControl = new EmptyScreenControl { ID = "wikiListPagesEmpty", ImgSrc = WebImageSupplier.GetAbsoluteWebPath("wikilogo150.png", WikiManager.ModuleId), Header = emptyScreenCaption, Describe = emptyScreenText, CssClass = "display-none" }; if (CommunitySecurity.CheckPermissions(Community.Wiki.Common.Constants.Action_AddPage)) { emptyScreenControl.ButtonHTML = String.Format("<a class='link underline blue plus' href='default.aspx?action=New'>{0}</a>", WikiResource.menu_AddNewPage); } phListEmptyScreen.Controls.Add(emptyScreenControl); } else { List <Page> result; result = isShowCat ? Wiki.GetPages(categoryName) : Wiki.GetPages(); result.RemoveAll(pemp => string.IsNullOrEmpty(pemp.PageName)); Page.RegisterInlineScript(String.Format(" wikiCategoryAlfaList = '{0}'; wikiPages = {1}; ASC.Community.Wiki.InitListPagesByLetter();", WikiResource.wikiCategoryAlfaList, JsonConvert.SerializeObject(result.ConvertAll(p => new { PageName = GetPageName(p), ID = p.ID, PageLink = GetPageViewLink(p) })) ), onReady: true); var emptyScreenControl = new EmptyScreenControl { ID = "wikiListPagesByLetterEmpty", ImgSrc = WebImageSupplier.GetAbsoluteWebPath("wikilogo150.png", WikiManager.ModuleId), Header = WikiResource.EmptyScreenWikiIndexCaption, Describe = WikiResource.EmptyScreenWikiIndexText, CssClass = "display-none" }; if (CommunitySecurity.CheckPermissions(Community.Wiki.Common.Constants.Action_AddPage)) { emptyScreenControl.ButtonHTML = String.Format("<a class='link underline blue plus' href='default.aspx?action=New'>{0}</a>", WikiResource.menu_AddNewPage); } phListEmptyScreen.Controls.Add(emptyScreenControl); } }
private void BindRepeater() { phListResult.Visible = phTableResult.Visible = false; if (isByUser || isShowNew || isShowFresh) { phListResult.Visible = true; List <Page> dataSource; var emptyScreenCaption = string.Empty; var emptyScreenText = string.Empty; if (isByUser) { dataSource = Wiki.GetPages(byUserID); } else if (isShowNew) { dataSource = Wiki.GetNewPages(MaxNewResults); emptyScreenCaption = WikiResource.EmptyScreenWikiNewPagesCaption; emptyScreenText = WikiResource.EmptyScreenWikiNewPagesText; } else { dataSource = Wiki.GetRecentEditedPages(MaxNewResults); emptyScreenCaption = WikiResource.EmptyScreenWikiRecentlyEditedCaption; emptyScreenText = WikiResource.EmptyScreenWikiRecentlyEditedText; } //foreach (Pages p in dataSource) //{ // p.PageName = HttpUtility.HtmlEncode(p.PageName); //} if (dataSource.Count > 0) { rptPageList.DataSource = dataSource; rptPageList.DataBind(); } else { var emptyScreenControl = new EmptyScreenControl { ImgSrc = WebImageSupplier.GetAbsoluteWebPath("WikiLogo150.png", WikiManager.ModuleId), Header = emptyScreenCaption, Describe = emptyScreenText }; if (CommunitySecurity.CheckPermissions(Community.Wiki.Common.Constants.Action_AddPage)) { emptyScreenControl.ButtonHTML = String.Format("<a class='link underline blue plus' href='default.aspx?action=New'>{0}</a>", WikiResource.menu_AddNewPage); } phListResult.Controls.Add(emptyScreenControl); } } else { phTableResult.Visible = true; List <Page> result; result = isShowCat ? Wiki.GetPages(categoryName) : Wiki.GetPages(); result.RemoveAll(pemp => string.IsNullOrEmpty(pemp.PageName)); var letters = new List <string>(WikiResource.wikiCategoryAlfaList.Split(',')); var otherSymbol = string.Empty; if (letters.Count > 0) { otherSymbol = letters[0]; letters.Remove(otherSymbol); } var dictList = new List <PageDictionary>(); foreach (var page in result) { page.PageName = HttpUtility.HtmlEncode(page.PageName); var firstLetter = new string(page.PageName[0], 1); if (!letters.Exists(lt => lt.Equals(firstLetter, StringComparison.InvariantCultureIgnoreCase))) { firstLetter = otherSymbol; } PageDictionary pageDic; if (!dictList.Exists(dl => dl.HeadName.Equals(firstLetter, StringComparison.InvariantCultureIgnoreCase))) { pageDic = new PageDictionary { HeadName = firstLetter }; pageDic.Pages.Add(page); dictList.Add(pageDic); } else { pageDic = dictList.Find(dl => dl.HeadName.Equals(firstLetter, StringComparison.InvariantCultureIgnoreCase)); pageDic.Pages.Add(page); } } dictList.Sort(SortPageDict); var countAll = dictList.Count * 3 + result.Count; //1 letter is like 2 links to category var perColumn = (int)(Math.Round((decimal)countAll / 3)); var mainDictList = new List <List <PageDictionary> >(); int index = 0, lastIndex = 0, count = 0; for (int i = 0; i < dictList.Count; i++) { var p = dictList[i]; count += 3; count += p.Pages.Count; index++; if (count >= perColumn || i == dictList.Count - 1) { count = count - perColumn; mainDictList.Add(dictList.GetRange(lastIndex, index - lastIndex)); lastIndex = index; } } if (mainDictList.Count > 0) { rptMainPageList.DataSource = mainDictList; rptMainPageList.DataBind(); } else { var emptyScreenControl = new EmptyScreenControl { ImgSrc = WebImageSupplier.GetAbsoluteWebPath("WikiLogo150.png", WikiManager.ModuleId), Header = WikiResource.EmptyScreenWikiIndexCaption, Describe = WikiResource.EmptyScreenWikiIndexText }; if (CommunitySecurity.CheckPermissions(Community.Wiki.Common.Constants.Action_AddPage)) { emptyScreenControl.ButtonHTML = String.Format("<a class='link underline blue plus' href='default.aspx?action=New'>{0}</a>", WikiResource.menu_AddNewPage); } phTableResult.Controls.Add(emptyScreenControl); } } }
private void BindRepeater() { phListResult.Visible = phTableResult.Visible = false; if (isByUser || isShowNew || isShowFresh) { phListResult.Visible = true; List <Page> dataSource; if (isByUser) { dataSource = Wiki.GetPages(byUserID); } else if (isShowNew) { dataSource = Wiki.GetNewPages(MaxNewResults); } else { dataSource = Wiki.GetRecentEditedPages(MaxNewResults); } //foreach (Pages p in dataSource) //{ // p.PageName = HttpUtility.HtmlEncode(p.PageName); //} rptPageList.DataSource = dataSource; rptPageList.DataBind(); } else { phTableResult.Visible = true; List <Page> result; if (isShowCat) { result = Wiki.GetPages(categoryName); } else { result = Wiki.GetPages(); } result.RemoveAll(pemp => string.IsNullOrEmpty(pemp.PageName)); string firstLetter; List <string> letters = new List <string>(WikiResource.wikiCategoryAlfaList.Split(',')); string otherSymbol = string.Empty; if (letters.Count > 0) { otherSymbol = letters[0]; letters.Remove(otherSymbol); } List <PageDictionary> dictList = new List <PageDictionary>(); PageDictionary pageDic; foreach (Page page in result) { page.PageName = HttpUtility.HtmlEncode(page.PageName); firstLetter = new string(page.PageName[0], 1); if (!letters.Exists(lt => lt.Equals(firstLetter, StringComparison.InvariantCultureIgnoreCase))) { firstLetter = otherSymbol; } if (!dictList.Exists(dl => dl.HeadName.Equals(firstLetter, StringComparison.InvariantCultureIgnoreCase))) { pageDic = new PageDictionary(); pageDic.HeadName = firstLetter; pageDic.Pages.Add(page); dictList.Add(pageDic); } else { pageDic = dictList.Find(dl => dl.HeadName.Equals(firstLetter, StringComparison.InvariantCultureIgnoreCase)); pageDic.Pages.Add(page); } } dictList.Sort(SortPageDict); int countAll = dictList.Count * 3 + result.Count; //1 letter is like 2 links to category int perColumn = (int)(Math.Round((decimal)countAll / 3)); List <List <PageDictionary> > mainDictList = new List <List <PageDictionary> >(); int index = 0, lastIndex = 0, count = 0; PageDictionary p; for (int i = 0; i < dictList.Count; i++) { p = dictList[i]; count += 3; count += p.Pages.Count; index++; if (count >= perColumn || i == dictList.Count - 1) { count = count - perColumn; mainDictList.Add(dictList.GetRange(lastIndex, index - lastIndex)); lastIndex = index; } } rptMainPageList.DataSource = mainDictList; rptMainPageList.DataBind(); } }