public string Render(string xpath, PageEntry pageEntry, XmlDocument content, Stack<string> placeHolderStack, out bool containsCacheableContent)
 {
     string text = "";
     XmlNodeList nodes;
     try
     {
         nodes = content.SelectNodes(xpath);
     }
     catch
     {
         containsCacheableContent = false;
         return "[Cannot render placeholder; invalid XPath expression]";
     }
     if (nodes.Count == 0)
     {
         containsCacheableContent = false;
         return null;
     }
     bool cacheable = true;
     foreach (XmlElement node in nodes)
     {
         if (node != null)
         {
             if (node.HasAttribute("Embed"))
             {
                 PageEntry embedPageEntry = PageRegistry.Pages.FromPageCode(node.GetAttribute("Embed"));
                 if (embedPageEntry == null)
                     text += "[Embed failed. Page code \"" + node.GetAttribute("Embed") + "\" not found]";
                 else
                 {
                     bool returnValueCached;
                     string embed = embedPageEntry.Render(placeHolderStack, out returnValueCached);
                     cacheable = cacheable && returnValueCached;
                     if (embed == null)
                         text += "[Content not found for embedded page " + pageEntry.PageCode + "]";
                     else
                         text += embed;
                 }
             }
             else
             {
                 if (node.FirstChild != null)
                 {
                     bool cache;
                     string str = node.FirstChild.Value;
                     foreach (PlaceHolder ph in PlaceHolder.Extract(str))
                     {
                         str = str.Replace(ph.RawText, ph.Render(pageEntry, content, placeHolderStack, out cache));
                         cacheable = cacheable && cache;
                     }
                     text += str;
                 }
             }
         }
         else
             text += "[Content not found for node " + xpath + "]";
     }
     containsCacheableContent = cacheable;
     return text;
 }
        public string Render(PlaceHolder placeHolder, PageEntry pageEntry, System.Xml.XmlDocument content, Stack<string> placeHolderStack, out bool containsCacheableContent)
        {
            containsCacheableContent = true;
            switch (placeHolder.Expression.ToLower())
            {
                case "action":
                    return PayPal.PayPalPostURL;

                case "subscribetest":

                    PaypalSubscription pps = new PaypalSubscription();
                    pps.CustomValue = Guid.NewGuid().ToString();
                    pps.ItemName = "Test Subscription";
                    pps.ItemNumber = 400;
                    pps.NotifyURL = "http://snowdevil78.dyndns.org/prospector/public/paypal-ipn-process/";
                    pps.SubscriptionPeriodSize = 3;
                    pps.SubscriptionPeriodUnit = PayPalSubscriptionPeriodUnit.Day;
                    pps.SubscriptionPrice = 10;
                    pps.TrialPeriodSize = 0;
                    pps.EditMode = PayPalSubscriptionEditMode.ModifyOnly;
                    return pps.GetFormFields();

                default:
                    return "[PayPalPlaceHolderRenderer error: Expression \"" + placeHolder.Expression + "\" not recognised]";
            }
        }
 public string Render(PlaceHolder placeHolder, PageEntry pageEntry, XmlDocument content, Stack<string> placeHolderStack, out bool containsCacheableContent)
 {
     ListDefinition list = ListRegistry.Lists[placeHolder.Expression];
     if (list == null)
     {
         containsCacheableContent = false;
         return "[No list found named " + placeHolder.Expression + "]";
     }
     return list.Render(placeHolderStack, out containsCacheableContent);
 }
        public string Render(PlaceHolder placeHolder, PageEntry pageEntry, XmlDocument content, Stack<string> placeHolderStack, out bool containsCacheableContent)
        {
            containsCacheableContent = true;
            switch (placeHolder.Expression.ToLower())
            {
                case "path":
                    return WebUtility.MakeFullPath(pageEntry.Path);

                default:
                    return "[The {pageEntry} renderer does not support the expression " + placeHolder.Expression + "]";
            }
        }
 public string Render(PlaceHolder placeHolder, PageEntry pageEntry, XmlDocument content, Stack<string> placeHolderStack, out bool containsCacheableContent)
 {
     containsCacheableContent = true;
     Template t = TemplateRegistry.Templates[placeHolder.Expression];
     string text = t.Text;
     foreach (PlaceHolder ph in t.PlaceHolders)
     {
         bool cache;
         text = text.Replace(ph.RawText, ph.Render(pageEntry, content, placeHolderStack, out cache));
         containsCacheableContent = containsCacheableContent && cache;
     }
     return text;
 }
        public string Render(PlaceHolder placeHolder, PageEntry pageEntry, System.Xml.XmlDocument content, Stack<string> placeHolderStack, out bool containsCacheableContent)
        {
            containsCacheableContent = false;
            if (!WebAuthentication.Instance.IsLoggedIn)
                return "[not logged in]";
            switch (placeHolder.Expression)
            {
                case "username":
                    return SecurityProvider.CurrentUser.Username;

                default:
                    return "[\"" + placeHolder.Expression + "\" is not a recognised placeholder expression for currentuser]";
            }
        }
        public string Render(PlaceHolder placeHolder, PageEntry pageEntry, XmlDocument content, Stack<string> placeHolderStack, out bool containsCacheableContent)
        {
            containsCacheableContent = false;
            String[] arr = placeHolder.Expression.Split('|');
            if (arr.Length != 2)
                return "[EmbedSecure requires expression: loggedInPageCode|loggedOutPageCode (use relevant page code values, or blank for none)]";

            string pagecode = (WebAuthentication.Instance.IsLoggedIn ? arr[0] : arr[1]).Trim();
            if (pagecode == "")
                return "";

            PageEntry page = PageRegistry.Pages.FromPageCode(pagecode);
            if (page == null)
                return "[No page found with PageCode \"" + pagecode + "\"]";

            bool discard;
            return page.Render(placeHolderStack, out discard);
        }
        public string Render(PlaceHolder placeHolder, PageEntry pageEntry, XmlDocument content, Stack<string> placeHolderStack, out bool containsCacheableContent)
        {
            Template template = TemplateRegistry.Templates[placeHolder.Expression];
            if (template == null)
            {
                containsCacheableContent = false;
                return "[No template found named \"" + placeHolder.Expression + "\"]";
            }

            string text = template.Text;
            bool ccc = true;
            foreach (PlaceHolder ph in template.PlaceHolders)
            {
                bool check;
                text = text.Replace(ph.RawText, ph.Render(pageEntry, content, placeHolderStack, out check));
                ccc = ccc & check;
            }
            containsCacheableContent = ccc;
            return text;
        }
        public string Render(PlaceHolder placeHolder, PageEntry pageEntry, XmlDocument content, Stack<string> placeHolderStack, out bool containsCacheableContent)
        {
            containsCacheableContent = true;

            String[] arr = placeHolder.Expression.Split('|');
            if (arr.Length != 2)
                return "[TemplateSecure requires expression: loggedInTemplateName|loggedOutTemplateName (use relevant template names, or blank for none)]";
            string name = (WebAuthentication.Instance.IsLoggedIn ? arr[0] : arr[1]).Trim();
            if (name.Length == 0)
                return "";
            Template t = TemplateRegistry.Templates[name];
            string text = t.Text;
            foreach (PlaceHolder ph in t.PlaceHolders)
            {
                bool cache;
                text = text.Replace(ph.RawText, ph.Render(pageEntry, content, placeHolderStack, out cache));
                containsCacheableContent = containsCacheableContent && cache;
            }
            return text;
        }
        public override string Render(PlaceHolder placeHolder, PageEntry pageEntry, XmlDocument content, Stack<string> placeHolderStack, out bool containsCacheableContent)
        {
            int scindex = placeHolder.Expression.IndexOf(';');
            if (scindex == -1)
            {
                containsCacheableContent = false;
                return "[externalXml placeholder expression formatted improperly. Expected {externalXml:pagecode;xpath}]";
            }
            string code = placeHolder.Expression.Substring(0, scindex);
            string xpath = placeHolder.Expression.Substring(scindex + 1);

            PageEntry page = PageRegistry.Pages.FromPageCode(code);
            if (page == null)
            {
                containsCacheableContent = false;
                return "[No external page exists with code " + code + "]";
            }

            return Render(xpath, page, page.LoadContentDocument(), placeHolderStack, out containsCacheableContent);
        }
        public string Render(PlaceHolder placeHolder, PageEntry pageEntry, XmlDocument content, Stack<string> placeHolderStack, out bool containsCacheableContent)
        {
            containsCacheableContent = true;

            Type[] types;
            if (placeHolder.Expression.Trim().Length > 0)
            {
                string[] typeNames = placeHolder.Expression.Split(',');
                types = new Type[typeNames.Length];
                for (int i = 0; i < typeNames.Length; i++)
                {
                    string typeName = typeNames[i].Trim();
                    if (typeName == "")
                        continue;

                    RegisteredModule mod = Core.Instance[typeName];
                    if(mod == null)
                    {
                        containsCacheableContent = false;
                        return "alert('[Type " + typeName + " not found]');";
                    }
                    types[i] = mod.Module.GetType();
                }
            }
            else
                types = new Type[0];

            string scr =
                ResourceLoader.LoadTextResource(typeof(WebClientScripts).Assembly, "Sprocket.Web.javascript.generic.js")
                + ResourceLoader.LoadTextResource(typeof(WebClientScripts).Assembly, "Sprocket.Web.javascript.json.js")
                + ResourceLoader.LoadTextResource(typeof(WebClientScripts).Assembly, "Sprocket.Web.javascript.ajax.js")
                    .Replace("$APPLICATIONROOT$", WebUtility.BasePath)
                + WebClientScripts.Instance.GetAjaxMethodsScript(types);
            if (WebClientScripts.CompressJavaScript)
                return JavaScriptCondenser.Condense(scr);
            else
                return scr;
        }
Ejemplo n.º 12
0
        public string Render(Stack <string> placeHolderStack, out bool isCacheable)
        {
            isCacheable = true;

            if (itemTemplate == null)
            {
                return("[Cannot render list \"" + name + "\". No ItemTemplate specified]");
            }

            if (selectExpr == null || selectExpr == "")
            {
                return("[Cannot render list \"" + name + "\". No page selection expression has been specified]");
            }

            List <PageEntry> pages = PageRegistry.Pages.SelectPages(selectExpr);
            bool             alt = false;
            StringBuilder    output = new StringBuilder();
            bool             cacheable = true;
            int startx, endx, incrementx;

            if (isReverseOrder)
            {
                startx     = pages.Count - 1;
                endx       = 0;
                incrementx = -1;
            }
            else
            {
                startx     = 0;
                endx       = pages.Count - 1;
                incrementx = 1;
            }
            int c = 1;

            for (int x = startx; x <= pages.Count - 1 && x >= 0; x += incrementx)
            {
                PageEntry page = pages[x];
                Template  t    = null;
                if (singleItemTemplate != null)
                {
                    if (singleItemTemplate.ContainsKey(c))
                    {
                        t = singleItemTemplate[c];
                    }
                }
                if (t == null)
                {
                    t = alt && alternatingItemTemplate != null ? alternatingItemTemplate : itemTemplate;
                }
                string      canvas  = t.Text;
                XmlDocument content = PageRequestHandler.Instance.GetXmlDocument("resources/content/" + page.ContentFile);
                if (content == null)
                {
                    output.Append("[Unable to load content document " + page.ContentFile + "]");
                    continue;
                }
                bool containsCacheableContent;
                foreach (PlaceHolder ph in t.PlaceHolders)
                {
                    canvas    = canvas.Replace(ph.RawText, ph.Render(page, content, placeHolderStack, out containsCacheableContent));
                    cacheable = cacheable && containsCacheableContent;
                }
                if (output.Length > 0 && dividerTemplate != null)
                {
                    output.Append(dividerTemplate.Text);
                }
                output.Append(canvas);
                alt = !alt;
                c++;
            }
            isCacheable = cacheable;
            return(output.ToString());
        }
Ejemplo n.º 13
0
        public string Render(PageEntry pageEntry, XmlDocument content, Stack<string> placeHolderStack, out bool containsCacheableContent)
        {
            string phcode = pageEntry.InternalID.ToString() + ";" + rawText;
            if (placeHolderStack.Contains(phcode))
            {
                containsCacheableContent = false;
                return "[Unable to render placeholder; circular dependency detected]";
            }

            placeHolderStack.Push(phcode);

            string output;
            if (this.renderer == null)
            {
                containsCacheableContent = false;
                output = "[No renderer exists for placeholders of type \"" + prefix + "\"]";
            }
            else
            {
                if (placeHolderStack == null)
                    placeHolderStack = new Stack<string>();
                output = renderer.Render(this, pageEntry, content, placeHolderStack, out containsCacheableContent);
                if (output == null)
                    output = RawText;
                else
                    output = outputFormatter.Format(output, outputFormat);
            }

            placeHolderStack.Pop();
            return output;
        }
        public string Render(string xpath, PageEntry pageEntry, XmlDocument content, Stack <string> placeHolderStack, out bool containsCacheableContent)
        {
            string      text = "";
            XmlNodeList nodes;

            try
            {
                nodes = content.SelectNodes(xpath);
            }
            catch
            {
                containsCacheableContent = false;
                return("[Cannot render placeholder; invalid XPath expression]");
            }
            if (nodes.Count == 0)
            {
                containsCacheableContent = false;
                return(null);
            }
            bool cacheable = true;

            foreach (XmlElement node in nodes)
            {
                if (node != null)
                {
                    if (node.HasAttribute("Embed"))
                    {
                        PageEntry embedPageEntry = PageRegistry.Pages.FromPageCode(node.GetAttribute("Embed"));
                        if (embedPageEntry == null)
                        {
                            text += "[Embed failed. Page code \"" + node.GetAttribute("Embed") + "\" not found]";
                        }
                        else
                        {
                            bool   returnValueCached;
                            string embed = embedPageEntry.Render(placeHolderStack, out returnValueCached);
                            cacheable = cacheable && returnValueCached;
                            if (embed == null)
                            {
                                text += "[Content not found for embedded page " + pageEntry.PageCode + "]";
                            }
                            else
                            {
                                text += embed;
                            }
                        }
                    }
                    else
                    {
                        if (node.FirstChild != null)
                        {
                            bool   cache;
                            string str = node.FirstChild.Value;
                            foreach (PlaceHolder ph in PlaceHolder.Extract(str))
                            {
                                str       = str.Replace(ph.RawText, ph.Render(pageEntry, content, placeHolderStack, out cache));
                                cacheable = cacheable && cache;
                            }
                            text += str;
                        }
                    }
                }
                else
                {
                    text += "[Content not found for node " + xpath + "]";
                }
            }
            containsCacheableContent = cacheable;
            return(text);
        }
 public virtual string Render(PlaceHolder placeHolder, PageEntry pageEntry, XmlDocument content, Stack <string> placeHolderStack, out bool containsCacheableContent)
 {
     return(Render(placeHolder.Expression, pageEntry, content, placeHolderStack, out containsCacheableContent));
 }
 public virtual string Render(PlaceHolder placeHolder, PageEntry pageEntry, XmlDocument content, Stack<string> placeHolderStack, out bool containsCacheableContent)
 {
     return Render(placeHolder.Expression, pageEntry, content, placeHolderStack, out containsCacheableContent);
 }
 public string Render(PlaceHolder placeHolder, PageEntry pageEntry, XmlDocument content, Stack <string> placeHolderStack, out bool containsCacheableContent)
 {
     containsCacheableContent = true;
     return("");
 }
Ejemplo n.º 18
0
 public string Render(PlaceHolder placeHolder, PageEntry pageEntry, XmlDocument content, Stack <string> placeHolderStack, out bool containsCacheableContent)
 {
     containsCacheableContent = true;
     return("[No renderer exists for placeholders of type " + placeHolder.Prefix + "]");
 }
Ejemplo n.º 19
0
        private PageEntry LoadEntry(XmlElement xml, PageEntry parent)
        {
            PageEntry pageEntry = new PageEntry();
            pageEntry.Parent = parent;
            pageEntry.TemplateName = xml.GetAttribute("Template");
            pageEntry.ContentFile = xml.GetAttribute("ContentFile");
            if (xml.HasAttribute("PageID"))
            {
                pageEntry.PageID = new Guid(xml.GetAttribute("PageID"));
                pageIDs[pageEntry.PageID.Value] = pageEntry;
            }
            if (xml.HasAttribute("Path"))
            {
                pageEntry.Path = xml.GetAttribute("Path").ToLower();
                requestPaths[pageEntry.Path] = pageEntry;
            }
            if (xml.HasAttribute("Code"))
            {
                pageEntry.PageCode = xml.GetAttribute("Code");
                pageCodes[pageEntry.PageCode] = pageEntry;
            }
            if (xml.HasAttribute("ContentFile"))
            {
                pageEntry.ContentFile = xml.GetAttribute("ContentFile");
                contentFiles[pageEntry.ContentFile] = pageEntry;
            }
            //else throw new Exception("Sprocket.Web.CMS.Pages.PageRegistry: A Page entry has been detected that is missing a PageCode attribute");

            foreach (XmlElement node in xml.ChildNodes)
                pageEntry.Pages.Add(LoadEntry(node, pageEntry));

            pages.Add(pageEntry);
            return pageEntry;
        }
Ejemplo n.º 20
0
 public string Render(PlaceHolder placeHolder, PageEntry pageEntry, XmlDocument content, Stack<string> placeHolderStack, out bool containsCacheableContent)
 {
     containsCacheableContent = true;
     return "[No renderer exists for placeholders of type " + placeHolder.Prefix + "]";
 }