/// <summary> /// Creates the bread crumb link string from the start page of the site to the supplied page /// </summary> /// <param name="page">The last page in the bread crumb string.</param> /// <returns>A bread crumb string with anchors to parent pages.</returns> private string GenerateBreabCrumbs(PageData page) { // Initiate a string builder based on max length. The generated html is considerably longer than the visible text. StringBuilder breadCrumbsText = new StringBuilder(8 * MaxLength); // Initiate a counter holding the visible length of the bread crumbs with the length of the start page link text. int breadCrumbsLength = Translate("/navigation/startpage").Length; while (page != null && page.PageLink != PageReference.StartPage) { breadCrumbsLength += page.PageName.Length + Separator.Length; if (breadCrumbsLength > MaxLength) { breadCrumbsText.Insert(0, Separator + "..."); break; } // Insert the link at beginning of the bread crumbs string breadCrumbsText.Insert(0, Separator + GetLink(page)); // Get next visible parent page = GetParentPageData(page); } // Generate the start page link string startPageLinkUrl = Server.UrlPathEncode(GetPage(PageReference.StartPage).LinkURL); string startPageLink = String.Format(_link, startPageLinkUrl, Translate("/navigation/startpagelinktitle"), Translate("/navigation/startpage")); // Insert the startpage link and return return breadCrumbsText.Insert(0, startPageLink).ToString(); }
protected virtual void BuildPageTemplate(PageData pageData, string theme, RequestContext context, StringBuilder output, CursorCollection placeHolders, DirectiveCollection directives, List<IControlsContainer> controlConatiners) { controlConatiners.Add(pageData); if (!String.IsNullOrEmpty(pageData.MasterPage)) { this.BuildWithMasterPage(pageData.MasterPage, context, output, placeHolders, directives); return; } if (!String.IsNullOrEmpty(pageData.ExternalPage)) { this.BuildWithExternalPage(pageData.ExternalPage, context, output, placeHolders, directives); return; } if (this.BuildTemplateFromPresentationData(pageData.Presentation, theme, output, placeHolders, directives, context)) return; if (pageData.Template != null) { BuildPageTemplateRecursive(pageData.Template, theme, context, output, placeHolders, directives, controlConatiners); return; } var defaultRootTemplate = new RootTemplate(); defaultRootTemplate.FromString(ControlUtilities.GetSitefinityTextResource(Constants.DefaultFrontendPageTemplate)); RootTemplate result = this.GetRootTemplate(defaultRootTemplate, context, theme); this.ProcessStringTemplate(result.Template, output, placeHolders, directives); }
private static IEnumerable<string> GetPropertyTags(PageData page, PropertyDefinition propertyDefinition) { var tagNames = page[propertyDefinition.Name] as string; return tagNames == null ? Enumerable.Empty<string>() : tagNames.Split(new[] {',', ' '}, StringSplitOptions.RemoveEmptyEntries); }
private bool ShowInSiteMap(PageData page) { //// Might want to only expose project page types. //if(!(page is MyProjectPageBase)) //{ // return false; //} if (!page.IsIndexablePageType()) { return false; } if (!page.CheckPublishedStatus(PagePublishedStatus.Published)) { return false; } if (!_filterAccessWrapper.QueryDistinctAccessEdit(page, AccessLevel.NoAccess)) { return false; } //// Dynamic property: Checkbox for including/excluding page instance in sitemap.xml. For an overridable dynamic property checkbox //// wrapper, see https://blog.mathiaskunto.com/2015/02/09/custom-property-checkbox-wrapper-as-dynamic-property-in-episerver-7-5/ //if (!(page as MyProjectPageBase).IncludeInSitemap) //{ // return false; //} return true; }
public override object RoutePartial(PageData content, SegmentContext segmentContext) { var routedContet = base.RoutePartial(content, segmentContext); var segmentPair = segmentContext.GetNextValue(segmentContext.RemainingPath); if (String.IsNullOrEmpty(segmentPair.Next)) { return routedContet; } var facetNames = _facetUrlCreator.GetFacetModels().ToArray(); var nextSegment = _facetUrlCreator.GetFacetValue(facetNames, segmentPair.Next); if (String.IsNullOrEmpty(nextSegment)) { return routedContet; } var routeFacets = segmentContext.RouteData.Values[FacetUrlService.RouteFacets] as ConcurrentDictionary<RouteFacetModel, HashSet<object>>; if (routeFacets == null) { segmentContext.RouteData.Values[FacetUrlService.RouteFacets] = new ConcurrentDictionary<RouteFacetModel, HashSet<object>>(); routeFacets = (ConcurrentDictionary<RouteFacetModel, HashSet<object>>)segmentContext.RouteData.Values[FacetUrlService.RouteFacets]; } AddFacetsToSegmentContext(routeFacets, segmentContext, facetNames, nextSegment, segmentPair.Remaining, null); return routedContet; }
public string ConvertUrlToExternal(PageData pageData = null, PageReference p = null) { if (pageData == null && p == null) { return string.Empty; } var page = pageData ?? _repository.Get<PageData>(p); var pageUrlBuilder = new UrlBuilder(page.LinkURL); Global.UrlRewriteProvider.ConvertToExternal(pageUrlBuilder, page.PageLink, Encoding.UTF8); string pageURL = pageUrlBuilder.ToString(); UriBuilder uriBuilder = new UriBuilder(SiteDefinition.Current.SiteUrl); uriBuilder.Path = pageURL; var jj = ServiceLocator.Current.GetInstance<UrlResolver>().GetUrl(p); if (uriBuilder.Path == "/") return uriBuilder.Uri.AbsoluteUri; string[] words = uriBuilder.Uri.AbsoluteUri.Split(new char[] {':', '/', '.'}, StringSplitOptions.RemoveEmptyEntries); bool reoccurs = words.Count(q => q == "http") > 1; if (reoccurs) return uriBuilder.Uri.LocalPath.StartsWith("/") ? uriBuilder.Uri.LocalPath.Remove(0,1) : uriBuilder.Uri.LocalPath; return uriBuilder.Uri.AbsoluteUri; }
/// <summary> /// Appends the page. /// </summary> /// <param name="pageData">The page data.</param> /// <param name="json">The json.</param> private void AppendPage(PageData pageData, StringBuilder json) { json.Append(string.Format("{{\"w\":{0},\"h\":{1},\"number\":{2}", pageData.Width.ToString(_defaultCulture), pageData.Height.ToString(_defaultCulture), pageData.Number.ToString(_defaultCulture))); }
public ActionResult EditAlbums(int page = 1) { string login = User.Identity.Name; var album = new PageData<string>(albumService.GetAllUserAlbumsNams(login), page); return View(album); }
public static string GetFriendlyURL(PageData pageData) { UrlBuilder pageURLBuilder = new UrlBuilder(pageData.LinkURL); EPiServer.Global.UrlRewriteProvider.ConvertToExternal(pageURLBuilder, pageData.PageLink, UTF8Encoding.UTF8); return GetSiteRoot() + pageURLBuilder.Path; }
public IEnumerable<ChromeLanguageInfo> GetLanguageInfo(PageData page) { List<ChromeLanguageInfo> languages = new List<ChromeLanguageInfo>(); ReadOnlyStringList pageLanguages = page.PageLanguages; string currentLanguage = page.LanguageBranch; foreach (string language in pageLanguages) { LanguageBranch languageBranch = _languageBranchRepository.ListEnabled().FirstOrDefault(l => l.LanguageID.Equals(language, StringComparison.InvariantCultureIgnoreCase)); if (languageBranch != null) { languages.Add(new ChromeLanguageInfo() { DisplayName = languageBranch.Name, IconUrl = languageBranch.ResolvedIconPath, //"/Content/Images/flags/" + language + ".png", // We use this to enable language switching inside edit mode too Url = languageBranch.CurrentUrlSegment, EditUrl = PageEditing.GetEditUrlForLanguage(page.ContentLink, languageBranch.LanguageID), Selected = string.Compare(language, currentLanguage, StringComparison.InvariantCultureIgnoreCase) == 0 }); } } return languages; }
/// <summary> /// Gets the currnt page's preview version /// </summary> /// <param name="pageManager">The page manager</param> /// <param name="pageName">The current page name</param> /// <returns>The current page preview</returns> public PageDraft GetCurrentPagePreview(PageManager pageManager, string pageName) { var homePage = new PageData(); foreach (var f in pageManager.GetPageDataList()) { if (f.NavigationNode.Title.GetString(f.NavigationNode.AvailableCultures[0], false).ToLower() == pageName.ToLower() && !f.NavigationNode.IsDeleted && f.NavigationNode.ParentId == new Guid(System.Web.SiteMap.RootNode.Key)) { homePage = f; break; } } if (homePage == null) return null; var homePagePreview = pageManager.GetPreview(homePage.NavigationNode.PageId); if (homePagePreview == null) return null; if (homePagePreview.Controls[0].Properties.FirstOrDefault(r => r.Name == "Settings") == null) return null; return homePagePreview; }
/// <summary> /// Populates needed mail information before sending. Will also check /// for Mailgun specific properties /// </summary> /// <remarks> /// Note! Mailgun validate campaign codes, and if the campaign does /// not exist, it will be ignored (the email will still be sent) /// Note! Tags are limited to a count of 200 /// </remarks> /// <param name="mailPage"></param> /// <returns></returns> public override MailInformation GetMailInformation(PageData mailPage) { MailInformation mailInformation = base.GetMailInformation(mailPage); IPopulateCustomProperties customPropertiesProvider = mailPage as IPopulateCustomProperties; if (customPropertiesProvider == null) { // The base class will add custom properties if the page type // implements that - if NOT, we'll try to add them ourselves // by looking for special property names relevant to Mailgun var campaign = mailPage[MAILGUN_CAMPAIGN_PROPERTYNAME]; if (campaign != null) { mailInformation.Utm.Campaign = campaign.ToString(); } // Since the Utm Campaign can be set independently, we check if it // is set, and use it as a Mailgun campaign too if(string.IsNullOrEmpty(mailInformation.Utm.Campaign) == false) { mailInformation.CustomProperties.Add("o:campaign", mailInformation.Utm.Campaign); } if (mailPage[MAILGUN_TAG_PROPERTYNAME] != null) { mailInformation.CustomProperties.Add("o:tag", mailPage[MAILGUN_TAG_PROPERTYNAME]); } } return mailInformation; }
private IEnumerable<string> GetPageTags(PageData page) { var pageType = _pageTypeRepository.Load(page.PageTypeID); return pageType.PropertyDefinitions .Where(TagsHelper.IsTagProperty) .SelectMany(x => GetPropertyTags(page, x)); }
public ActionResult EditAlbum(string albumName, int page = 1) { ViewBag.AlbumName = albumName; string login = User.Identity.Name; var photos = new PageData<PhotoOfAlbumDTO>(photoService.GetPhotosOfAlbum(login, albumName), page); return View(photos); }
/// <summary> /// Initializes a new instance of the <see cref="Page"/> class. /// </summary> /// <param name="client"><see cref="T:TcmCoreService.Client" /></param> /// <param name="pageData"><see cref="T:Tridion.ContentManager.CoreService.Client.PageData" /></param> protected Page(Client client, PageData pageData) : base(client, pageData) { if (pageData == null) throw new ArgumentNullException("pageData"); mPageData = pageData; }
public virtual TypedPageData CreateAndPopulateTypedInstance(PageData originalPage, Type typedType) { TypedPageData typedPage = CreateInstance(typedType); TypedPageData.PopuplateInstance(originalPage, typedPage); PropertyInfo[] properties = typedPage.GetType().GetPublicOrPrivateProperties(); CreateAndPopulateNestedPropertyGroupInstances(typedPage, typedPage, properties, string.Empty); return typedPage; }
/// <summary> /// Adds a page access token to the store. /// </summary> /// <param name="pageToken">The page token.</param> /// <param name="pageData">The page data.</param> /// <returns></returns> public PageAccessToken Add(PageAccessToken pageToken, PageData pageData) { EnsurePageAccessRights(pageData); Identity identity = Store.Save(pageToken); pageToken.Id = identity.ExternalId; return pageToken; }
protected PageData FindParentByPageType(PageData pd, Type pagetype, IContentRepository contentLocator) { if (pd is BlogStartPage) { return pd; } return FindParentByPageType(contentLocator.Get<PageData>(pd.ParentLink), pagetype, contentLocator); }
public ActionResult ShowAlbums(string userName, int page = 1) { if(userName == null) userName = User.Identity.Name; ViewBag.UserName = userName; var albums = new PageData<string>(albumService.GetAllUserAlbumsNams(userName), page); return View(albums); }
public virtual PageData ConvertToTyped(PageData page) { Type type = GetPageTypeType(page.PageTypeID); if (type == null) return page; return Activator.CreateAndPopulateTypedInstance(page, type); }
/// <summary> /// Is the page used to generate a connector feed? /// </summary> /// <param name="pageData">the page data</param> /// <returns>true if the page is used to generate a connector feed</returns> public static bool IsEditionPage(PageData page) { if (_connectorPageTypeNames.Contains<string>(page.PageTypeName)) { return true; } return false; }
public AuthorizedPropertyDefinitionLocator(PageData pageData, Type pageTypeType, ITabDefinitionRepository tabDefinitionRepository) { PageData = pageData; PageTypeType = pageTypeType; ClassAttribute = AttributedTypesUtility.GetAttributeFromType<AuthorizeAttribute>(PageTypeType); Properties = AttributedTypesUtility.GetPublicOrPrivateProperties(PageTypeType); _tabDefinitionRepository = tabDefinitionRepository; }
public ActionResult GetPhotosByTag(string tagName, int page = 1) { TempData["TagName"] = tagName; string login = User.Identity.Name; var photos = tagService.GetPhotosByTag(tagName, login); var photoPage = new PageData<PhotoPropertiesDTO>(photos, page); return PartialView(photoPage); }
public void Test() { PageData<int> grid = new PageData<int>() { Total = 5, Rows = new int[] { 1, 2, 3, 4, 5 } }; Assert.Equal(5, grid.Total); Assert.Equal(new int[] { 1, 2, 3, 4, 5 }, grid.Rows); }
public PreviewBlock(PageData currentPage, IContent previewContent) : base(currentPage) { this.PreviewContent = previewContent; this.ContentArea=new ContentArea(); this.ContentArea.Items.Add(new ContentAreaItem { ContentLink = this.PreviewContent.ContentLink }); }
public override void DataBind() { if (_ContextSensitive) { // Override content with current context-PageData from repeater Control controlItem = Globals.GetFirstParentControlOfType(this, "System.Web.UI.WebControls.RepeaterItem"); if (controlItem != null) { RepeaterItem repeaterItem = (RepeaterItem)controlItem; string type = repeaterItem.DataItem.GetType().ToString(); if (type == "Camelonta.CMS.FrameWork.PageData") _pageData = (PageData)repeaterItem.DataItem; else if (type == "System.Data.DataRowView") { Foreach forEachControl = (Foreach)controlItem.Parent; Int32 currentRowIndex = repeaterItem.ItemIndex + 1; string elementName = forEachControl.Property; // Simple elements if (_PropertyName == "this") { _PropertyName = elementName; // Set new PropertyName if (elementName.Contains("|")) { // PropertyName contains serveral properties, split them up and fix the xpath _PropertyName = "("; foreach (string split in elementName.Split("|".ToCharArray())) _PropertyName += split + "|"; _PropertyName = _PropertyName.Substring(0, _PropertyName.Length - 1); _PropertyName += ")[" + currentRowIndex + "]"; } else { // PropertyName contains one property _PropertyName = elementName + "[" + currentRowIndex + "]"; } } // Advanced (Panel) elements else { // Set new PropertyName _PropertyName = "(" + elementName + ")[" + currentRowIndex + "]/" + _PropertyName; } } } } if (_pageData == null) _pageData = CMS.Context.PageData; base.DataBind(); }
public Publisher() { currentPage = ((PageBase)HttpContext.Current.Handler).CurrentPage; editionListPage = DataFactory.Instance.GetPage(currentPage.ParentLink); request = HttpContext.Current.Request; fileTypesToCache = Common.GetConfigSettingValue("FileTypesToCache"); languageId = LanguageBranch.Load(ContentLanguage.PreferredCulture).LanguageID; siteRoot = Common.GetSiteRoot(); manifestEntries = new List<string>(); }
private static MenuItem CreateMenuItem(PageData page, ContentReference currentContentLink, List<ContentReference> pagePath, IContentLoader contentLoader, Func<IEnumerable<PageData>, IEnumerable<PageData>> filter) { var menuItem = new MenuItem(page) { Selected = page.ContentLink.CompareToIgnoreWorkID(currentContentLink) || pagePath.Contains(page.ContentLink), HasChildren = new Lazy<bool>(() => filter(contentLoader.GetChildren<PageData>(page.ContentLink)).Any()) }; return menuItem; }
public ActionResult GetPhotosOfAlbum(string userName, string albumName, int page = 1) { TempData["AlbumName"] = albumName; if(userName == null) userName = User.Identity.Name; string login = User.Identity.Name; var photos = new PageData<PhotoPropertiesDTO>(photoService.GetPhotosPropertiesOfAlbum(userName, albumName, login), page); return PartialView(photos); }
/// <summary> /// Ensures the page access rights. /// </summary> /// <param name="pageData">The page data.</param> public void EnsurePageAccessRights(PageData pageData) { var accessClone = pageData.ACL.CreateWritableClone(); if (accessClone.Exists(AccessTokenRole.RoleName)) accessClone.Remove(AccessTokenRole.RoleName); accessClone.Add(new AccessControlEntry(AccessTokenRole.RoleName, AccessLevel.Edit | AccessLevel.Read)); accessClone.Save(); }