public override PipelineProcessorResponseValue ProcessRequest() { var response = new PipelineProcessorResponseValue(); try { response.Value = GenerateUrl(); } catch (Exception ex) { response.AbortMessage = ex.ToString(); } return(response); }
public override PipelineProcessorResponseValue ProcessRequest() { SaveArgs.SaveItem saveItem = RequestContext.GetSaveArgs().Items[0]; PipelineProcessorResponseValue processorResponseValue = new PipelineProcessorResponseValue(); Item existingItem; // Change made in relation to https://github.com/SitecoreUnicorn/Unicorn/issues/351 if (saveItem.Language != null && saveItem.Version != null) { existingItem = RequestContext.Item.Database.GetItem(saveItem.ID, saveItem.Language, saveItem.Version); } else { existingItem = RequestContext.Item.Database.GetItem(saveItem.ID, Language.Parse(RequestContext.Language), Sitecore.Data.Version.Parse(RequestContext.Version)); } if (existingItem == null) { return(processorResponseValue); } // added: ignore transparent synced items, whose revisions are randomly generated if (existingItem.Statistics.UpdatedBy.Equals(UnicornDataProvider.TransparentSyncUpdatedByValue, StringComparison.Ordinal)) { return(processorResponseValue); } string cleanedExistingRevision = existingItem[FieldIDs.Revision].Replace("-", string.Empty); if (saveItem.Revision == string.Empty) { saveItem.Revision = cleanedExistingRevision; } string cleanedNewRevision = saveItem.Revision.Replace("-", string.Empty); if (cleanedExistingRevision.Equals(cleanedNewRevision, StringComparison.InvariantCultureIgnoreCase) || EditorConstants.IgnoreRevision.Equals(cleanedNewRevision, StringComparison.InvariantCultureIgnoreCase)) { return(processorResponseValue); } processorResponseValue.ConfirmMessage = Translate.Text("One or more items have been changed.\n\nDo you want to overwrite these changes?"); return(processorResponseValue); }
public override PipelineProcessorResponseValue ProcessRequest() { var item = this.RequestContext.Item; var url = string.Format( //"/sitecore/client/AccessibilityChecker/AccessibilityChecker?sc_lang={0}&itemId={1}", "/axe", this.RequestContext.Language, item.ID); var pipelineProcessorResponseValue = new PipelineProcessorResponseValue() { Value = new UrlString(url).ToString() }; return(pipelineProcessorResponseValue); }
public override PipelineProcessorResponseValue ProcessRequest() { var processorResponseValue = new PipelineProcessorResponseValue(); var items = base.RequestContext.GetSaveArgs().Items; var list = ((IEnumerable <SaveArgs.SaveItem>)items).SelectMany <SaveArgs.SaveItem, SaveArgs.SaveField>((Func <SaveArgs.SaveItem, IEnumerable <SaveArgs.SaveField> >)(i => (IEnumerable <SaveArgs.SaveField>)i.Fields)).ToList <SaveArgs.SaveField>(); var obj = this.RequestContext.Item.Database.GetItem(items[0].ID, items[0].Language); if (obj == null || obj.Paths.IsMasterPart || StandardValuesManager.IsStandardValuesHolder(obj)) { return(processorResponseValue); } var fields = WebUtility.GetFields(this.RequestContext.Item.Database, this.RequestContext.FieldValues); var fieldValidationErrorList = new List <FieldValidationError>(); foreach (var pageEditorField in fields) { var field = this.RequestContext.Item.Database.GetItem(pageEditorField.ItemID, pageEditorField.Language).Fields[pageEditorField.FieldID]; var valueToValidate = list.FirstOrDefault <SaveArgs.SaveField>((Func <SaveArgs.SaveField, bool>)(f => f.ID == field.ID))?.Value ?? field.Value; var fieldValidationError = this.ItemFieldValidator.GetFieldTypeValidationError(field, valueToValidate) ?? this.ItemFieldValidator.GetFieldRegexValidationError(field, valueToValidate); if (fieldValidationError != null) { fieldValidationErrorList.Add(fieldValidationError); } } var validators = ValidationHelpers.GetValidatorCollection(obj); if (validators == null) { return(processorResponseValue); } var validationErrorsCustom = ValidationHelpers.AreFieldsValid(validators); if (validationErrorsCustom.Any()) { var invalidFields = validationErrorsCustom.Select(i => obj.Database.GetItem(i).Name).ToList(); processorResponseValue.ConfirmMessage = $"{obj.DisplayName ?? obj.Name} has content entry errors in {obj.Language} on the following fields: {Environment.NewLine}" + $"{string.Join(Environment.NewLine, invalidFields)}{Environment.NewLine} " + "It will not be published in that language"; } processorResponseValue.Value = (object)fieldValidationErrorList; return(processorResponseValue); }