コード例 #1
0
 private int SortPageDict(PageDictionary cd1, PageDictionary cd2)
 {
     return(cd1.HeadName.CompareTo(cd2.HeadName));
 }
コード例 #2
0
        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);
                }
            }
        }
コード例 #3
0
        protected void BindPagesByCategory()
        {
            if (Action != ActionOnPage.CategoryView || string.IsNullOrEmpty(m_categoryName))
            {
                return;
            }

            var result = Wiki.GetPages(m_categoryName);

            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)
            {
                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 (var 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;
                }
            }

            rptCategoryPageList.DataSource = mainDictList;
            rptCategoryPageList.DataBind();
        }
コード例 #4
0
ファイル: Default.aspx.cs プロジェクト: ridhouan/teamlab.v6.5
 private int SortPageDict(PageDictionary cd1, PageDictionary cd2)
 {
     return cd1.HeadName.CompareTo(cd2.HeadName);
 }
コード例 #5
0
ファイル: Default.aspx.cs プロジェクト: ridhouan/teamlab.v6.5
        protected void BindPagesByCategory()
        {
            if (Action != ActionOnPage.CategoryView || string.IsNullOrEmpty(m_categoryName))
                return;

            var result = Wiki.GetPages(m_categoryName);

            result.RemoveAll(pemp => string.IsNullOrEmpty(pemp.PageName));

            string firstLetter;
            var letters = new List<string>(WikiResource.wikiCategoryAlfaList.Split(','));

            string otherSymbol = string.Empty;
            if (letters.Count > 0)
            {
                otherSymbol = letters[0];
                letters.Remove(otherSymbol);
            }

            var dictList = new List<PageDictionary>();
            PageDictionary pageDic;
            foreach (var page in result)
            {
                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 { 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;

            PageDictionary p;
            for (var 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;
                }
            }

            rptCategoryPageList.DataSource = mainDictList;
            rptCategoryPageList.DataBind();
        }
コード例 #6
0
        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);
                }
            }
        }
コード例 #7
0
        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();
            }
        }
コード例 #8
0
        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();
            }
        }