Example #1
0
        /// <summary>
        /// Gets the list of all the available categories that can be used as parent for a given articles.
        /// If the given articles is a Category, the article itself and any categories of which it is already a parent are excluded from the list.
        /// This prevents the creation of loops in the article hierarchy.
        /// This method is used on the Properties page to display the list of all the categories in which the current article can be added.
        /// </summary>
        /// <param name="article">A Wiki article.</param>        
        /// <returns>A list of Wiki articles.</returns>
        public static List<WikiArticleInfo> GetAvailableParentCategories(WikiArticleInfo article)
        {
            List<WikiArticleInfo> allCategories = GetArticles(ArticleType.Category);
            if (article.Type != ArticleType.Category)
                return allCategories;

            List<WikiArticleInfo> availableCategories = new List<WikiArticleInfo>();
            foreach (WikiArticleInfo category in allCategories)
            {
                if (!IsCategoryInCategoryHierarchy(article, category))
                    availableCategories.Add(category);
            }
            return availableCategories;

            //string optionalClause = (articleId > 0) ? string.Format(" AND art_id_pkey <> {0}", articleId) : string.Empty;
            //string query = string.Format(@"SELECT {2} FROM tbl_articles WHERE art_type = {0}{1} ORDER BY art_title",
            //    (int)articleType, optionalClause, ARTICLE_INFO_FIELDS);
            //return GetArticleInfosFromQuery(query);
        }
Example #2
0
 private static bool IsCategoryInCategoryHierarchy(WikiArticleInfo category, WikiArticleInfo parentCategory)
 {
     if (parentCategory.Id == category.Id || IsCategoryInCategoriesHierarchy(category, parentCategory.ParentCategories))
         return true;
     return false;
 }
Example #3
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="info">A WikiArticleInfo containing all the information about the article except its text content.</param>
 /// <param name="text">The text content of the article.</param>
 public WikiArticle(WikiArticleInfo info, string text)
     : base(info)
 {
     this.m_Text = text;
 }
Example #4
0
 /// <summary>
 /// Checks whether a category is included in the parent hierarchy of the given categories using recursion.
 /// This should not happend because it could cause loops in the hiearchy.
 /// Besides, the categories should only broaden in scope when moving upward in their hiearchy so it make little sense to have loops.
 /// </summary>
 /// <param name="category">The category for which to check whether it's included in the hiearchy of its parents.</param>
 /// <param name="parentCategories">The direct parent categories of the given category.</param>
 /// <returns>True if the category exists somewhere in its parent hiearchy.</returns>
 private static bool IsCategoryInCategoriesHierarchy(WikiArticleInfo category, List<WikiArticleInfo> parentCategories)
 {
     foreach (WikiArticleInfo parentCategory in parentCategories)
         if (parentCategory.Id == category.Id || IsCategoryInCategoriesHierarchy(category, parentCategory.ParentCategories))
             return true;
     return false;
 }
Example #5
0
        /// <summary>
        /// Copy constructor.
        /// </summary>
        /// <param name="info">The underlying WikiArticleInfo from which this object is constructed.</param>
        public WikiArticleInfo(WikiArticleInfo info)
            : base(info.Title, info.Type)
        {
            this.m_Id = info.Id;
            this.m_CreationDate = info.CreationDate;
            this.m_CreationUser = info.CreationUser;
            this.m_LastModificationDate = info.LastModificationDate;
            this.m_LastModificationUser = info.LastModificationUser;
            this.m_Status = info.Status;
            this.m_LockedBy = info.LockedBy;
            this.m_LockedAt = info.LockedAt;
            this.m_ValidationDate = info.ValidationDate;
            this.m_ValidationUser = info.ValidationUser;

            this.m_ParentCategories = info.ParentCategories;
            this.m_ParentApprovedCategories = info.ParentApprovedCategories;
            this.m_ChildPortals = info.ChildPortals;
            this.m_ChildCategories = info.ChildCategories;
            this.m_ChildArticles = info.ChildArticles;
            this.m_ChildHowTo = info.ChildHowTo;
            this.m_ChildSamples = info.ChildSamples;
            this.m_ChildApprovedPortals = info.ChildApprovedPortals;
            this.m_ChildApprovedCategories = info.ChildApprovedCategories;
            this.m_ChildApprovedArticles = info.ChildApprovedArticles;
            this.m_ChildApprovedHowTo = info.ChildApprovedHowTo;
            this.m_ChildApprovedSamples = info.ChildApprovedSamples;
            this.m_Summary = info.Summary;
        }