protected SiteNav GetParent(Guid?rootContentID)
        {
            SiteNav pageNav = null;

            if (rootContentID.HasValue)
            {
                pageNav = navHelper.GetPageNavigation(SiteData.CurrentSiteID, rootContentID.Value);
            }
            return(pageNav);
        }
Esempio n. 2
0
 protected SiteNav GetHomePage(SiteData site)
 {
     if (_navHome == null)
     {
         using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) {
             _navHome = navHelper.FindHome(site.SiteID, false);
         }
     }
     return(_navHome);
 }
        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);
        }
        protected SiteNav GetParentPage()
        {
            SiteNav pageNav = navHelper.GetParentPageNavigation(SiteData.CurrentSiteID, SiteData.AlternateCurrentScriptName);

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

            return(pageNav);
        }
        protected void LoadData()
        {
            ParentPageNav = GetParentPage();

            if (ShowSecondLevel)
            {
                lstTwoLevelNav = navHelper.GetTwoLevelNavigation(SiteData.CurrentSiteID, !SecurityData.IsAuthEditor);
            }
            else
            {
                lstTwoLevelNav = navHelper.GetTopNavigation(SiteData.CurrentSiteID, !SecurityData.IsAuthEditor);
            }

            lstTwoLevelNav.RemoveAll(x => x.ShowInSiteNav == false);
            lstTwoLevelNav.ToList().ForEach(q => IdentifyLinkAsInactive(q));
        }
Esempio n. 6
0
 public void NavigatePages()
 {
     SiteNav.GotoLeadershipPage();
     SiteNav.GotoA_GamePage();
     SiteNav.GotoAdverTranPage();
     SiteNav.GotoAzureServicesPage();
     SiteNav.GotoCit261Page();
     SiteNav.GotoCs313Page();
     SiteNav.GotoCs364Page();
     SiteNav.GotoEncompassPage();
     SiteNav.GotoFamilyKeyPage();
     SiteNav.GotoGitPage();
     SiteNav.GotoMlmLinkupPage();
     SiteNav.GotoRedheadMobilePage();
     SiteNav.GotoTechnicalPage();
     SiteNav.GotoWorkHistoryPage();
 }
Esempio n. 7
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);
            }
        }
        protected override void LoadData()
        {
            base.LoadData();

            List <SiteNav> lstNav = navHelper.GetSiblingNavigation(SiteData.CurrentSiteID, SiteData.AlternateCurrentScriptName, !SecurityData.IsAuthEditor);

            if (this.IncludeParent && lstNav != null && lstNav.Where(x => x.ShowInSiteNav == true).Count() > 0)
            {
                SiteNav p = GetParent(lstNav.OrderByDescending(x => x.Parent_ContentID).FirstOrDefault().Parent_ContentID);
                if (p != null)
                {
                    p.NavOrder = -100;
                    lstNav.Add(p);
                }
            }

            this.NavigationData = lstNav.OrderBy(ct => ct.NavMenuText).OrderBy(ct => ct.NavOrder).ToList();
        }
        protected override void LoadData()
        {
            base.LoadData();
            List <SiteNav> lstNav    = null;
            SiteNav        parentNav = GetParentPage();

            if (parentNav.Root_ContentID != Guid.Empty && parentNav.Parent_ContentID != null)
            {
                lstNav = navHelper.GetSiblingNavigation(SiteData.CurrentSiteID, parentNav.FileName, !SecurityData.IsAuthEditor);
            }
            else
            {
                lstNav = navHelper.GetTopNavigation(SiteData.CurrentSiteID, !SecurityData.IsAuthEditor);
            }

            switch (this.SortNavBy)
            {
            case SortOrder.TitleAsc:
                this.NavigationData = lstNav.OrderBy(ct => ct.NavMenuText).ToList();
                break;

            case SortOrder.TitleDesc:
                this.NavigationData = lstNav.OrderByDescending(ct => ct.NavMenuText).ToList();
                break;

            case SortOrder.DateAsc:
                this.NavigationData = lstNav.OrderBy(ct => ct.NavMenuText).OrderBy(ct => ct.GoLiveDate).ToList();
                break;

            case SortOrder.DateDesc:
                this.NavigationData = lstNav.OrderBy(ct => ct.NavMenuText).OrderByDescending(ct => ct.GoLiveDate).ToList();
                break;

            case SortOrder.SortDesc:
                this.NavigationData = lstNav.OrderBy(ct => ct.NavMenuText).OrderByDescending(ct => ct.NavOrder).ToList();
                break;

            case SortOrder.SortAsc:
            default:
                this.NavigationData = lstNav.OrderBy(ct => ct.NavMenuText).OrderBy(ct => ct.NavOrder).ToList();
                break;
            }
        }
        protected override void RenderContents(HtmlTextWriter output)
        {
            int indent = output.Indent;

            SiteNav pageNav = GetParentPage();
            string  sParent = pageNav.FileName.ToLower();

            List <SiteNav> lstNav = navHelper.GetTopNavigation(SiteData.CurrentSiteID, !SecurityData.IsAuthEditor);

            lstNav.RemoveAll(x => x.ShowInSiteNav == false);
            lstNav.ToList().ForEach(q => IdentifyLinkAsInactive(q));

            output.Indent = indent + 3;
            output.WriteLine();

            string sCSS = "";

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

            output.WriteLine("<ul" + sCSS + " id=\"" + this.HtmlClientID + "\">");
            output.Indent++;

            foreach (SiteNav c in lstNav)
            {
                if (SiteData.IsFilenameCurrentPage(c.FileName) || AreFilenamesSame(c.FileName, sParent))
                {
                    output.WriteLine("<li class=\"" + CSSSelected + "\"><a href=\"" + c.FileName + "\">" + c.NavMenuText + "</a></li> ");
                }
                else
                {
                    output.WriteLine("<li><a href=\"" + c.FileName + "\">" + c.NavMenuText + "</a></li> ");
                }
            }

            output.Indent--;
            output.WriteLine("</ul>");

            output.Indent = indent;
        }
Esempio n. 11
0
        public void LeadershipPage()
        {
            _logger.DebugFormat($"'{GetType().Name}.{MethodBase.GetCurrentMethod().Name}' called");

            if (string.IsNullOrEmpty(WebDriverConfig.ServiceEndPoint))
            {
                throw new NoNullAllowedException($"{nameof(WebDriverConfig.ServiceEndPoint)} cannot be null.");
            }

            DerivedSetUp();

            SiteNav.GotoLeadershipPage();

            IWebElement element = Leadership.H2Elements.FindByText("Leadership");

            Assert.IsNotNull(element);

            element = Leadership.H3Elements.FindByText("DevOps Manager");
            Assert.IsNotNull(element);

            element = Leadership.H3Elements.FindByText("Quality Assurance Lead / Manager");
            Assert.IsNotNull(element);

            element = Leadership.H3Elements.FindByText("Scrum Master");
            Assert.IsNotNull(element);

            element = Leadership.H3Elements.FindByText("Development Lead / Manager");
            Assert.IsNotNull(element);

            element = Leadership.H3Elements.FindByText("Two Year Service Mission");
            Assert.IsNotNull(element);

            element = Leadership.H3Elements.FindByText("Personality and Leadership Profile");
            Assert.IsNotNull(element);

            element = Leadership.H3Elements.FindByText("Seminars, Trainings, Audios");
            Assert.IsNotNull(element);

            element = Leadership.H3Elements.FindByText("My Book List");
            Assert.IsNotNull(element);
        }
Esempio n. 12
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();
        }
Esempio n. 13
0
        protected virtual void WriteTopLevel(HtmlTextWriter output)
        {
            int indent = output.Indent;

            output.Indent = indent + 2;

            List <SiteNav> lstNav        = GetTopNav();
            SiteNav        parentPageNav = GetParentPage();
            List <SiteNav> lstNavTree    = GetPageNavTree().OrderByDescending(x => x.NavOrder).ToList();

            this.ParentFileName = parentPageNav.FileName.ToLowerInvariant();

            if (lstNav != null && lstNav.Any())
            {
                output.WriteLine();
                WriteListPrefix(output);

                int indent2 = output.Indent + 1;

                string sItemCSS = "";
                if (!String.IsNullOrEmpty(CSSItem))
                {
                    sItemCSS = String.Format(" {0} ", this.CSSItem);
                }

                string sThis1CSS = sItemCSS;

                foreach (SiteNav c1 in lstNav)
                {
                    output.Indent = indent2;
                    List <SiteNav> cc = GetChildren(c1.Root_ContentID);

                    string sChild = " ";
                    if (this.MultiLevel)
                    {
                        if (cc != null && cc.Any())
                        {
                            sChild = " level1-haschildren " + this.CSSHasChildren + " ";
                        }
                        sThis1CSS = " level1 " + sItemCSS + sChild;
                    }
                    else
                    {
                        sThis1CSS = sItemCSS;
                    }
                    if (SiteData.IsFilenameCurrentPage(c1.FileName) || (IsContained(lstNavTree, c1.Root_ContentID) != null) || AreFilenamesSame(c1.FileName, this.ParentFileName))
                    {
                        sThis1CSS = sThis1CSS + " " + this.CSSSelected;
                    }
                    if (lstNav.Where(x => x.NavOrder < 0).Count() > 0)
                    {
                        if (c1.NavOrder < 0)
                        {
                            sThis1CSS = sThis1CSS + " parent-nav";
                        }
                        else
                        {
                            sThis1CSS = sThis1CSS + " child-nav";
                        }
                    }
                    sThis1CSS = sThis1CSS.Replace("   ", " ").Replace("  ", " ").Trim();

                    iItemNumber++;
                    output.WriteLine("<li id=\"listitem" + iItemNumber.ToString() + "\" class=\"" + sThis1CSS + "\"><a href=\"" + c1.FileName + "\">" + c1.NavMenuText + "</a>");

                    int indent3 = output.Indent;
                    if (this.MultiLevel && cc != null && cc.Any())
                    {
                        LoadChildren(output, c1.Root_ContentID, sItemCSS, iItemNumber, 2);
                    }
                    output.Indent = indent3;
                    output.WriteLine("</li>");
                    output.WriteLine();
                }
                WriteListSuffix(output);
            }
            else
            {
                output.WriteLine("<span style=\"display: none;\" id=\"" + this.ClientID + "\"></span>");
            }

            output.Indent = indent;
        }
Esempio n. 14
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);
        }
        public void ImportStuff()
        {
            this.HasLoaded = false;
            this.Site      = ContentImportExportUtils.GetSerializedSiteExport(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.ToLowerInvariant()).ToList();
                List <string> cats = site.GetCategoryList().Select(x => x.CategorySlug.ToLowerInvariant()).ToList();

                this.Site.TheTags.RemoveAll(x => tags.Contains(x.TagSlug.ToLowerInvariant()));
                this.Site.TheCategories.RemoveAll(x => cats.Contains(x.CategorySlug.ToLowerInvariant()));

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

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

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

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

            if (this.ImportSnippets)
            {
                List <string> snippets = site.GetContentSnippetList().Select(x => x.ContentSnippetSlug.ToLowerInvariant()).ToList();

                this.Site.TheSnippets.RemoveAll(x => snippets.Contains(x.ContentSnippetSlug.ToLowerInvariant()));

                sMsg += "<li>Imported Content Snippets</li>";

                List <ContentSnippet> lstSnip = (from l in this.Site.TheSnippets.Distinct()
                                                 select new ContentSnippet {
                    SiteID = site.SiteID,
                    Root_ContentSnippetID = Guid.NewGuid(),
                    ContentSnippetID = Guid.NewGuid(),
                    CreateUserId = SecurityData.CurrentUserGuid,
                    CreateDate = site.Now,
                    EditUserId = SecurityData.CurrentUserGuid,
                    EditDate = site.Now,
                    RetireDate = l.RetireDate,
                    GoLiveDate = l.GoLiveDate,
                    ContentSnippetActive = l.ContentSnippetActive,
                    ContentBody = l.ContentBody,
                    ContentSnippetSlug = l.ContentSnippetSlug,
                    ContentSnippetName = l.ContentSnippetName
                }).ToList();

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

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

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

            //iterate author collection and find if in the system
            foreach (SiteExportUser seu in this.Site.TheUsers)
            {
                SecurityData sd = new SecurityData();

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

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

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

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

            if (this.ImportPages)
            {
                sMsg        += "<li>Imported Pages</li>";
                this.Content = site.GetFullSiteFileList();

                int iOrder = 0;

                SiteNav navHome = GetHomePage(site);

                if (navHome != null)
                {
                    iOrder = 2;
                }

                foreach (var impCP in (from c in this.Site.ThePages
                                       where c.ThePage.ContentType == ContentPageType.PageType.ContentEntry
                                       orderby c.ThePage.NavOrder, c.ThePage.NavMenuText
                                       select c).ToList())
                {
                    ContentPage cp = impCP.ThePage;
                    cp.Root_ContentID = impCP.NewRootContentID;
                    cp.ContentID      = Guid.NewGuid();
                    cp.SiteID         = site.SiteID;
                    cp.ContentType    = ContentPageType.PageType.ContentEntry;
                    cp.EditDate       = SiteData.CurrentSite.Now;
                    cp.EditUserId     = this.Site.FindImportUser(impCP.TheUser);
                    cp.CreateUserId   = this.Site.FindImportUser(impCP.TheUser);
                    if (impCP.CreditUser != null)
                    {
                        cp.CreditUserId = this.Site.FindImportUser(impCP.CreditUser);
                    }
                    cp.NavOrder     = iOrder;
                    cp.TemplateFile = this.PageTemplate;

                    ContentPageExport parent = (from c in this.Site.ThePages
                                                where c.ThePage.ContentType == ContentPageType.PageType.ContentEntry &&
                                                c.ThePage.FileName.ToLowerInvariant() == impCP.ParentFileName.ToLowerInvariant()
                                                select c).FirstOrDefault();

                    BasicContentData navParent = null;
                    BasicContentData navData   = GetFileInfoFromList(site, cp.FileName);

                    if (parent != null)
                    {
                        cp.Parent_ContentID = parent.NewRootContentID;
                        navParent           = GetFileInfoFromList(site, parent.ThePage.FileName);
                    }

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

                        impCP.ThePage.RetireDate = navData.RetireDate;
                        impCP.ThePage.GoLiveDate = navData.GoLiveDate;

                        if (navData.NavOrder == 0)
                        {
                            cp.NavOrder = 0;
                        }
                    }
                    //preserve homepage
                    if (navHome != null && navHome.FileName.ToLowerInvariant() == cp.FileName.ToLowerInvariant())
                    {
                        cp.NavOrder = 0;
                    }
                    //if the file url in the upload has an existing ID, use that, not the ID from the queue
                    if (navParent != null)
                    {
                        cp.Parent_ContentID = navParent.Root_ContentID;
                    }

                    cp.RetireDate = impCP.ThePage.RetireDate;
                    cp.GoLiveDate = impCP.ThePage.GoLiveDate;

                    cp.SavePageEdit();

                    iOrder++;
                }
            }
            SetMsg(sMsg);

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

                List <ContentTag>      lstTags       = site.GetTagList();
                List <ContentCategory> lstCategories = site.GetCategoryList();

                foreach (var impCP in (from c in this.Site.ThePages
                                       where c.ThePage.ContentType == ContentPageType.PageType.BlogEntry
                                       orderby c.ThePage.CreateDate
                                       select c).ToList())
                {
                    ContentPage cp = impCP.ThePage;
                    cp.Root_ContentID   = impCP.NewRootContentID;
                    cp.ContentID        = Guid.NewGuid();
                    cp.SiteID           = site.SiteID;
                    cp.Parent_ContentID = null;
                    cp.ContentType      = ContentPageType.PageType.BlogEntry;
                    cp.EditDate         = SiteData.CurrentSite.Now;
                    cp.EditUserId       = this.Site.FindImportUser(impCP.TheUser);
                    cp.CreateUserId     = this.Site.FindImportUser(impCP.TheUser);
                    if (impCP.CreditUser != null)
                    {
                        cp.CreditUserId = this.Site.FindImportUser(impCP.CreditUser);
                    }
                    cp.NavOrder     = SiteData.BlogSortOrderNumber;
                    cp.TemplateFile = this.PostTemplate;

                    cp.ContentCategories = (from l in lstCategories
                                            join o in impCP.ThePage.ContentCategories on l.CategorySlug.ToLowerInvariant() equals o.CategorySlug.ToLowerInvariant()
                                            select l).Distinct().ToList();

                    cp.ContentTags = (from l in lstTags
                                      join o in impCP.ThePage.ContentTags on l.TagSlug.ToLowerInvariant() equals o.TagSlug.ToLowerInvariant()
                                      select l).Distinct().ToList();

                    BasicContentData navData = GetFileInfoFromList(site, cp.FileName);

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

                        impCP.ThePage.RetireDate = navData.RetireDate;
                        impCP.ThePage.GoLiveDate = navData.GoLiveDate;
                    }

                    cp.RetireDate = impCP.ThePage.RetireDate;
                    cp.GoLiveDate = impCP.ThePage.GoLiveDate;

                    cp.SavePageEdit();
                }

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

            if (this.ImportComments)
            {
                sMsg        += "<li>Imported Comments</li>";
                this.Content = site.GetFullSiteFileList();

                foreach (var impCP in (from c in this.Site.TheComments
                                       orderby c.TheComment.CreateDate
                                       select c).ToList())
                {
                    int              iCommentCount = -1;
                    PostComment      pc            = impCP.TheComment;
                    BasicContentData navData       = GetFileInfoFromList(site, pc.FileName);
                    if (navData != null)
                    {
                        pc.Root_ContentID   = navData.Root_ContentID;
                        pc.ContentCommentID = Guid.NewGuid();

                        iCommentCount = PostComment.GetCommentCountByContent(site.SiteID, pc.Root_ContentID, pc.CreateDate, pc.CommenterIP, pc.PostCommentText);
                        if (iCommentCount < 1)
                        {
                            iCommentCount = PostComment.GetCommentCountByContent(site.SiteID, pc.Root_ContentID, pc.CreateDate, pc.CommenterIP);
                        }

                        if (iCommentCount < 1)
                        {
                            pc.Save();
                        }
                    }
                }
            }

            SetMsg(sMsg);
        }
        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;
                    }
                }
            }
        }
Esempio n. 17
0
        public static string GetParentPageName()
        {
            SiteNav nav = ControlUtilities.GetParentPage();

            return(nav.FileName.ToLowerInvariant());
        }
        protected override void RenderContents(HtmlTextWriter output)
        {
            SiteNav        pageNav = GetCurrentPage();
            string         sParent = pageNav.FileName.ToLower();
            List <SiteNav> lstNav  = new List <SiteNav>();

            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.ToList().ForEach(q => IdentifyLinkAsInactive(q));

            string sCSS = String.Empty;

            if (!String.IsNullOrEmpty(CssClass))
            {
                sCSS = " class=\"" + CssClass + "\" ";
            }
            string sSelCSS = (CSSSelected + " " + CSSWrapper).Trim();

            string sWrapCSS = String.Empty;

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

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

                    if (iCtr == iMax)
                    {
                        sDivider = String.Empty;
                    }
                }
                output.WriteLine("</div>");
            }
        }
Esempio n. 19
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());
        }
 public static SiteNav IdentifyLinkAsInactive(SiteNav nav)
 {
     return(CMSConfigHelper.IdentifyLinkAsInactive(nav));
 }
        protected string GetParentPageName()
        {
            SiteNav nav = GetParentPage();

            return(nav.FileName.ToLower());
        }
        protected virtual StringBuilder WriteTopLevel(StringBuilder output)
        {
            List <SiteNav> lstNav        = GetTopNav();
            SiteNav        parentPageNav = ControlUtilities.GetParentPage();
            List <SiteNav> lstNavTree    = ControlUtilities.GetPageNavTree().OrderByDescending(x => x.NavOrder).ToList();

            this.ParentFileName = parentPageNav.FileName.ToLower();

            if (lstNav != null && lstNav.Any())
            {
                output.AppendLine();
                WriteListPrefix(output);

                string sItemCSS = String.Empty;
                if (!String.IsNullOrEmpty(this.CssItem))
                {
                    sItemCSS = String.Format(" {0} ", this.CssItem);
                }

                string sThis1CSS = sItemCSS;

                foreach (SiteNav c1 in lstNav)
                {
                    List <SiteNav> cc = GetChildren(c1.Root_ContentID);

                    string sChild = " ";
                    if (this.MultiLevel)
                    {
                        if (cc != null && cc.Any())
                        {
                            sChild = " level1-haschildren " + this.CssHasChildren + " ";
                        }
                        sThis1CSS = " level1 " + sItemCSS + sChild;
                    }
                    else
                    {
                        sThis1CSS = sItemCSS;
                    }
                    if (SiteData.IsFilenameCurrentPage(c1.FileName) ||
                        (c1.NavOrder == 0 && SiteData.IsCurrentLikelyHomePage) ||
                        (IsContained(lstNavTree, c1.Root_ContentID) != null) ||
                        ControlUtilities.AreFilenamesSame(c1.FileName, this.ParentFileName))
                    {
                        sThis1CSS = sThis1CSS + " " + this.CssSelected;
                    }
                    if (lstNav.Where(x => x.NavOrder < 0).Count() > 0)
                    {
                        if (c1.NavOrder < 0)
                        {
                            sThis1CSS = sThis1CSS + " parent-nav";
                        }
                        else
                        {
                            sThis1CSS = sThis1CSS + " child-nav";
                        }
                    }
                    sThis1CSS = sThis1CSS.Replace("   ", " ").Replace("  ", " ").Trim();

                    iItemNumber++;
                    output.AppendLine("<li id=\"listitem" + iItemNumber.ToString() + "\" class=\"" + sThis1CSS + "\"><a href=\"" + c1.FileName + "\">" + c1.NavMenuText + "</a>");

                    if (this.MultiLevel && cc != null && cc.Any())
                    {
                        LoadChildren(output, c1.Root_ContentID, sItemCSS, iItemNumber, 2);
                    }

                    output.AppendLine("</li>");
                    output.AppendLine();
                }
                WriteListSuffix(output);
            }
            else
            {
                output.AppendLine("<span style=\"display: none;\" id=\"" + this.ElementId + "\"></span>");
            }

            return(output);
        }
Esempio n. 23
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.ToLower()).ToList();
                List <string> cats = site.GetCategoryList().Select(x => x.CategorySlug.ToLower()).ToList();

                exSite.TheTags.RemoveAll(x => tags.Contains(x.TagSlug.ToLower()));
                exSite.TheCategories.RemoveAll(x => cats.Contains(x.CategorySlug.ToLower()));

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

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

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

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

            if (chkSnippet.Checked)
            {
                List <string> snippets = site.GetContentSnippetList().Select(x => x.ContentSnippetSlug.ToLower()).ToList();

                exSite.TheSnippets.RemoveAll(x => snippets.Contains(x.ContentSnippetSlug.ToLower()));

                sMsg += "<p>Imported Content Snippets</p>";

                List <ContentSnippet> lstSnip = (from l in exSite.TheSnippets.Distinct()
                                                 select new ContentSnippet {
                    SiteID = site.SiteID,
                    Root_ContentSnippetID = Guid.NewGuid(),
                    ContentSnippetID = Guid.NewGuid(),
                    CreateUserId = SecurityData.CurrentUserGuid,
                    CreateDate = site.Now,
                    EditUserId = SecurityData.CurrentUserGuid,
                    EditDate = site.Now,
                    RetireDate = l.RetireDate,
                    GoLiveDate = l.GoLiveDate,
                    ContentSnippetActive = l.ContentSnippetActive,
                    ContentBody = l.ContentBody,
                    ContentSnippetSlug = l.ContentSnippetSlug,
                    ContentSnippetName = l.ContentSnippetName
                }).ToList();

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

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

            if (!chkMapAuthor.Checked)
            {
                exSite.TheUsers = new List <SiteExportUser>();
            }

            //itterate author collection and find if in the system
            foreach (SiteExportUser seu in exSite.TheUsers)
            {
                seu.ImportUserID = Guid.Empty;

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

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

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

            if (chkPages.Checked)
            {
                sMsg        += "<p>Imported Pages</p>";
                sitePageList = site.GetFullSiteFileList();

                int iOrder = 0;

                SiteNav navHome = GetHomePage(site);

                if (navHome != null)
                {
                    iOrder = 2;
                }

                foreach (var impCP in (from c in exSite.ThePages
                                       where c.ThePage.ContentType == ContentPageType.PageType.ContentEntry
                                       orderby c.ThePage.NavOrder, c.ThePage.NavMenuText
                                       select c).ToList())
                {
                    ContentPage cp = impCP.ThePage;
                    cp.Root_ContentID = impCP.NewRootContentID;
                    cp.ContentID      = Guid.NewGuid();
                    cp.SiteID         = site.SiteID;
                    cp.ContentType    = ContentPageType.PageType.ContentEntry;
                    cp.EditDate       = SiteData.CurrentSite.Now;
                    cp.EditUserId     = exSite.FindImportUser(impCP.TheUser);
                    cp.CreateUserId   = exSite.FindImportUser(impCP.TheUser);
                    if (impCP.CreditUser != null)
                    {
                        cp.CreditUserId = exSite.FindImportUser(impCP.CreditUser);
                    }
                    cp.NavOrder     = iOrder;
                    cp.TemplateFile = ddlTemplatePage.SelectedValue;

                    ContentPageExport parent = (from c in exSite.ThePages
                                                where c.ThePage.ContentType == ContentPageType.PageType.ContentEntry &&
                                                c.ThePage.FileName.ToLower() == impCP.ParentFileName.ToLower()
                                                select c).FirstOrDefault();

                    BasicContentData navParent = null;
                    BasicContentData navData   = GetFileInfoFromList(site, cp.FileName);

                    if (parent != null)
                    {
                        cp.Parent_ContentID = parent.NewRootContentID;
                        navParent           = GetFileInfoFromList(site, parent.ThePage.FileName);
                    }

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

                        impCP.ThePage.RetireDate = navData.RetireDate;
                        impCP.ThePage.GoLiveDate = navData.GoLiveDate;

                        if (navData.NavOrder == 0)
                        {
                            cp.NavOrder = 0;
                        }
                    }
                    //preserve homepage
                    if (navHome != null && navHome.FileName.ToLower() == cp.FileName.ToLower())
                    {
                        cp.NavOrder = 0;
                    }
                    //if the file url in the upload has an existing ID, use that, not the ID from the queue
                    if (navParent != null)
                    {
                        cp.Parent_ContentID = navParent.Root_ContentID;
                    }

                    cp.RetireDate = impCP.ThePage.RetireDate;
                    cp.GoLiveDate = impCP.ThePage.GoLiveDate;

                    cp.SavePageEdit();

                    iOrder++;
                }
            }
            SetMsg(sMsg);

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

                List <ContentTag>      lstTags       = site.GetTagList();
                List <ContentCategory> lstCategories = site.GetCategoryList();

                foreach (var impCP in (from c in exSite.ThePages
                                       where c.ThePage.ContentType == ContentPageType.PageType.BlogEntry
                                       orderby c.ThePage.CreateDate
                                       select c).ToList())
                {
                    ContentPage cp = impCP.ThePage;
                    cp.Root_ContentID   = impCP.NewRootContentID;
                    cp.ContentID        = Guid.NewGuid();
                    cp.SiteID           = site.SiteID;
                    cp.Parent_ContentID = null;
                    cp.ContentType      = ContentPageType.PageType.BlogEntry;
                    cp.EditDate         = SiteData.CurrentSite.Now;
                    cp.EditUserId       = exSite.FindImportUser(impCP.TheUser);
                    cp.CreateUserId     = exSite.FindImportUser(impCP.TheUser);
                    if (impCP.CreditUser != null)
                    {
                        cp.CreditUserId = exSite.FindImportUser(impCP.CreditUser);
                    }
                    cp.NavOrder     = SiteData.BlogSortOrderNumber;
                    cp.TemplateFile = ddlTemplatePost.SelectedValue;

                    cp.ContentCategories = (from l in lstCategories
                                            join o in impCP.ThePage.ContentCategories on l.CategorySlug.ToLower() equals o.CategorySlug.ToLower()
                                            select l).Distinct().ToList();

                    cp.ContentTags = (from l in lstTags
                                      join o in impCP.ThePage.ContentTags on l.TagSlug.ToLower() equals o.TagSlug.ToLower()
                                      select l).Distinct().ToList();

                    BasicContentData navData = GetFileInfoFromList(site, cp.FileName);

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

                        impCP.ThePage.RetireDate = navData.RetireDate;
                        impCP.ThePage.GoLiveDate = navData.GoLiveDate;
                    }

                    cp.RetireDate = impCP.ThePage.RetireDate;
                    cp.GoLiveDate = impCP.ThePage.GoLiveDate;

                    cp.SavePageEdit();
                }

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

            if (chkComments.Checked)
            {
                sMsg        += "<p>Imported Comments</p>";
                sitePageList = site.GetFullSiteFileList();

                foreach (var impCP in (from c in exSite.TheComments
                                       orderby c.TheComment.CreateDate
                                       select c).ToList())
                {
                    int              iCommentCount = -1;
                    PostComment      pc            = impCP.TheComment;
                    BasicContentData navData       = GetFileInfoFromList(site, pc.FileName);
                    if (navData != null)
                    {
                        pc.Root_ContentID   = navData.Root_ContentID;
                        pc.ContentCommentID = Guid.NewGuid();

                        iCommentCount = PostComment.GetCommentCountByContent(site.SiteID, pc.Root_ContentID, pc.CreateDate, pc.CommenterIP, pc.PostCommentText);
                        if (iCommentCount < 1)
                        {
                            iCommentCount = PostComment.GetCommentCountByContent(site.SiteID, pc.Root_ContentID, pc.CreateDate, pc.CommenterIP);
                        }

                        if (iCommentCount < 1)
                        {
                            pc.Save();
                        }
                    }
                }
            }
            SetMsg(sMsg);

            BindData();
        }
Esempio n. 24
0
        protected override void OnDataBinding(EventArgs e)
        {
            RepeaterItem container = (RepeaterItem)this.NamingContainer;

            string sFieldValue = string.Empty;
            string sValue      = "";
            string sField      = DataField.ToString();

            try {
                if (sField.StartsWith("Author_") || sField.StartsWith("Credit_"))
                {
                    SiteNav sn = (SiteNav)DataBinder.GetDataItem(container);
                    if (sn != null)
                    {
                        ExtendedUserData usr = null;
                        if (sField.StartsWith("Credit_"))
                        {
                            sField = DataField.ToString().Replace("Credit_", String.Empty);
                            usr    = sn.GetCreditUserInfo();
                        }

                        if (sField.StartsWith("Author_") || usr == null)
                        {
                            sField = DataField.ToString().Replace("Credit_", String.Empty).Replace("Author_", String.Empty);
                            usr    = sn.GetUserInfo();
                        }

                        if (usr == null)
                        {
                            usr = sn.BylineUser;
                        }

                        if (usr != null)
                        {
                            object obj = ReflectionUtilities.GetPropertyValue(usr, sField);
                            if (obj != null)
                            {
                                sValue = obj.ToString();
                            }
                        }
                    }

                    sFieldValue = String.Format(FieldFormat, sValue);
                }
                else
                {
                    sFieldValue = String.Format(FieldFormat, DataBinder.Eval(container, "DataItem." + sField));
                }
            } catch {
                if (!SiteData.IsWebView)
                {
                    sFieldValue = sField;
                }
            }

            this.Text = sFieldValue;

            string sFileName = DataBinder.Eval(container, "DataItem.FileName").ToString();
            Guid   pageID    = new Guid(DataBinder.Eval(container, "DataItem.Root_ContentID").ToString());

            this.NavigateUrl = sFileName;
            this.ContentID   = pageID;

            base.OnDataBinding(e);
        }
Esempio n. 25
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);
            }
        }
Esempio n. 26
0
        protected void Submit_ContentCommentForm(object sender, EventArgs e)
        {
            bool bCaptcha = false;

            Captcha captcha = (Captcha)GetEntryFormControl("ContentCommentCaptcha");

            if (captcha != null)
            {
                bCaptcha = captcha.Validate();
            }
            else
            {
                bCaptcha = true;
            }

            if (bCaptcha)
            {
                HttpRequest request = HttpContext.Current.Request;

                bool bIgnorePublishState = SecurityData.AdvancedEditMode || SecurityData.IsAdmin || SecurityData.IsSiteEditor;

                SiteNav navData = navHelper.GetLatestVersion(SiteData.CurrentSiteID, !bIgnorePublishState, SiteData.CurrentScriptName);

                Label   lblContentCommentFormMsg = (Label)GetEntryFormControl("ContentCommentFormMsg");
                TextBox txtCommenterName         = (TextBox)GetEntryFormControl("CommenterName");
                TextBox txtCommenterEmail        = (TextBox)GetEntryFormControl("CommenterEmail");
                TextBox txtVisitorComments       = (TextBox)GetEntryFormControl("VisitorComments");
                TextBox txtCommenterURL          = (TextBox)GetEntryFormControl("CommenterURL");

                string sIP = request.ServerVariables["REMOTE_ADDR"].ToString();

                PostComment pc = new PostComment();
                pc.ContentCommentID = Guid.NewGuid();
                pc.Root_ContentID   = navData.Root_ContentID;
                pc.CreateDate       = SiteData.CurrentSite.Now;
                pc.IsApproved       = false;
                pc.IsSpam           = false;
                pc.CommenterIP      = sIP;

                if (txtCommenterName != null)
                {
                    pc.CommenterName = txtCommenterName.Text;
                }
                if (txtCommenterEmail != null)
                {
                    pc.CommenterEmail = txtCommenterEmail.Text;
                }
                if (txtVisitorComments != null)
                {
                    pc.PostCommentText = txtVisitorComments.Text;
                }
                if (txtCommenterURL != null)
                {
                    pc.CommenterURL = txtCommenterURL.Text;
                }

                if (SiteData.IsWebView && SecurityData.IsAuthenticated)
                {
                    if ((this.AutoApproveAdmin))
                    {
                        pc.IsApproved = SecurityData.IsAdmin;
                    }
                    if (!String.IsNullOrEmpty(this.AutoApproveGroupName))
                    {
                        pc.IsApproved = SecurityData.IsUserInRole(this.AutoApproveGroupName);
                    }
                }

                pc.Save();

                if (!String.IsNullOrEmpty(this.DirectEmail) || this.NotifyEditors || !String.IsNullOrEmpty(this.DirectEmailKeyName))
                {
                    List <string> emails = new List <string>();

                    if (!String.IsNullOrEmpty(this.DirectEmail))
                    {
                        emails.Add(this.DirectEmail);
                    }
                    if (!String.IsNullOrEmpty(this.DirectEmailKeyName))
                    {
                        emails.Add(ConfigurationManager.AppSettings[this.DirectEmailKeyName].ToString());
                    }
                    if (this.NotifyEditors)
                    {
                        ContentPage page = navData.GetContentPage();
                        emails.Add(page.CreateUser.EmailAddress);

                        if (page.EditUser.UserId != page.CreateUser.UserId)
                        {
                            emails.Add(page.EditUser.EmailAddress);
                        }
                        if (page.CreditUserId.HasValue)
                        {
                            emails.Add(page.CreditUser.EmailAddress);
                        }
                    }

                    string sEmail = String.Join(",", emails.ToArray());

                    string strHTTPHost = String.Empty;
                    try { strHTTPHost = request.ServerVariables["HTTP_HOST"] + String.Empty; } catch { strHTTPHost = String.Empty; }

                    string hostName = strHTTPHost.ToLowerInvariant();

                    string strHTTPProto = "http://";
                    try {
                        strHTTPProto = request.ServerVariables["SERVER_PORT_SECURE"] + String.Empty;
                        if (strHTTPProto == "1")
                        {
                            strHTTPProto = "https://";
                        }
                        else
                        {
                            strHTTPProto = "http://";
                        }
                    } catch { }

                    string mailSubject = String.Format("Comment Form From {0}", hostName);

                    strHTTPHost = String.Format("{0}{1}", strHTTPProto, strHTTPHost).ToLowerInvariant();

                    string sBody = "Name:   " + pc.CommenterName
                                   + "\r\nEmail:   " + pc.CommenterEmail
                                   + "\r\nURL:   " + pc.CommenterURL
                                   + "\r\n-----------------\r\nComment:\r\n" + HttpUtility.HtmlEncode(pc.PostCommentText)
                                   + "\r\n=================\r\n\r\nIP:   " + pc.CommenterIP
                                   //+ "\r\nSite Page:   " + request.ServerVariables["script_name"].ToString()
                                   + "\r\nSite URL:   " + String.Format("{0}{1}", strHTTPHost, request.ServerVariables["script_name"])
                                   + "\r\nSite Time:   " + SiteData.CurrentSite.Now.ToString()
                                   + "\r\nUTC Time:   " + DateTime.UtcNow.ToString();

                    EmailHelper.SendMail(null, sEmail, mailSubject, sBody, false);
                }

                //if (lbl != null && txt1 != null && txt2 != null) {
                //    lbl.Text = "Clicked the button: " + txt1.Text + " - " + txt2.Text;
                //}

                phEntry.Visible  = false;
                phThanks.Visible = true;
            }
        }