public virtual void Process(GetContentEditorWarningsArgs args) { Item item = args.Item; if (item == null) { return; } var existingSitecoreItem = new ItemData(item); var configuration = _configurations.FirstOrDefault(config => config.Resolve <IPredicate>().Includes(existingSitecoreItem).IsIncluded); if (configuration != null) { var evaluator = configuration.Resolve <IEvaluator>(); var warningObject = evaluator.EvaluateEditorWarning(item); if (warningObject != null) { GetContentEditorWarningsArgs.ContentEditorWarning warning = args.Add(); warning.Title = warningObject.Title; warning.Text = warningObject.Message; } } }
/// <summary> /// Called by getContentEditorWarnings pipeline to determine if a warning should be /// displayed or not if the item is configured for publish exclusion. /// Override this method for any custom implementation logic. /// </summary> /// <param name="args">content editor warning arguments</param> public virtual void Process(GetContentEditorWarningsArgs args) { Assert.ArgumentNotNull(args, "args"); try { if (!PublishExclusionsContext.Current.ShowContentEditorWarnings || args.Item == null || (Context.ContentDatabase != null && Context.ContentDatabase.Name != "master")) return; List<PublishExclusion> exclusions = PublishExclusionsContext.Current.GetAllPublishExclusions(args.Item); if (exclusions == null || exclusions.Count == 0) return; GetContentEditorWarningsArgs.ContentEditorWarning warning = args.Add(); warning.Title = WarningTitle; warning.Text = string.Join("<br/>", exclusions.Select(e => string.Format(WarningTextFormat, e.PublishingTarget, GetFormattedPublishModes(e.PublishModes)))); } catch (Exception ex) { Log.Error("Sitecore.PublishExclusions : IsExcludedFromPublish processor - error in evaluating content editor warnings", ex, this); } }
// Adds warning message to Content Editor and specifies its details protected virtual void AddWarning(GetContentEditorWarningsArgs args) { var warning = args.Add(); warning.Title = Globalization.Translate.Text(WarningTitleKey); warning.Text = Globalization.Translate.Text(WarningTextKey); }
public virtual void Process(GetContentEditorWarningsArgs args) { Item item = args.Item; if (item == null) { return; } var existingSitecoreItem = new ItemData(item); PredicateResult matchingPredicate = null; foreach (var configuration in _configurations) { matchingPredicate = configuration.Resolve <IPredicate>().Includes(existingSitecoreItem); if (matchingPredicate.IsIncluded) { var evaluator = configuration.Resolve <IEvaluator>(); var warningObject = evaluator.EvaluateEditorWarning(item, matchingPredicate); if (warningObject != null) { GetContentEditorWarningsArgs.ContentEditorWarning warning = args.Add(); warning.Title = warningObject.Title; warning.Text = warningObject.Message; } } } }
/// <summary> /// Called by getContentEditorWarnings pipeline to determine if a warning should be /// displayed or not if the item is configured for publish exclusion. /// Override this method for any custom implementation logic. /// </summary> /// <param name="args">content editor warning arguments</param> public virtual void Process(GetContentEditorWarningsArgs args) { Assert.ArgumentNotNull(args, "args"); try { if (!PublishExclusionsContext.Current.ShowContentEditorWarnings || args.Item == null || (Context.ContentDatabase != null && Context.ContentDatabase.Name != "master")) { return; } List <PublishExclusion> exclusions = PublishExclusionsContext.Current.GetAllPublishExclusions(args.Item); if (exclusions == null || exclusions.Count == 0) { return; } GetContentEditorWarningsArgs.ContentEditorWarning warning = args.Add(); warning.Title = WarningTitle; warning.Text = string.Join("<br/>", exclusions.Select(e => string.Format(WarningTextFormat, e.PublishingTarget, GetFormattedPublishModes(e.PublishModes)))); } catch (Exception ex) { Log.Error("Sitecore.PublishExclusions : IsExcludedFromPublish processor - error in evaluating content editor warnings", ex, this); } }
/// <summary> /// Adds a warning message to the pipeline. /// </summary> /// <param name="title">Message title</param> /// <param name="message">Message text</param> /// <param name="args">Arguments for processing</param> protected void AddWarning( GetContentEditorWarningsArgs args, string title, string message) { GetContentEditorWarningsArgs.ContentEditorWarning warning = args.Add(); warning.Title = title; warning.Text = message; }
/// <summary> /// Adds a warning message to the pipeline. /// </summary> /// <param name="title">Message title</param> /// <param name="message">Message text</param> /// <param name="args">Arguments for processing</param> protected void AddWarning( GetContentEditorWarningsArgs args, string title, string message) { GetContentEditorWarningsArgs.ContentEditorWarning warning = args.Add(); warning.Title = title; warning.Text = message; }
public new bool AddPartOfActiveTestWarning(GetContentEditorWarningsArgs args) { if (new TestingSearch().GetRunningTestsWithDataSourceItem(args.Item).Any()) { args.Add(Translate.Text("This component is part of an active test."), Translate.Text("If you edit the content it could have a negative impact on statistical significance of the test.")); return(true); } return(false); }
/// <summary> /// Process the pipeline processor. /// </summary> /// <param name="args"></param> public void Process(GetContentEditorWarningsArgs args) { if (args.Item == null || (!args.Item.TemplateID.Equals(ItemIds.Templates.HostNameRewriteRule) && !args.Item.TemplateID.Equals(ItemIds.Templates.UrlRewriteRule))) { // Only apply the notifications to rewrite rule items. return; } if (args.Item.TemplateID.Equals(ItemIds.Templates.HostNameRewriteRule)) { // Add a Content Editor warning with instructions on how to use hostname rewrite rules. args.Add("How to use Hostname rewrite rules", this.GetHostNameRuleHelp()); } if (args.Item.TemplateID.Equals(ItemIds.Templates.UrlRewriteRule)) { // Add a Content Editor warning with instructions on how to use url rewrite rules. args.Add("How to use URL rewrite rules", this.GetUrlRuleHelp()); } }
/// <summary> /// Process the pipeline processor. /// </summary> /// <param name="args"></param> public void Process(GetContentEditorWarningsArgs args) { if (args.Item == null || (!args.Item.TemplateID.Equals(ItemIds.Templates.HostNameRewriteRule) && !args.Item.TemplateID.Equals(ItemIds.Templates.UrlRewriteRule))) { // Only apply the notifications to rewrite rule items. return; } if (args.Item.TemplateID.Equals(ItemIds.Templates.HostNameRewriteRule)) { // Add a Content Editor warning with instructions on how to use hostname rewrite rules. args.Add("How to use Hostname rewrite rules", this.GetHostNameRuleHelp()); } if (args.Item.TemplateID.Equals(ItemIds.Templates.UrlRewriteRule)) { // Add a Content Editor warning with instructions on how to use url rewrite rules. args.Add("How to use URL rewrite rules", this.GetUrlRuleHelp()); } }
public void Process(GetContentEditorWarningsArgs args) { if (args == null || args.Item == null) { return; } var warning = args.Add(); warning.Title = "Item Child Count"; warning.Text = args.Item.Children.Count.ToString(); }
public void Process(GetContentEditorWarningsArgs args) { Item item = args.Item; // check if the current item is in final workflow state and then check for validation errors if (! Utility.IsItemInFinalWorkflowState(item, workflowStateIsFinal)) return; // set the warning Title _contentEditorWarning = args.Add(); _contentEditorWarning.Title = Sitecore.Globalization.Translate.Text("If you publish now, the current item may not render properly because the following dependencies have not been moved to a final workflow state. Click the links below to review these items:"); SetValidatorWarningMessages(item, args); }
public void Process(GetContentEditorWarningsArgs args) { Assert.ArgumentNotNull(args, "args"); if (args.Item != null) { IExportExecuter exportExecuter = MediaFrameworkContext.GetExportExecuter(args.Item); if (exportExecuter != null && exportExecuter.IsNew(args.Item)) { args.Add(Translate.Text(Translations.NotExportedWarningTitle), Translate.Text(Translations.NotExportedWarningText)); } } }
/// <summary> /// Processes the specified args. /// </summary> /// <param name="args">The args.</param> public void Process([NotNull] GetContentEditorWarningsArgs args) { DateTime expiration = DateUtil.IsoDateToDateTime(Nexus.LicenseApi.Expiration); double minimumNumberOfDaysToWarn = 7; double.TryParse(SettingsFixed.SettingsFromMaster.DefaultNumberOfDaysToWarn.ToString(), out minimumNumberOfDaysToWarn); if (MainUtil.GetBool(SettingsFixed.SettingsFromMaster.AlwaysWarn, false) || DateTime.Now.Date > expiration.AddDays(-minimumNumberOfDaysToWarn)) { GetContentEditorWarningsArgs.ContentEditorWarning warning = args.Add(); warning.Title = SettingsFixed.SettingsFromMaster.WarningTitle; warning.Text = SettingsFixed.SettingsFromMaster.WarningSubtitle.Replace("[date]", expiration.ToLongDateString()).Replace("[url]", WebUtil.GetServerUrl()); warning.Icon = "Applications/16x16/delete.png"; } }
private void SetNotification(GetContentEditorWarningsArgs arguments, ItemWorkflowModel wfModel) { var editorNotification = arguments.Add(); editorNotification.Title = "Datasource Item in Workflow"; editorNotification.Text = wfModel.GetEditorDescription(false); editorNotification.Icon = wfModel.WorkflowState.Icon; if (wfModel.HasWriteAccess()) { foreach (var command in wfModel.Commands) { editorNotification.AddOption(command.DisplayName, new WorkflowCommandBuilder(wfModel.ContextItem, wfModel.Workflow, command).ToString()); } } }
public virtual void Process(GetContentEditorWarningsArgs args) { Item item = args.Item; if (item == null) return; var existingSitecoreItem = new ItemData(item); if (_configurations.Any(configuration => configuration.Resolve<IPredicate>().Includes(existingSitecoreItem).IsIncluded)) { GetContentEditorWarningsArgs.ContentEditorWarning warning = args.Add(); warning.Title = RenderTitle(item); warning.Text = RenderWarning(item); } }
public void Process(GetContentEditorWarningsArgs args) { GetContentEditorWarningsArgs.ContentEditorWarning contentEditorWarning; if (args.Item.IsProjectItem()) { string project = args.Item.ProjectTitle(); string output = string.Format(" <a href=\"#\" onclick='javascript:return scForm.invoke(\"{0}\")' title=\"View project items\">[ View project items ]</a>", string.Format("Project:ViewItems(Id={0})", args.Item.ID)); contentEditorWarning = args.Add(); contentEditorWarning.Title = "Sitecore Project"; contentEditorWarning.Text = "This item is part of the '" + project + "' project " + output; } }
private void SetNotification(GetContentEditorWarningsArgs arguments, ItemWorkflowModel wfModel) { var editorNotification = arguments.Add(); editorNotification.Title = "Datasource Item in Workflow"; editorNotification.Text = wfModel.GetEditorDescription(false); editorNotification.Icon = wfModel.WorkflowState.Icon; if (wfModel.HasWriteAccess()) { foreach (var command in wfModel.Commands) { editorNotification.AddOption(command.DisplayName, new WorkflowCommandBuilder(wfModel.ContextItem, wfModel.Workflow, command).ToString()); } } }
private void BuildWarning(GetContentEditorWarningsArgs args) { GetContentEditorWarningsArgs.ContentEditorWarning warning = args.Add(); warning.Icon = IconPath; warning.Title = Translate.Text(TitleKey); String format = Translate.Text(TextKey); String date = DateUtil.IsoDateToDateTime(args.Item[Constants.FieldNames.Refreshed]).ToShortDateString(); String message = String.Format(format, date); warning.Text = message; warning.AddOption(OptionKey, Constants.CommandNames.Refresh); warning.IsExclusive = false; warning.HideFields = false; }
public void Process(GetContentEditorWarningsArgs args) { Item item = args.Item; Assert.IsNotNull(item, "item"); ScheduledPublishRepo scheduledPublishRepo = new ScheduledPublishRepo(); IEnumerable<PublishSchedule> schedulesForCurrentItem = scheduledPublishRepo.GetSchedules(item.ID); if (schedulesForCurrentItem.Any()) { GetContentEditorWarningsArgs.ContentEditorWarning warning = args.Add(); warning.Icon = "Applications/32x32/information2.png"; warning.Text = "This item has been scheduled for publish."; warning.IsExclusive = false; } }
public static void AddWarning(Item item, GetContentEditorWarningsArgs args, IList <Language> languages, string sitename) { GetContentEditorWarningsArgs.ContentEditorWarning warning = args.Add(); warning.Title = "You are not in the language of the current site: " + sitename; warning.Text = "Switch to the correct language"; foreach (var language in languages) { if (language != null) { warning.AddOption(string.Format("Switch to {0}", language.GetDisplayName()), string.Format(CultureInfo.InvariantCulture, "item:load(id={0},language={1})", item.ID, language.Name)); } } warning.IsExclusive = true; }
public void Process(GetContentEditorWarningsArgs args) { Item item = args.Item; Assert.IsNotNull(item, "item"); ScheduledPublishRepo scheduledPublishRepo = new ScheduledPublishRepo(); IEnumerable <PublishSchedule> schedulesForCurrentItem = scheduledPublishRepo.GetSchedules(item.ID); if (schedulesForCurrentItem.Any()) { GetContentEditorWarningsArgs.ContentEditorWarning warning = args.Add(); warning.Icon = "Applications/32x32/information2.png"; warning.Text = "This item has been scheduled for publish."; warning.IsExclusive = false; } }
public virtual void Process(GetContentEditorWarningsArgs args) { Item item = args.Item; if (item == null) { return; } var existingSitecoreItem = new ItemData(item); if (_configurations.Any(configuration => configuration.Resolve <IPredicate>().Includes(existingSitecoreItem).IsIncluded)) { GetContentEditorWarningsArgs.ContentEditorWarning warning = args.Add(); warning.Title = RenderTitle(item); warning.Text = RenderWarning(item); } }
private static void AddTranslateWarning(Item item, GetContentEditorWarningsArgs args, IList <Sitecore.Globalization.Language> notranslation, IList <Item> fallback, string sitename) { GetContentEditorWarningsArgs.ContentEditorWarning warning = args.Add(); warning.Title = "This item is not translated for the site: " + sitename; warning.Text = "Switch to the not translated language and create a version"; foreach (var language in notranslation) { warning.AddOption(string.Format("Switch to {0}", language.GetDisplayName()), string.Format(CultureInfo.InvariantCulture, "item:load(id={0},language={1})", item.ID, language.Name)); } if (fallback.Any()) { foreach (var languageitem in fallback) { warning.AddOption(string.Format("Switch to {0} (now uses {1} language fallback)", languageitem.Language.GetDisplayName(), languageitem.OriginalLanguage.GetDisplayName()), string.Format(CultureInfo.InvariantCulture, "item:load(id={0},language={1})", item.ID, languageitem.Language.Name)); } } warning.IsExclusive = false; }
public void Process([NotNull] GetContentEditorWarningsArgs args) { Assert.ArgumentNotNull(args, nameof(args)); var user = Context.User; var allowed = user.IsAdministrator || user.IsInRole(Role.FromName("sitecore\\Sitecore Client Developing")) || false; if (!allowed) { return; } var item = args.Item; var dataProvider = item.Database .GetDataProviders() .OfType <CompositeDataProvider>() .First(); if (!dataProvider.CanBeRemovedFromHead(item.ID)) { return; } var newWarning = args.Add(); newWarning.Title = "Item is completely default"; newWarning.Text = "Current item is stored in SQL database, but it is completely default and can be removed from SQL database without any negative effects on the system."; newWarning.Options.Add(new Pair <string, string>("Remove item SQL data", "item:removesqldata")); newWarning.Options.Add(new Pair <string, string>("Remove item SQL data with all descendant items in this condition", "item:removesqldatawithdescendants")); foreach (var warning in args.Warnings) { if (warning.IsExclusive) { warning.IsExclusive = false; } } }
public void Process(GetContentEditorWarningsArgs args) { var item = args.Item; if (item == null || !item.Paths.IsMediaItem) { return; } if (!item.Template.InheritsTemplate(UnversionedFile) && !item.Template.InheritsTemplate(VersionedFile)) { return; } var contentEditorInfo = args.Add(); contentEditorInfo.Key = "Stendahls.Sc.BlobStorage.Cms.Pipelines.ContentEditorBlobInfo"; contentEditorInfo.Title = $"Information about blob storage"; contentEditorInfo.Text = item["Blob"]; }
public void Process(GetContentEditorWarningsArgs args) { Item item = args.Item; Assert.IsNotNull(item, "item"); ScheduledPublishRepo scheduledPublishRepo = new ScheduledPublishRepo(); using (new LanguageSwitcher(LanguageManager.DefaultLanguage)) { IEnumerable <PublishSchedule> schedulesForCurrentItem = scheduledPublishRepo.GetSchedules(item.ID); if (schedulesForCurrentItem.Any()) { GetContentEditorWarningsArgs.ContentEditorWarning warning = args.Add(); warning.Icon = Constants.SCHEDULED_PUBLISH_ICON; warning.Text = Constants.SCHEDULED_PUBLISH_NOTIFICATION; warning.IsExclusive = false; } } }
public void Process(GetContentEditorWarningsArgs args) { var item = args.Item; if (item == null) { return; } if (!item.IsProfileMap() || item.HasTrackingField()) { return; } GetContentEditorWarningsArgs.ContentEditorWarning key = args.Add(); key.Key = "Sitecore.Pipelines.GetContentEditorWarnings.ProfileMapTrackingFieldNotSet"; key.IsExclusive = false; key.Title = "No tracking field set on profile map."; key.Text = $"Before publishing a profile map you should associate it with a profile card or set custom profile key values."; key.HideFields = false; }
public void Process(GetContentEditorWarningsArgs args) { Item item = args.Item; // If Item is null return if (item == null) { return; } //Check if the current item has sticky notes if (item.Fields["StickyNotes"] != null && item.Fields["StickyNotes"].Value != null) { GetContentEditorWarningsArgs.ContentEditorWarning warning = args.Add(); warning.Title = Translate.Text("Following are the sticky notes added to this item"); StringBuilder warningText = new StringBuilder(); string stickyNoteOnItem = item.Fields["StickyNotes"].Value.ToString(); if (!string.IsNullOrEmpty(stickyNoteOnItem)) { //Read through all the sticky notes available on the item var stickyNotes = JsonConvert.DeserializeObject <StickyNotes>(stickyNoteOnItem); if (stickyNotes != null && stickyNotes.notesOnAnItem != null && stickyNotes.notesOnAnItem.Any()) { foreach (var note in stickyNotes.notesOnAnItem) { if (note.Properties != null && !string.IsNullOrEmpty(note.Properties.Text)) { warningText.AppendFormat("{0} was added by {1} on {2}", note.Properties.Text, note.Properties.UserName, note.Properties.DateCreated); warningText.Append("<br>"); } } } } //Assign the sticky notes to the warning warning.Text = warningText.ToString(); } }
public virtual void Process(GetContentEditorWarningsArgs args) { Item item = args.Item; if (item == null) return; var existingSitecoreItem = new ItemData(item); var configuration = _configurations.FirstOrDefault(config => config.Resolve<IPredicate>().Includes(existingSitecoreItem).IsIncluded); if (configuration != null) { var evaluator = configuration.Resolve<IEvaluator>(); var warningObject = evaluator.EvaluateEditorWarning(item); if (warningObject != null) { GetContentEditorWarningsArgs.ContentEditorWarning warning = args.Add(); warning.Title = warningObject.Title; warning.Text = warningObject.Message; } } }
public void Process(GetContentEditorWarningsArgs arguments) { Assert.ArgumentNotNull(arguments, "arguments"); if (arguments.Item == null || Sitecore.Context.User.IsAdministrator) { return; } NotificationsController controller = new NotificationsController(); List <Notification> notifications = notifications = controller.Get(arguments.Item, arguments.Item.HasPresentation()); if (notifications.Count > 0) { for (int i = 0; i < notifications.Count; i++) { var notification = arguments.Add(); notification.Text = notifications[i].Message; notification.Icon = Constants.WarningIcon; notification.AddOption(notifications[i].CommandDisplayName, notifications[i].Command); } } }
public void Process(GetContentEditorWarningsArgs args) { Assert.ArgumentNotNull(args, nameof(args)); var item = args.Item; Assert.IsNotNull(item, "item to process"); var databaseName = item.Database.Name; var itemID = item.ID; JsonDataProvider dataProvider; if (!JsonDataProvider.Instances.TryGetValue(databaseName, out dataProvider) || dataProvider == null) { return; } var mappings = dataProvider.Mappings.OfType<IFileMapping>().ToArray(); if (mappings.Length == 0) { return; } var mapping = mappings.FirstOrDefault(x => x.GetItemDefinition(itemID) != null); if (mapping != null) { var jsonItem = args.Add(); jsonItem.Title = "JSON Read-Only Item"; jsonItem.Text = $"This item is stored in <b>{mapping.Name}</b> file mapping{(mapping.ReadOnly ? ", but is read-only as configured in the mapping settings" : "")}. The file path is:<br />{MainUtil.MapPath(mapping.FilePath)}"; } IFileMapping overrideMapping = null; var overrideJsonMapping = Registry.GetValue("overrideJsonMapping"); if (!string.IsNullOrEmpty(overrideJsonMapping)) { mapping = mappings.FirstOrDefault(m => m.DisplayName == overrideJsonMapping && m.AcceptsNewChildrenOf(item.ID)); overrideMapping = mapping; } var firstMapping = mappings.FirstOrDefault(m => m.AcceptsNewChildrenOf(item.ID)); mapping = mapping ?? firstMapping; if (mapping == null) { return; } var createChildren = args.Add(); createChildren.Title = "JSON Children"; createChildren.Text = $"All new children of this item will be stored in the <b>{mapping.Name}</b> file mapping. The file path is:<br />{MainUtil.MapPath(mapping.FilePath)}"; if (mappings.Length > 1) { foreach (IFileMapping otherMapping in mappings) { if (otherMapping == mapping || !otherMapping.AcceptsNewChildrenOf(itemID)) { continue; } var reset = overrideMapping != null && firstMapping == otherMapping; if (reset) { createChildren.Options.Add(new Pair<string, string>("Change to " + otherMapping.DisplayName + " (remove override)", "json:override(action=reset)".FormatWith(HttpUtility.UrlEncode(otherMapping.DisplayName)))); } else { createChildren.Options.Add(new Pair<string, string>("Change to " + otherMapping.DisplayName, "json:override(id={0})".FormatWith(HttpUtility.UrlEncode(otherMapping.DisplayName)))); } } } }
// Adds warning message to Content Editor and specifies its details protected virtual void AddWarning(GetContentEditorWarningsArgs args) { var warning = args.Add(); warning.Title = Globalization.Translate.Text(WarningTitleKey); warning.Text = Globalization.Translate.Text(WarningTextKey); }
public void Process(GetContentEditorWarningsArgs args) { Assert.IsNotNull(args, "Redirect Manager: displaylinks GetContentEditorWarningsArgs"); SiteContext siteContext = DisplayLinks.ResolveSiteContext(args.Item); if (siteContext == null) { Log.Error("Redirect Manager: displaylinks could not resolve site", this); return; } //Build and display the primary link for the item as long as it's not a media item and it has a layout. if (DisplayLinks.DisplayModeEnabled(DisplayLinks.DisplayModeEnum.Primary) && !args.Item.Paths.IsMediaItem && args.Item.Visualization.Layout != null) { string itemUrl = UrlFromItemCompare(args.Item, siteContext); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendFormat("<div><a href=\"{0}\" target=\"_blank\"><input class=\"scEditorHeaderQuickInfoInput\" style=\"Width:500px\" readonly=\"readonly\" value=\"{0}\" /></a></div>", itemUrl); if (stringBuilder.Length > 0) { args.Add("Primary Link", stringBuilder.ToString()); } } //Build and display any redirects that exist for the item if (DisplayLinks.DisplayModeEnabled(DisplayLinks.DisplayModeEnum.Redirects)) { StringBuilder stringBuilder2 = new StringBuilder(); int num = 1; IEnumerable <IRedirect> redirectItems = DisplayLinks.GetRedirectItems(args.Item); if (redirectItems != null) { foreach (IRedirect current in redirectItems) { if (!this.IsSamePath(args, siteContext, current.RequestPath)) { if (Config.SiteContextChecking) { string empty = string.Empty; string txtQueryViewControls = string.Empty; string txtQueryControls = string.Empty; string txtRedirectInfo = string.Format("<a href=\"#\" onclick='javascript:return scForm.invoke(\"{0}\")' title=\"Delete redirect\">[ Delete ]</a>", string.Format("redirect:delete(targetId={0}, requestPath={1})", args.Item.ID, HttpUtility.HtmlEncode(current.RequestPath))); //logic here for querystring relevant information to be displayed based on the existence or lack of a querystring for a given redirect if (string.IsNullOrEmpty(current.QueryString)) { //I don't need the ItemID for the querystring gen, but for perms checking. I DO need the path of this particular redirect in order to gen //an invocation which will provide the ability to add a querystring to that particular redirect. txtQueryControls = string.Format("<a href=\"#\" onclick='javascript:return scForm.invoke(\"{0}\")' title=\"Add QueryString\">[ Add QueryString ]</a>", string.Format("querystring:add(targetId={0}, requestPath={1})", args.Item.ID, HttpUtility.HtmlEncode(current.RequestPath))); } else { //gen invocation for viewing the querystring to append to the deletion invocation presentation txtQueryViewControls = string.Format("<a href=\"#\" onclick='javascript:return scForm.invoke(\"{0}\")' title=\"View QueryString\">[ View QueryString ]</a>", string.Format("querystring:view(targetId={0}, requestPath={1})", current.QueryString, HttpUtility.HtmlEncode(current.RequestPath))); //gen invocation to delete the querystring, adds the above invocation to complete the presentation of the querystring remove/view for the stringbuilder below txtQueryControls = string.Format("<a href=\"#\" onclick='javascript:return scForm.invoke(\"{0}\")' title=\"Delete QueryString\">[ Delete QueryString ]</a>", string.Format("querystring:delete(targetId={0}, queryString={1}, requestPath={2})", args.Item.ID, current.QueryString, HttpUtility.HtmlEncode(current.RequestPath))) + " " + txtQueryViewControls; } string txtLanguage = string.Empty; //TODO: //this thing is hard-coded for English, which is entirely unhelpful for anyone else. Maybe look into this later... if (LinkManager.LanguageEmbedding != LanguageEmbedding.Never) { txtLanguage = "<span style=\"color:#999999\">/en</span>"; } stringBuilder2.AppendFormat("<div><span style=\"font-weight: bold; width:300px\">{4}<a href=\"{0}\" target=\"_blank\">{0}</a><div style=\"float:right\"></span><span>{1}</span> <span>[ {2} ]</span> <span>[ {3} ]</span> <span>{5}</span> <span>{4}</span> <span>{6}</span> </div></div><hr style=\"border: 0; height: 0; margin-right: 20px; border-top: 1px solid rgba(0, 0, 0, 0.1);\">", new object[] { current.RequestPath, txtRedirectInfo, current.Enabled ? "<span style=\"color:green\">Enabled</span>" : "<span style=\"text-decoration:line-through; color:red\">Enabled</span>", current.ResponseStatusCode, empty, txtQueryControls, txtLanguage }); } else { stringBuilder2.AppendFormat("<div><a href=\"{0}\" target=\"_blank\"><input class=\"scEditorHeaderQuickInfoInput\" style=\"Width:500px\" readonly=\"readonly\" value=\"{0}\" /></a></div>", current.RequestPath); } } if (num >= Config.DisplayMaxLinks) { stringBuilder2.AppendFormat("<div style=\"Width:500px\" readonly=\"readonly\"><br />Limited to displaying the first {0} of {1} items</div>", Config.DisplayMaxLinks, redirectItems.Count <IRedirect>()); break; } num++; } } if (stringBuilder2.Length > 0) { args.Add("Urls that redirect here", stringBuilder2.ToString()); } } if (DisplayLinks.DisplayModeEnabled(DisplayLinks.DisplayModeEnum.Aliases)) { StringBuilder stringBuilder3 = new StringBuilder(); IEnumerable <Item> aliasItems = DisplayLinks.GetAliasItems(args.Item); int num2 = 1; if (aliasItems != null) { foreach (Item current2 in aliasItems) { string arg = current2.Paths.Path.ToLowerInvariant().Replace("/sitecore/system/aliases".ToLowerInvariant(), string.Empty); stringBuilder3.AppendFormat("<div><a href=\"{0}\" target=\"_blank\"><input class=\"scEditorHeaderQuickInfoInput\" style=\"Width:500px\" readonly=\"readonly\" value=\"{0}\" /></a></div>", arg); if (num2 >= Config.DisplayMaxLinks) { stringBuilder3.AppendFormat("<div style=\"Width:500px\" readonly=\"readonly\"><br />Limited to displaying the first {0} of {1} items</div>", Config.DisplayMaxLinks, aliasItems.Count <Item>()); break; } num2++; } } if (stringBuilder3.Length > 0) { string str = Settings.AliasesActive ? string.Empty : " (aliases not active)"; args.Add("Aliases" + str, stringBuilder3.ToString()); } } }
// Methods #region Public methods /// <summary> /// Gets the field value. /// </summary> /// <param name="args">The arguments.</param> public void Process(GetContentEditorWarningsArgs args) { if (args != null) { Item item = args.Item; if (item != null) { if (Settings.GetBoolSetting("VersionManager.ShowContentEditorWarnings", true) && VersionManager.IsItemUnderRoots(item)) { int count = item.Versions.Count; int maximum = Settings.GetIntSetting("VersionManager.NumberOfVersionsToKeep", 5); if (maximum < 1) { return; } if (count >= maximum) { GetContentEditorWarningsArgs.ContentEditorWarning warning = args.Add(); if (count == maximum) { warning.Title = Translate.Text("The current item has reached maximum allowed number of versions."); } if (count > maximum) { warning.Title = Translate.Text("The current item has exceeded maximum allowed number of versions."); warning.AddOption("Delete obsolete versions", "version:clean"); } if (Settings.GetBoolSetting("VersionManager.AutomaticCleanupEnabled", false)) { warning.Text = this.GetText(item, count - maximum + 1) + "."; } else { warning.Text = string.Empty; } warning.IsExclusive = false; warning.HideFields = false; } } } } }
private static void ProcessNonSiteItem(Item item, GetContentEditorWarningsArgs args) { Version[] versionNumbers = item.Versions.GetVersionNumbers(false); if (versionNumbers != null && versionNumbers.Length > 0) { return; } LanguageCollection languages = LanguageManager.GetLanguages(Sitecore.Context.ContentDatabase); int lancount = 0; var languageList = new List <string>(); foreach (Language language in languages) { if (HasLanguage(item, language)) { lancount++; languageList.Add(language.ToString()); if (lancount > 3) { //limit to 4, but add en if precent because this is the default if (!languageList.Contains("en")) { var defaultlang = Sitecore.Globalization.Language.Parse("en"); if (defaultlang != null && HasLanguage(item, defaultlang)) { languageList.Add(defaultlang.ToString()); } } break; } } } if (languageList.Any()) { GetContentEditorWarningsArgs.ContentEditorWarning contentEditorWarning = args.Add(); contentEditorWarning.Title = string.Format(Translate.Text("The current item does not have a version in \"{0}\"."), (object)item.Language.GetDisplayName()); if (item.Access.CanWriteLanguage() && item.Access.CanWrite()) { contentEditorWarning.Text = Translate.Text("To create a version, click Add a New Version or Switch language."); contentEditorWarning.AddOption(Translate.Text("Add a new version."), "item:addversion"); foreach (var languageitem in languageList) { contentEditorWarning.AddOption(string.Format("Switch to {0}", languageitem), string.Format(CultureInfo.InvariantCulture, "item:load(id={0},language={1})", item.ID, languageitem)); } contentEditorWarning.IsExclusive = true; } else { contentEditorWarning.IsExclusive = false; } contentEditorWarning.HideFields = true; contentEditorWarning.Key = HasNoVersions.Key; } else { GetContentEditorWarningsArgs.ContentEditorWarning contentEditorWarning = args.Add(); contentEditorWarning.Title = string.Format(Translate.Text("The current item does not have a version in \"{0}\"."), (object)item.Language.GetDisplayName()); if (item.Access.CanWriteLanguage() && item.Access.CanWrite()) { contentEditorWarning.Text = Translate.Text("To create a version, click Add a New Version or click Add on the Versions tab."); contentEditorWarning.AddOption(Translate.Text("Add a new version."), "item:addversion"); contentEditorWarning.IsExclusive = true; } else { contentEditorWarning.IsExclusive = false; } contentEditorWarning.HideFields = true; contentEditorWarning.Key = HasNoVersions.Key; } }