private static bool AreEqual(ContentItem item1, ContentItem item2, XElement item1Export, XElement item2Export)
        {
            //todo: this is a little too generous
            if (!item1.SharesIdentifierWith(item2))
                return false;

            if (item1.Has<TitlePart>() && item2.Has<TitlePart>())
            {
                if (!item1.As<TitlePart>().Title.Equals(item2.As<TitlePart>().Title, StringComparison.CurrentCulture))
                {
                    return false;
                }
            }

            if (item1.Has<BodyPart>() && item2.Has<BodyPart>())
            {
                var text1 = item1.As<BodyPart>().Text;
                var text2 = item2.As<BodyPart>().Text;

                if (text1 == null || text2 == null)
                    return false;

                if (!item1.As<BodyPart>().Text.Equals(item2.As<BodyPart>().Text, StringComparison.CurrentCulture))
                {
                    return false;
                }
            }

            // compare xml elements
            return Differences(item1Export, item2Export) == 0;
        }
 public static bool SharesIdentifierWith(this ContentItem item1, ContentItem item2)
 {
     if (item1.Has<IdentityPart>() && item2.Has<IdentityPart>())
     {
         return item1.As<IdentityPart>().Identifier.Equals(item2.As<IdentityPart>().Identifier,
                                                        StringComparison.InvariantCultureIgnoreCase);
     }
     return false;
 }
 private TreeNode GetContentItemNode(ContentItem item) {
     return new TreeNode {
         Title = _contentManager.GetItemMetadata(item).DisplayText,
         Type = "content-item-" + item.Id,
         Id = item.Id.ToString(CultureInfo.InvariantCulture),
         Url = _url.ItemEditUrl(item),
         IsLeaf = !item.Has<ContainerPart>()
     };
 }
Esempio n. 4
0
        private static string GetUniqueIdentifier(ContentItem item)
        {
            string slug = null;
            if (item.Has<AutoroutePart>())
            {
                var route = item.Get<AutoroutePart>();
                slug = route.Path;
            }

            return string.Format("{0} {1}", item.Id, slug);
        }
        public string GetUniqueIdentifier(ContentItem item)
        {
            string slug = null;
            if (item.Has<RoutePart>())
            { 
                var route = item.Get<RoutePart>();
                slug = route.Slug;
            }

            return string.Format("{0} {1}", item.Id, slug);
        }
Esempio n. 6
0
        private bool IsValid(int itemId, out ContentItem item, out ActionResult invalidResult)
        {
            if (_orchardServices.WorkContext.CurrentUser == null || !_orchardServices.Authorizer.Authorize(Permissions.WatchItems))
            {
                invalidResult = new HttpUnauthorizedResult();
                item = null;
                return false;
            }

            item = _orchardServices.ContentManager.Get(itemId);

            if (item == null)
            {
                invalidResult = HttpNotFound();
                return false;
            }

            if (!_orchardServices.Authorizer.Authorize(Orchard.Core.Contents.Permissions.ViewContent))
            {
                invalidResult = new HttpUnauthorizedResult();
                return false;
            }

            if (!item.Has<WatchablePart>())
            {
                invalidResult = HttpNotFound();
                return false;
            }

            invalidResult = null;
            return true;
        }
Esempio n. 7
0
 public void TestShape(dynamic Display, TextWriter Output, HtmlHelper Html, ContentItem item) {
     if (item.Has<IdentityPart>()) {
         Output.Write("testshape: " + item.As<IdentityPart>().Identifier);
     }
 }
 private bool InvalidForm(Orchard.ContentManagement.ContentItem form)
 {
     return(form == null || !form.Has(typeof(ContactFormPart)));
 }