Beispiel #1
0
        public string GetTemplate(string templatename, string lang, string themeFolder, bool debugMode = false)
        {
            if (lang == "")
            {
                lang = Utils.GetCurrentCulture();
            }
            string templ       = null;
            var    strCacheKey = templatename + "*" + lang + "*" + PortalSettings.Current.PortalId.ToString("");

            if (debugMode == false)
            {
                templ = (String)Utils.GetCache(strCacheKey);
            }

            if (templ == null)
            {
                var templCtrl = NBrightBuyUtils.GetTemplateGetter(themeFolder);
                templ = templCtrl.GetTemplateData(templatename, lang, true, true, true, StoreSettings.Current.Settings());

                if (debugMode == false)
                {
                    NBrightBuyUtils.SetModCache(-1, strCacheKey, templ);
                }
            }
            // always replace url tokens after cache, they could be different per url, not by cache key
            templ = Utils.ReplaceUrlTokens(templ);
            return(templ);
        }
Beispiel #2
0
        private static List <NBrightInfo> CreatePortalPlugins()
        {
            var pluginList = new List <NBrightInfo>();

            var info = new NBrightInfo();

            info.PortalId = PortalSettings.Current.PortalId;

            var templCtrl  = NBrightBuyUtils.GetTemplateGetter(PortalSettings.Current.PortalId, "config");
            var menuplugin = templCtrl.GetTemplateData("menuplugin.xml", Utils.GetCurrentCulture(), true, true, true, StoreSettings.Current.Settings());

            if (menuplugin != "")
            {
                // menuplugin.xml exists, which is legacy data for this portal.
                info.XMLData = menuplugin;
                pluginList   = CalcPortalPluginList(info);
                if (pluginList.Any())
                {
                    CreateDBrecords(pluginList, PortalSettings.Current.PortalId);
                }
                else
                {
                    // we may not have a menuplugin.xml, this only exists on upgrade.
                    CopySystemPluginsToPortal();
                }
            }
            else
            {
                CopySystemPluginsToPortal();
            }

            return(pluginList);
        }
Beispiel #3
0
        private string GetReturnData(HttpContext context)
        {
            try
            {
                var strOut = "";

                var strIn   = HttpUtility.UrlDecode(Utils.RequestParam(context, "inputxml"));
                var xmlData = GenXmlFunctions.GetGenXmlByAjax(strIn, "");
                var objInfo = new NBrightInfo();

                objInfo.ItemID   = -1;
                objInfo.TypeCode = "AJAXDATA";
                objInfo.XMLData  = xmlData;
                var settings = objInfo.ToDictionary();

                var themeFolder = StoreSettings.Current.ThemeFolder;
                if (settings.ContainsKey("themefolder"))
                {
                    themeFolder = settings["themefolder"];
                }
                var templCtrl = NBrightBuyUtils.GetTemplateGetter(themeFolder);

                if (!settings.ContainsKey("portalid"))
                {
                    settings.Add("portalid", PortalSettings.Current.PortalId.ToString(""));                                    // aways make sure we have portalid in settings
                }
                var objCtrl = new NBrightBuyController();

                // run SQL and template to return html
                if (settings.ContainsKey("sqltpl") && settings.ContainsKey("xsltpl"))
                {
                    var strSql  = templCtrl.GetTemplateData(settings["sqltpl"], _uilang, true, true, true, StoreSettings.Current.Settings());
                    var xslTemp = templCtrl.GetTemplateData(settings["xsltpl"], _uilang, true, true, true, StoreSettings.Current.Settings());

                    // replace any settings tokens (This is used to place the form data into the SQL)
                    strSql = Utils.ReplaceSettingTokens(strSql, settings);
                    strSql = Utils.ReplaceUrlTokens(strSql);

                    strSql = GenXmlFunctions.StripSqlCommands(strSql); // don't allow anything to update through here.

                    strOut = objCtrl.GetSqlxml(strSql);
                    if (!strOut.StartsWith("<root>"))
                    {
                        strOut = "<root>" + strOut + "</root>";                               // always wrap with root node.
                    }
                    strOut = XslUtils.XslTransInMemory(strOut, xslTemp);
                }

                return(strOut);
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }
Beispiel #4
0
        private void DisplayOrderData(int portalId, UserInfo userInfo, String entryId)
        {
            var strOut = "***ERROR***  Invalid Data";

            if (Utils.IsNumeric(entryId) && entryId != "0")
            {
                var orderData = new OrderData(portalId, Convert.ToInt32(entryId));
                if (orderData.PurchaseInfo.TypeCode == "ORDER")
                {
                    strOut = "***ERROR***  Invalid Security";
                    if (userInfo.UserID == orderData.UserId || userInfo.IsInRole(StoreSettings.ManagerRole) || userInfo.IsInRole(StoreSettings.EditorRole))
                    {
                        //check the payment provider for a print url
                        var shippingprovider = orderData.PurchaseInfo.GetXmlProperty("genxml/extrainfo/genxml/radiobuttonlist/shippingprovider");
                        if (shippingprovider != "")
                        {
                            var shipprov = ShippingInterface.Instance(shippingprovider);
                            if (shipprov != null)
                            {
                                if (_template == "printdeliverylabel.html")
                                {
                                    var printurl = shipprov.GetDeliveryLabelUrl(orderData.PurchaseInfo);
                                    if (printurl != "")
                                    {
                                        Response.Redirect(printurl);
                                    }
                                }
                            }
                        }

                        // not provider label, so print template
                        var templCtrl = NBrightBuyUtils.GetTemplateGetter(_theme);
                        var strTempl  = templCtrl.GetTemplateData(_template, Utils.GetCurrentCulture(), true, true, true, StoreSettings.Current.Settings());

                        strOut = GenXmlFunctions.RenderRepeater(orderData.PurchaseInfo, strTempl, "", "XMLData", Utils.GetCurrentCulture(), StoreSettings.Current.Settings());
                        if (_template.EndsWith(".xsl"))
                        {
                            strOut = XslUtils.XslTransInMemory(orderData.PurchaseInfo.XMLData, strOut);
                        }
                    }
                }
            }
            var l = new Literal();

            l.Text = strOut;
            phData.Controls.Add(l);
        }
Beispiel #5
0
        private static List <NBrightInfo> CalcPortalPluginList(NBrightInfo info)
        {
            var templCtrl = NBrightBuyUtils.GetTemplateGetter(PortalSettings.Current.PortalId, "config");

            var rtnList = new List <NBrightInfo>();

            // get the systemlevel, incase this is an update and we have new system level provider that needs to be added
            // Some systems create their own portal specific menu we assume they don't require new updates from NBS core, so take that if we have one.
            var menupluginsys = templCtrl.GetTemplateData("menuplugin" + PortalSettings.Current.PortalId + ".xml", Utils.GetCurrentCulture(), true, true, false, StoreSettings.Current.Settings());

            // if no portal specific menus exist, take the default
            if (menupluginsys == "")
            {
                menupluginsys = templCtrl.GetTemplateData("menuplugin.xml", Utils.GetCurrentCulture(), true, true, false, StoreSettings.Current.Settings());
            }
            var infosys = new NBrightInfo();

            infosys.XMLData = menupluginsys;
            if (infosys.XMLDoc != null)
            {
                var xmlNodeList2 = infosys.XMLDoc.SelectNodes("genxml/plugin/*");
                if (xmlNodeList2 != null)
                {
                    foreach (XmlNode carNod in xmlNodeList2)
                    {
                        var newInfo = new NBrightInfo {
                            XMLData = carNod.OuterXml
                        };
                        newInfo.GUIDKey = newInfo.GetXmlProperty("genxml/textbox/ctrl");
                        var resultsys = rtnList.Where(p => p.GUIDKey == newInfo.GUIDKey);
                        if (!resultsys.Any())
                        {
                            // add the missing plugin to the active list
                            newInfo.ItemID   = rtnList.Count;
                            newInfo.PortalId = PortalSettings.Current.PortalId;
                            newInfo.SetXmlProperty("genxml/hidden/index", rtnList.Count.ToString(""), TypeCode.Double);
                            newInfo.GUIDKey = newInfo.GetXmlProperty("genxml/textbox/ctrl");
                            rtnList.Add(newInfo);
                        }
                    }
                }
            }

            return(rtnList);
        }
Beispiel #6
0
        public static String GetClientVoucherCodes(HttpContext context)
        {
            try
            {
                //get uploaded params
                var strOut   = "";
                var settings = NBrightBuyUtils.GetAjaxDictionary(context);
                if (!settings.ContainsKey("userid"))
                {
                    settings.Add("userid", "");
                }
                var userid = settings["userid"];
                if (!settings.ContainsKey("portalid"))
                {
                    settings.Add("portalid", "");
                }
                var portalid = settings["portalid"];
                if (Utils.IsNumeric(portalid) && Utils.IsNumeric(userid))
                {
                    // get template
                    var themeFolder = StoreSettings.Current.ThemeFolder;
                    if (settings.ContainsKey("themefolder"))
                    {
                        themeFolder = settings["themefolder"];
                    }
                    var templCtrl = NBrightBuyUtils.GetTemplateGetter(themeFolder);
                    var bodyTempl = templCtrl.GetTemplateData("clientvouchercodes.html", Utils.GetCurrentCulture(), true, true, true, StoreSettings.Current.Settings());
                    bodyTempl = Utils.ReplaceSettingTokens(bodyTempl, StoreSettings.Current.Settings());
                    //get data
                    var clientData = new ClientData(Convert.ToInt32(portalid), Convert.ToInt32(userid));
                    strOut = GenXmlFunctions.RenderRepeater(clientData.VoucherCodes, bodyTempl);
                }

                return(strOut);
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }
Beispiel #7
0
        public PluginData(int portalId, Boolean systemlevel = false)
        {
            _portalId = portalId;

            _templCtrl = NBrightBuyUtils.GetTemplateGetter(portalId, "config");

            _portallevel = !systemlevel;

            if (StoreSettings.Current == null)
            {
                _storeSettings = new StoreSettings(portalId);
            }
            else
            {
                _storeSettings = StoreSettings.Current;
            }

            _cachekey = "pluginlist" + portalId + "*" + systemlevel;
            var pList = NBrightBuyUtils.GetModCache(_cachekey);

            if (pList != null)
            {
                // if we've created an empty cache record, clear cache data
                _pluginList = (List <NBrightInfo>)pList;
                if (_pluginList.Count == 0)
                {
                    DotNetNuke.Common.Utilities.DataCache.ClearCache();
                }
            }

            if (pList != null && !_storeSettings.DebugMode)
            {
                _pluginList = (List <NBrightInfo>)pList;
            }
            else
            {
                Load();
            }
        }
Beispiel #8
0
        public string GetTemplateData(int moduleId, string templatename, string lang, Dictionary <string, string> settings, bool debugMode = false)
        {
            if (lang == "")
            {
                lang = Utils.GetCurrentCulture();
            }
            string templ       = null;
            var    strCacheKey = templatename + "*" + moduleId.ToString("") + "*" + lang + "*" + PortalSettings.Current.PortalId.ToString("");

            if (debugMode == false)
            {
                templ = (String)Utils.GetCache(strCacheKey);
            }

            if (templ == null)
            {
                var themeFolder = "";
                if (settings != null && settings.ContainsKey("themefolder"))
                {
                    themeFolder = settings["themefolder"];
                }
                var templCtrl = NBrightBuyUtils.GetTemplateGetter(themeFolder);
                templ = templCtrl.GetTemplateData(templatename, lang, true, true, true, settings);

                // WARNING!! do not inject text here, it will cause a loop on the GetMenuTemplates function.

                if (debugMode == false)
                {
                    NBrightBuyUtils.SetModCache(-1, strCacheKey, templ);
                }
            }
            // always replace url tokens after cache, they could be different per url, not by cache key
            templ = Utils.ReplaceUrlTokens(templ);

            return(templ);
        }
Beispiel #9
0
        private void DisplayProductData(int portalId, String entryId)
        {
            var strOut = "***ERROR***  Invalid Data";

            if (Utils.IsNumeric(entryId) && entryId != "0")
            {
                var prodData = ProductUtils.GetProductData(Convert.ToInt32(entryId), Utils.GetCurrentCulture());
                if (prodData.Exists)
                {
                    var templCtrl = NBrightBuyUtils.GetTemplateGetter(_theme);
                    var strTempl  = templCtrl.GetTemplateData(_template, Utils.GetCurrentCulture(), true, true, true, StoreSettings.Current.Settings());

                    strOut = GenXmlFunctions.RenderRepeater(prodData.Info, strTempl, "", "XMLData", Utils.GetCurrentCulture(), StoreSettings.Current.Settings());
                    if (_template.EndsWith(".xsl"))
                    {
                        strOut = XslUtils.XslTransInMemory(prodData.Info.XMLData, strOut);
                    }
                }
            }
            var l = new Literal();

            l.Text = strOut;
            phData.Controls.Add(l);
        }