Ejemplo 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();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// sets the currentEditMode and redirects to another CmsPage. if the newEditMode is Edit, the target page is locked for editing.
        /// If the newEditMode is View, the target page is unlocked for editing.
        /// This function ends the current Request, so nothing will execute after it.
        /// </summary>
        /// <param name="newEditMode"></param>
        /// <param name="targetPage">The page to redirect to</param>
        /// <param name="paramList"></param>
        public static void setEditModeAndRedirect(CmsEditMode newEditMode, CmsPage targetPage, NameValueCollection paramList)
        {
            List <string> paramListKeys = new List <string>();

            foreach (string k in paramList.Keys)
            {
                paramListKeys.Add(k);
            }
            // -- only allow authorized people to go to CmsEditMode.Edit
            if (newEditMode == CmsEditMode.Edit && targetPage.currentUserCanWrite)
            {
                if (targetPage.lockPageForEditing() != null)
                {
                    // only add parameter if it doesn't exist already
                    if (StringUtils.IndexOf(paramListKeys.ToArray(), EditModeFormName, StringComparison.CurrentCultureIgnoreCase) < 0)
                    {
                        paramList.Add(EditModeFormName, "1");
                    }
                    else
                    {
                        paramList[EditModeFormName] = "1";
                    }
                }
            }
            else // View
            {
                targetPage.clearCurrentPageLock();
                // remove the edit mode parameter (if it exists)
                if (StringUtils.IndexOf(paramListKeys.ToArray(), EditModeFormName, StringComparison.CurrentCultureIgnoreCase) >= 0)
                {
                    paramList.Remove(EditModeFormName);
                }
            }

            // -- bust through the cache if user is logged on
            if (CmsContext.currentUserIsLoggedIn)
            {
                paramList.Add("nocache", DateTime.Now.Ticks.ToString());
            }



            // note: do not use targetPage.getUrl(paramList); (it causes an infinite loop)
            string url = getUrlByPagePath(targetPage.Path, paramList);

            System.Web.HttpContext context = System.Web.HttpContext.Current;
            if (context != null)
            {
                context.Response.Redirect(url, true);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// sets the currentEditMode and redirects to another CmsPage. if the newEditMode is Edit, the target page is locked for editing.
 /// If the newEditMode is View, the target page is unlocked for editing.
 /// Note: targetCmsPagePath should never contain the language code
 /// </summary>
 /// <param name="newEditMode"></param>
 /// <param name="targetPage">The page to redirect to</param>
 public static void setEditModeAndRedirect(CmsEditMode newEditMode, CmsPage targetPage)
 {
     setEditModeAndRedirect(newEditMode, targetPage, new NameValueCollection());
 }
Ejemplo n.º 4
0
        } // currentEditMode

        /// <summary>
        /// sets the currentEditMode and redirects the user to the current page
        /// </summary>
        /// <param name="newEditMode"></param>
        public static void setEditModeAndRedirectToCurrent(CmsEditMode newEditMode)
        {
            setEditModeAndRedirect(newEditMode, currentPage);
        }
Ejemplo n.º 5
0
        private CmsPageEditMenuAction[] getAllPageActionsForCurrentContext()
        {
            // -- if the user can't author, they can't do anything.
            if (!CmsContext.currentPage.currentUserCanWrite)
            {
                return(new CmsPageEditMenuAction[0]);
            }

            List <CmsPageEditMenuAction> actionsByCategory = new List <CmsPageEditMenuAction>();

            CmsEditMode     currEditMode = CmsContext.currentEditMode;
            CmsPageLockData lockData     = _page.getCurrentPageLockData();

            // -- if the page is locked and we're viewing it, show PageLockMaintenance options
            if (lockData != null && currEditMode == CmsEditMode.View)
            {
                actionsByCategory.AddRange(getActionItemsByCategory(AllStandardActions, CmsEditMenuActionCategory.PageLockMaintenance));
            }
            else if (currEditMode == CmsEditMode.View && CmsContext.requestedPageVersionNumberToView >= 0)
            {
                actionsByCategory.AddRange(getActionItemsByCategory(AllStandardActions, CmsEditMenuActionCategory.RevisionInformation));
            }
            else
            {
                actionsByCategory.AddRange(getActionItemsByCategory(AllStandardActions, CmsEditMenuActionCategory.ThisPageAction));
                actionsByCategory.AddRange(getActionItemsByCategory(AllStandardActions, CmsEditMenuActionCategory.SubPageAction));
                actionsByCategory.AddRange(getActionItemsByCategory(AllStandardActions, CmsEditMenuActionCategory.SiteTool));
            }

            // -- Include those actions that match the current edit mode
            List <CmsPageEditMenuAction> ret = new List <CmsPageEditMenuAction>();

            foreach (CmsPageEditMenuAction a in actionsByCategory)
            {
                if (a.RequiredEditMode == currEditMode)
                {
                    ret.Add(a);
                }
            } // foreach

            // -- If we only have one language, don't include language switching
            if (CmsConfig.Languages.Length < 2)
            {
                removeActionItem(ret, CmsEditMenuActionItem.SwitchEditLanguage);
            }

            // -- don't allow the home page to be deleted nor renamed
            if (_page.ID == CmsContext.HomePage.ID)
            {
                removeActionItem(ret, CmsEditMenuActionItem.DeleteThisPage);
                removeActionItem(ret, CmsEditMenuActionItem.RenameThisPage);
            }

            // -- sort child pages only if there's more than one child page
            if (_page.ChildPages.Length <= 1)
            {
                removeActionItem(ret, CmsEditMenuActionItem.SortSubPages);
            }

            // -- remove Admin only tools
            if (!CmsContext.currentUserIsSuperAdmin)
            {
                removeActionItem(ret, CmsEditMenuActionItem.ChangeTemplate);
                removeActionItem(ret, CmsEditMenuActionItem.AdminReportsAndTools);
                removeActionItem(ret, CmsEditMenuActionItem.RemoveEditLock);
                removeActionItem(ret, CmsEditMenuActionItem.UserManagement);
            }

            return(ret.ToArray());
        }