Exemple #1
0
        ContentLink IContentRepository.UpdateLink(ContentLink link)
        {
            var result = MapperFacade.ContentLinkMapper.GetBizObject(DefaultRepository.SimpleUpdate(MapperFacade.ContentLinkMapper.GetDalObject(link)));

            result.WasNew = false;
            return(result);
        }
Exemple #2
0
        /// <summary>
        /// Get a single document from a content link
        /// ** Sitefinitysteve.com Extension **
        /// </summary>
        /// <returns>Telerik.Sitefinity.Libraries.Model.Image object</returns>
        public static Document GetDocument(this DynamicContent item, string fieldName)
        {
            var         contentLinks   = (ContentLink[])item.GetValue(fieldName);
            ContentLink docContentLink = contentLinks.FirstOrDefault();

            return((docContentLink == null) ? null : docContentLink.ChildItemId.GetDocument());
        }
Exemple #3
0
        public string ResolveLinkUrl(ContentLink link)
        {
            var urlHelper = GetHelper(_urlHelperFactory, _actionContextAccessor);

            switch (link.ContentTypeCodename)
            {
            case AboutUs.Codename:
            case FactAboutUs.Codename:
                return(TranslateLink("Index", "About").Result);

            case Article.Codename:
                return(TranslateLink("Show", "Articles", new { urlSlug = link.UrlSlug }).Result);

            case Brewer.Codename:
            case Coffee.Codename:
                return(TranslateLink("Detail", "Product", new { urlSlug = link.UrlSlug }).Result);

            case Cafe.Codename:
                return(TranslateLink("Index", "Cafes").Result);

            case Home.Codename:
                return(TranslateLink("Index", "Home").Result);

            default:
                return(urlHelper.Action("NotFound", "Errors"));
            }
        }
        public string ResolveContentLinks(string text, JToken links)
        {
            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }

            if (links == null)
            {
                throw new ArgumentNullException(nameof(links));
            }

            if (text == string.Empty)
            {
                return(text);
            }

            return(_elementRegex.Replace(text, match =>
            {
                var contentItemId = match.Groups["id"].Value;
                var linkSource = links[contentItemId];

                if (linkSource == null)
                {
                    return ResolveMatch(match, _linkUrlResolver.ResolveBrokenLinkUrl());
                }

                var link = new ContentLink(contentItemId, linkSource);

                return ResolveMatch(match, _linkUrlResolver.ResolveLinkUrl(link));
            }));
        }
Exemple #5
0
        /// <summary>
        /// Get a single image from a content link
        /// ** Sitefinitysteve.com Extension **
        /// </summary>
        /// <returns>Telerik.Sitefinity.Libraries.Model.Image object</returns>
        public static Image GetImage(this DynamicContent item, string fieldName)
        {
            var         contentLinks     = (ContentLink[])item.GetValue(fieldName);
            ContentLink imageContentLink = contentLinks.FirstOrDefault();

            return((imageContentLink == null) ? null : imageContentLink.ChildItemId.GetImage());
        }
        public string ResolveLinkUrl(ContentLink link)
        {
            switch (link.ContentTypeCodename)
            {
            case "about_us":
            case "fact_about_us":
                return($"/{CurrentCulture}/about");

            case "article":
                return($"/{CurrentCulture}/articles/{link.UrlSlug}");

            case "brewer":
                return($"/{CurrentCulture}/product/detail/{link.UrlSlug}");

            case "cafe":
                return($"/{CurrentCulture}/cafes");

            case "coffee":
                return($"/{CurrentCulture}/product/detail/{link.UrlSlug}");

            case "home":
                return($"/{CurrentCulture}/");

            default:
                return($"/not_found");
            }
        }
        public ContentLink Retrieve(int id = -1)
        {
            ResultManager.IsCorrect = false;
            //initial validations
            //-sys validations
            if (id == -1 || id == 0)
            {//no id was received
                ResultManager.Add(ErrorDefault, Trace + "Retrieve.131 No se recibio el id del cultivo");
                return(null);
            }

            ContentLink auxItem = null;

            try
            {
                auxItem = Repository.ContentLinks.Get(id);
                if (auxItem == null)
                {
                    ResultManager.Add(ErrorDefault, Trace + "Retrieve.511 No se encontró un item con id '" + id + "'");
                }
                else
                {
                    ResultManager.IsCorrect = true;
                }
            }
            catch (Exception ex)
            {
                ResultManager.Add(ErrorDefault, Trace + "Retrieve.511 Excepción al obtener el item: " + ex.Message);
            }

            return(auxItem);
        }
Exemple #8
0
        public void Node_Reference_SetReference_Simple_Invisible()
        {
            Test(() =>
            {
                var root    = CreateTestRoot();
                var u1      = CreateUser("U1");
                var target0 = new Folder(root)
                {
                    Name = "folder1"
                };
                target0.Save();
                var target1 = new Folder(root)
                {
                    Name = "folder2"
                };
                target1.Save();
                var link = new ContentLink(root)
                {
                    Name = "Link1", Link = target0
                };
                link.Save();

                Providers.Instance.SecurityHandler.CreateAclEditor()
                .Allow(target1.Id, u1.Id, false, PermissionType.See)
                .Allow(link.Id, u1.Id, false, PermissionType.Save)
                .Apply();

                Assert.IsFalse(target0.Security.HasPermission(u1, PermissionType.See));
                Assert.IsTrue(target1.Security.HasPermission(u1, PermissionType.See));
                Assert.IsTrue(link.Security.HasPermission(u1, PermissionType.Save));

                // ACTION
                using (new CurrentUserBlock(u1))
                {
                    var loadedLink = Node.Load <ContentLink>(link.Id);

                    // Restrictive user cannot access the current target.
                    //Assert.IsNull(loadedLink.Link);
                    try
                    {
                        var currentLint = loadedLink.Link;
                        Assert.Fail("The expected AccessDeniedException was not thrown.");
                    }
                    catch (SenseNetSecurityException)
                    {
                        // expected exception
                    }

                    // Set new target
                    var loadedTarget = Node.LoadNode(target1.Id);
                    loadedLink.Link  = loadedTarget;
                    loadedLink.Save();
                }

                // ASSERT
                var reloaded = Node.Load <ContentLink>(link.Id);
                Assert.AreEqual(reloaded.Link.Id, target1.Id);
            });
        }
Exemple #9
0
 public bool Equals(ContentLanguageReference other)
 {
     if (other is object)
     {
         return(ContentLink.Equals(other.ContentLink) && Language.Equals(other.Language));
     }
     return(false);
 }
Exemple #10
0
    public string ResolveLinkUrl(ContentLink link)
    {
        // Resolves URLs to content items based on the Article content type
        if (link.ContentTypeCodename == "article")
        {
            return($"/articles/{link.UrlSlug}");
        }

        // TODO: Add the rest of the resolver logic
    }
Exemple #11
0
        public string ResolveLinkUrl(ContentLink link)
        {
            // Resolves URLs to content items based on the 'accessory' content type
            if (link.ContentTypeCodename == "website")
            {
                return($"/website/{link.Codename}");
            }

            return(ResolveBrokenLinkUrl());
        }
Exemple #12
0
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         int hash = 17;
         hash = hash * 23 + ContentLink.GetHashCode();
         hash = hash * 23 + Language.GetHashCode();
         return(hash);
     }
 }
Exemple #13
0
        public ActionResult Edit(ContentLink model)
        {
            if (controller.Update(model) || controller.ResultManager.IsCorrect)
            {
                NotifyUser(messageOk: "Link editado correctamente");
                return(RedirectToAction("Index"));
            }

            NotifyUser(resultManager: controller.ResultManager);
            return(View(model));
        }
Exemple #14
0
        public ActionResult Add(ContentLink item)
        {
            if (controller.Add(item) || controller.ResultManager.IsCorrect)
            {
                NotifyUser(messageOk: "Link agregado correctamente");
                return(RedirectToAction("Index"));
            }

            NotifyUser(resultManager: controller.ResultManager);
            return(View(item));
        }
Exemple #15
0
        /// <summary>
        /// Gets the video.
        /// </summary>
        /// <param name="contentLink">The content link.</param>
        /// <returns></returns>
        public static Video GetVideo(this ContentLink contentLink)
        {
            if (contentLink == null)
            {
                return(null);
            }

            var videoManager = Telerik.Sitefinity.Modules.Libraries.LibrariesManager.GetManager(contentLink.ChildItemProviderName);
            var video        = videoManager.GetVideos().FirstOrDefault(i => i.Id == contentLink.ChildItemId);

            return(video);
        }
Exemple #16
0
        /// <summary>
        /// Gets the image.
        /// </summary>
        /// <param name="contentLink">The content link.</param>
        /// <returns></returns>
        public static Image GetImage(this ContentLink contentLink)
        {
            if (contentLink == null)
            {
                return(null);
            }

            var imagesManager = Telerik.Sitefinity.Modules.Libraries.LibrariesManager.GetManager(contentLink.ChildItemProviderName);
            var image         = imagesManager.GetImages().FirstOrDefault(i => i.Id == contentLink.ChildItemId);

            return(image);
        }
Exemple #17
0
        public ActionResult Edit(int Id)
        {
            ContentLink itemToEdit = controller.Retrieve(Id);

            if (controller.ResultManager.IsCorrect)
            {
                return(View(itemToEdit));
            }

            NotifyUser(resultManager: controller.ResultManager);
            return(RedirectToAction("Index"));
        }
Exemple #18
0
        /// <summary>
        /// Gets the document.
        /// </summary>
        /// <param name="contentLink">The content link.</param>
        /// <returns></returns>
        public static Document GetDocument(this ContentLink contentLink)
        {
            if (contentLink == null)
            {
                return(null);
            }

            var documentManager = Telerik.Sitefinity.Modules.Libraries.LibrariesManager.GetManager(contentLink.ChildItemProviderName);
            var document        = documentManager.GetDocuments().FirstOrDefault(i => i.Id == contentLink.ChildItemId);

            return(document);
        }
Exemple #19
0
        private void CopyLink(ContentLink link, int i)
        {
            var newLink = link.Clone(SourceId, DestinationId);

            if (ForceLinkIds != null)
            {
                newLink.ForceLinkId = ForceLinkIds[i];
            }

            newLink = ((IContentRepository) new ContentRepository()).SaveLink(newLink);
            _linksMap.Add(link.LinkId, newLink.LinkId);
        }
        public bool Update(ContentLink item)
        {
            ResultManager.IsCorrect = false;

            //initial validations
            //-sys validations
            if (item == null)
            {
                ResultManager.Add(ErrorDefault, Trace + "Update.111 No se recibio el objeto del item a editar");
                return(false);
            }
            if (item.Id == -1 || item.Id == 0)
            {//no id was received
                ResultManager.Add(ErrorDefault, Trace + "Update.131 No se recibio el id del item a editar");
                return(false);
            }
            //-business validations
            if (string.IsNullOrWhiteSpace(item.DisplayName))
            {
                ResultManager.Add("El texto a mostrar no puede estar vacío");
                return(false);
            }
            if (string.IsNullOrWhiteSpace(item.Url))
            {
                ResultManager.Add("La url no puede estar vacía");
                return(false);
            }

            //update item
            try
            {
                ContentLink auxItem = Repository.ContentLinks.Get(item.Id);
                if (auxItem == null)
                {
                    ResultManager.Add(ErrorDefault, Trace + "Update.311 item con id '" + item.Id + "' no encontrado en bd");
                    return(false);
                }
                auxItem.DisplayName = item.DisplayName;
                auxItem.Url         = item.Url;
                Repository.Complete();
                ResultManager.IsCorrect = true;
                return(true);
            }
            catch (Exception ex)
            {
                ResultManager.Add(ErrorDefault, Trace + "Update.511 Excepción al editar el item con id '" + item.Id + "': " + ex.Message);
            }
            return(false);
        }
        public string ResolveLinkUrl(ContentLink link)
        {
            // Resolves URLs to content items based on the 'accessory' content type
            switch (link.ContentTypeCodename)
            {
            case "article":
                return($"/Articles/Detail/{link.UrlSlug}");

            case "coffee":
                return($"/Coffees/Detail/{link.UrlSlug}");

            default:
                return("/404");
            }
        }
Exemple #22
0
        public async Task <ContentLinkDto> CreateAsync(ContentLinkDto dto)
        {
            var link = new ContentLink
            {
                Name        = dto.Name,
                Description = dto.Description,
                IsDeleted   = false,
                Link        = dto.Link,
                LinkType    = dto.LinkType
            };

            _unitOfWork.ContentLinks.Create(link);
            await _unitOfWork.SaveChangesAsync();

            return(dto);
        }
Exemple #23
0
        ContentLink IContentRepository.SaveLink(ContentLink link)
        {
            EntityObject.VerifyIdentityInserting(EntityTypeCode.ContentLink, link.LinkId, link.ForceLinkId);
            if (link.ForceLinkId != 0)
            {
                link.LinkId = link.ForceLinkId;
            }

            DefaultRepository.TurnIdentityInsertOn(EntityTypeCode.ContentLink);
            var result = MapperFacade.ContentLinkMapper.GetBizObject(DefaultRepository.SimpleSave(MapperFacade.ContentLinkMapper.GetDalObject(link)));

            DefaultRepository.TurnIdentityInsertOff(EntityTypeCode.ContentLink);

            result.WasNew = true;
            return(result);
        }
Exemple #24
0
        // ================================================================ Events

        protected void LinkContentsButton_Click(object sender, EventArgs e)
        {
            var targetNode = GetContextNode();

            if (targetNode != null)
            {
                foreach (var node in this.RequestNodeList)
                {
                    var link = new ContentLink(targetNode);
                    link.Link = node;
                    link.Save();
                }
            }

            CallDone();
        }
        public string ResolveLinkUrl(ContentLink link)
        {
            switch (link.ContentTypeCodename)
            {
            case Article.Codename:
                return($"/{CurrentCulture}/articles/{link.UrlSlug}");

            case BlogPost.Codename:
                return($"/{CurrentCulture}/blog/{link.UrlSlug}");

            case Home.Codename:
                return($"/{CurrentCulture}/");

            default:
                return($"/not_found");
            }
        }
Exemple #26
0
        private async Task <string> ResolveContentLinks(string text, CustomContentLinkUrlResolver linkUrlResolver)
        {
            var          linkResolver = new ContentLinkResolver(linkUrlResolver);
            IContentLink link         = new ContentLink()
            {
                ContentTypeCodename = "article",
                UrlSlug             = "about-us",
                Codename            = "about_us"
            };

            link.Id = ContentItemIdA;
            var links = new Dictionary <Guid, IContentLink> {
                { ContentItemIdA, link }
            };

            return(await linkResolver.ResolveContentLinksAsync(text, links));
        }
Exemple #27
0
        public string ConcatenateChildrenWithReviews()
        {
            var contentLoader = ServiceLocator.Current.GetInstance <ReviewsContentLoader>();
            var items         = contentLoader.GetChildrenWithReviews <IContent>(ContentLink);
            var list          = new List <string>();

            foreach (var item in items)
            {
                list.Add(item.Name);
            }

            var             reference  = ContentLink.ToReferenceWithoutVersion();
            ContentProvider provider   = ServiceLocator.Current.GetInstance <IContentProviderManager>().ProviderMap.GetProvider(reference);
            string          languageID = Language.Name;
            IList <GetChildrenReferenceResult> childrenReferences = provider.GetChildrenReferences <IContent>(reference, languageID, 0, 1000);

            return(string.Join(", ", list));
        }
Exemple #28
0
        /// <summary>
        /// Changes the profile avatar.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <param name="image">The profile image.</param>
        /// <param name="userProfileManager">The user profile manager.</param>
        private void ChangeProfileAvatar(Guid userId, Image image, UserProfileManager userProfileManager)
        {
            User user = SecurityManager.GetUser(userId);

            if (user != null && image != null)
            {
                SitefinityProfile profile = userProfileManager.GetUserProfile <SitefinityProfile>(user);

                if (profile != null)
                {
                    ContentLink avatarLink = ContentLinksExtensions.CreateContentLink(profile, image);

                    profile.Avatar = avatarLink;

                    // Setting the Avatar does not modify the actual Profile persistent object and cache entries that depend on the Profile are not invalidated.
                    // By setting another property of the Profile we force all cache entries that depend ot this profile to be invalidated.
                    profile.LastModified = DateTime.UtcNow;
                }
            }
        }
        public bool Add(ContentLink item)
        {
            ResultManager.IsCorrect = false;

            //initial validations
            //-sys validations
            if (item == null)
            {
                ResultManager.Add(ErrorDefault, Trace + "Add.111 No se recibio el objeto del cultivo a editar");
                return(false);
            }
            //-business validations
            if (string.IsNullOrWhiteSpace(item.DisplayName))
            {
                ResultManager.Add("El texto a mostrar no puede estar vacío");
                return(false);
            }
            if (string.IsNullOrWhiteSpace(item.Url))
            {
                ResultManager.Add("La url no puede estar vacía");
                return(false);
            }

            //insert new item
            try
            {
                //ContentLink auxNew = new ContentLink();
                //auxNew.DisplayName = item.DisplayName;
                //auxNew.Url = item.Url;
                Repository.ContentLinks.Add(item);
                Repository.Complete();
                ResultManager.IsCorrect = true;
                return(true);
            }
            catch (Exception ex)
            {
                ResultManager.Add(ErrorDefault, Trace + "Add.511 Excepción al agregar el link con id '" + item.Id + "': " + ex.Message);
            }
            return(false);
        }
 /// <summary>
 /// Resolves the link URL.
 /// </summary>
 /// <param name="link">The link.</param>
 /// <returns>A relative URL to the page where the content is displayed</returns>
 public string ResolveLinkUrl(ContentLink link)
 {
     return($"/{link.UrlSlug}");
 }
Exemple #31
0
 public override bool Include(ContentLink link)
 {
     return link.LinkType == NodeLinkType.ExternalHtmlImage || true;
 }