コード例 #1
0
        public static void CreateVersionForEachSupportedSiteLanguage(this Item item, SiteInfo site)
        {
            if (!site.ShouldAutoCreateLanguageVersions())
            {
                Log.Warn(
                    $"Verndale.Feature.LanguageFallback: Item Version Creation triggered for {site.Name} but automatic version creation is not enabled for this site.",
                    typeof(ItemExtensions));
                return;
            }

            var languages = site.GetSupportedLanguages();

            foreach (Language language in languages)
            {
                Item localizedItem = item.Database.GetItem(item.ID, language);

                //if Versions.Count == 0 then no entries exist in the given language
                if (localizedItem.Versions.Count == 0)
                {
                    localizedItem.Editing.BeginEdit();
                    localizedItem.Versions.AddVersion();
                    localizedItem.Editing.EndEdit();
                }
            }
        }