public override void ModifyTree(TreePanel treePanel, IMainInterface mainInterface)
        {
            if (!Context.Current.Resolve<GlobalizationSection>().Enabled)
                return;

            // Setup tree bottom toolbar.
            Toolbar bottomToolbar = new Toolbar();
            treePanel.BottomBar.Add(bottomToolbar);

            ToolbarTextItem textItem = new ToolbarTextItem { Text = "Language: " };
            bottomToolbar.Items.Add(textItem);

            IconCombo comboBox = new IconCombo
            {
                EmptyText = "Select...",
                Width = Unit.Pixel(100),
                Editable = false
            };
            comboBox.Listeners.Select.Handler = string.Format(@"
                Ext.net.DirectMethods.LanguageChooser.ChangeLanguage(record.get('value'),
                {{
                    url: '{0}',
                    success: function(result)
                    {{
                        stbStatusBar.setStatus({{ text: 'Changed language', iconCls: '', clear: true }});
                    }}
                }});",
                Context.AdminManager.GetAdminDefaultUrl());

            foreach (Language language in Context.Current.Resolve<ILanguageManager>().GetAvailableLanguages())
            {
                IconComboListItem listItem = new IconComboListItem(language.Title, language.Name, language.IconUrl);
                comboBox.Items.Add(listItem);
                if (language.Name == Context.AdminManager.CurrentAdminLanguageBranch)
                {
                    comboBox.SelectedItem.Text = listItem.Text;
                    comboBox.SelectedItem.Value = listItem.Value;
                }
            }

            bottomToolbar.Items.Add(comboBox);
        }
Example #2
0
        protected override void OnInit(EventArgs e)
        {
            if (Discriminator != null)
            {
                Title = "New " + TypeDefinition.Title;
            }
            else
            {
                if (SelectedLanguageCode != null)
                {
                    ContentItem translatedItem = Engine.LanguageManager.GetTranslationDirect(SelectedItem, SelectedLanguageCode);
                    if (translatedItem == null)
                    {
                        Title = string.Format("New Translation of '{0}'", SelectedItem.Title);
                        ContentItem selectedItem = Engine.ContentTypes.CreateInstance(SelectedItem.GetType(), SelectedItem.Parent);
                        selectedItem.Language = SelectedLanguageCode;
                        selectedItem.TranslationOf = SelectedItem;
                        SelectedItem.Translations.Add(selectedItem);
                        selectedItem.Parent = null;
                        zeusItemEditView.CurrentItem = selectedItem;
                    }
                    else
                    {
                        zeusItemEditView.CurrentItem = translatedItem;
                        Title = "Edit \"" + translatedItem.Title + "\"";
                    }
                }
                else
                {
                    zeusItemEditView.CurrentItem = SelectedItem;
                    Title = "Edit \"" + SelectedItem.Title + "\"";
                }
            }

            bool languagesVisible = GlobalizationEnabled && Engine.LanguageManager.CanBeTranslated((ContentItem) zeusItemEditView.CurrentItem);
            txiLanguages.Visible = ddlLanguages.Visible = languagesVisible;

            if (!Engine.Resolve<AdminSection>().Versioning.Enabled || !Engine.SecurityManager.IsAuthorized(SelectedItem, User, Operations.Version))
            {
                btnSaveUnpublished.Visible = btnSaveUnpublished2.Visible = false;
                btnPreview.Visible = btnPreview2.Visible = false;
                btnSave.Text = btnSave2.Text = "Save";
            }

            if (!ExtNet.IsAjaxRequest && GlobalizationEnabled)
            {
                foreach (Language language in Engine.Resolve<ILanguageManager>().GetAvailableLanguages())
                {
                    IconComboListItem listItem = new IconComboListItem(language.Title, language.Name, language.IconUrl);
                    ddlLanguages.Items.Add(listItem);
                }
            }

            base.OnInit(e);
        }