Example #1
0
        public void Process(RenderFieldArgs args)
        {
            var item = GetItem(args);

            if (item == null)
            {
                return;
            }

            var oldText     = item[args.FieldName];
            var updatedText = args.Item[args.FieldName];

            if (String.CompareOrdinal(updatedText, oldText) == 0)
            {
                if (!IndicateUnchangedFields)
                {
                    return;
                }
            }

            if (RenderBeforeComparison)
            {
                oldText     = RenderWithoutDifferences(item, args);
                updatedText = RenderWithoutDifferences(args.Item, args);
            }

            if (RenderTextualDifferences && args.FieldTypeKey != "image")
            {
                var evaluator = new FieldDifferenceEvaluator();
                args.Result.FirstPart = evaluator.GetDifferences(oldText, updatedText);
            }
        }
Example #2
0
        public void Process(RenderFieldArgs args)
        {
            Item item = this.GetItem(args);

            if (item == null)
            {
                return;
            }

            string oldText      = item[args.FieldName];
            string updatedText  = args.Item[args.FieldName];
            bool   fieldChanged = true;

            if (String.Compare(updatedText, oldText, false) == 0)
            {
                fieldChanged = false;

                if (!this.IndicateUnchangedFields)
                {
                    return;
                }
            }

            if (this.RenderBeforeComparison)
            {
                oldText     = this.RenderWithoutDifferences(item, args);
                updatedText = this.RenderWithoutDifferences(args.Item, args);
            }

            if (this.RenderTextualDifferences && args.FieldTypeKey != "image")
            {
                FieldDifferenceEvaluator evaluator = new FieldDifferenceEvaluator();
                args.Result.FirstPart = evaluator.GetDifferences(
                    updatedText,
                    oldText);
            }

            args.Result.FirstPart = @"<div style=""border: 1px "
                                    + this.GetColor(fieldChanged, Sitecore.Context.Item.ID == args.Item.ID)
                                    + @" solid; margin: -1px;"">"
                                    + args.Result.FirstPart;
            args.Result.LastPart += "</div>";
        }