Ejemplo n.º 1
0
        public static void AddWikiHelpRequest(string section)
        {
            string url             = HttpContext.Current.Request.Url.AbsoluteUri.ToLower();
            string application     = "";
            string applicationPage = url.Substring(url.LastIndexOf("/") + 1, url.Length - url.LastIndexOf("/") - 1);

            WikiHelpRequest.Create(section.ToLower(), application, applicationPage, url);
        }
Ejemplo n.º 2
0
        public bool Execute(string url)
        {
            HttpContext.Current.Trace.Write("umbraco.wikiHandler", "init");

            bool _succes = false;

            url = url.Replace(".aspx", string.Empty);
            string currentDomain = HttpContext.Current.Request.ServerVariables["SERVER_NAME"];

            if (url.Length > 0)
            {
                if (url.Substring(0, 1) == "/")
                {
                    url = url.Substring(1, url.Length - 1);
                }

                XmlNode urlNode = null;
                string  topic   = "";

                // We're not at domain root
                if (url.IndexOf("/") != -1)
                {
                    string theRealUrl   = url.Substring(0, url.LastIndexOf("/"));
                    string realUrlXPath = CreateXPathQuery(theRealUrl, true);

                    urlNode = content.Instance.XmlContent.SelectSingleNode(realUrlXPath);
                    topic   = url.Substring(url.LastIndexOf("/") + 1, url.Length - url.LastIndexOf(("/")) - 1);
                }

                if (url.Contains("wiki/umbraco-help"))
                {
                    string[] urlparts = url.Split('/');

                    string section         = urlparts[urlparts.Length - 2];
                    string application     = "";
                    string applicationPage = urlparts[urlparts.Length - 1];

                    //log the request
                    WikiHelpRequest.Create(section.ToLower(), application, applicationPage, url);


                    //if it isn't a page create request
                    if (HttpContext.Current.Request["wikiEditor"] == null)
                    {
                        //set redirect id to main umbraco help page
                        if (Library.Utils.GetWikiHelpFallBackPage(section) > 0)
                        {
                            _redirectID = Library.Utils.GetWikiHelpFallBackPage(section);
                            return(true);
                        }
                    }
                }


                if (urlNode != null && topic != "" && urlNode.Name == "WikiPage")
                {
                    _redirectID = int.Parse(urlNode.Attributes.GetNamedItem("id").Value);

                    HttpContext.Current.Items["altTemplate"] = "createwikipage";
                    HttpContext.Current.Items["topic"]       = url.Substring(url.LastIndexOf("/") + 1, url.Length - url.LastIndexOf(("/")) - 1);

                    HttpContext.Current.Trace.Write("umbraco.altTemplateHandler",
                                                    string.Format("Templated changed to: '{0}'",
                                                                  HttpContext.Current.Items["altTemplate"]));
                    _succes = true;
                }
            }
            return(_succes);
        }