コード例 #1
0
        /// <summary>
        /// Render the "Add an event"
        /// </summary>
        /// <param name="action"></param>
        /// <param name="pageToRenderFor"></param>
        /// <param name="langToRenderFor"></param>
        /// <returns></returns>
        protected static string AddEventEditMenuRender(CmsPageEditMenuAction action, CmsPage pageToRenderFor, CmsLanguage langToRenderFor)
        {
            NameValueCollection createPageParams = action.CreateNewPageOptions.GetCreatePagePopupParams();

            if (action.CreateNewPageOptions.RequiresUserInput())
            {
                return(CmsPageEditMenu.DefaultStandardActionRenderers.RenderPopupLink("CreateNewPagePath", "/_admin/createPage", createPageParams, pageToRenderFor, langToRenderFor, "<strong>Add</strong> an event", 500, 400));
            }
            else
            {
                return(CmsPageEditMenu.DefaultStandardActionRenderers.RenderLink("CreateNewPagePath", "/_admin/createPage", createPageParams, pageToRenderFor, langToRenderFor, "<strong>Add</strong> an event"));
            }
        }
コード例 #2
0
        public static string DeleteThisFileDetailsPageAction(CmsPageEditMenuAction action, CmsPage pageToRenderFor, CmsLanguage langToRenderFor)
        {
            NameValueCollection paramList = new NameValueCollection();
            paramList.Add("target", pageToRenderFor.Id.ToString());

            string confirmText = "Do you really want to delete this file?";
            int numPagesToDelete = pageToRenderFor.getLinearizedPages().Keys.Count;
            if (numPagesToDelete > 1)
                confirmText = "Do you really want to delete this file and all " + (numPagesToDelete - 1) + " sub-pages?";

            string deleteFilesUrl = CmsContext.getUrlByPagePath(CmsConfig.getConfigValue("DeleteFileLibraryPath", "/_admin/actions/deleteFileLibrary"), paramList, langToRenderFor);
            return "<a href=\"#\" onclick=\"EditMenuConfirmModal('" + confirmText + "','" + deleteFilesUrl + "',300, 300);\"><strong>Delete</strong> this file</a>";

        }
コード例 #3
0
        /// <summary>
        /// Replaces the "Delete page" command with a custom one.
        /// </summary>
        /// <param name="pageToAddCommandTo"></param>        
        public static void UpdateFileLibraryCommandsInEditMenu(CmsPage pageToAddCommandTo)
        {
            // -- only add the command if the user can author
            if (!pageToAddCommandTo.currentUserCanWrite)
                return;

            // get the existing command
            CmsPageEditMenuAction deletePageAction = pageToAddCommandTo.EditMenu.getActionItem(CmsEditMenuActionItem.DeleteThisPage);

            if (deletePageAction == null)
                return; // do not throw an exception (note: the home page does not have a deletepageaction)

            deletePageAction.doRenderToString = DeleteThisFileDetailsPageAction;            
        }
コード例 #4
0
        /// <summary>
        /// Adds the "Add a new job" menu item to the Edit Menu.
        /// </summary>
        /// <param name="pageToAddCommandTo"></param>
        /// <param name="jobAggregatorPage"></param>
        public static void AddJobPostingCommandToEditMenu(CmsPage pageToAddCommandTo, CmsPage jobAggregatorPage)
        {
            // -- only add the command if the user can author
            if (!pageToAddCommandTo.currentUserCanWrite)
            {
                return;
            }

            // -- base the command off the existing "create new sub-page" command
            CmsPageEditMenuAction createNewSubPage = pageToAddCommandTo.EditMenu.getActionItem(CmsEditMenuActionItem.CreateNewPage);

            if (createNewSubPage == null)
            {
                throw new Exception("Fatal Error in in JobPostingAggregator placeholder - could not get the existing CreateNewPage action");
            }

            CmsPageEditMenuAction CreateNewJobMenuAction = createNewSubPage.Copy(); // copy everything from the CreateNewPage entry

            // -- configure this command to not prompt authors for any information.
            //    the minimum information needed to create a page is the new page's filename (page.name)
            //      -- get the next unique filename
            string newPageName = "";

            for (int jobNum = 1; jobNum < int.MaxValue; jobNum++)
            {
                string pageNameToTest = "Job " + jobNum.ToString();
                if (!CmsContext.childPageWithNameExists(jobAggregatorPage.Id, pageNameToTest))
                {
                    newPageName = pageNameToTest;
                    break;
                }
            }


            string newPageTitle     = "";
            string newPageMenuTitle = "";
            string newPageSearchEngineDescription = "";
            bool   newPageShowInMenu = false;
            string newPageTemplate   = CmsConfig.getConfigValue("JobPosting.DetailsTemplateName", "_JobPosting");

            CreateNewJobMenuAction.CreateNewPageOptions = CmsCreateNewPageOptions.GetInstanceWithNoUserPrompts(newPageName, newPageTitle, newPageMenuTitle, newPageSearchEngineDescription, newPageShowInMenu, newPageTemplate, jobAggregatorPage.Id);

            CreateNewJobMenuAction.CreateNewPageOptions.ParentPageId = jobAggregatorPage.Id;
            CreateNewJobMenuAction.SortOrdinal      = createNewSubPage.SortOrdinal + 1;
            CreateNewJobMenuAction.doRenderToString = AddJobPostingEditMenuRender;

            pageToAddCommandTo.EditMenu.addCustomActionItem(CreateNewJobMenuAction);
        }
コード例 #5
0
        /// <summary>
        /// Adds the "Add an image gallery" menu item to the Edit Menu.
        /// </summary>
        /// <param name="pageToAddCommandTo"></param>
        /// <param name="userImageGalleryAggregator"></param>
        public static void AddGalleryCommandToEditMenu(CmsPage pageToAddCommandTo, CmsPage userImageGalleryAggregator)
        {
            // -- only add the command if the user can author
            if (!pageToAddCommandTo.currentUserCanWrite)
            {
                return;
            }

            // -- base the command off the existing "create new sub-page" command
            CmsPageEditMenuAction createNewSubPage = pageToAddCommandTo.EditMenu.getActionItem(CmsEditMenuActionItem.CreateNewPage);

            if (createNewSubPage == null)
            {
                return;
            }

            CmsPageEditMenuAction newAction = createNewSubPage.Copy(); // copy everything from the CreateNewPage entry

            // -- configure this command to not prompt authors for any information.
            //    the minimum information needed to create a page is the new page's filename (page.name)
            //      -- get the next unique filename
            string newPageName = "";

            for (int eventNum = 1; eventNum < int.MaxValue; eventNum++)
            {
                string pageNameToTest = "Gallery" + eventNum.ToString();
                if (!CmsContext.childPageWithNameExists(userImageGalleryAggregator.ID, pageNameToTest))
                {
                    newPageName = pageNameToTest;
                    break;
                }
            }

            string newPageTitle     = "";
            string newPageMenuTitle = "";
            string newPageSearchEngineDescription = "";
            bool   newPageShowInMenu = true;
            string newPageTemplate   = CmsConfig.getConfigValue("UserImageGallery.DetailsTemplateName", "UserImageGallery");

            newAction.CreateNewPageOptions = CmsCreateNewPageOptions.GetInstanceWithNoUserPrompts(newPageName, newPageTitle, newPageMenuTitle, newPageSearchEngineDescription, newPageShowInMenu, newPageTemplate, userImageGalleryAggregator.ID);

            newAction.CreateNewPageOptions.ParentPageId = userImageGalleryAggregator.ID;
            newAction.SortOrdinal      = createNewSubPage.SortOrdinal + 1;
            newAction.doRenderToString = AddGalleryEditMenuRender;

            pageToAddCommandTo.EditMenu.addCustomActionItem(newAction);
        }