public void ProcessRequest(HttpContext context)
        {
            int code = 301;

            Int32.TryParse(StatusCode ?? "301", out code);

            HttpContext.Current.Response.StatusCode = code;

            if (code >= 300 && code < 400)
            {
                var action    = ActionFramework.GetAction(PortalContext.Current.ActionName ?? "browse", Content.Create(PortalContext.Current.ContextNode), (this.AllowQueryString) ? HttpUtility.ParseQueryString(PortalContext.Current.RequestedUri.Query) : null);
                var actionUri = ActionFramework.GetActionUrl(PortalContext.Current.ContextNodePath, "Browse");

                if (action == null)
                {
                    HttpContext.Current.Response.StatusCode = 500;
                }
                else if (!string.IsNullOrEmpty(action.Uri))
                {
                    HttpContext.Current.Response.RedirectLocation = action.Uri;
                }
                else
                {
                    HttpContext.Current.Response.StatusCode = 404;
                }
            }

            HttpContext.Current.Response.End();
        }
Пример #2
0
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            Panel pnlContainer = new Panel();


            pnlContainer.CssClass = CssClass;
            System.Web.UI.WebControls.Image cImage = new System.Web.UI.WebControls.Image();
            //string imageid = string.Format("CaptchaImage.ashx?guid={0}&s=1", _captcha.UniqueId);
            //string currentPath = PortalContext.Current.RequestedUri.AbsoluteUri;
            //string imageid = string.Format("{0}?Action=GetCaptcha&guid={1}&s=1", currentPath, _captcha.UniqueId);
            cImage.ImageUrl = ActionFramework.GetActionUrl("/Root", "GetCaptcha", string.Empty) + string.Format("&guid={0}&s=1", _captcha.UniqueId);

            cImage.BorderStyle   = BorderStyle.None;
            cImage.AlternateText = ToolTip;
            cImage.Width         = _captcha.Width;
            cImage.Height        = _captcha.Height;
            pnlContainer.Controls.Add(cImage);

            if (this.LayoutStyle == Layout.Vertical)
            {
                Literal lBr = new Literal();
                lBr.Text = "<br />";
                pnlContainer.Controls.Add(lBr);
            }
            else
            {
                Literal lSpace = new Literal();
                lSpace.Text = "&nbsp;&nbsp;";
                pnlContainer.Controls.Add(lSpace);
            }

            Label lblInstruct = new Label();

            lblInstruct.ID        = "lblInstructoin";
            lblInstruct.Text      = Text;
            lblInstruct.AccessKey = AccessKey;
            pnlContainer.Controls.Add(lblInstruct);

            tbUserEntry           = new TextBox();
            tbUserEntry.ID        = "tbUserEntry";
            tbUserEntry.AccessKey = AccessKey;
            tbUserEntry.Attributes.Add("size", _captcha.TextLength.ToString());
            tbUserEntry.Attributes.Add("maxlength", _captcha.TextLength.ToString());
            if (!Enabled)
            {
                tbUserEntry.Attributes.Add("disabled", "disabled");
            }
            if (TabIndex > 0)
            {
                tbUserEntry.Attributes.Add("tabindex", TabIndex.ToString());
            }
            pnlContainer.Controls.Add(tbUserEntry);

            // Set the style::
            pnlContainer.Attributes.Add("style", this.CssStyle());
            this.Controls.Add(pnlContainer);
        }
Пример #3
0
        /// <summary>
        /// This method can be used when no back url is given (e.g. in case of a Browse view).
        /// </summary>
        protected void RedirectToParent()
        {
            if (this.Content == null)
            {
                return;
            }

            Response.Redirect(ActionFramework.GetActionUrl(this.Content.ContentHandler.ParentPath, "Browse"), false);
        }
Пример #4
0
        private static string GetOnClientClick(string nodePath, string actionName)
        {
            var result = new StringBuilder();

            result.Append(@"javascript: window.location = '");
            result.Append(ActionFramework.GetActionUrl(nodePath, actionName));
            result.Append(@"';");
            result.Append(@"return false;");
            return(result.ToString());
        }
Пример #5
0
        private static string GetOnClientClick(string nodePath, string actionName)
        {
            var result = new StringBuilder();

            result.Append(@"javascript: window.location = '");
            result.Append(ActionFramework.GetActionUrl(nodePath, actionName, HttpUtility.UrlEncode(HttpContext.Current.Request.RawUrl)));
            result.Append(@"';");
            result.Append(@"return false;");
            return(result.ToString());
        }
Пример #6
0
        protected void BtnEdit_Click(object sender, EventArgs e)
        {
            var templateName = (sender as Button).CommandArgument;

            var contextNode      = PortalContext.Current.ContextNode;
            var templateNode     = contextNode.GetReference <Node>(string.Concat(templateName, "Page"));
            var templateNodePath = templateNode.Path;

            if (templateNodePath.Contains("System/SystemPlugins"))
            {
                var targetPath = RepositoryPath.Combine(contextNode.Path, "configuration");

                if (!Node.Exists(targetPath))
                {
                    var folder = new Folder(contextNode, "Folder")
                    {
                        Name = "configuration", DisplayName = "Configuration"
                    };
                    folder.Save();
                }

                var wcd = NodeType.CreateInstance("WebContentDemo", Node.LoadNode(targetPath));

                wcd["Name"]        = templateNode["Name"];
                wcd["DisplayName"] = templateNode["DisplayName"];
                wcd["Subtitle"]    = templateNode["Subtitle"];
                wcd["Body"]        = templateNode["Body"];
                wcd.Save();

                templateNodePath = wcd.Path;

                contextNode.SetReference(string.Concat(templateName, "Page"), wcd);
                contextNode.Save();
            }

            Response.Redirect(ActionFramework.GetActionUrl(templateNodePath, "EditSurveyTemplate", PortalContext.Current.BackUrl));
        }
Пример #7
0
        private void RedirectToSearchPage()
        {
            //direct search page mode
            if (string.IsNullOrEmpty(SearchResultPagePath))
            {
                //COMMENT: sometimes the request contains the app url, not the actual node.
                //Only the rawurl property contains the original path (e.g. the workspace).

                var contextInfo = UITools.FindContextInfo(this, ContextInfoID);
                var ctxPath     = contextInfo != null ? contextInfo.Path : string.Empty;

                if (string.IsNullOrEmpty(ctxPath))
                {
                    var ctx = GetContextNode();
                    if (ctx != null)
                    {
                        ctxPath = ctx.Path;
                    }
                }

                var actionUrl = string.IsNullOrEmpty(ctxPath) ? "?action=Search" : (_includeBackUrl ? ActionFramework.GetActionUrl(ctxPath, "Search") : ActionFramework.GetActionUrl(ctxPath, "Search", null));
                var url       = string.Format("{0}&{1}={2}", actionUrl, QueryParameterName, HttpUtility.UrlEncode(this.SearchBox.Text.Trim()));

                HttpContext.Current.Response.Redirect(url);
            }
            else
            {
                var urlSeparator = SearchResultPagePath.Contains("?") ? "&" : "?";
                var url          = string.Format("{0}{1}{2}={3}", PortalContext.GetSiteRelativePath(SearchResultPagePath), urlSeparator,
                                                 QueryParameterName, HttpUtility.UrlEncode(this.SearchBox.Text.Trim()));

                if (_includeBackUrl)
                {
                    url = string.Format("{0}&{1}={2}", url, PortalContext.BackUrlParamName, HttpUtility.UrlEncode(HttpContext.Current.Request.RawUrl));
                }

                HttpContext.Current.Response.Redirect(url, true);
            }
        }
        protected override void OnInit(EventArgs e)
        {
            Page.RegisterRequiresControlState(this);

            base.OnInit(e);

            if (!this.Page.IsPostBack)
            {
                var context = Node.LoadNode(ContextInfo.Path);

                Acl = SnAccessControlList.GetAcl(context.Id);
                this.Isi.RebuildAceVisiblityList(this.Acl);
            }

            RebuildEntryIdList();

            if (ListViewAcl != null)
            {
                ListViewAcl.ItemDataBound += ListViewAcl_ItemDataBound;
            }

            RefreshInheritanceControls();

            try
            {
                if (this.ContextNode.Id == Identifiers.PortalRootId)
                {
                    if (BreakedPermission != null)
                    {
                        BreakedPermission.Visible = false;
                    }

                    if (ButtonBreak != null)
                    {
                        ButtonBreak.Visible = false;
                    }
                }
                else
                {
                    // Start the permission tree from this or parent node

                    //TODO: Consider elevated mode
                    var currentNode = this.ContextNode.Parent;
                    while (!HasCustomPermissions(currentNode) && currentNode.Id != Identifiers.PortalRootId)
                    {
                        //TODO: Consider elevated mode
                        currentNode = currentNode.Parent;
                    }

                    ParentLink.Text        = HttpUtility.HtmlEncode(ContentRepository.Content.Create(currentNode).DisplayName);
                    ParentLink.NavigateUrl = ActionFramework.GetActionUrl(currentNode.Path, "SetPermissions",
                                                                          PortalContext.Current.BackUrl);
                }
            }
            catch (Exception)
            {
                // there is a node in the tree where we can't see the permission settings
                if (InheritedPermission != null)
                {
                    InheritedPermission.Visible = false;
                }
            }

            if (PanelError != null)
            {
                PanelError.Visible = false;
                PanelError.Controls.Clear();
            }

            RefreshListView();

            RefreshAddEntryPanel();
        }
        public override void Initialize(SenseNet.ContentRepository.Content context, string backUri, Application application, object parameters)
        {
            //base.Initialize(context, backUri, application, parameters);
            base.Initialize(context, backUri, application, null);
            TargetPath    = string.Empty;
            CustomUrl     = string.Empty;
            ContextNodeId = context.ContentHandler.Id;
            Parameters    = parameters;

            if (application.HasProperty("ToBlank"))
            {
                ToBlank = (int)application.GetProperty("ToBlank") == 1;
            }
            if (application.HasProperty("UrlFragment"))
            {
                Fragment = (string)application.GetProperty("UrlFragment");
            }
            if (application.HasProperty(ALLOWQUERYSTRING))
            {
                AllowQueryString = (int)application.GetProperty(ALLOWQUERYSTRING) == 1;
            }


            if (application.NodeType.Name == "SoftLinkAction")
            {
                TargetLifeSpanWatch = application.GetProperty <int>("TargetLifeSpanWatch") == 1;
                if (application.GetProperty <int>("LinkContentTargetAction") == 0)
                {
                    CustomUrl = application.GetProperty <string>("CustomUrl");

                    TargetNode = application.GetReference <Node>("TargetPath");
                    if (TargetNode != null && TargetNode.Id != context.Id && TargetNode.Id != application.Id) // deny reference of itself! (should we check app id only?)
                    {
                        if (this.IsModal)
                        {
                            TargetPath = ActionFramework.GetActionUrl(TargetNode.Path, "Browse", backUri);
                        }
                        else
                        {
                            TargetPath = ActionFramework.GetActionUrl(TargetNode.Path, "Browse");
                        }
                    }
                }
                else
                {
                    TargetAction = application.GetProperty <string>("ContentTargetAction");
                    string format = "{0}?action={1}";
                    if (string.IsNullOrEmpty(TargetAction))
                    {
                        format = "{0}";
                    }

                    if (application.IsModal)
                    {
                        format += string.Concat(format.Contains("?") ? "&" : "? ", "back={2}");
                    }

                    if (Content.ContentHandler.HasProperty("ToBlank"))
                    {
                        ToBlank = Content.ContentHandler.GetProperty <int>("ToBlank") != 0;
                    }
                    if (Content.ContentHandler.HasProperty("UrlFragment"))
                    {
                        Fragment = Content.ContentHandler.GetProperty <string>("UrlFragment");
                    }

                    TargetProperty = application.GetProperty <string>("ContentTargetReference");
                    PropertyType type = null;
                    if ((Content.Fields.Where(a => a.Key == TargetProperty && a.Value.GetType() == typeof(ReferenceField)).Any()))
                    {
                        var tnodes = context[TargetProperty] as IEnumerable <Node>;
                        if (tnodes != null && tnodes.Any())
                        {
                            TargetNode = tnodes.FirstOrDefault();
                        }

                        if (TargetNode != null && TargetNode.Id != context.Id && TargetNode.Id != application.Id) // deny reference of itself! (should we check app id only?)
                        {
                            string actionName = (string.IsNullOrWhiteSpace(TargetAction)) ? "Browse" : TargetAction;
                            if (this.IsModal)
                            {
                                TargetPath = ActionFramework.GetActionUrl(TargetNode.Path, actionName, backUri);
                            }
                            else
                            {
                                TargetPath = ActionFramework.GetActionUrl(TargetNode.Path, actionName);
                            }
                            return;
                        }
                    }

                    TargetProperty = application.GetProperty <string>("ContentTargetCustom");
                    if (string.IsNullOrEmpty(TargetPath) &&
                        (Content.Fields.Where(a => a.Key == TargetProperty && a.Value.GetType() == typeof(ShortTextField)).Any()))
                    {
                        string tPath = Content[TargetProperty] as string;

                        if (!string.IsNullOrWhiteSpace(tPath))
                        {
                            TargetPath = tPath;
                            return;
                        }
                    }

                    /*Remove rediret loop*/

                    /*if (string.IsNullOrEmpty(TargetPath))
                     *  TargetPath = string.Format(format, context.Path, TargetAction, backUri);*/

                    /*Last Chance*/
                    CustomUrl = application.GetProperty <string>("CustomUrl");
                }
            }
        }