Exemplo n.º 1
0
 public CmsPageEditMenuAction(CmsEditMenuActionCategory actionCategory, CmsEditMenuActionItem actionItem, CmsEditMode requiredEditMode, int sortOrdinal, RenderToString renderDelegate)
 {
     ActionCategory       = actionCategory;
     ActionItem           = actionItem;
     RequiredEditMode     = requiredEditMode;
     SortOrdinal          = sortOrdinal;
     doRenderToString     = renderDelegate;
     CreateNewPageOptions = new CmsCreateNewPageOptions();
 }
Exemplo n.º 2
0
            public static string CreateNewPage(CmsPageEditMenuAction action, CmsPage pageToRenderFor, CmsLanguage langToRenderFor)
            {
                action.CreateNewPageOptions = CmsCreateNewPageOptions.CreateInstanceWithDefaultsForCurrentUser(pageToRenderFor);
                NameValueCollection createPageParams = action.CreateNewPageOptions.GetCreatePagePopupParams();

                if (action.CreateNewPageOptions.RequiresUserInput())
                {
                    return(RenderPopupLink("CreateNewPagePath", "/_admin/createPage", createPageParams, pageToRenderFor, langToRenderFor, "<strong>Create</strong> a new sub-page", 500, 400));
                }
                else
                {
                    return(RenderLink("CreateNewPagePath", "/_admin/createPage", createPageParams, pageToRenderFor, langToRenderFor, "<strong>Create</strong> a new sub-page"));
                }
            }
        public static CmsCreateNewPageOptions ReadFromQueryString()
        {
            int parentId = PageUtils.getFromForm("ParentPageId", -1);
            CmsCreateNewPageOptions ret = new CmsCreateNewPageOptions();

            // -- modify smart defaults if the query string isn't formatted correctly.
            if (parentId >= 0)
            {
                CmsPage parentPage = CmsContext.getPageById(parentId);
                if (parentPage.ID >= 0)
                {
                    parentId = parentPage.ID;
                    ret      = CreateInstanceWithDefaultsForCurrentUser(parentPage);
                }
            }

            ret.PromptUserForFilename   = PageUtils.getFromForm("pFilename", ret.PromptUserForFilename);
            ret.PromptUserForTitle      = PageUtils.getFromForm("pTitle", ret.PromptUserForTitle);
            ret.PromptUserForMenuTitle  = PageUtils.getFromForm("pMenuTitle", ret.PromptUserForMenuTitle);
            ret.PromptUserForShowInMenu = PageUtils.getFromForm("pShowInMenu", ret.PromptUserForShowInMenu);
            ret.PromptUserForTemplate   = PageUtils.getFromForm("pTemplate", ret.PromptUserForTemplate);
            ret.PromptUserForParentPage = PageUtils.getFromForm("pParentPage", ret.PromptUserForParentPage);

            List <CmsPageLanguageInfo> langInfos = new List <CmsPageLanguageInfo>();

            foreach (CmsLanguage lang in CmsConfig.Languages)
            {
                CmsPageLanguageInfo langInfo = CmsPageLanguageInfo.GetFromHaystack(lang, ret.NewPageLanguageInfos); // returns a new CmsPageLangInfo if not found
                langInfo.languageShortCode       = lang.shortCode;
                langInfo.menuTitle               = PageUtils.getFromForm("MenuTitle_" + lang.shortCode, langInfo.menuTitle);
                langInfo.title                   = PageUtils.getFromForm("Title_" + lang.shortCode, langInfo.title);
                langInfo.searchEngineDescription = PageUtils.getFromForm("SEDesc_" + lang.shortCode, langInfo.searchEngineDescription);
                langInfo.name = PageUtils.getFromForm("Name_" + lang.shortCode, langInfo.name);

                langInfos.Add(langInfo);
            } // foreach lang

            ret.NewPageLanguageInfos = langInfos.ToArray();

            ret.ShowInMenu   = PageUtils.getFromForm("ShowInMenu", ret.ShowInMenu);
            ret.Template     = PageUtils.getFromForm("Template", ret.Template);
            ret.ParentPageId = parentId;

            return(ret);
        }
        public static CmsCreateNewPageOptions CreateInstanceWithNoUserPrompts(CmsPageLanguageInfo[] newPageLangInfos, bool newPageShowInMenu, string newPageTemplate, int newPageParentId)
        {
            CmsCreateNewPageOptions ret = new CmsCreateNewPageOptions();

            ret.PromptUserForFilename   = false;
            ret.PromptUserForTitle      = false;
            ret.PromptUserForMenuTitle  = false;
            ret.PromptUserForShowInMenu = false;
            ret.PromptUserForTemplate   = false;
            ret.PromptUserForParentPage = false;

            ret.NewPageLanguageInfos = newPageLangInfos;
            ret.ShowInMenu           = newPageShowInMenu;
            ret.Template             = newPageTemplate;
            ret.ParentPageId         = newPageParentId;

            return(ret);
        }
        public static CmsCreateNewPageOptions CreateInstanceWithDefaultsForCurrentUser(CmsPage editMenuPage)
        {
            CmsCreateNewPageOptions ret = new CmsCreateNewPageOptions();
            // CreateNewPage_DefaultTemplate; use "~~ParentTemplate~~" for the new page's parent's template
            string defaultTemplate = CmsConfig.getConfigValue("CreateNewPage_DefaultTemplate", editMenuPage.TemplateName);

            if (string.Compare(defaultTemplate, "~~ParentTemplate~~", true) == 0)
            {
                defaultTemplate = editMenuPage.TemplateName;
            }

            if (CmsContext.currentUserIsSuperAdmin)
            {
                ret.PromptUserForFilename   = true;
                ret.PromptUserForTitle      = true;
                ret.PromptUserForMenuTitle  = true;
                ret.PromptUserForShowInMenu = true;
                ret.PromptUserForTemplate   = true;
                ret.PromptUserForParentPage = true;

                List <CmsPageLanguageInfo> langInfos = new List <CmsPageLanguageInfo>();
                foreach (CmsLanguage lang in CmsConfig.Languages)
                {
                    CmsPageLanguageInfo l = new CmsPageLanguageInfo();
                    l.languageShortCode = lang.shortCode;
                    l.name      = "";
                    l.title     = "";
                    l.menuTitle = "";
                    l.searchEngineDescription = "";

                    langInfos.Add(l);
                }

                ret.NewPageLanguageInfos = langInfos.ToArray();

                ret.ShowInMenu   = true;
                ret.Template     = defaultTemplate;
                ret.ParentPageId = editMenuPage.ID;
            }
            else if (editMenuPage.currentUserCanWrite)
            {
                ret.PromptUserForFilename   = true;
                ret.PromptUserForTitle      = true;
                ret.PromptUserForMenuTitle  = false;
                ret.PromptUserForShowInMenu = false;
                ret.PromptUserForTemplate   = false;
                ret.PromptUserForParentPage = false;

                List <CmsPageLanguageInfo> langInfos = new List <CmsPageLanguageInfo>();
                foreach (CmsLanguage lang in CmsConfig.Languages)
                {
                    CmsPageLanguageInfo l = new CmsPageLanguageInfo();
                    l.languageShortCode = lang.shortCode;
                    l.name      = "";
                    l.title     = "";
                    l.menuTitle = "";
                    l.searchEngineDescription = "";

                    langInfos.Add(l);
                }

                ret.NewPageLanguageInfos = langInfos.ToArray();

                ret.ShowInMenu   = true;
                ret.Template     = defaultTemplate;
                ret.ParentPageId = editMenuPage.ID;
            }
            else
            {
                ret.PromptUserForFilename   = false;
                ret.PromptUserForTitle      = false;
                ret.PromptUserForMenuTitle  = false;
                ret.PromptUserForShowInMenu = false;
                ret.PromptUserForTemplate   = false;
                ret.PromptUserForParentPage = false;

                List <CmsPageLanguageInfo> langInfos = new List <CmsPageLanguageInfo>();
                foreach (CmsLanguage lang in CmsConfig.Languages)
                {
                    CmsPageLanguageInfo l = new CmsPageLanguageInfo();
                    l.languageShortCode = lang.shortCode;
                    l.name      = "";
                    l.title     = "";
                    l.menuTitle = "";
                    l.searchEngineDescription = "";

                    langInfos.Add(l);
                }

                ret.NewPageLanguageInfos = langInfos.ToArray();

                ret.ShowInMenu   = true;
                ret.Template     = defaultTemplate;
                ret.ParentPageId = editMenuPage.ID;
            }

            return(ret);
        }