예제 #1
0
        public override void LoadData()
        {
            base.LoadData();

            try {
                if (this.PublicParmValues.Any())
                {
                    this.LevelDepth = int.Parse(base.GetParmValue("LevelDepth", "3"));
                }
            } catch (Exception ex) { }

            if (this.LevelDepth <= 0)
            {
                this.LevelDepth = 1;
            }

            if (this.LevelDepth > 50)
            {
                this.LevelDepth = 50;
            }

            using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) {
                this.NavigationData = navHelper.GetLevelDepthNavigation(SiteData.CurrentSiteID, this.LevelDepth, !SecurityData.IsAuthEditor);
            }
        }
예제 #2
0
        public void FetchData()
        {
            base.ReadPageNbr();
            List <PostComment> lstContents = new List <PostComment>();

            using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) {
                if (SiteData.IsWebView)
                {
                    SiteNav sn = navHelper.FindByFilename(SiteData.CurrentSiteID, SiteData.CurrentScriptName);

                    if (sn != null)
                    {
                        TotalRecords = PostComment.GetCommentCountByContent(sn.Root_ContentID, !SecurityData.IsAuthEditor);
                        lstContents  = PostComment.GetCommentsByContentPageNumber(sn.Root_ContentID, this.PageNumberZeroIndex, this.PageSize, this.OrderBy, !SecurityData.IsAuthEditor);
                    }
                }
                else
                {
                    TotalRecords = 0;
                    lstContents  = new List <PostComment>();
                }
            }

            lstContents.ToList().ForEach(q => CMSConfigHelper.IdentifyLinkAsInactive(q));

            this.DataSource = lstContents;
        }
예제 #3
0
 protected SiteNav GetHomePage(SiteData site)
 {
     if (_navHome == null)
     {
         using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) {
             _navHome = navHelper.FindHome(site.SiteID, false);
         }
     }
     return(_navHome);
 }
        protected void DoDataBind()
        {
            List <SiteNav> lstNav = null;

            using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) {
                lstNav = navHelper.GetChildNavigation(SiteData.CurrentSiteID, guidContentID, !SecurityData.IsAuthEditor);
            }

            if (bClickedSort && ddlAlternateSort.SelectedIndex > 0)
            {
                switch (ddlAlternateSort.SelectedValue)
                {
                case "alpha":
                    lstNav = lstNav.OrderBy(x => x.NavMenuText).ToList();
                    break;

                case "datecreated":
                    lstNav = lstNav.OrderBy(x => x.CreateDate).ToList();
                    break;

                case "dateupdated":
                    lstNav = lstNav.OrderBy(x => x.EditDate).ToList();
                    break;

                case "alpha2":
                    lstNav = lstNav.OrderByDescending(x => x.NavMenuText).ToList();
                    break;

                case "datecreated2":
                    lstNav = lstNav.OrderByDescending(x => x.CreateDate).ToList();
                    break;

                case "dateupdated2":
                    lstNav = lstNav.OrderByDescending(x => x.EditDate).ToList();
                    break;

                default:
                    lstNav = lstNav.OrderBy(x => x.NavOrder).ToList();
                    break;
                }
            }

            lstNav.ToList().ForEach(q => CMSConfigHelper.IdentifyLinkAsInactive(q));

            GeneralUtilities.BindRepeater(rpPages, lstNav);

            if (lstNav.Count < 2)
            {
                btnSave.Visible = false;
            }
        }
        protected override void OnPreRender(EventArgs e)
        {
            string sFieldValue = string.Empty;

            ContentPage cp      = cu.GetContainerContentPage(this);
            SiteNav     navNext = new SiteNav();

            if (NavigationDirection != NavDirection.Unknown)
            {
                using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) {
                    if (NavigationDirection == NavDirection.Prev)
                    {
                        navNext = navHelper.GetPrevPost(SiteData.CurrentSiteID, cp.Root_ContentID, !SecurityData.IsAuthEditor);
                    }
                    if (NavigationDirection == NavDirection.Next)
                    {
                        navNext = navHelper.GetNextPost(SiteData.CurrentSiteID, cp.Root_ContentID, !SecurityData.IsAuthEditor);
                    }

                    if (navNext != null)
                    {
                        if (UseDefaultText)
                        {
                            string sField = this.CaptionDataField.ToString();

                            object objData = ReflectionUtilities.GetPropertyValue(navNext, sField);
                            if (objData != null)
                            {
                                sFieldValue = String.Format("{0}", objData);
                            }

                            this.Text = sFieldValue;
                        }

                        this.NavigateUrl = navNext.FileName;
                    }
                    else
                    {
                        this.Visible = false;
                    }
                }
            }
            else
            {
                this.Visible = false;
            }

            base.OnPreRender(e);
        }
예제 #6
0
        public static SiteNav GetParentPage()
        {
            using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) {
                SiteNav pageNav = navHelper.GetParentPageNavigation(SiteData.CurrentSiteID, SiteData.AlternateCurrentScriptName);

                //assign bogus page name for comp purposes
                if (pageNav == null || pageNav.SiteID == Guid.Empty)
                {
                    pageNav = new SiteNav();
                    pageNav.Root_ContentID = Guid.Empty;
                    pageNav.FileName       = "/##/";
                    pageNav.TemplateFile   = "/##/";
                }

                return(pageNav);
            }
        }
예제 #7
0
        public void SearchOne()
        {
            int iTake = 25;

            this.SelectedPage = null;
            this.Widgets      = null;
            this.SelectedItem = Guid.Empty;
            this.TotalPages   = 0;

            using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) {
                if (!String.IsNullOrEmpty(this.SearchFor))
                {
                    this.TotalPages = navHelper.GetSiteSearchCount(SiteData.CurrentSiteID, this.SearchFor, this.HideInactive);
                    this.Pages      = navHelper.GetLatestContentSearchList(SiteData.CurrentSiteID, this.SearchFor, this.HideInactive, iTake, 0, "NavMenuText", "ASC");
                }
            }
        }
예제 #8
0
        public void SortChildren()
        {
            List <SiteNav> lstNav = null;

            using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) {
                lstNav = navHelper.GetChildNavigation(SiteData.CurrentSiteID, this.Root_ContentID, !SecurityData.IsAuthEditor);
            }

            if (!String.IsNullOrEmpty(this.SelectedSort))
            {
                switch (this.SelectedSort)
                {
                case "alpha":
                    lstNav = lstNav.OrderBy(x => x.NavMenuText).ToList();
                    break;

                case "datecreated":
                    lstNav = lstNav.OrderBy(x => x.CreateDate).ToList();
                    break;

                case "dateupdated":
                    lstNav = lstNav.OrderBy(x => x.EditDate).ToList();
                    break;

                case "alpha2":
                    lstNav = lstNav.OrderByDescending(x => x.NavMenuText).ToList();
                    break;

                case "datecreated2":
                    lstNav = lstNav.OrderByDescending(x => x.CreateDate).ToList();
                    break;

                case "dateupdated2":
                    lstNav = lstNav.OrderByDescending(x => x.EditDate).ToList();
                    break;

                default:
                    lstNav = lstNav.OrderBy(x => x.NavOrder).ToList();
                    break;
                }
            }

            lstNav.ToList().ForEach(q => CMSConfigHelper.IdentifyLinkAsInactive(q));

            this.Pages = lstNav;
        }
예제 #9
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            List <SiteNav> lstContents = new List <SiteNav>();
            int            iTake       = 25;
            int            iTotal      = -1;

            phResults.Visible     = true;
            sSearchTerm           = txtSearchTerm.Text;
            hdnSelectedItem.Value = "";

            GeneralUtilities.BindDataBoundControl(gvWidgets, null);

            if (!String.IsNullOrEmpty(gvPages.DefaultSort))
            {
                int pos = gvPages.DefaultSort.LastIndexOf(" ");
                sSortFld = gvPages.DefaultSort.Substring(0, pos).Trim();
                sSortDir = gvPages.DefaultSort.Substring(pos).Trim();
            }

            bool bLimit = chkActive.Checked;

            using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) {
                if (!String.IsNullOrEmpty(sSearchTerm))
                {
                    iTotal      = navHelper.GetSiteSearchCount(SiteData.CurrentSiteID, sSearchTerm, bLimit);
                    lstContents = navHelper.GetLatestContentSearchList(SiteData.CurrentSiteID, sSearchTerm, bLimit, iTake, 0, sSortFld, sSortDir);
                }
            }

            if (iTotal > 0)
            {
                if (iTotal > lstContents.Count)
                {
                    litResults.Text = String.Format("Showing {0} of {1} total results", lstContents.Count, iTotal);
                }
                else
                {
                    litResults.Text = String.Format("Showing {0} results", lstContents.Count);
                }
            }

            GeneralUtilities.BindDataBoundControl(gvPages, lstContents);
        }
예제 #10
0
        protected List <SiteNav> GetUpdates()
        {
            List <SiteNav> lst = new List <SiteNav>();

            using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) {
                switch (this.ContentType)
                {
                case ListContentType.Blog:
                    lst = navHelper.GetLatestPosts(SiteData.CurrentSiteID, this.TakeTop, !SecurityData.IsAuthEditor);
                    break;

                case ListContentType.ContentPage:
                    lst = navHelper.GetLatest(SiteData.CurrentSiteID, this.TakeTop, !SecurityData.IsAuthEditor);
                    break;

                case ListContentType.SpecifiedCategories:
                    if (this.TakeTop > 0)
                    {
                        lst = navHelper.GetFilteredContentByIDPagedList(SiteData.CurrentSite, this.SelectedCategories, this.SelectedCategorySlugs, !SecurityData.IsAuthEditor, this.TakeTop, 0, "GoLiveDate", "DESC");
                    }
                    else
                    {
                        lst = navHelper.GetFilteredContentByIDPagedList(SiteData.CurrentSite, this.SelectedCategories, this.SelectedCategorySlugs, !SecurityData.IsAuthEditor, 3200000, 0, "NavMenuText", "ASC");
                    }
                    break;
                }

                if (this.ShowUpdateDate && String.IsNullOrEmpty(this.DateFormat))
                {
                    this.DateFormat = "({0:d})";
                }

                if (this.ShowUpdateDate && !String.IsNullOrEmpty(this.DateFormat))
                {
                    lst.ForEach(x => x.NavMenuText = String.Format("{0}  {1}", x.NavMenuText, String.Format(this.DateFormat, x.GoLiveDate)));
                }
            }

            return(lst);
        }
예제 #11
0
        protected BasicContentData GetFileInfoFromList(SiteData site, string sFilename)
        {
            if (sitePageList == null || sitePageList.Count < 1 || iAccessCounter % 25 == 0)
            {
                sitePageList   = site.GetFullSiteFileList();
                iAccessCounter = 0;
            }
            iAccessCounter++;

            BasicContentData pageData = (from m in sitePageList
                                         where m.FileName.ToLower() == sFilename.ToLower()
                                         select m).FirstOrDefault();

            if (pageData == null)
            {
                using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) {
                    pageData = BasicContentData.CreateBasicContentDataFromSiteNav(navHelper.GetLatestVersion(site.SiteID, false, sFilename.ToLower()));
                }
            }

            return(pageData);
        }
예제 #12
0
        public override string GetHtml()
        {
            string sFieldValue = string.Empty;

            if (this.ContentPage == null)
            {
                this.ContentPage = SiteData.GetCurrentPage();
            }

            SiteNav navNext = new SiteNav();

            if (this.NavigationDirection != NavDirection.Unknown)
            {
                using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) {
                    if (NavigationDirection == NavDirection.Prev)
                    {
                        navNext = navHelper.GetPrevPost(SiteData.CurrentSiteID, this.ContentPage.Root_ContentID, !SecurityData.IsAuthEditor);
                    }
                    if (NavigationDirection == NavDirection.Next)
                    {
                        navNext = navHelper.GetNextPost(SiteData.CurrentSiteID, this.ContentPage.Root_ContentID, !SecurityData.IsAuthEditor);
                    }

                    if (navNext != null)
                    {
                        if (this.UseDefaultText)
                        {
                            string sField = this.CaptionDataField.ToString();

                            object objData = ReflectionUtilities.GetPropertyValue(navNext, sField);
                            if (objData != null)
                            {
                                sFieldValue = String.Format("{0}", objData);
                            }

                            this.NavigateText = sFieldValue;
                        }

                        this.NavigateUrl = navNext.FileName;
                    }
                    else
                    {
                        this.NavigateUrl = String.Empty;
                    }
                }
            }
            else
            {
                this.NavigateUrl = String.Empty;
            }

            if (!String.IsNullOrEmpty(this.NavigateUrl))
            {
                var lnkBuilder = new TagBuilder("a");
                lnkBuilder.MergeAttribute("href", this.NavigateUrl);

                lnkBuilder.InnerHtml = this.NavigateUrl;
                if (!String.IsNullOrEmpty(this.NavigateText))
                {
                    lnkBuilder.InnerHtml = this.NavigateText;
                }

                var lnkAttribs = (IDictionary <string, object>)HtmlHelper.AnonymousObjectToHtmlAttributes(linkAttributes);
                lnkBuilder.MergeAttributes(lnkAttribs);

                return(lnkBuilder.ToString(TagRenderMode.Normal));
            }
            else
            {
                return(String.Empty);
            }
        }
예제 #13
0
 public static List <SiteNav> GetPageNavTree()
 {
     using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) {
         return(navHelper.GetPageCrumbNavigation(SiteData.CurrentSiteID, SiteData.AlternateCurrentScriptName, !SecurityData.IsAuthEditor));
     }
 }
예제 #14
0
        private void ImportStuff()
        {
            SiteData.CurrentSite = null;

            SiteData site = SiteData.CurrentSite;

            litMessage.Text = "<p>No Items Selected For Import</p>";
            string sMsg = "";

            if (chkSite.Checked || chkPages.Checked || chkPosts.Checked)
            {
                List <string> tags = site.GetTagList().Select(x => x.TagSlug.ToLowerInvariant()).ToList();
                List <string> cats = site.GetCategoryList().Select(x => x.CategorySlug.ToLowerInvariant()).ToList();

                wpSite.Tags.RemoveAll(x => tags.Contains(x.InfoKey.ToLowerInvariant()));
                wpSite.Categories.RemoveAll(x => cats.Contains(x.InfoKey.ToLowerInvariant()));

                sMsg += "<p>Imported Tags and Categories</p>";

                List <ContentTag> lstTag = (from l in wpSite.Tags.Distinct()
                                            select new ContentTag {
                    ContentTagID = Guid.NewGuid(),
                    IsPublic = true,
                    SiteID = site.SiteID,
                    TagSlug = l.InfoKey,
                    TagText = l.InfoLabel
                }).Distinct().ToList();

                List <ContentCategory> lstCat = (from l in wpSite.Categories.Distinct()
                                                 select new ContentCategory {
                    ContentCategoryID = Guid.NewGuid(),
                    IsPublic = true,
                    SiteID = site.SiteID,
                    CategorySlug = l.InfoKey,
                    CategoryText = l.InfoLabel
                }).Distinct().ToList();

                foreach (var v in lstTag)
                {
                    v.Save();
                }
                foreach (var v in lstCat)
                {
                    v.Save();
                }
            }
            SetMsg(sMsg);

            if (chkSite.Checked)
            {
                sMsg            += "<p>Updated Site Name</p>";
                site.SiteName    = wpSite.SiteTitle;
                site.SiteTagline = wpSite.SiteDescription;
                site.Save();
            }
            SetMsg(sMsg);

            if (!chkMapAuthor.Checked)
            {
                wpSite.Authors = new List <WordPressUser>();
            }

            //itterate author collection and find if in the system
            foreach (WordPressUser wpu in wpSite.Authors)
            {
                wpu.ImportUserID = Guid.Empty;

                MembershipUser usr = null;
                //attempt to find the user in the userbase
                usr = SecurityData.GetUserListByEmail(wpu.Email).FirstOrDefault();
                if (usr != null)
                {
                    wpu.ImportUserID = new Guid(usr.ProviderUserKey.ToString());
                }
                else
                {
                    usr = SecurityData.GetUserListByName(wpu.Login).FirstOrDefault();
                    if (usr != null)
                    {
                        wpu.ImportUserID = new Guid(usr.ProviderUserKey.ToString());
                    }
                }

                if (chkAuthors.Checked)
                {
                    if (wpu.ImportUserID == Guid.Empty)
                    {
                        usr = Membership.CreateUser(wpu.Login, ProfileManager.GenerateSimplePassword(), wpu.Email);
                        Roles.AddUserToRole(wpu.Login, SecurityData.CMSGroup_Users);
                        wpu.ImportUserID = new Guid(usr.ProviderUserKey.ToString());
                    }

                    if (wpu.ImportUserID != Guid.Empty)
                    {
                        ExtendedUserData ud = new ExtendedUserData(wpu.ImportUserID);
                        if (ud != null)
                        {
                            if (!String.IsNullOrEmpty(wpu.FirstName) || !String.IsNullOrEmpty(wpu.LastName))
                            {
                                ud.FirstName = wpu.FirstName;
                                ud.LastName  = wpu.LastName;
                                ud.Save();
                            }
                        }
                        else
                        {
                            throw new Exception(String.Format("Could not find new user: {0} ({1})", wpu.Login, wpu.Email));
                        }
                    }
                }
            }

            wpSite.Comments.ForEach(r => r.ImportRootID = Guid.Empty);

            using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) {
                if (chkPages.Checked)
                {
                    sMsg += "<p>Imported Pages</p>";

                    int     iOrder  = 0;
                    SiteNav navHome = navHelper.FindHome(site.SiteID, false);
                    if (navHome != null)
                    {
                        iOrder = 2;
                    }

                    foreach (var wpp in (from c in wpSite.Content
                                         where c.PostType == WordPressPost.WPPostType.Page
                                         orderby c.PostOrder, c.PostTitle
                                         select c).ToList())
                    {
                        GrabAttachments(wpp);
                        RepairBody(wpp);

                        ContentPage cp = ContentImportExportUtils.CreateWPContentPage(wpSite, wpp, site);
                        cp.SiteID       = site.SiteID;
                        cp.ContentType  = ContentPageType.PageType.ContentEntry;
                        cp.EditDate     = SiteData.CurrentSite.Now;
                        cp.NavOrder     = iOrder;
                        cp.TemplateFile = ddlTemplatePage.SelectedValue;

                        WordPressPost parent = (from c in wpSite.Content
                                                where c.PostType == WordPressPost.WPPostType.Page &&
                                                c.PostID == wpp.ParentPostID
                                                select c).FirstOrDefault();

                        SiteNav navParent = null;

                        SiteNav navData = navHelper.GetLatestVersion(site.SiteID, false, cp.FileName.ToLowerInvariant());
                        if (parent != null)
                        {
                            navParent = navHelper.GetLatestVersion(site.SiteID, false, parent.ImportFileName.ToLowerInvariant());
                        }

                        //if URL exists already, make this become a new version in the current series
                        if (navData != null)
                        {
                            cp.Root_ContentID = navData.Root_ContentID;
                            if (navData.NavOrder == 0)
                            {
                                cp.NavOrder = 0;
                            }
                        }

                        if (navParent != null)
                        {
                            cp.Parent_ContentID = navParent.Root_ContentID;
                        }
                        else
                        {
                            if (parent != null)
                            {
                                cp.Parent_ContentID = parent.ImportRootID;
                            }
                        }
                        //preserve homepage
                        if (navHome != null && navHome.FileName.ToLowerInvariant() == cp.FileName.ToLowerInvariant())
                        {
                            cp.NavOrder = 0;
                        }

                        cp.RetireDate = CMSConfigHelper.CalcNearestFiveMinTime(cp.CreateDate).AddYears(200);
                        cp.GoLiveDate = CMSConfigHelper.CalcNearestFiveMinTime(cp.CreateDate).AddMinutes(-5);

                        //if URL exists already, make this become a new version in the current series
                        if (navData != null)
                        {
                            cp.Root_ContentID = navData.Root_ContentID;
                            cp.RetireDate     = navData.RetireDate;
                            cp.GoLiveDate     = navData.GoLiveDate;
                        }

                        cp.SavePageEdit();

                        wpSite.Comments.Where(x => x.PostID == wpp.PostID).ToList().ForEach(r => r.ImportRootID = cp.Root_ContentID);

                        iOrder++;
                    }
                }

                if (chkPosts.Checked)
                {
                    sMsg += "<p>Imported Posts</p>";

                    foreach (var wpp in (from c in wpSite.Content
                                         where c.PostType == WordPressPost.WPPostType.BlogPost
                                         orderby c.PostOrder
                                         select c).ToList())
                    {
                        GrabAttachments(wpp);
                        RepairBody(wpp);

                        ContentPage cp = ContentImportExportUtils.CreateWPContentPage(wpSite, wpp, site);
                        cp.SiteID           = site.SiteID;
                        cp.Parent_ContentID = null;
                        cp.ContentType      = ContentPageType.PageType.BlogEntry;
                        cp.EditDate         = SiteData.CurrentSite.Now;
                        cp.NavOrder         = SiteData.BlogSortOrderNumber;
                        cp.TemplateFile     = ddlTemplatePost.SelectedValue;

                        SiteNav navData = navHelper.GetLatestVersion(site.SiteID, false, cp.FileName.ToLowerInvariant());

                        cp.RetireDate = CMSConfigHelper.CalcNearestFiveMinTime(cp.CreateDate).AddYears(200);
                        cp.GoLiveDate = CMSConfigHelper.CalcNearestFiveMinTime(cp.CreateDate).AddMinutes(-5);

                        //if URL exists already, make this become a new version in the current series
                        if (navData != null)
                        {
                            cp.Root_ContentID = navData.Root_ContentID;
                            cp.RetireDate     = navData.RetireDate;
                            cp.GoLiveDate     = navData.GoLiveDate;
                        }

                        cp.SavePageEdit();

                        wpSite.Comments.Where(x => x.PostID == wpp.PostID).ToList().ForEach(r => r.ImportRootID = cp.Root_ContentID);
                    }

                    using (ContentPageHelper cph = new ContentPageHelper()) {
                        //cph.BulkBlogFileNameUpdateFromDate(site.SiteID);
                        cph.ResolveDuplicateBlogURLs(site.SiteID);
                        cph.FixBlogNavOrder(site.SiteID);
                    }
                }
            }
            SetMsg(sMsg);

            wpSite.Comments.RemoveAll(r => r.ImportRootID == Guid.Empty);

            if (wpSite.Comments.Any())
            {
                sMsg += "<p>Imported Comments</p>";
            }

            foreach (WordPressComment wpc in wpSite.Comments)
            {
                int iCommentCount = -1;

                iCommentCount = PostComment.GetCommentCountByContent(site.SiteID, wpc.ImportRootID, wpc.CommentDateUTC, wpc.AuthorIP, wpc.CommentContent);
                if (iCommentCount < 1)
                {
                    iCommentCount = PostComment.GetCommentCountByContent(site.SiteID, wpc.ImportRootID, wpc.CommentDateUTC, wpc.AuthorIP);
                }

                if (iCommentCount < 1)
                {
                    PostComment pc = new PostComment();
                    pc.ContentCommentID = Guid.NewGuid();
                    pc.Root_ContentID   = wpc.ImportRootID;
                    pc.CreateDate       = site.ConvertUTCToSiteTime(wpc.CommentDateUTC);
                    pc.IsApproved       = false;
                    pc.IsSpam           = false;

                    pc.CommenterIP     = wpc.AuthorIP;
                    pc.CommenterName   = wpc.Author;
                    pc.CommenterEmail  = wpc.AuthorEmail;
                    pc.PostCommentText = wpc.CommentContent;
                    pc.CommenterURL    = wpc.AuthorURL;

                    if (wpc.Approved == "1")
                    {
                        pc.IsApproved = true;
                    }
                    if (wpc.Approved.ToLowerInvariant() == "trash")
                    {
                        pc.IsSpam = true;
                    }
                    if (wpc.Type.ToLowerInvariant() == "trackback" || wpc.Type.ToLowerInvariant() == "pingback")
                    {
                        pc.CommenterEmail = wpc.Type;
                    }

                    pc.Save();
                }
            }
            SetMsg(sMsg);

            BindData();
        }
예제 #15
0
        public void ImportStuff()
        {
            this.HasLoaded = false;
            this.Site      = ContentImportExportUtils.GetSerializedWPExport(this.ImportID);

            SiteData.CurrentSite = null;

            SiteData site = SiteData.CurrentSite;

            this.Message = String.Empty;
            string sMsg = String.Empty;

            if (this.ImportSite || this.ImportPages || this.ImportPosts)
            {
                List <string> tags = site.GetTagList().Select(x => x.TagSlug.ToLower()).ToList();
                List <string> cats = site.GetCategoryList().Select(x => x.CategorySlug.ToLower()).ToList();

                this.Site.Tags.RemoveAll(x => tags.Contains(x.InfoKey.ToLower()));
                this.Site.Categories.RemoveAll(x => cats.Contains(x.InfoKey.ToLower()));

                sMsg += "<li>Imported Tags and Categories</li>";

                List <ContentTag> lstTag = (from l in this.Site.Tags.Distinct()
                                            select new ContentTag {
                    ContentTagID = Guid.NewGuid(),
                    IsPublic = true,
                    SiteID = site.SiteID,
                    TagSlug = l.InfoKey,
                    TagText = l.InfoLabel
                }).Distinct().ToList();

                List <ContentCategory> lstCat = (from l in this.Site.Categories.Distinct()
                                                 select new ContentCategory {
                    ContentCategoryID = Guid.NewGuid(),
                    IsPublic = true,
                    SiteID = site.SiteID,
                    CategorySlug = l.InfoKey,
                    CategoryText = l.InfoLabel
                }).Distinct().ToList();

                foreach (var v in lstTag)
                {
                    v.Save();
                }
                foreach (var v in lstCat)
                {
                    v.Save();
                }
            }
            SetMsg(sMsg);

            if (this.ImportSite)
            {
                sMsg            += "<li>Updated Site Name</li>";
                site.SiteName    = this.Site.SiteTitle;
                site.SiteTagline = this.Site.SiteDescription;
                site.Save();
            }
            SetMsg(sMsg);

            if (!this.MapUsers)
            {
                this.Site.Authors = new List <WordPressUser>();
            }

            //iterate author collection and find if in the system
            foreach (WordPressUser wpu in this.Site.Authors)
            {
                SecurityData sd = new SecurityData();

                ExtendedUserData usr = null;
                wpu.ImportUserID = Guid.Empty;

                //attempt to find the user in the userbase
                usr = ExtendedUserData.FindByEmail(wpu.Email);
                if (usr != null)
                {
                    wpu.ImportUserID = usr.UserId;
                }
                else
                {
                    usr = ExtendedUserData.FindByUsername(wpu.Login);
                    if (usr != null)
                    {
                        wpu.ImportUserID = usr.UserId;
                    }
                }

                if (this.CreateUsers)
                {
                    if (wpu.ImportUserID == Guid.Empty)
                    {
                        ApplicationUser user = new ApplicationUser {
                            UserName = wpu.Login, Email = wpu.Email
                        };
                        var result = sd.CreateApplicationUser(user, out usr);
                        if (result.Succeeded)
                        {
                            usr = ExtendedUserData.FindByUsername(wpu.Login);
                        }
                        else
                        {
                            throw new Exception(String.Format("Could not create user: {0} ({1}) \r\n{3}", wpu.Login, wpu.Email, String.Join("\r\n", result.Errors)));
                        }
                        wpu.ImportUserID = usr.UserId;
                    }

                    if (wpu.ImportUserID != Guid.Empty)
                    {
                        ExtendedUserData ud = new ExtendedUserData(wpu.ImportUserID);
                        if (!String.IsNullOrEmpty(wpu.FirstName) || !String.IsNullOrEmpty(wpu.LastName))
                        {
                            ud.FirstName = wpu.FirstName;
                            ud.LastName  = wpu.LastName;
                            ud.Save();
                        }
                    }
                }
            }

            this.Site.Comments.ForEach(r => r.ImportRootID = Guid.Empty);

            using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) {
                if (this.ImportPages)
                {
                    sMsg += "<li>Imported Pages</li>";

                    int     iOrder  = 0;
                    SiteNav navHome = navHelper.FindHome(site.SiteID, false);
                    if (navHome != null)
                    {
                        iOrder = 2;
                    }

                    foreach (var wpp in (from c in this.Site.Content
                                         where c.PostType == WordPressPost.WPPostType.Page
                                         orderby c.PostOrder, c.PostTitle
                                         select c).ToList())
                    {
                        GrabAttachments(wpp);
                        RepairBody(wpp);

                        ContentPage cp = ContentImportExportUtils.CreateWPContentPage(this.Site, wpp, site);
                        cp.SiteID       = site.SiteID;
                        cp.ContentType  = ContentPageType.PageType.ContentEntry;
                        cp.EditDate     = SiteData.CurrentSite.Now;
                        cp.NavOrder     = iOrder;
                        cp.TemplateFile = this.PageTemplate;

                        WordPressPost parent = (from c in this.Site.Content
                                                where c.PostType == WordPressPost.WPPostType.Page &&
                                                c.PostID == wpp.ParentPostID
                                                select c).FirstOrDefault();

                        SiteNav navParent = null;

                        SiteNav navData = navHelper.GetLatestVersion(site.SiteID, false, cp.FileName.ToLower());
                        if (parent != null)
                        {
                            navParent = navHelper.GetLatestVersion(site.SiteID, false, parent.ImportFileName.ToLower());
                        }

                        //if URL exists already, make this become a new version in the current series
                        if (navData != null)
                        {
                            cp.Root_ContentID = navData.Root_ContentID;
                            if (navData.NavOrder == 0)
                            {
                                cp.NavOrder = 0;
                            }
                        }

                        if (navParent != null)
                        {
                            cp.Parent_ContentID = navParent.Root_ContentID;
                        }
                        else
                        {
                            if (parent != null)
                            {
                                cp.Parent_ContentID = parent.ImportRootID;
                            }
                        }
                        //preserve homepage
                        if (navHome != null && navHome.FileName.ToLower() == cp.FileName.ToLower())
                        {
                            cp.NavOrder = 0;
                        }

                        cp.RetireDate = CMSConfigHelper.CalcNearestFiveMinTime(cp.CreateDate).AddYears(200);
                        cp.GoLiveDate = CMSConfigHelper.CalcNearestFiveMinTime(cp.CreateDate).AddMinutes(-5);

                        //if URL exists already, make this become a new version in the current series
                        if (navData != null)
                        {
                            cp.Root_ContentID = navData.Root_ContentID;
                            cp.RetireDate     = navData.RetireDate;
                            cp.GoLiveDate     = navData.GoLiveDate;
                        }

                        cp.SavePageEdit();

                        this.Site.Comments.Where(x => x.PostID == wpp.PostID).ToList().ForEach(r => r.ImportRootID = cp.Root_ContentID);

                        iOrder++;
                    }
                }

                if (this.ImportPosts)
                {
                    sMsg += "<li>Imported Posts</li>";

                    foreach (var wpp in (from c in this.Site.Content
                                         where c.PostType == WordPressPost.WPPostType.BlogPost
                                         orderby c.PostOrder
                                         select c).ToList())
                    {
                        GrabAttachments(wpp);
                        RepairBody(wpp);

                        ContentPage cp = ContentImportExportUtils.CreateWPContentPage(this.Site, wpp, site);
                        cp.SiteID           = site.SiteID;
                        cp.Parent_ContentID = null;
                        cp.ContentType      = ContentPageType.PageType.BlogEntry;
                        cp.EditDate         = SiteData.CurrentSite.Now;
                        cp.NavOrder         = SiteData.BlogSortOrderNumber;
                        cp.TemplateFile     = this.PostTemplate;

                        SiteNav navData = navHelper.GetLatestVersion(site.SiteID, false, cp.FileName.ToLower());

                        cp.RetireDate = CMSConfigHelper.CalcNearestFiveMinTime(cp.CreateDate).AddYears(200);
                        cp.GoLiveDate = CMSConfigHelper.CalcNearestFiveMinTime(cp.CreateDate).AddMinutes(-5);

                        //if URL exists already, make this become a new version in the current series
                        if (navData != null)
                        {
                            cp.Root_ContentID = navData.Root_ContentID;
                            cp.RetireDate     = navData.RetireDate;
                            cp.GoLiveDate     = navData.GoLiveDate;
                        }

                        cp.SavePageEdit();

                        this.Site.Comments.Where(x => x.PostID == wpp.PostID).ToList().ForEach(r => r.ImportRootID = cp.Root_ContentID);
                    }

                    using (ContentPageHelper cph = new ContentPageHelper()) {
                        //cph.BulkBlogFileNameUpdateFromDate(site.SiteID);
                        cph.ResolveDuplicateBlogURLs(site.SiteID);
                        cph.FixBlogNavOrder(site.SiteID);
                    }
                }
            }
            SetMsg(sMsg);

            this.Site.Comments.RemoveAll(r => r.ImportRootID == Guid.Empty);

            if (this.Site.Comments.Any())
            {
                sMsg += "<li>Imported Comments</li>";
            }

            foreach (WordPressComment wpc in this.Site.Comments)
            {
                int iCommentCount = -1;

                iCommentCount = PostComment.GetCommentCountByContent(site.SiteID, wpc.ImportRootID, wpc.CommentDateUTC, wpc.AuthorIP, wpc.CommentContent);
                if (iCommentCount < 1)
                {
                    iCommentCount = PostComment.GetCommentCountByContent(site.SiteID, wpc.ImportRootID, wpc.CommentDateUTC, wpc.AuthorIP);
                }

                if (iCommentCount < 1)
                {
                    PostComment pc = new PostComment();
                    pc.ContentCommentID = Guid.NewGuid();
                    pc.Root_ContentID   = wpc.ImportRootID;
                    pc.CreateDate       = site.ConvertUTCToSiteTime(wpc.CommentDateUTC);
                    pc.IsApproved       = false;
                    pc.IsSpam           = false;

                    pc.CommenterIP     = wpc.AuthorIP;
                    pc.CommenterName   = wpc.Author;
                    pc.CommenterEmail  = wpc.AuthorEmail;
                    pc.PostCommentText = wpc.CommentContent;
                    pc.CommenterURL    = wpc.AuthorURL;

                    if (wpc.Approved == "1")
                    {
                        pc.IsApproved = true;
                    }
                    if (wpc.Approved.ToLower() == "trash")
                    {
                        pc.IsSpam = true;
                    }
                    if (wpc.Type.ToLower() == "trackback" || wpc.Type.ToLower() == "pingback")
                    {
                        pc.CommenterEmail = wpc.Type;
                    }

                    pc.Save();
                }
            }
            SetMsg(sMsg);
        }
예제 #16
0
        public override string GetHtml()
        {
            List <SiteNav> lstNav  = new List <SiteNav>();
            StringBuilder  sb      = new StringBuilder();
            SiteNav        pageNav = this.ContentPage.GetSiteNav();
            string         sParent = pageNav.FileName.ToLower();

            using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) {
                if (SiteData.CurretSiteExists && SiteData.CurrentSite.Blog_Root_ContentID.HasValue &&
                    pageNav.ContentType == ContentPageType.PageType.BlogEntry)
                {
                    lstNav = navHelper.GetPageCrumbNavigation(SiteData.CurrentSiteID, SiteData.CurrentSite.Blog_Root_ContentID.Value, !SecurityData.IsAuthEditor);

                    if (lstNav != null && lstNav.Any())
                    {
                        pageNav.NavOrder = lstNav.Max(x => x.NavOrder) + 100;
                        lstNav.Add(pageNav);
                    }
                }
                else
                {
                    lstNav = navHelper.GetPageCrumbNavigation(SiteData.CurrentSiteID, pageNav.Root_ContentID, !SecurityData.IsAuthEditor);
                }
                lstNav.RemoveAll(x => x.ShowInSiteNav == false && x.ContentType == ContentPageType.PageType.ContentEntry);
            }

            lstNav.ForEach(q => ControlUtilities.IdentifyLinkAsInactive(q));

            string sCSS = String.Empty;

            if (!String.IsNullOrEmpty(this.CssClass))
            {
                sCSS = " class=\"" + this.CssClass + "\" ";
            }

            string sSelCSS = String.Format("{0} {1}", this.CssSelected, this.CssWrapper).Trim();

            string sWrapCSS = String.Empty;

            if (!String.IsNullOrEmpty(this.CssWrapper))
            {
                sWrapCSS = " class=\"" + this.CssWrapper + "\" ";
            }

            if (this.DisplayAsList)
            {
                sb.AppendLine("<ul" + sCSS + " id=\"" + this.ElementId + "\">");
                foreach (SiteNav c in lstNav)
                {
                    if (SiteData.IsFilenameCurrentPage(c.FileName) || ControlUtilities.AreFilenamesSame(c.FileName, sParent))
                    {
                        sb.AppendLine("<li class=\"" + sSelCSS + "\">" + c.NavMenuText + "</li> ");
                    }
                    else
                    {
                        sb.AppendLine("<li" + sWrapCSS + "><a href=\"" + c.FileName + "\">" + c.NavMenuText + "</a></li> ");
                    }
                }
                sb.AppendLine("</ul>");
            }
            else
            {
                string sDivider = String.Format(" {0} ", this.TextDivider);
                int    iCtr     = 1;
                int    iMax     = lstNav.Count;
                sb.AppendLine("<div" + sCSS + " id=\"" + this.ElementId + "\">");
                foreach (SiteNav c in lstNav)
                {
                    if (SiteData.IsFilenameCurrentPage(c.FileName) || ControlUtilities.AreFilenamesSame(c.FileName, sParent))
                    {
                        sb.AppendLine("<span class=\"" + sSelCSS + "\">" + c.NavMenuText + " " + sDivider + "</span> ");
                    }
                    else
                    {
                        sb.AppendLine("<span" + sWrapCSS + "><a href=\"" + c.FileName + "\">" + c.NavMenuText + "</a> " + sDivider + "</span> ");
                    }
                    iCtr++;

                    if (iCtr == iMax)
                    {
                        sDivider = String.Empty;
                    }
                }
                sb.AppendLine("</div>");
            }

            return(sb.ToString());
        }
예제 #17
0
        public void FetchData()
        {
            base.ReadPageNbr();

            string sPagePath = SiteData.CurrentScriptName;

            if (String.IsNullOrEmpty(this.OrderBy))
            {
                this.InitOrderByDescending(x => x.GoLiveDate);
            }

            List <SiteNav> lstContents = new List <SiteNav>();

            string sSearchTerm = String.Empty;

            ContentPageType.PageType viewContentType = ContentPageType.PageType.BlogEntry;

            if (this.IgnoreSitePath)
            {
                sPagePath = String.Format("/siteid-{0}", SiteData.CurrentSiteID);
            }

            if (SiteData.IsWebView)
            {
                if (SiteData.CurrentSite.IsSiteSearchPath && !this.IgnoreSitePath)
                {
                    this.ContentType = SummaryContentType.SiteSearch;
                    sSearchTerm      = GetSearchTerm();
                }
            }

            switch (this.ContentType)
            {
            case SummaryContentType.Blog:
            case SummaryContentType.ContentPage:
            case SummaryContentType.SiteSearch:
                this.InitOrderByDescending(x => x.GoLiveDate);
                break;
            }

            SortParm sp       = this.ParseSort();
            string   sSortFld = sp.SortField;
            string   sSortDir = sp.SortDirection;

            if (this.PageNumber <= 0)
            {
                this.PageNumber = 1;
            }

            using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) {
                if (SiteData.IsWebView)
                {
                    switch (this.ContentType)
                    {
                    case SummaryContentType.Blog:
                        viewContentType   = ContentPageType.PageType.BlogEntry;
                        this.TotalRecords = navHelper.GetFilteredContentPagedCount(SiteData.CurrentSite, sPagePath, !SecurityData.IsAuthEditor);
                        lstContents       = navHelper.GetFilteredContentPagedList(SiteData.CurrentSite, sPagePath, !SecurityData.IsAuthEditor, this.PageSize, this.PageNumberZeroIndex, sSortFld, sSortDir);
                        break;

                    case SummaryContentType.ChildContentPage:
                        viewContentType   = ContentPageType.PageType.ContentEntry;
                        this.TotalRecords = navHelper.GetChildNavigationCount(SiteData.CurrentSiteID, sPagePath, !SecurityData.IsAuthEditor);
                        lstContents       = navHelper.GetLatestChildContentPagedList(SiteData.CurrentSiteID, sPagePath, !SecurityData.IsAuthEditor, this.PageSize, this.PageNumberZeroIndex, sSortFld, sSortDir);
                        break;

                    case SummaryContentType.ContentPage:
                        viewContentType   = ContentPageType.PageType.ContentEntry;
                        this.TotalRecords = navHelper.GetSitePageCount(SiteData.CurrentSiteID, viewContentType, !SecurityData.IsAuthEditor);
                        lstContents       = navHelper.GetLatestContentPagedList(SiteData.CurrentSiteID, viewContentType, !SecurityData.IsAuthEditor, this.PageSize, this.PageNumberZeroIndex, sSortFld, sSortDir);
                        break;

                    case SummaryContentType.SpecifiedCategories:
                        viewContentType   = ContentPageType.PageType.BlogEntry;
                        this.TotalRecords = navHelper.GetFilteredContentByIDPagedCount(SiteData.CurrentSite, null, SelectedCategorySlugs, !SecurityData.IsAuthEditor);
                        lstContents       = navHelper.GetFilteredContentByIDPagedList(SiteData.CurrentSite, null, SelectedCategorySlugs, !SecurityData.IsAuthEditor, this.PageSize, this.PageNumberZeroIndex, sSortFld, sSortDir);
                        break;

                    case SummaryContentType.SiteSearch:
                        this.TotalRecords = navHelper.GetSiteSearchCount(SiteData.CurrentSiteID, sSearchTerm, !SecurityData.IsAuthEditor);
                        lstContents       = navHelper.GetLatestContentSearchList(SiteData.CurrentSiteID, sSearchTerm, !SecurityData.IsAuthEditor, this.PageSize, this.PageNumberZeroIndex, sSortFld, sSortDir);
                        break;
                    }
                }
                else
                {
                    viewContentType   = ContentPageType.PageType.ContentEntry;
                    this.TotalRecords = navHelper.GetSitePageCount(SiteData.CurrentSiteID, viewContentType, false);
                    lstContents       = navHelper.GetLatestContentPagedList(Guid.NewGuid(), viewContentType, false, this.PageSize, this.PageNumberZeroIndex, sSortFld, sSortDir);
                }
            }

            lstContents.ToList().ForEach(q => CMSConfigHelper.IdentifyLinkAsInactive(q));

            this.DataSource = lstContents;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) {
                string sCurrentPage = SiteData.CurrentScriptName;
                string sScrubbedURL = SiteData.AlternateCurrentScriptName;

                if (sScrubbedURL.ToLowerInvariant() != sCurrentPage.ToLowerInvariant())
                {
                    sCurrentPage = sScrubbedURL;
                }

                ContentPage currentPage = pageHelper.FindByFilename(SiteData.CurrentSiteID, sCurrentPage);

                if (currentPage == null && SiteData.IsPageReal)
                {
                    IsPageTemplate = true;
                }

                if ((SiteData.IsPageSampler || IsPageTemplate) && currentPage == null)
                {
                    currentPage = ContentPageHelper.GetSamplerView();
                }

                litVersion.Text  = SiteData.CarrotCakeCMSVersion;
                litRelease.Text  = currentPage.GoLiveDate.ToString();
                litRetire.Text   = currentPage.RetireDate.ToString();
                litTemplate.Text = currentPage.TemplateFile;

                CurrentPageID   = currentPage.Root_ContentID;
                lnkCurrent.HRef = SiteData.CurrentScriptName;

                EditPageURL  = SiteFilename.PageAddEditURL;
                PageIndexURL = SiteFilename.PageIndexURL;

                if (currentPage.ContentType == ContentPageType.PageType.BlogEntry)
                {
                    EditPageURL  = SiteFilename.BlogPostAddEditURL;
                    PageIndexURL = SiteFilename.BlogPostIndexURL;
                }

                if (!IsPostBack)
                {
                    List <SiteNav> nav = navHelper.GetChildNavigation(SiteData.CurrentSiteID, CurrentPageID, !SecurityData.IsAuthEditor);

                    SiteNav pageContents2 = navHelper.GetParentPageNavigation(SiteData.CurrentSiteID, CurrentPageID);
                    if (pageContents2 != null)
                    {
                        pageContents2.NavMenuText = "Parent: " + pageContents2.NavMenuText;
                        pageContents2.NavOrder    = -110;
                        lnkParent.Visible         = true;
                        lnkParent.HRef            = pageContents2.FileName;
                    }
                    else
                    {
                        lnkParent.Visible = false;
                    }

                    ContentPage homePage = pageHelper.FindHome(SiteData.CurrentSiteID);

                    List <SiteNav> lstNavTop = null;
                    if (homePage != null && homePage.Root_ContentID == CurrentPageID)
                    {
                        lstNavTop = (from n in navHelper.GetTopNavigation(SiteData.CurrentSiteID, !SecurityData.IsAuthEditor)
                                     where n.Root_ContentID != CurrentPageID
                                     orderby n.NavOrder
                                     select new SiteNav {
                            NavOrder = n.NavOrder,
                            FileName = n.FileName,
                            NavMenuText = (n.NavOrder > 0 ? "  -- " : "") + n.FileName + "  [[" + (n.PageActive ? "" : "{*U*}  ") + n.NavMenuText + "]]",
                            PageActive = n.PageActive,
                            ContentID = n.ContentID,
                            Root_ContentID = n.Root_ContentID,
                            PageHead = n.PageHead,
                            SiteID = n.SiteID
                        }).ToList();
                    }

                    List <SiteNav> lstNav = (from n in nav
                                             orderby n.NavOrder
                                             select new SiteNav {
                        NavOrder = n.NavOrder,
                        FileName = n.FileName,
                        NavMenuText = (n.NavOrder > 0 ? "  -- " : "") + n.FileName + "  [[" + (n.PageActive ? "" : "{*U*}  ") + n.NavMenuText + "]]",
                        PageActive = n.PageActive,
                        ContentID = n.ContentID,
                        Root_ContentID = n.Root_ContentID,
                        PageHead = n.PageHead,
                        SiteID = n.SiteID
                    }).ToList();

                    if (lstNavTop != null)
                    {
                        lstNav = lstNavTop.Union(lstNav).ToList();
                    }

                    GeneralUtilities.BindListDefaultText(ddlCMSLinks, lstNav, null, "Navigate", "00000");

                    if (lstNav.Count < 1)
                    {
                        ddlCMSLinks.Visible = false;
                        lblChildDDL.Visible = false;
                    }
                }
            }
        }