示例#1
0
 private SearchItemModel ConvertPageToSearchItem(SitePageData page)
 {
     return(new SearchItemModel
     {
         Title = page.DisplayName,
         LinkUrl = urlResolver.GetUrl(page.ContentLink)
     });
 }
        public ActionResult Manager(SitePageData currentPage)
        {
            var model = new FavoriteViewModel();

            model.Favorites = FavoriteRepository
                              .GetFavorites(PrincipalInfo.Current.Name);
            model.CurrentPageContentReference = currentPage.ContentLink;

            return(PartialView("~/Features/Favorites/FavoritesMenu.cshtml", model));
        }
示例#3
0
 internal IMenuPage GetMenuPage(SitePageData sitePageData)
 {
     return(new MenuPage
     {
         Name = sitePageData.Name,
         Page = sitePageData,
         Children = FilterForVisitor.Filter(loader.GetChildren <SitePageData>(sitePageData.ContentLink))
                    .Cast <SitePageData>()
                    .Where(page => page.VisibleInMenu)
     });
 }
示例#4
0
        // GET: Favorite
        public ActionResult Manager(SitePageData currentPage)
        {
            var model = new FavoriteViewModel
            {
                Favorites = FavoriteRepository
                            .GetFavorites(PrincipalInfo.Current.Name),
                CurrentPageContentReference = currentPage.ContentLink
            };



            return(PartialView("FavoritesManager", model));
        }
示例#5
0
        public static string ExternalURLFromSitePageData(this SitePageData page)
        {
            UrlBuilder pageURLBuilder = new UrlBuilder(page.LinkURL);

            Global.UrlRewriteProvider.ConvertToExternal(pageURLBuilder, page.PageLink, UTF8Encoding.UTF8);

            string pageURL = pageURLBuilder.ToString();

            UriBuilder uriBuilder = new UriBuilder(EPiServer.Web.SiteDefinition.Current.SiteUrl);

            uriBuilder.Path = pageURL;

            return(uriBuilder.Uri.AbsoluteUri);
        }
        private static void RenderFooterText(StringBuilder stringBuilder, SitePageData page, IContentLoader loader)
        {
            stringBuilder.Append($"{CreateLink(page)}");
            var childPages = FilterForVisitor
                             .Filter(loader.GetChildren <SitePageData>(page.ContentLink))
                             .Cast <SitePageData>().Where(p => p.VisibleInMenu);

            if (childPages != null && childPages.Count() > 0)
            {
                stringBuilder.Append("<ul>");
                foreach (var childPage in childPages)
                {
                    stringBuilder.Append("<li>");
                    RenderFooterText(stringBuilder, childPage, loader);
                    stringBuilder.Append("</li>");
                }
                stringBuilder.Append("</ul>");
            }
        }
示例#7
0
 private string GetUrl(SitePageData sitePageData)
 {
     if (sitePageData is CaseStudyPage)
     {
         OurWorkPage ourWorkPage;
         if (contentRepository.TryGet(sitePageData.ParentLink, out ourWorkPage))
         {
             return(UrlResolver.Current.GetUrl(ourWorkPage));
         }
     }
     else if (sitePageData is ServicePage)
     {
         var serviceListLink = UrlResolver.Current.GetUrl(settingPage.ServiceListRoot); //get setting;
         return(serviceListLink);
     }
     else
     {
         return(UrlResolver.Current.GetUrl(sitePageData.ContentLink));
     }
     return(string.Empty);
 }
示例#8
0
        private List <BlockData> GetFormContentByPage(SitePageData page)
        {
            var inlineBlocks    = page.GetInlineBlockForPage();
            var listFormContent = new List <BlockData>();

            if (inlineBlocks != null && inlineBlocks.Length > 0)
            {
                foreach (var inlineBlock in inlineBlocks)
                {
                    GetBlockItems(inlineBlock, listFormContent, page);
                }
            }

            var contentAreaItems = page.GetContentAreaItemsForPage();

            if (contentAreaItems.Length > 0)
            {
                foreach (var contentAreaItem in contentAreaItems)
                {
                    if (contentAreaItem.ContentLink.IsNullOrEmpty())
                    {
                        continue;
                    }

                    IContent content;
                    _contentRepository.TryGet(contentAreaItem.ContentLink, page.Language, out content);

                    if (content is BlockData)
                    {
                        if (CheckBlockIsFormType(content as BlockData))
                        {
                            listFormContent.Add(content as BlockData);
                        }
                        GetBlockItems((BlockData)content, listFormContent, page);
                    }
                }
            }
            return(listFormContent);
        }
示例#9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ApplicationUser currentUser = HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>().FindById(HttpContext.Current.User.Identity.GetUserId());

            // Check if currentUser is suspended, if so redirect out
            if (currentUser.AccountState == "Suspended")
            {
                Session["Suspended_message"]       = "Your account is suspended. For more details contact the site admin. Thank you.";
                Session["Suspended_message_count"] = 0;

                Response.Redirect("/Default");
            }

            // Generate Sidebar Links
            List <SitePage> sitePages = new SitePageData().GetSitePages();

            // Determine if Admin page should be displayed
            if (HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>().IsInRole(HttpContext.Current.User.Identity.GetUserId(), "Admin"))
            {
                sitePages.Add(new SitePage
                {
                    LinkLocation = "/Account/Admin/Default",
                    LinkTitle    = "Manage Users",
                    LinkActive   = false,
                    LinkText     = "Manage Users"
                });
            }

            foreach (var page in sitePages.ToList())
            {
                if (page.LinkLocation == Request.Url.PathAndQuery)
                {
                    page.LinkActive = true;
                }
            }

            SidebarNav.DataSource = sitePages;
            SidebarNav.DataBind();
        }
示例#10
0
 private void OnPublishedContent(object sender, ContentEventArgs e)
 {
     if (e.Content is BlogListingPage || e.Content is NewsListingPage)
     {
         var currentNode       = e.Content as SitePageData;
         var repository        = ServiceLocator.Current.GetInstance <IContentRepository>();
         var referenceLinkList = repository.GetDescendents(e.Content.ContentLink);
         foreach (var item in referenceLinkList)
         {
             SitePageData page = null;
             repository.TryGet(item, out page);
             if (page != null)
             {
                 var pageTemp = (SitePageData)page.CreateWritableClone();
                 pageTemp.Heading             = currentNode.Heading;
                 pageTemp.BackgroundImage     = currentNode.BackgroundImage;
                 pageTemp.MediumBackgroundUrl = currentNode.MediumBackgroundUrl;
                 pageTemp.SmallBackgroundUrl  = currentNode.SmallBackgroundUrl;
                 repository.Save(pageTemp, EPiServer.DataAccess.SaveAction.Publish);
             }
         }
     }
 }
示例#11
0
        public void ReplaceButton_Click(object sender, EventArgs e)
        {
            string searchQuery = SearchQuery.Text;
            string replaceText = ReplaceTextBox.Text;

            if (!string.IsNullOrEmpty(searchQuery) && !string.IsNullOrEmpty(replaceText))
            {
                List <PageData> results = FindPagesContainSearchQuery(searchQuery);

                foreach (PageData result in results)
                {
                    SitePageData         writablePage = (SitePageData)result.CreateWritableClone();
                    XhtmlStringConverter converter    = new XhtmlStringConverter();

                    if (writablePage["MainBody"] != null)
                    {
                        string mainBody = writablePage["MainBody"].ToString();
                        mainBody = mainBody.Replace(searchQuery, replaceText);
                        writablePage["MainBody"] = (XhtmlString)converter.ConvertFromString(mainBody);
                    }
                    string name = writablePage.Name;
                    name = name.Replace(searchQuery, replaceText);
                    writablePage.Name = name;

                    string descr = writablePage.MetaDescription;

                    if (descr != null)
                    {
                        descr = descr.Replace(searchQuery, replaceText);
                        writablePage.MetaDescription = descr;
                    }

                    DataFactory.Instance.Save(writablePage, DataAccess.SaveAction.Publish, Security.AccessLevel.Create);
                }
            }
            ResultsLiteral.Text = string.Format("Replaced {0} with {1}", searchQuery, replaceText);
        }
示例#12
0
 public FooterModel(SitePageData currentPage)
 {
     loginUrl = GetLoginUrl(currentPage.ContentLink);
     loggedIn = HttpContext.Current.User.Identity.IsAuthenticated;
     RetrieveSiteProductPages();
 }
 public virtual string Json(SitePageData currentPage)
 {
     Response.ContentType = "application/json; charset=utf8;";
     return(currentPage.ToJson());
 }
        private static IPageViewModel <SitePageData> CreateModel(SitePageData page)
        {
            var type = typeof(PageViewModel <>).MakeGenericType(page.GetOriginalType());

            return(Activator.CreateInstance(type, page) as IPageViewModel <SitePageData>);
        }
        /* public ActionResult Index(DemoPage currentPage)
         * {
         *//* Implementation of action. You can create your own view model class that you pass to the view or
         * you can pass the page type for simpler templates *//*
         *
         *   return View(currentPage);
         * } */
        public ViewResult Index(SitePageData currentPage)
        {
            var model = CreateModel(currentPage);

            return(View(string.Format("~/Views/DemoPage/Index.cshtml", currentPage.GetOriginalType().Name), model));
        }
        public override string Execute()
        {
            OnStatusChanged($"Starting execution of {jobName} job...");

            var finder = ServiceLocator.Current.GetInstance <IPageCriteriaQueryService>();

            var criteria = new PropertyCriteriaCollection();

            criteria.Add(new PropertyCriteria
            {
                Type      = PropertyDataType.LongString,
                Name      = "PageName", // you cannot use Name
                Condition = CompareCondition.Contained,
                Value     = "iWatch"
            });
            criteria.Add(new PropertyCriteria
            {
                Type      = PropertyDataType.LongString,
                Name      = "MetaTitle",
                Condition = CompareCondition.Contained,
                Value     = "iWatch"
            });
            criteria.Add(new PropertyCriteria
            {
                Type      = PropertyDataType.LongString,
                Name      = "MetaDescription",
                Condition = CompareCondition.Contained,
                Value     = "iWatch"
            });

            PageDataCollection matches = finder.FindPagesWithCriteria(
                ContentReference.RootPage, criteria);

            int total = matches.Count;
            int count = 0;

            var repo = ServiceLocator.Current.GetInstance <IContentRepository>();

            foreach (PageData page in matches)
            {
                if (_stopSignaled)
                {
                    return($"{jobName} job was stopped. {count} of {total} pieces of content were corrected.");
                }

                SitePageData sitepage = page.CreateWritableClone() as SitePageData;
                if (sitepage != null)
                {
                    sitepage.Name            = sitepage.Name.Replace("iWatch", "Apple Watch");
                    sitepage.MetaDescription = sitepage.MetaDescription.Replace("iWatch", "Apple Watch");
                    sitepage.MetaTitle       = sitepage.MetaTitle.Replace("iWatch", "Apple Watch");

                    repo.Save(content: sitepage,
                              action: EPiServer.DataAccess.SaveAction.Publish,
                              access: EPiServer.Security.AccessLevel.NoAccess);

                    count++;
                }

                OnStatusChanged($"{jobName} is {count/(double)total*100:0.0}% complete. Please wait...");

                // pause for five seconds to simulate work, and
                // to allow us to test the Stop functionality ;)
                System.Threading.Thread.Sleep(5000);
            }

            return($"{jobName} job completed successfully. {count} of {total} pieces of content were corrected.");
        }
        private static string CreateLink(SitePageData page)
        {
            var urlResolver = ServiceLocator.Current.GetInstance <UrlResolver>();

            return($"<a href='{urlResolver.GetUrl(page.ContentLink)}'>{page.Name}</a>");
        }