protected void OnItemCreated(object sender, EventArgs args) { if (args == null) { return; } if (String.IsNullOrEmpty(PathsToCheckForLanguageVersions)) { return; } var createdArgs = Event.ExtractParameter(args, 0) as ItemCreatedEventArgs; if (createdArgs == null) { return; } var item = createdArgs.Item; var pathsList = PathsToCheckForLanguageVersions.Split('|'); foreach (var path in pathsList) { if (item.Paths.FullPath.ToLower().Contains(path.ToLower())) { LanguageHelper.CreateVersionInEachLanguage(item); break; } } }
protected void Run(ClientPipelineArgs args) { Item item = base.DeserializeItems(args.Parameters["items"])[0]; if (item == null) { return; } if (SheerResponse.CheckModified()) { //prompt user they want to add versions if (args.IsPostBack) { if (args.Result == "yes") { LanguageHelper.CreateVersionInEachLanguage(item); Sitecore.Web.UI.HtmlControls.DataContext contentEditorDataContext = Sitecore.Context.ClientPage.FindControl("ContentEditorDataContext") as Sitecore.Web.UI.HtmlControls.DataContext; contentEditorDataContext.SetFolder(item.Uri); } } else { StringBuilder builder = new StringBuilder(); builder.Append("Create version for each language?"); SheerResponse.Confirm(builder.ToString()); args.WaitForPostBack(); } } }
protected void CopyVersion(Item sourceVersion, Item targetLangItem) { // if the checkbox to add all other language versions was checked, // call the CreateVersionInEachLanguage LanguageHelper method, it will create versions in all languages // otherwise, if the OnlyCreateIfNoVersion checkbox was checked // (meaning if it already exists in a language, don't just create another version of it) // OR if there is no version yet, then add a version in the target language // and finally, only if user specified they want the field values copied via the chkOnlyVersion checkbox, call CopyFields method if (AddAllOtherLanguages) { LanguageHelper.CreateVersionInEachLanguage(sourceVersion); } else if (!OnlyCreateIfNoVersion || targetLangItem.Versions.Count == 0) { using (new EditContext(targetLangItem)) { var newVer = targetLangItem.Versions.AddVersion(); if (!TransferOnlyVersion) { CopyFields(newVer, sourceVersion); } } } // if delete source checkbox was checked (in a case where content is being transferred from one language to another) // then call ItemManager.RemoveVersion if (DeleteSource) { using (new EditContext(sourceVersion)) { ItemManager.RemoveVersion(sourceVersion); } } }