Example #1
0
        public List<string> UpdateCategoriesByPageContent(Page page)
        {
            var RegExCategorySearch = string.Format(@"\[\[{0}:([^\|^\]]+)(\|[^]]+)*\]\]", Constants.WikiCategoryKeyCaption);          
            var result = new List<string>();

            using (var dao = GetCategoryDAO())
            {
                var catReg = new Regex(RegExCategorySearch, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
                var oldCategories = dao.GetCategories(page.PageName, false);
                dao.RemoveCategories(page.PageName);
                string categoryName;
                string bodyWikiOnly = HtmlWikiUtil.rexNoSection.Replace(page.Body, string.Empty);
                foreach (Match m in catReg.Matches(bodyWikiOnly))
                {
                    categoryName = m.Groups[1].Value.Trim();
                    if (categoryName.Length > 240) categoryName = categoryName.Substring(0, 240).Trim();
                    categoryName = PageNameUtil.NormalizeNameCase(PageNameUtil.NormalizeNameCase(categoryName));
                    if (!oldCategories.Exists(oc => oc.CategoryName.Equals(categoryName, StringComparison.InvariantCulture)))
                    {
                        result.Add(categoryName);
                    }
                    dao.SaveCategory(new Category { PageName = page.PageName, CategoryName = categoryName });
                }
            }

            return result;
        }
 public PageWrapper(Page page)
 {
     Name = page.PageName;
     Content = page.Body;
     UpdatedBy = EmployeeWraper.Get(Core.CoreContext.UserManager.GetUsers(page.UserID));
     Updated = (ApiDateTime)page.Date;
 }
Example #3
0
        public SaveResult Save(Guid userId, out string pageName)
        {
            try
            {

                if (SetNewFCKMode != null)
                {
                    bool isSource;
                    bool.TryParse(hfFCKLastState.Value, out isSource);
                    SetNewFCKMode(!isSource);

                    IsWysiwygDefault = !isSource; //We need to update the variable if SetNewFCKMode is used only!!!
                }

                Page page;
                string currentPageName = txtPageName.Text.Trim();
                if (currentPageName.Length > 240) currentPageName = currentPageName.Substring(0, 240).Trim();
                currentPageName = PageNameUtil.Clean(currentPageName);
                if (pageSection >= 0)
                {
                    currentPageName = PageNameUtil.Decode(PageName);
                }

                pageName = currentPageName;
                bool isPageRename = pageName != PageNameUtil.Decode(PageName) && !string.IsNullOrEmpty(PageName);
                string oldPageName = PageName;

                if (currentPageName.Equals(string.Empty) && !txtPageName.ReadOnly)
                {
                    SetWikiFCKEditorValue(currentPageName, Wiki_FCKEditor.Value);
                    return SaveResult.PageNameIsEmpty;
                }

                if (!IsSpecialName && IsNameReserved(currentPageName))
                {
                    SetWikiFCKEditorValue(currentPageName, Wiki_FCKEditor.Value);
                    return SaveResult.PageNameIsIncorrect;
                }

                if (userId.Equals(Guid.Empty))
                {
                    SetWikiFCKEditorValue(currentPageName, Wiki_FCKEditor.Value);
                    return SaveResult.UserIdIsEmpty;
                }

                if (!PageNameUtil.Decode(PageName).Equals(currentPageName, StringComparison.InvariantCulture))
                {
                    page = Wiki.GetPage(currentPageName);
                    if (page != null)
                    {
                        SetWikiFCKEditorValue(currentPageName, Wiki_FCKEditor.Value);
                        return SaveResult.SamePageExists;
                    }
                    page = new Page();
                }
                else
                {
                    page = Wiki.GetPage(currentPageName);
                    if (page == null)
                    {
                        page = new Page();
                    }
                }

                page.PageName = currentPageName;
                string PageResult;
                if (pageSection < 0)
                {
                    PageResult = Wiki_FCKEditor.Value;
                }
                else
                {
                    PageResult = HtmlWikiUtil.SetWikiSectionBySectionNumber(page.Body, pageSection, Wiki_FCKEditor.Value);
                }

                if (PageResult.Equals(page.Body))
                {
                    SetWikiFCKEditorValue(page.PageName, Wiki_FCKEditor.Value);
                    return SaveResult.NoChanges;
                }

                page.Body = PageResult;

                if (pageVersion > 0 && pageVersion < Wiki.GetPageMaxVersion(page.PageName))
                {
                    SetWikiFCKEditorValue(page.PageName, Wiki_FCKEditor.Value);
                    return SaveResult.OldVersion;
                }
                page.Date = TenantUtil.DateTimeNow();
                page.UserID = userId;

                page.Version++;
                Wiki.SavePage(page);

                var newCats = Wiki.UpdateCategoriesByPageContent(page);
                if (newCats.Count > 0 && SaveNewCategoriesAdded != null)
                {
                    SaveNewCategoriesAdded(this, newCats, page.PageName);
                }

                pageVersion = page.Version;
                RisePublishVersionInfo(page);

                SetWikiFCKEditorValue(page.PageName, Wiki_FCKEditor.Value);

                if (pageSection >= 0)
                {
                    return SaveResult.SectionUpdate;
                }
                if (isPageRename)
                {
                    //create dumb page
                    var oldpage = Wiki.GetPage(PageNameUtil.Decode(oldPageName));
                    if (oldpage != null)
                    {
                        oldpage.Date = TenantUtil.DateTimeNow();
                        oldpage.UserID = userId;
                        oldpage.Body = string.Format(WikiUCResource.wikiPageMoved, pageName); //Dummy
                        oldpage.Version++;
                        Wiki.SavePage(oldpage);

                        return SaveResult.OkPageRename;
                    }
                    else
                    {
                        return SaveResult.SamePageExists;
                    }
                }
                return SaveResult.Ok;
            }
            catch (Exception)
            {
                pageName = txtPageName.Text.Trim();
                return SaveResult.Error;
            }
        }
Example #4
0
 protected new string GetPageName(Page page)
 {
     if (string.IsNullOrEmpty(page.PageName))
         return WikiResource.MainWikiCaption;
     return page.PageName;
 }
Example #5
0
 private void NotifyCommentCreated(Page page, Comment comment)
 {
     WikiNotifyClient.SendNoticeAsync(
         SecurityContext.CurrentAccount.ID.ToString(),
         Constants.EditPage,
         PageNameUtil.Encode(page.PageName),
         null,
         GetNotifyTags(page.PageName, "new wiki page comment", comment));
     WikiActivityPublisher.AddPageComment(page, comment);
 }
        public static bool EditPage(Page page)
        {
            if(page.Version == 1) //New Page Saved!!!
            {
                AddPage(page);
                return false;
            }
            UserActivity ua =
                        ApplyCustomeActivityParams(
                            ComposeActivityByPage(page),
                            WikiResource.wikiAction_PageEdited,
                            page.UserID,
                            UserActivityConstants.ActivityActionType,
                            UserActivityConstants.ImportantActivity
                        );

            PublishInternal(ua);
            return true;
        }
        public static void DeletePageComment(Page page, Comment newComment)
        {
            UserActivity ua =
                        ApplyCustomeActivityParams(
                            ComposeActivityByPage(page),
                            WikiResource.wikiAction_CommentDeleted,
                            newComment.UserId,
                            UserActivityConstants.ActivityActionType,
                            UserActivityConstants.SmallActivity
                        );

            PublishInternal(ua);
        }
 protected string GetDate(Page page)
 {
     return string.Format("{0} {1}", page.Date.ToString("t"), page.Date.ToString("d"));
 }
 protected new string GetPageName(Page page)
 {
     return string.IsNullOrEmpty(page.PageName) ? WikiResource.MainWikiCaption : page.PageName;
 }
Example #10
0
 protected string GetPageName(Page page)
 {
     return string.IsNullOrEmpty(page.PageName)
                ? WikiResource.MainWikiCaption
                : HttpUtility.HtmlEncode(page.PageName);
 }
Example #11
0
        public Page SavePage(Page page)
        {
            if (page == null) throw new ArgumentNullException("page");

            var i1 = Insert("wiki_pages")
                .InColumnValue("pagename", page.PageName)
                .InColumnValue("version", page.Version)
                .InColumnValue("modified_by", page.UserID)
                .InColumnValue("modified_on", DateTime.UtcNow);

            var i2 = Insert("wiki_pages_history")
                .InColumnValue("pagename", page.PageName)
                .InColumnValue("version", page.Version)
                .InColumnValue("create_by", page.UserID)
                .InColumnValue("create_on", DateTime.UtcNow)
                .InColumnValue("body", page.Body);

            db.ExecuteBatch(new[] { i1, i2 });

            return page;
        }
Example #12
0
 protected string GetDate(Page page)
 {
     return string.Format("<span class=\"wikiDateTime\">{0}</span> {1}", page.Date.ToString("t"), page.Date.ToString("d"));
 }
Example #13
0
 private bool IsStandartName(Page page)
 {
     return page.PageName == WikiUCResource.HelpPageCaption || page.PageName == ""; //Main or help
 }
Example #14
0
        //protected void cmdDelete_Click(object sender, EventArgs e)
        //{
        //    PagesProvider.PagesDelete((sender as LinkButton).CommandName);
        //    BindRepeater();
        //}



        //protected string GetPageEditLink(Pages page)
        //{
        //    return ActionHelper.GetEditPagePath(this.ResolveUrlLC("Default.aspx"), page.PageName);
        //}

        //protected string GetPageInfo(Pages page)
        //{
        //    if (page.UserID.Equals(Guid.Empty))
        //    {
        //        return string.Empty;
        //    }


        //    return ProcessVersionInfo(page.PageName, page.UserID, page.Date, page.Version, false);
        //}

        protected string GetAuthor(Page page)
        {
            return CoreContext.UserManager.GetUsers(page.UserID).RenderCustomProfileLink("", "linkMedium");
        }
Example #15
0
 private void NotifyCommentCreated(Page page, Comment comment)
 {
     WikiNotifyClient.SendNoticeAsync(
         SecurityContext.CurrentAccount.ID.ToString(),
         Constants.EditPage,
         PageNameUtil.ReplaceSpaces(page.PageName),
         null,
         GetNotifyTags(page.PageName, "new wiki page comment", comment));
 }
Example #16
0
 private void NotifyPageEdited(Page page)
 {
     WikiNotifyClient.SendNoticeAsync(
         SecurityContext.CurrentAccount.ID.ToString(),
         Constants.EditPage,
         PageNameUtil.ReplaceSpaces(page.PageName),
         null,
         GetNotifyTags(page.PageName, "edit wiki page", null));
 }
Example #17
0
        public Page SavePage(Page page)
        {
            using (var dao = GetPageDao())
            {
                var saved = dao.SavePage(page);

                if (saved != null)
                {
                    var subscriptionProvider = WikiNotifySource.Instance.GetSubscriptionProvider();
                    var amAsRecipient = (IDirectRecipient)WikiNotifySource.Instance.GetRecipientsProvider().GetRecipient(SecurityContext.CurrentAccount.ID.ToString());

                    subscriptionProvider.Subscribe(
                        Constants.EditPage,
                        PageNameUtil.ReplaceSpaces(page.PageName),
                        amAsRecipient
                        );

                    if (saved.Version == 1) NotifyPageCreated(saved);
                    else NotifyPageEdited(saved);
                }

                return saved;
            }
        }
Example #18
0
 protected string GetPageEditLink(Page page)
 {
     return ActionHelper.GetEditPagePath(this.ResolveUrlLC("Default.aspx"), page.PageName);
 }
Example #19
0
 protected string GetPageViewLink(Page page)
 {
     return ActionHelper.GetViewPagePath(this.ResolveUrlLC("Default.aspx"), HttpUtility.HtmlDecode(page.PageName));
 }
Example #20
0
 public Page GetPage(string pageName)
 {
     using (var dao = GetPageDAO())
     {
         var page = dao.GetPage(pageName, 0);
         if (page == null)
         {
             if (pageName == string.Empty)
             {
                 page = new Page()
                 {
                     PageName = string.Empty,
                     Body = WikiUCResource.MainPage_DefaultBody
                 };
             }
             else if (pageName == WikiUCResource.HelpPageCaption)
             {
                 page = new Page()
                 {
                     PageName = WikiUCResource.HelpPageCaption,
                     Body = WikiUCResource.HelpPage_DefaultBody
                 };
             }
         }
         return page;
     }
 }
 protected string GetAuthor(Page page)
 {
     return CoreContext.UserManager.GetUsers(page.UserID).RenderCustomProfileLink(ASC.Web.Community.Product.CommunityProduct.ID, "", "linkMedium");
 }
Example #22
0
        public Page SavePage(Page page)
        {
            using (var dao = GetPageDAO())
            {
                var saved = dao.SavePage(page);

                if (saved != null)
                {
                    if(saved.Version == 1) NotifyPageCreated(saved);
                    else NotifyPageEdited(saved);
                }

                return saved;
            }  
        }
 protected new string GetPageViewLink(Page page)
 {
     return ActionHelper.GetViewPagePathWithVersion(this.ResolveUrlLC("Default.aspx"), page.PageName, page.Version);
 }
Example #24
0
        public Page CreatePage(Page page)
        {
            if (String.IsNullOrEmpty(page.PageName)) throw new ArgumentException(@"page name cannot be empty", "page");
            if (String.IsNullOrEmpty(page.Body)) throw new ArgumentException(@"page content cannot be empty", "page");

            page.UserID = SecurityContext.CurrentAccount.ID;
            page.Version = 1;
            page.Date = DateTime.UtcNow;

            page = SavePage(page);
            UpdateCategoriesByPageContent(page);

            //NotifyPageCreated(page);

            return page;
        }
        public static void AddPage(Page page)
        {
            UserActivity ua =
                        ApplyCustomeActivityParams(
                            ComposeActivityByPage(page),
                            WikiResource.wikiAction_PageAdded,
                            page.UserID,
                            UserActivityConstants.ContentActionType,
                            UserActivityConstants.NormalContent
                        );

                PublishInternal(ua);
        }
Example #26
0
        public Page UpdatePage(Page page)
        {
            var toUpdate = GetPage(page.PageName);

            if (toUpdate == null) throw new ItemNotFoundException("page not found");
            if(String.IsNullOrEmpty(page.Body)) throw new ArgumentException(@"page content cannot be empty", "page");

            toUpdate.UserID = SecurityContext.CurrentAccount.ID;
            toUpdate.Body = page.Body;
            toUpdate.Version++;
            toUpdate.Date = DateTime.UtcNow;

            toUpdate = SavePage(toUpdate);
            UpdateCategoriesByPageContent(toUpdate);

            //NotifyPageEdited(toUpdate);

            return toUpdate;
        }
        public static void RevertPage(Page page)
        {
            UserActivity ua =
                        ApplyCustomeActivityParams(
                            ComposeActivityByPage(page),
                            WikiResource.wikiAction_VersionRevert,
                            page.UserID,
                            UserActivityConstants.ActivityActionType,
                            UserActivityConstants.SmallActivity
                        );

            PublishInternal(ua);
        }
Example #28
0
 private void NotifyPageCreated(Page page)
 {
     WikiNotifyClient.SendNoticeAsync(
         SecurityContext.CurrentAccount.ID.ToString(), 
         Constants.NewPage,
         null,
         null,
         GetNotifyTags(page.PageName));
     WikiActivityPublisher.AddPage(page);
 }
Example #29
0
 private void NotifyPageEdited(Page page)
 {
     WikiNotifyClient.SendNoticeAsync(
         SecurityContext.CurrentAccount.ID.ToString(),
         Constants.EditPage,
         PageNameUtil.Encode(page.PageName),
         null,
         GetNotifyTags(page.PageName, "edit wiki page", null));
     WikiActivityPublisher.EditPage(page);
 }
Example #30
0
 protected string GetAuthor(Page page)
 {
     return CoreContext.UserManager.GetUsers(page.UserID).RenderProfileLink(Product.CommunityProduct.ID);
 }