Example #1
0
        /// <summary>
        /// Uses the Published Item Comparer
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public string Execute(FieldGutterArgs args)
        {
            if (args.InnerItem == null)
            {
                return(string.Format("<span title=\"The item could not be retrieved from Sitecore.\"><img class=\"fieldGutterItem\" src=\"/sitecore modules/shell/field suite/images/bullet_ball_red.png\"/></span>"));
            }

            if (args.InnerItem.Database != null && args.InnerItem.Database.Name.ToLower() == "core")
            {
                return(string.Empty);
            }

            //verify settings item exists
            ItemComparerSettingsItem settingsItem = ItemComparerSettingsItem.GetSettingsItem();

            if (settingsItem == null)
            {
                Logger.Error("Published Item Comparer: The Settings Item Could not be retrieved.");
                return("<span title=\"The settings item could not be retrieved from Sitecore.\"><img class=\"fieldGutterItem\" src=\"/sitecore modules/shell/field suite/images/bullet_ball_red.png\"/></span>");
            }

            //verify target database
            Database targetDatabase = ItemComparerUtil.GetTargetDatabase();

            if (targetDatabase == null)
            {
                Logger.Error("Published Item Comparer: The Target Database Could not be retrieved.");
                return("<span title=\"The target database could not be retrieved from Sitecore.\"><img class=\"fieldGutterItem\" src=\"/sitecore modules/shell/field suite/images/bullet_ball_red.png\"/></span>");
            }

            try
            {
                ItemComparerContext context = new ItemComparerContext();
                context.Item = args.InnerItem;
                context.ItemComparerSettingsItem = settingsItem;
                context.TargetDatabase           = targetDatabase;

                ItemValidator itemValidator = new ItemValidator();
                List <string> validations   = itemValidator.Validate(context);
                if (validations != null && validations.Count > 0)
                {
                    return(string.Format("<span title=\"The item did not pass validation.\"><a href=\"#\" style=\"border:0;padding:0;\" class=\"itemComparerGutterLink\" onclick=\"FieldSuite.Fields.OpenItemComparer('{0}','{1}')\"><img class=\"fieldGutterItem\" src=\"/sitecore modules/shell/field suite/images/bullet_ball_red.png\"/></a></span>", args.InnerItem.ID, args.FieldId));
                }

                return("<span title=\"The item passed validation.\"><img class=\"fieldGutterItem\" src=\"/sitecore modules/shell/field suite/images/bullet_ball_green.png\"/></span>");
            }
            catch (Exception e)
            {
                Logger.Error("Field Gutter - Published Item Comparer: Error trying to validate");
                Logger.Error(e.InnerException);
                Logger.Error(e.Message);
            }

            return(string.Empty);
        }
        /// <summary>
        /// Uses the Published Item Comparer
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public string Execute(FieldGutterArgs args)
        {
            if (args.InnerItem == null)
            {
                return string.Format("<span title=\"The item could not be retrieved from Sitecore.\"><img class=\"fieldGutterItem\" src=\"/sitecore modules/shell/field suite/images/bullet_ball_red.png\"/></span>");
            }

            if (args.InnerItem.Database != null && args.InnerItem.Database.Name.ToLower() == "core")
            {
                return string.Empty;
            }

            //verify settings item exists
            ItemComparerSettingsItem settingsItem = ItemComparerSettingsItem.GetSettingsItem();
            if (settingsItem == null)
            {
                Logger.Error("Published Item Comparer: The Settings Item Could not be retrieved.");
                return "<span title=\"The settings item could not be retrieved from Sitecore.\"><img class=\"fieldGutterItem\" src=\"/sitecore modules/shell/field suite/images/bullet_ball_red.png\"/></span>";
            }

            //verify target database
            Database targetDatabase = ItemComparerUtil.GetTargetDatabase();
            if (targetDatabase == null)
            {
                Logger.Error("Published Item Comparer: The Target Database Could not be retrieved.");
                return "<span title=\"The target database could not be retrieved from Sitecore.\"><img class=\"fieldGutterItem\" src=\"/sitecore modules/shell/field suite/images/bullet_ball_red.png\"/></span>";
            }

            try
            {
                ItemComparerContext context = new ItemComparerContext();
                context.Item = args.InnerItem;
                context.ItemComparerSettingsItem = settingsItem;
                context.TargetDatabase = targetDatabase;

                ItemValidator itemValidator = new ItemValidator();
                List<string> validations = itemValidator.Validate(context);
                if (validations != null && validations.Count > 0)
                {
                    return string.Format("<span title=\"The item did not pass validation.\"><a href=\"#\" style=\"border:0;padding:0;\" class=\"itemComparerGutterLink\" onclick=\"FieldSuite.Fields.OpenItemComparer('{0}','{1}')\"><img class=\"fieldGutterItem\" src=\"/sitecore modules/shell/field suite/images/bullet_ball_red.png\"/></a></span>", args.InnerItem.ID, args.FieldId);
                }

                return "<span title=\"The item passed validation.\"><img class=\"fieldGutterItem\" src=\"/sitecore modules/shell/field suite/images/bullet_ball_green.png\"/></span>";
            }
            catch (Exception e)
            {
                Logger.Error("Field Gutter - Published Item Comparer: Error trying to validate");
                Logger.Error(e.InnerException);
                Logger.Error(e.Message);
            }

            return string.Empty;
        }
Example #3
0
        protected virtual string GetFieldGutterHtml(FieldGutterArgs args)
        {
            if (args == null || args.InnerItem.IsNull())
            {
                return string.Empty;
            }

            IFieldGutterProcessor fieldGutterProcessor = FieldGutterProcessorFactory.GetProcessor();
            if (fieldGutterProcessor == null)
            {
                return string.Empty;
            }

            string fieldGutterHtml = fieldGutterProcessor.Process(args);
            if (string.IsNullOrEmpty(fieldGutterHtml))
            {
                return string.Empty;
            }

            return fieldGutterHtml;
        }
Example #4
0
        /// <summary>
        /// Process Item's Field Gutter
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public virtual string Process(FieldGutterArgs args)
        {
            if (args == null || args.InnerItem == null)
            {
                return(string.Empty);
            }

            //list check
            List <IFieldGutter> fieldGutters = FieldGutterItems;

            if (fieldGutters == null || fieldGutters.Count == 0)
            {
                return(string.Empty);
            }

            string outputHtml = string.Empty;

            foreach (IFieldGutter fieldGutter in fieldGutters)
            {
                if (fieldGutter == null)
                {
                    continue;
                }

                //validate item
                string html = fieldGutter.Execute(args);
                if (string.IsNullOrEmpty(html))
                {
                    continue;
                }

                //add output of validation to the master validation list
                outputHtml += html;
            }

            //return all output validation
            return(string.Format("<div id=\"{1}_{2}_fieldGutterDiv\">{0}</div>", outputHtml, args.FieldId, args.InnerItem.ID));
        }
        /// <summary>
        /// Process Item's Field Gutter
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public virtual string Process(FieldGutterArgs args)
        {
            if (args == null || args.InnerItem == null)
            {
                return string.Empty;
            }

            //list check
            List<IFieldGutter> fieldGutters = FieldGutterItems;
            if (fieldGutters == null || fieldGutters.Count == 0)
            {
                return string.Empty;
            }

            string outputHtml = string.Empty;
            foreach (IFieldGutter fieldGutter in fieldGutters)
            {
                if (fieldGutter == null)
                {
                    continue;
                }

                //validate item
                string html = fieldGutter.Execute(args);
                if (string.IsNullOrEmpty(html))
                {
                    continue;
                }

                //add output of validation to the master validation list
                outputHtml += html;
            }

            //return all output validation
            return string.Format("<div id=\"{1}_{2}_fieldGutterDiv\">{0}</div>", outputHtml, args.FieldId, args.InnerItem.ID);
        }