protected string GetPageEditUrl(Job job) { if (job.PageId != 0) { return(PageEditing.GetEditUrl(new ContentReference(job.PageId))); } return(string.Empty); }
private static string GetEditUrl(IContent content) { var relativeUrl = PageEditing.GetEditUrl(content.ContentLink); var absoluteUrl = new UrlBuilder(HttpContext.Current.Request.Url) { Path = relativeUrl, Query = null // Had to do this because if the auth token is passed in the querystring, it was getting copied to the edit URL... }; return(absoluteUrl.Uri.AbsoluteUri); }
public virtual async System.Threading.Tasks.Task ImageViewed(ImageData image, IContent page, HttpContextBase httpContext) { try { var trackingData = new TrackingData <ImageView> { EventType = "Imagery", Value = "Image viewed: '" + (image as IContent).Name + "' on page - '" + page.Name + "'", PageUri = PageEditing.GetEditUrl(page.ContentLink), Payload = new ImageView { PageName = page.Name, PageId = page.ContentLink.ID, ImageId = (image as IContent).ContentLink.ID, ImageName = (image as IContent).Name } }; await _trackingService.Track(trackingData, httpContext); } catch { } }
public virtual async System.Threading.Tasks.Task BlockViewed(BlockData block, IContent page, HttpContextBase httpContext) { try { var trackingData = new TrackingData <BlockView> { EventType = typeof(BlockView).Name, Value = "Block viewed: '" + (block as IContent).Name + "' on page - '" + page.Name + "'", PageUri = PageEditing.GetEditUrl(page.ContentLink), Payload = new BlockView { PageName = page.Name, PageId = page.ContentLink.ID, BlockId = (block as IContent).ContentLink.ID, BlockName = (block as IContent).Name } }; await _trackingService.Track(trackingData, httpContext); } catch { } }
public ContentInspectorViewModel CreateModel(ContentReference contentReference, List<string> visitorGroupNames, string contentGroup, int level, List<ContentReference> parentIds) { level++; IContent content; if (!_contentLoader.TryGet(contentReference, out content)) { return null; } if (!content.QueryDistinctAccess(AccessLevel.Read)) { return null; } var currentItem = CreateInspectorContentViewModel(content); if (parentIds.Contains(contentReference)) { currentItem.HasDuplicateParent = true; } else { parentIds.Add(contentReference); } currentItem.EditUrl = PageEditing.GetEditUrl(content.ContentLink); if (content is ImageData) { currentItem.MainType = MainContentType.Image; currentItem.ThumbnailUrl = content.ThumbnailUrl(); } else if (content is BlockData) currentItem.MainType = MainContentType.Block; else currentItem.MainType = MainContentType.Page; var model = new ContentInspectorViewModel() { Content = currentItem, VisitorGroupsNames = visitorGroupNames, ContentAreaItems = new List<ContentInspectorViewModel.ContentAreaItemViewModel>(), ContentGroup = contentGroup, ContentReferenceItems = new List<ContentInspectorViewModel.ContentReferenceViewModel>(), XhtmlStringItems = new List<ContentInspectorViewModel.XhtmlStringViewModel>() }; var contentType = ServiceLocator.Current.GetInstance<IContentTypeRepository>().Load(content.ContentTypeID); if (level >= _maxLevel) { model.Content.IsMaxLevel = true; } else if (!currentItem.HasDuplicateParent) { model.ContentAreaItems = GetContentAreaItems(level, parentIds, contentType, content); ; } var inspectablePropertes = GetInspectableProperties(contentType); foreach (var propertyInfo in inspectablePropertes) { if (propertyInfo.PropertyType == typeof(ContentReference) || propertyInfo.PropertyType == typeof(PageReference)) { GetContentReferenceProperty(level, parentIds, content, propertyInfo, model); } else if (propertyInfo.PropertyType == typeof(XhtmlString)) { var property = content.Property[propertyInfo.Name] as PropertyXhtmlString; var fragments = property?.XhtmlString?.Fragments; var xhtmlStringViewModel = new ContentInspectorViewModel.XhtmlStringViewModel(); xhtmlStringViewModel.Name = property.TranslateDisplayName(); if (fragments != null) { foreach (var fragment in fragments) { CreateFragment(level, parentIds, fragment, xhtmlStringViewModel, null); } } model.XhtmlStringItems.Add(xhtmlStringViewModel); } else { var property = content.Property[propertyInfo.Name]; if (property != null) { model.Content.AdditionalProperties.Add(property.TranslateDisplayName(), property.Value); } else { model.Content.AdditionalProperties.Add(propertyInfo.Name, propertyInfo.GetValue(content)); } } } return model; }
public RatingListDto GetRatings([FromUri] RatingFilterDto filterParams) { var ratingDataList = new RatingListDto(); var filter = new FilterContentForVisitor(); var pages = GetChildPages(ContentReference.StartPage).ToList(); filter.Filter(pages); var ratingTableDataList = new List <RatingTableDataDto>(); var ratingInterfacePages = filterParams != null && filterParams.RatingEnabled ? pages.OfType <IRatingPage>().Where(p => p.RatingEnabled == filterParams.RatingEnabled).ToList() : pages.OfType <IRatingPage>().ToList(); //var reviews = GetReviews(ratingInterfacePages); foreach (var ratingPage in ratingInterfacePages) { var ratingContent = (IContent)ratingPage; var ratings = _reviewService.GetReviews(ratingContent.ContentLink); if (ratings == null) { continue; } var ratingsList = ratings.ToList(); var ratingTableData = new RatingTableDataDto { PageName = ratingContent.Name, RatingEnabled = ratingPage.RatingEnabled, ContentId = ratingContent.ContentLink.ID.ToString(), ContentUrl = PageEditing.GetEditUrl(ratingContent.ContentLink), PageFriendlyUrl = _urlResolver.GetUrl(ratingContent.ContentLink) }; if (ratingsList.Any()) { if (filterParams != null) { ratingsList = ratingsList.Where(r => !filterParams.DateFrom.HasValue || r.Created.Date >= filterParams.DateFrom.Value.Date && (!filterParams.DateTo.HasValue || r.Created.Date <= filterParams.DateTo.Value.Date)) .ToList(); } var allCommentsDto = ratingsList.Where(r => !string.IsNullOrEmpty(r.Text)) .Select(r => new RatingCommentDto { CommentText = r.Text, CommentDate = r.Created }).ToList(); ratingTableData.ShortComments = new List <RatingCommentDto>(allCommentsDto .OrderByDescending(c => c.CommentDate).Take(5) .Select(c => new RatingCommentDto { CommentText = c.CommentText.Length > 500 ? c.CommentText.Substring(0, 500) + "..." : c.CommentText, CommentDate = c.CommentDate })); ratingTableData.Comments = new List <RatingCommentDto>(allCommentsDto.Select(comment => new RatingCommentDto { CommentText = comment.CommentText + "{nl}", CommentDate = comment.CommentDate })); ratingTableData.Rating = (int)ratingsList.Select(r => r.Rating).Sum(); ratingTableData.LastCommentDate = allCommentsDto.OrderByDescending(c => c.CommentDate).First().CommentDate; ratingTableData.RatingCount = ratingsList.Count; ratingTableData.PositiveRatingCount = ratingsList.Count(r => r.Rating > 0); ratingTableData.NegativeRatingCount = ratingsList.Count(r => r.Rating < 0); } if (filterParams == null || !filterParams.OnlyRatedPages || (filterParams.OnlyRatedPages && ratingsList.Any())) { ratingTableDataList.Add(ratingTableData); } } ratingDataList.RatingData = ratingTableDataList; return(ratingDataList); }
public string GetEditUrl(ContentReference contentLink) { return(PageEditing.GetEditUrl(contentLink)); }
private async Task <List <ContentTask> > ProcessChangeData(int pageNumber, int pageSize, string sorting, AdvancedTaskIndexViewData model) { //List of All task for the user var query = new ApprovalQuery { Status = ApprovalStatus.InReview, Username = PrincipalInfo.CurrentPrincipal.Identity.Name, Reference = new Uri("changeapproval:") }; var list = await _approvalRepository.ListAsync(query, (pageNumber - 1) *pageSize, pageSize); model.TotalItemsCount = Convert.ToInt32(list.TotalCount); var taskList = new List <ContentTask>(); foreach (var task in list.PagedResult) { IContent content = null; var id = task.ID.ToString(); var customTask = new ContentTask { ApprovalId = task.ID, DateTime = task.ActiveStepStarted.ToString("dd MMMM HH:mm"), StartedBy = task.StartedBy, URL = PageEditing.GetEditUrl(new ContentReference(task.ID)).Replace(".contentdata:", ".changeapproval:") }; if (!(task is ContentApproval)) { var taskDetails = _changeTaskHelper.GetData(task.ID); if (taskDetails != null) { customTask.Type = taskDetails.Type; customTask.ContentName = taskDetails.Name; customTask.Details = taskDetails.Details; } if (task.Reference != null) { if (!string.IsNullOrEmpty(task.Reference.AbsolutePath)) { var pageId = task.Reference.AbsolutePath.Replace("/", ""); int.TryParse(pageId, out var contentId); if (contentId != 0) { _contentRepository.TryGet(new ContentReference(contentId), out content); } } } if (content != null) { customTask.ContentReference = content.ContentLink; customTask.ContentType = GetTypeContent(content); } customTask = await GetNotifications(id, customTask, false); taskList.Add(customTask); } } taskList = SortColumns(sorting, taskList); return(taskList); }
private async Task <List <ContentTask> > ProcessContentData(int pageNumber, int pageSize, string sorting, AdvancedTaskIndexViewData model, string taskValues, string approvalComment) { if (!string.IsNullOrEmpty(taskValues)) { await ApproveContent(taskValues, approvalComment); } //List of All task for the user var query = new ApprovalQuery { Status = ApprovalStatus.InReview, Username = PrincipalInfo.CurrentPrincipal.Identity.Name, Reference = new Uri("content:") }; var list = await _approvalRepository.ListAsync(query, (pageNumber - 1) *pageSize, pageSize); model.TotalItemsCount = Convert.ToInt32(list.TotalCount); var taskList = new List <ContentTask>(); foreach (var task in list.PagedResult) { var id = task.ID.ToString(); var customTask = new ContentTask { ApprovalId = task.ID, DateTime = task.ActiveStepStarted.ToString("dd MMMM HH:mm"), StartedBy = task.StartedBy }; if (task is ContentApproval approval) { _contentRepository.TryGet(approval.ContentLink, out IContent content); if (content != null) { customTask.URL = PageEditing.GetEditUrl(approval.ContentLink); id = content.ContentLink.ID.ToString(); var canUserPublish = await _helper.CanUserPublish(content); customTask.CanUserPublish = canUserPublish; customTask.ContentReference = content.ContentLink; customTask.ContentName = content.Name; customTask.ContentType = GetTypeContent(content); if (content is PageData) { customTask.Type = "Page"; } else if (content is BlockData) { customTask.Type = "Block"; if (!string.IsNullOrWhiteSpace(customTask.ContentType) && customTask.ContentType.Equals("Form container")) { customTask.Type = "Form"; } } else if (content is ImageData) { customTask.Type = "Image"; } else if (content is MediaData) { customTask.Type = "Media"; if (!string.IsNullOrWhiteSpace(customTask.ContentType) && customTask.ContentType.Equals("Video")) { customTask.Type = "Video"; } } var enableContentApprovalDeadline = bool.Parse(ConfigurationManager.AppSettings["ATM:EnableContentApprovalDeadline"] ?? "false"); var warningDays = int.Parse(ConfigurationManager.AppSettings["ATM:WarningDays"] ?? "4"); if (enableContentApprovalDeadline) { //Deadline Property of The Content var propertyData = content.Property.Get(ContentApprovalDeadlinePropertyName) ?? content.Property[ContentApprovalDeadlinePropertyName]; if (propertyData != null) { DateTime.TryParse(propertyData.ToString(), out DateTime dateValue); if (dateValue != DateTime.MinValue) { if (!string.IsNullOrEmpty(customTask.Type)) { customTask.Deadline = dateValue.ToString("dd MMMM HH:mm"); var days = DateTime.Now.CountDaysInRange(dateValue); if (days == 0) { customTask.WarningColor = "red"; } else if (days > 0 && days < warningDays) { customTask.WarningColor = "green"; } } else { customTask.Deadline = " - "; } } } } } //Get Notifications customTask = await GetNotifications(id, customTask, true); taskList.Add(customTask); } } taskList = SortColumns(sorting, taskList); return(taskList); }
/// <summary> /// Resolves the CMS edit URL to a specified content instance. /// </summary> /// <param name="content">The content instance.</param> /// <returns></returns> public static string ResolveEditUrl(IContent content) { return(PageEditing.GetEditUrl(content.ContentLink)); }
/// <summary> /// Gets the URI for this instance. /// </summary> /// <param name="content">The content.</param> /// <param name="createVersionUnspecificLink">if set to <c>true</c> creates a version unspecific link.</param> /// <returns> /// An <see cref="T:System.Uri"/> that represents the type and id of the item. /// </returns> public static string GetUri(this IContent content, bool createVersionUnspecificLink) { ContentReference contentReference = createVersionUnspecificLink ? content.ContentLink.ToReferenceWithoutVersion() : content.ContentLink; return(PageEditing.GetEditUrl(contentReference)); }