Пример #1
0
        /// <summary>
        /// Sets the callback URL of the ActionMenu. It represents the service url with correct parameters for the actions.
        /// </summary>
        private void SetServiceUrl()
        {
            var scParams = GetReplacedScenarioParameters();
            var context  = UITools.FindContextInfo(this, ContextInfoID);
            var path     = !String.IsNullOrEmpty(ContextInfoID) ? context.Path : NodePath;

            var encodedReturnUrl = Uri.EscapeDataString(PortalContext.Current.RequestedUri.PathAndQuery);
            var encodedParams    = Uri.EscapeDataString(scParams ?? string.Empty);

            if (String.IsNullOrEmpty(path))
            {
                path = GetPathFromContentView(this);
            }

            if (string.IsNullOrEmpty(path))
            {
                this.Visible = false;
                return;
            }

            this.Content = Content.Load(path);

            //Pre-check action count. If empty, hide the action menu.
            if (CheckActionCount)
            {
                var sc          = ScenarioManager.GetScenario(Scenario, scParams);
                var actionCount = 0;

                if (sc != null)
                {
                    actionCount = sc.GetActions(this.Content, PortalContext.Current.RequestedUri.PathAndQuery).Count();
                }

                if (actionCount < 2 && string.Equals(Scenario, "new", StringComparison.CurrentCultureIgnoreCase))
                {
                    ClickDisabled = true;
                }
                else if (actionCount == 0)
                {
                    this.Visible = false;
                    return;
                }
            }

            //Pre-check required permissions
            var permissions = ActionFramework.GetRequiredPermissions(RequiredPermissions);

            if (permissions.Count > 0 && !SecurityHandler.HasPermission(NodeHead.Get(path), permissions.ToArray()))
            {
                this.Visible = false;
                return;
            }

            var encodedPath = HttpUtility.UrlEncode(path);

            ServiceUrl = String.Format("/SmartAppHelper.mvc/GetActions?path={0}&scenario={1}&back={2}&parameters={3}",
                                       encodedPath, Scenario, encodedReturnUrl, encodedParams);
        }