예제 #1
0
        //--- Methods ---
        public virtual ArchiveBE Copy()
        {
            ArchiveBE archive = new ArchiveBE();

            archive._Comment      = _Comment;
            archive._DisplayName  = _DisplayName;
            archive._Namespace    = _Namespace;
            archive._Title        = _Title;
            archive._TimeStamp    = _TimeStamp;
            archive.ContentType   = ContentType;
            archive.Id            = Id;
            archive.IsHidden      = IsHidden;
            archive.Language      = Language;
            archive.LastPageId    = LastPageId;
            archive.Meta          = Meta;
            archive.MinorEdit     = MinorEdit;
            archive.OldId         = OldId;
            archive.Text          = Text;
            archive.TransactionId = TransactionId;
            archive.UserID        = UserID;
            archive.Revision      = Revision;
            return(archive);
        }
예제 #2
0
파일: ArchiveBE.cs 프로젝트: heran/DekiWiki
 //--- Methods ---
 public virtual ArchiveBE Copy() {
     ArchiveBE archive = new ArchiveBE();
     archive._Comment = _Comment;
     archive._DisplayName = _DisplayName;
     archive._Namespace = _Namespace;
     archive._Title = _Title;
     archive._TimeStamp = _TimeStamp;
     archive.ContentType = ContentType;
     archive.Id = Id;
     archive.IsHidden = IsHidden;
     archive.Language = Language;
     archive.LastPageId = LastPageId;
     archive.Meta = Meta;
     archive.MinorEdit = MinorEdit;
     archive.OldId = OldId;
     archive.Text = Text;
     archive.TransactionId = TransactionId;
     archive.UserID = UserID;
     archive.Revision = Revision;
     return archive;
 }
예제 #3
0
        private static XDoc GetArchivePageXml(XDoc doc, ArchiveBE archivedPage, UserBE user, DateTime ts) {
            XDoc ret = doc;
            bool singlePage = false;
            if (ret == null || ret.IsEmpty) {
                ret = new XDoc("page.archive");
                singlePage = true;
            } else {
                ret = ret.Start("page.archive");
            }

            ret = ret.Attr("id", archivedPage.LastPageId).Attr("href", DekiContext.Current.ApiUri.At("archive", "pages", archivedPage.LastPageId.ToString(), "info"))
            .Start("title").Value(archivedPage.Title.AsUserFriendlyName()).End()
            .Start("path").Value(archivedPage.Title.AsPrefixedDbPath()).End()
            .Start("contents").Attr("type", archivedPage.ContentType).Attr("href", DekiContext.Current.ApiUri.At("archive", "pages", archivedPage.LastPageId.ToString(), "contents")).End();

            if (user != null) {
                ret.Add(UserBL.GetUserXml(user, "deleted", false));
            }

            if (ts != DateTime.MinValue) {
                ret.Elem("date.deleted", ts);
            }
            if (!singlePage)
                ret.End();
            return ret;
        }
예제 #4
0
        private static void RestorePageRevisionsForPage(ArchiveBE[] archivedRevs, Title newTitle, uint transactionId, bool minorChange, DateTime utcTimestamp) {
            // add the most recent archive entry to the pages table
            // NOTE:  this will preserve the page id if it was saved with the archive or create a new page id if it is not available
            ArchiveBE mostRecentArchiveRev = archivedRevs[archivedRevs.Length - 1];
            PageBE restoredPage = null;
            if (0 < archivedRevs.Length) {
                restoredPage = new PageBE();
                restoredPage.Title = newTitle;
                restoredPage.Revision = mostRecentArchiveRev.Revision;
                restoredPage.MinorEdit = mostRecentArchiveRev.MinorEdit;
                bool conflict;
                PageBL.Save(restoredPage, null, mostRecentArchiveRev.Comment, mostRecentArchiveRev.Text, mostRecentArchiveRev.ContentType, mostRecentArchiveRev.Title.DisplayName, mostRecentArchiveRev.Language, -1, null, mostRecentArchiveRev.TimeStamp, mostRecentArchiveRev.LastPageId, false, false, null, false, out conflict);
                RecentChangeBL.AddRestorePageRecentChange(utcTimestamp, restoredPage, DekiContext.Current.User, String.Format(DekiResources.UNDELETED_ARTICLE, restoredPage.Title.AsPrefixedUserFriendlyPath()), minorChange, transactionId);
            }

            // add all other archive entries to the old table
            // NOTE:  this will preserve the old ids if they were saved with the archive or create new old ids if not available
            for (int i = 0; i < archivedRevs.Length - 1; i++) {
                ArchiveBE archivedRev = archivedRevs[i];
                PageBE currentPage = new PageBE();
                currentPage.Title = newTitle;
                if (i < archivedRevs.Length - 1) {
                    ParserResult parserResult = DekiXmlParser.ParseSave(currentPage, archivedRev.ContentType, currentPage.Language, archivedRev.Text, -1, null, false, null);
                    currentPage.SetText(parserResult.BodyText);
                    currentPage.ContentType = parserResult.ContentType;
                    currentPage.UserID = archivedRev.UserID;
                    currentPage.TimeStamp = archivedRev.TimeStamp;
                    currentPage.MinorEdit = archivedRev.MinorEdit;
                    currentPage.Comment = archivedRev.Comment;
                    currentPage.Language = archivedRev.Language;
                    currentPage.IsHidden = archivedRev.IsHidden;
                    currentPage.Revision = archivedRev.Revision;
                    currentPage.ID = restoredPage.ID;
                    PageBL.InsertOld(currentPage, archivedRev.OldId);
                }
            }
        }