예제 #1
0
        public SiteImportWordpressModel()
        {
            this.CreateUsers   = true;
            this.MapUsers      = true;
            this.FixHtmlBodies = true;
            this.HasLoaded     = false;

            BuildFolderList();

            using (ContentPageHelper pageHelper = new ContentPageHelper()) {
                this.PageCount = pageHelper.GetSitePageCount(SiteData.CurrentSiteID, ContentPageType.PageType.ContentEntry);

                using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) {
                    this.Templates = cmsHelper.Templates;

                    float iThird = (float)(this.PageCount - 1) / (float)3;
                    Dictionary <string, float> dictTemplates = null;

                    dictTemplates = pageHelper.GetPopularTemplateList(SiteData.CurrentSiteID, ContentPageType.PageType.ContentEntry);
                    if (dictTemplates.Any() && dictTemplates.First().Value >= iThird)
                    {
                        try { this.PageTemplate = dictTemplates.First().Key; } catch { }
                    }

                    dictTemplates = pageHelper.GetPopularTemplateList(SiteData.CurrentSiteID, ContentPageType.PageType.BlogEntry);
                    if (dictTemplates.Any())
                    {
                        try { this.PostTemplate = dictTemplates.First().Key; } catch { }
                    }
                }
            }
        }
        public void SetPage(ContentPage page)
        {
            this.ContentPage = page;

            this.OriginalFileName   = page.FileName;
            this.SelectedCategories = this.ContentPage.ContentCategories.Select(x => x.ContentCategoryID.ToString().ToLower()).ToList();
            this.SelectedTags       = this.ContentPage.ContentTags.Select(x => x.ContentTagID.ToString().ToLower()).ToList();
            this.InitSelections();

            if (this.ContentPage != null)
            {
                using (ContentPageHelper pageHelper = new ContentPageHelper()) {
                    if (this.ContentPage.Root_ContentID != Guid.Empty)
                    {
                        this.VersionHistory = (from v in pageHelper.GetVersionHistory(this.ContentPage.SiteID, this.ContentPage.Root_ContentID)
                                               join u in ExtendedUserData.GetUserList() on v.EditUserId equals u.UserId
                                               orderby v.EditDate descending
                                               select new KeyValuePair <string, string>(v.ContentID.ToString(),
                                                                                        String.Format("{0} ({1}) {2}", v.EditDate, u.UserName, (v.IsLatestVersion ? " [**] " : " ")))
                                               ).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
                    }
                    else
                    {
                        this.ContentPage.CreateDate = DateTime.UtcNow.Date;
                        this.ContentPage.EditDate   = DateTime.UtcNow.Date;
                        this.ContentPage.ContentID  = Guid.NewGuid();

                        if (this.ContentPage.ContentType == ContentPageType.PageType.ContentEntry)
                        {
                            this.ContentPage.NavOrder = pageHelper.GetSitePageCount(this.ContentPage.SiteID, this.ContentPage.ContentType) * 2;
                        }
                        else
                        {
                            this.ContentPage.Parent_ContentID = null;
                            this.ContentPage.NavOrder         = SiteData.BlogSortOrderNumber;
                        }

                        DateTime dtSite = CMSConfigHelper.CalcNearestFiveMinTime(SiteData.CurrentSite.Now);
                        this.ContentPage.GoLiveDate = dtSite;
                        this.ContentPage.RetireDate = dtSite.AddYears(200);

                        float iThird = (float)(this.ContentPage.NavOrder - 1) / (float)3;

                        Dictionary <string, float> dictTemplates = pageHelper.GetPopularTemplateList(this.ContentPage.SiteID, this.ContentPage.ContentType);
                        if (dictTemplates.Any() && dictTemplates.First().Value >= iThird)
                        {
                            try {
                                this.ContentPage.TemplateFile = dictTemplates.First().Key;
                            } catch { }
                        }
                    }
                }

                RefreshWidgetList();
            }
        }