Пример #1
0
        public virtual void InstallPagesCommandWidgets()
        {
            var configManager = ConfigManager.GetManager();

            using (new ElevatedModeRegion(configManager))
            {
                ContentViewConfig config;
                var masterView = ConfigurationsHelper.GetContentViewElement <MasterGridViewElement>(configManager,
                                                                                                    "FrontendPages", "FrontendPagesListView",
                                                                                                    out config);

                // TreeTable
                var actionsMenuElements = ConfigurationsHelper.GetActionsMenuItems(masterView, "TreeTable");

                bool   needSaveChanges = false;
                string commandName     = "unlockPageCustom";

                var command = actionsMenuElements.Elements
                              .Where(e => e.WidgetType == typeof(CommandWidget) &&
                                     ((CommandWidgetElement)e).CommandName == commandName)
                              .FirstOrDefault();

                if (command == null)
                {
                    var commandWidget = ConfigurationsHelper.CreateCommandWidgetElement(actionsMenuElements, string.Empty,
                                                                                        commandName, "UnlockPage", "Unlock page");
                    actionsMenuElements.Add(commandWidget);
                    needSaveChanges = true;
                }

                // ListView
                var actionsMenuItemsElementList = ConfigurationsHelper.GetActionsMenuItems(masterView, "Grid");

                var commandList = actionsMenuItemsElementList.Elements
                                  .Where(e => e.WidgetType == typeof(CommandWidget) &&
                                         ((CommandWidgetElement)e).CommandName == commandName)
                                  .FirstOrDefault();

                if (commandList == null)
                {
                    var commandWidget = ConfigurationsHelper.CreateCommandWidgetElement(actionsMenuItemsElementList, string.Empty,
                                                                                        commandName, "UnlockPage", "Unlock page");
                    actionsMenuItemsElementList.Add(commandWidget);
                    needSaveChanges = true;
                }

                if (needSaveChanges)
                {
                    configManager.SaveSection(config);
                }
            }
        }
Пример #2
0
        public virtual void InstallNewsExtensionScript()
        {
            var configManager = ConfigManager.GetManager();

            using (new ElevatedModeRegion(configManager))
            {
                ContentViewConfig config;
                string            contentView = NewsDefinitions.BackendDefinitionName;
                string            viewName    = NewsDefinitions.BackendListViewName;

                var masterView = ConfigurationsHelper.GetContentViewElement <ContentViewMasterElement>(configManager,
                                                                                                       contentView, viewName,
                                                                                                       out config);

                bool needSave;
                ConfigurationsHelper.AddExtensionScript(masterView, "~/News/NewsExtensionScript.js", "newsMasterViewLoadedExtended", out needSave);
                if (needSave)
                {
                    configManager.SaveSection(masterView.Section, true);
                }
            }
            configManager.Dispose();
        }
Пример #3
0
        public static void ModifyPressReleasesListViewToolbarCreateButton()
        {
            // 'Press releases' dynamic module, 'Press release' content type
            string contentViewControlName = "Telerik.Sitefinity.DynamicTypes.Model.Pressreleases.PressReleaseBackendDefinition";
            string viewName = "Press releaseBackendList";

            var configManager = ConfigManager.GetManager();

            using (new ElevatedModeRegion(configManager))
            {
                ContentViewConfig config;
                var masterView = ConfigurationsHelper.GetContentViewElement <MasterGridViewElement>(configManager, contentViewControlName, viewName, out config);

                var toolbar = masterView.ToolbarConfig.Sections.Elements.Where(e => e.Name == "toolbar").First();

                CommandWidgetElement createItem = toolbar.Items.Elements.Where(i => i.Name == "CreateItemWidget").First() as CommandWidgetElement;
                createItem.Text = "CREATE PRESS RELEASES";

                //configManager.SaveSection(config, true);
                configManager.SaveSection(createItem.Section, true);
            }
            configManager.Dispose();
        }
Пример #4
0
        public static void ModifyRecurrencyFieldCssClass()
        {
            string contentViewControlName = EventsDefinitions.BackendDefinitionName; // "EventsBackend"
            string viewName    = EventsDefinitions.BackendEditDetailsViewName;       // "EventsBackendEdit"
            string sectionName = "MainSection";
            string fieldName   = "RecurrencyField";

            var configManager = ConfigManager.GetManager();

            using (new ElevatedModeRegion(configManager))
            {
                ContentViewConfig config;
                var detailView = ConfigurationsHelper.GetContentViewElement <DetailFormViewElement>(configManager, contentViewControlName, viewName, out config);

                var fieldElement = ConfigurationsHelper.GetFieldElement(detailView, sectionName, fieldName);

                // Set additional CSS class
                fieldElement.CssClass += " myClass";

                configManager.SaveSection(fieldElement.Section);
            }
            configManager.Dispose();
        }