Exemplo n.º 1
0
        public string GetTreeCatList(int displaylevels = 20, int parentid = 0, int tabid = 0, string identClass = "nbrightbuy_catmenu", string styleClass = "", string activeClass = "active")
        {
            if (tabid == 0)
            {
                tabid = PortalSettings.Current.ActiveTab.TabID;
            }
            if (parentid < 0)
            {
                parentid = 0;
            }
            var rtnList     = "";
            var strCacheKey = "NBrightBuy_GetTreeCatListRazor" + PortalSettings.Current.PortalId + "*" + displaylevels + "*" + parentid + "*" + _lang + "*" + _currentCatId.ToString("");
            var objCache    = NBrightBuyUtils.GetModCache(strCacheKey);

            if (objCache == null | StoreSettings.Current.DebugMode)
            {
                rtnList = BuildTreeCatList(rtnList, 0, parentid, "cat", tabid, displaylevels, identClass, styleClass, activeClass);
                //remove emprty <ul> elements
                rtnList = rtnList.Replace("<ul></ul>", "");
                NBrightBuyUtils.SetModCache(-1, strCacheKey, rtnList);
            }
            else
            {
                rtnList = (string)objCache;
            }
            return(rtnList);
        }
Exemplo n.º 2
0
        private void Load(String lang, Boolean debugMode = false)
        {
            lock (lockobjectLoad)
            {
                _objCtrl = new NBrightBuyController();
                _lang    = lang;

                var strCacheKey = "GrpList_" + lang + "_" + _portalId;
                GroupList = (List <NBrightInfo>)NBrightBuyUtils.GetModCache(strCacheKey);
                if (GroupList == null || debugMode)
                {
                    // get groups
                    GroupList = NBrightBuyUtils.GetCategoryGroups(_portalId, _lang, true);
                    NBrightBuyUtils.SetModCache(-1, strCacheKey, GroupList);
                }

                strCacheKey      = "GroupsDictionary_" + lang + "_" + _portalId;
                GroupsDictionary = (Dictionary <string, string>)NBrightBuyUtils.GetModCache(strCacheKey);
                if (GroupsDictionary == null || debugMode)
                {
                    GroupsDictionary = new Dictionary <String, String>();
                    foreach (var g in GroupList)
                    {
                        if (!GroupsDictionary.ContainsKey(g.GetXmlProperty("genxml/textbox/groupref")))
                        {
                            GroupsDictionary.Add(g.GetXmlProperty("genxml/textbox/groupref"), g.GetXmlProperty("genxml/lang/genxml/textbox/groupname"));
                        }
                    }
                    NBrightBuyUtils.SetModCache(-1, strCacheKey, GroupsDictionary);
                }

                // build group category list
                strCacheKey     = "GrpCategoryList_" + lang + "_" + _portalId;
                GrpCategoryList = (List <GroupCategoryData>)NBrightBuyUtils.GetModCache(strCacheKey);
                if (GrpCategoryList == null || debugMode)
                {
                    GrpCategoryList = GetGrpCatListFromDatabase(lang);
                    NBrightBuyUtils.SetModCache(-1, strCacheKey, GrpCategoryList);
                }

                // build cateogry list for navigation from group category list
                strCacheKey  = "CategoryList_" + lang + "_" + _portalId;
                CategoryList = (List <GroupCategoryData>)NBrightBuyUtils.GetModCache(strCacheKey);
                if (CategoryList == null || debugMode)
                {
                    var lenum = from i in GrpCategoryList where i.grouptyperef == "cat" select i;
                    CategoryList = lenum.ToList();
                    NBrightBuyUtils.SetModCache(-1, strCacheKey, CategoryList);
                }

                // add breadcrumb (needs both GrpCategoryList and CategoryList )
                //[TODO: fix this catch 22 for list dependancy]
                foreach (var grpcat in CategoryList)
                {
                    grpcat.breadcrumb = GetBreadCrumb(grpcat.categoryid, 200, ">", false);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get ProductData class with cacheing
        /// </summary>
        /// <param name="categoryId"></param>
        /// <param name="lang"></param>
        /// <returns></returns>
        public static CategoryData GetCategoryData(int categoryId, String lang)
        {
            CategoryData catData;
            var          cacheKey = "NBSCategoryData*" + categoryId.ToString("") + "*" + lang;

            catData = (CategoryData)NBrightBuyUtils.GetModCache(cacheKey);
            if (catData == null)
            {
                catData = new CategoryData(categoryId, lang);
                NBrightBuyUtils.SetModCache(-1, cacheKey, catData); // use module cache, so recussive changes are release from cache on update.
            }
            return(catData);
        }
Exemplo n.º 4
0
        private void Load(String lang, Boolean debugMode = false)
        {
            _objCtrl = new NBrightBuyController();
            _lang    = lang;

            var strCacheKey = "NBS_GrpList_" + lang + "_" + _portalId;

            GroupList = (List <NBrightInfo>)NBrightBuyUtils.GetModCache(strCacheKey);
            if (GroupList == null || debugMode)
            {
                // get groups
                GroupList = NBrightBuyUtils.GetCategoryGroups(_lang, true);
                NBrightBuyUtils.SetModCache(-1, strCacheKey, GroupList);
            }

            strCacheKey      = "NBS_GroupsDictionary_" + lang + "_" + _portalId;
            GroupsDictionary = (Dictionary <string, string>)NBrightBuyUtils.GetModCache(strCacheKey);
            if (GroupsDictionary == null || debugMode)
            {
                GroupsDictionary = new Dictionary <String, String>();
                foreach (var g in GroupList)
                {
                    if (!GroupsDictionary.ContainsKey(g.GetXmlProperty("genxml/textbox/groupref")))
                    {
                        GroupsDictionary.Add(g.GetXmlProperty("genxml/textbox/groupref"), g.GetXmlProperty("genxml/lang/genxml/textbox/groupname"));
                    }
                }
                NBrightBuyUtils.SetModCache(-1, strCacheKey, GroupsDictionary);
            }

            // build group category list
            strCacheKey     = "NBS_GrpCategoryList_" + lang + "_" + _portalId;
            GrpCategoryList = (List <GroupCategoryData>)NBrightBuyUtils.GetModCache(strCacheKey);
            if (GrpCategoryList == null || debugMode)
            {
                GrpCategoryList = GetGrpCatListFromDatabase(lang);
                NBrightBuyUtils.SetModCache(-1, strCacheKey, GrpCategoryList);
            }

            // build cateogry list for navigation from group category list
            strCacheKey  = "NBS_CategoryList_" + lang + "_" + _portalId;
            CategoryList = (List <GroupCategoryData>)NBrightBuyUtils.GetModCache(strCacheKey);
            if (CategoryList == null || debugMode)
            {
                var lenum = from i in GrpCategoryList where i.grouptyperef == "cat" select i;
                CategoryList = lenum.ToList();
                NBrightBuyUtils.SetModCache(-1, strCacheKey, CategoryList);
            }
        }
Exemplo n.º 5
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();
            }
        }
Exemplo n.º 6
0
        private void RazorPageLoad()
        {
            NBrightInfo objCat = null;

            if (_templD.Trim() != "")  // if we don;t have a template, don't do anything
            {
                if (_displayentrypage)
                {
                    // get correct itemid, based on eid given
                    _eid = GetEntryIdFromName(_eid);
                    RazorDisplayDataEntry(_eid);
                }
                else
                {
                    // Get meta data from template

                    var metaTokens = NBrightBuyUtils.RazorPreProcessTempl(_templD, _controlPath, ModSettings.ThemeFolder, Utils.GetCurrentCulture(), ModSettings.Settings(), ModuleId.ToString());

                    #region "Order BY"

                    ////////////////////////////////////////////
                    // get ORDERBY SORT
                    ////////////////////////////////////////////
                    if (_orderbyindex != "") // if we have orderby set in url, find the meta tags
                    {
                        if (metaTokens.ContainsKey("orderby" + _orderbyindex))
                        {
                            if (metaTokens["orderby" + _orderbyindex].Contains("{") || metaTokens["orderby" + _orderbyindex].ToLower().Contains("order by"))
                            {
                                _navigationdata.OrderBy    = metaTokens["orderby" + _orderbyindex];
                                _navigationdata.OrderByIdx = _orderbyindex;
                            }
                            else
                            {
                                _navigationdata.OrderBy    = " Order by " + metaTokens["orderby" + _orderbyindex];
                                _navigationdata.OrderByIdx = _orderbyindex;
                            }
                            _navigationdata.Save();
                        }
                    }
                    else
                    {
                        if (String.IsNullOrEmpty(_navigationdata.OrderBy) && metaTokens.ContainsKey("orderby"))
                        {
                            if (metaTokens["orderby"].Contains("{") || metaTokens["orderby"].ToLower().Contains("order by"))
                            {
                                _navigationdata.OrderBy = metaTokens["orderby"];
                            }
                            else
                            {
                                _navigationdata.OrderBy = " Order by " + metaTokens["orderby"];
                            }
                            _navigationdata.OrderByIdx = "";
                            _navigationdata.Save();
                        }
                    }


                    #endregion

                    #region "Get Paging setup"

                    //See if we have a pagesize, uses the "searchpagesize" tag token.
                    // : This can be overwritten by the cookie value if we need user selection of pagesize.
                    CtrlPaging.Visible = false;

                    #region "Get pagesize, from best place"

                    var pageSize = 0;
                    if (Utils.IsNumeric(ModSettings.Get("pagesize")))
                    {
                        pageSize = Convert.ToInt32(ModSettings.Get("pagesize"));
                    }
                    // overwrite default module pagesize , if we have a pagesize control in the template
                    if (metaTokens.ContainsKey("selectpagesize") && Utils.IsNumeric(_navigationdata.PageSize))
                    {
                        pageSize = Convert.ToInt32(_navigationdata.PageSize);
                    }
                    //check for url param page size
                    if (Utils.IsNumeric(_pagesize) && (_pagemid == "" | _pagemid == ModuleId.ToString(CultureInfo.InvariantCulture)))
                    {
                        pageSize = Convert.ToInt32(_pagesize);
                    }
                    if (pageSize == 0)
                    {
                        var strPgSize = "";
                        if (metaTokens.ContainsKey("searchpagesize"))
                        {
                            strPgSize = metaTokens["searchpagesize"];
                        }
                        if (metaTokens.ContainsKey("pagesize") && strPgSize == "")
                        {
                            strPgSize = metaTokens["pagesize"];
                        }
                        if (Utils.IsNumeric(strPgSize))
                        {
                            pageSize = Convert.ToInt32(strPgSize);
                        }
                    }
                    if (pageSize > 0)
                    {
                        CtrlPaging.Visible = true;
                    }
                    _navigationdata.PageSize = pageSize.ToString("");

                    #endregion

                    var pageNumber = 1;
                    //check for url param paging
                    if (Utils.IsNumeric(_pagenum) && (_pagemid == "" | _pagemid == ModuleId.ToString(CultureInfo.InvariantCulture)))
                    {
                        pageNumber = Convert.ToInt32(_pagenum);
                    }

                    //Get returnlimt from module settings
                    var returnlimit    = 0;
                    var strreturnlimit = ModSettings.Get("returnlimit");
                    if (Utils.IsNumeric(strreturnlimit))
                    {
                        returnlimit = Convert.ToInt32(strreturnlimit);
                    }

                    #endregion

                    #region "Get filter setup"

                    // check the display header to see if we have a sqlfilter defined.
                    var strFilter         = "";
                    var sqlTemplateFilter = "";
                    if (metaTokens.ContainsKey("sqlfilter"))
                    {
                        sqlTemplateFilter = GenXmlFunctions.StripSqlCommands(metaTokens["sqlfilter"]);
                    }

                    if (_navigationdata.HasCriteria)
                    {
                        var paramcatid = Utils.RequestQueryStringParam(Context, "catid");
                        if (Utils.IsNumeric(paramcatid))
                        {
                            if (_navigationdata.CategoryId != Convert.ToInt32(paramcatid)) // filter mode DOES NOT persist catid (stop confusion when user selects a category)
                            {
                                _navigationdata.ResetSearch();
                            }
                        }

                        // if navdata is not deleted then get filter from navdata, created by productsearch module.
                        strFilter = _navigationdata.Criteria;
                        if (!strFilter.Contains(sqlTemplateFilter))
                        {
                            strFilter += " " + sqlTemplateFilter;
                        }

                        if (_navigationdata.Mode.ToLower() == "s")
                        {
                            _navigationdata.ResetSearch();                                        // single search so clear after
                        }
                    }
                    else
                    {
                        // reset search if category selected
                        // NOTE: keeping search across categories is VERY confusing for cleint, although it works logically.
                        _navigationdata.ResetSearch();
                        strFilter = sqlTemplateFilter;
                    }

                    #endregion

                    #region "Get Category select setup"

                    var objQual = DotNetNuke.Data.DataProvider.Instance().ObjectQualifier;
                    var dbOwner = DataProvider.Instance().DatabaseOwner;

                    //get default catid.
                    var catseo   = _catid;
                    var defcatid = ModSettings.Get("defaultcatid");
                    if (defcatid == "")
                    {
                        defcatid = "0";
                    }
                    if (Utils.IsNumeric(defcatid) && Convert.ToInt32(defcatid) > 0)
                    {
                        // if we have no filter use the default category
                        if (_catid == "" && strFilter.Trim() == "")
                        {
                            _catid = defcatid;
                        }
                    }
                    else
                    {
                        defcatid = ModSettings.Get("defaultpropertyid");
                        if (defcatid == "")
                        {
                            defcatid = "0";
                        }
                        if (Utils.IsNumeric(defcatid))
                        {
                            // if we have no filter use the default category
                            if (_catid == "" && strFilter.Trim() == "")
                            {
                                _catid = defcatid;
                            }
                        }
                    }

                    // If we have a static list,then always display the default category
                    if (ModSettings.Get("staticlist") == "True")
                    {
                        if (catseo == "")
                        {
                            catseo = _catid;
                        }
                        _catid = defcatid;
                        if (ModSettings.Get("chkcascaderesults").ToLower() == "true")
                        {
                            strFilter = strFilter + " and NB1.[ItemId] in (select parentitemid from " + dbOwner + "[" + objQual + "NBrightBuy] where (typecode = 'CATCASCADE' or typecode = 'CATXREF') and XrefItemId = " + _catid + ") ";
                        }
                        else
                        {
                            strFilter = strFilter + " and NB1.[ItemId] in (select parentitemid from " + dbOwner + "[" + objQual + "NBrightBuy] where typecode = 'CATXREF' and XrefItemId = " + _catid + ") ";
                        }

                        if (ModSettings.Get("caturlfilter") == "True" && catseo != "" && catseo != _catid)
                        {
                            // add aditional filter for catid filter on url (catseo holds catid from url)
                            if (ModSettings.Get("chkcascaderesults").ToLower() == "true")
                            {
                                strFilter = strFilter + " and NB1.[ItemId] in (select parentitemid from " + dbOwner + "[" + objQual + "NBrightBuy] where (typecode = 'CATCASCADE' or typecode = 'CATXREF') and XrefItemId = " + catseo + ") ";
                            }
                            else
                            {
                                strFilter = strFilter + " and NB1.[ItemId] in (select parentitemid from " + dbOwner + "[" + objQual + "NBrightBuy] where typecode = 'CATXREF' and XrefItemId = " + catseo + ") ";
                            }
                        }
                        // do special custom sort in each cateogry, this passes the catid to the SQL SPROC, whcih process the '{bycategoryproduct}' and orders by product/category seq.
                        if (_navigationdata.OrderBy.Contains("{bycategoryproduct}"))
                        {
                            _navigationdata.OrderBy = "{bycategoryproduct}" + _catid;
                        }
                    }
                    else
                    {
                        #region "use url to get category to display"

                        //check if we are display categories
                        // get category list data
                        if (_catname != "") // if catname passed in url, calculate what the catid is
                        {
                            objCat = ModCtrl.GetByGuidKey(PortalId, ModuleId, "CATEGORYLANG", _catname);
                            if (objCat == null)
                            {
                                // check it's not just a single language
                                objCat = ModCtrl.GetByGuidKey(PortalId, ModuleId, "CATEGORY", _catname);
                                if (objCat != null)
                                {
                                    _catid = objCat.ItemID.ToString("");
                                }
                            }
                            else
                            {
                                _catid = objCat.ParentItemId.ToString("");
                                if (!String.IsNullOrEmpty(objCat.GUIDKey) && Utils.IsNumeric(_catid) && objCat.Lang != Utils.GetCurrentCulture())
                                {
                                    // do a 301 redirect to correct url for the langauge (If the langauge is changed on the product list, we need to make sure we have the correct catref for the langauge)
                                    var catGrpCtrl = new GrpCatController(Utils.GetCurrentCulture());
                                    var activeCat  = catGrpCtrl.GetCategory(Convert.ToInt32(_catid));
                                    if (activeCat != null)
                                    {
                                        var redirecturl = "";
                                        if (Utils.IsNumeric(_eid))
                                        {
                                            var prdData = ProductUtils.GetProductData(Convert.ToInt32(_eid), Utils.GetCurrentCulture(), true, EntityTypeCode);
                                            redirecturl = NBrightBuyUtils.GetEntryUrl(PortalId, _eid, _modkey, prdData.SEOName, TabId.ToString(), "", activeCat.categoryrefGUIDKey);
                                        }
                                        else
                                        {
                                            redirecturl = catGrpCtrl.GetCategoryUrl(activeCat, TabId, Utils.GetCurrentCulture());
                                        }

                                        try
                                        {
                                            if (redirecturl != "")
                                            {
                                                Response.Redirect(redirecturl, false);
                                                Response.StatusCode = (int)System.Net.HttpStatusCode.MovedPermanently;
                                                Response.End();
                                            }
                                        }
                                        catch (Exception)
                                        {
                                            // catch err
                                        }
                                    }
                                }
                            }
                            // We have a category selected (in url), so overwrite categoryid navigationdata.
                            // This allows the return to the same category after a returning from a entry view.
                            if (Utils.IsNumeric(_catid))
                            {
                                _navigationdata.CategoryId = Convert.ToInt32(_catid);
                            }
                            catseo = _catid;
                            _navigationdata.ResetSearch();
                            strFilter = "";
                        }

                        if (Utils.IsNumeric(_catid))
                        {
                            if (ModSettings.Get("chkcascaderesults").ToLower() == "true")
                            {
                                strFilter = strFilter + " and NB1.[ItemId] in (select parentitemid from " + dbOwner + "[" + objQual + "NBrightBuy] where (typecode = 'CATCASCADE' or typecode = 'CATXREF') and XrefItemId = " + _catid + ") ";
                            }
                            else
                            {
                                strFilter = strFilter + " and NB1.[ItemId] in (select parentitemid from " + dbOwner + "[" + objQual + "NBrightBuy] where typecode = 'CATXREF' and XrefItemId = " + _catid + ") ";
                            }

                            if (Utils.IsNumeric(catseo))
                            {
                                var objSEOCat = ModCtrl.GetData(Convert.ToInt32(catseo), "CATEGORYLANG", Utils.GetCurrentCulture());
                                if (objSEOCat != null && _eid == "") // we may have a detail page and listonly module, in which can we need the product detail as page title
                                {
                                    //Page Title
                                    var seoname = objSEOCat.GetXmlProperty("genxml/lang/genxml/textbox/txtseoname");
                                    if (seoname == "")
                                    {
                                        seoname = objSEOCat.GetXmlProperty("genxml/lang/genxml/textbox/txtcategoryname");
                                    }

                                    var newBaseTitle = objSEOCat.GetXmlProperty("genxml/lang/genxml/textbox/txtseopagetitle");
                                    if (newBaseTitle == "")
                                    {
                                        newBaseTitle = objSEOCat.GetXmlProperty("genxml/lang/genxml/textbox/txtseoname");
                                    }
                                    if (newBaseTitle == "")
                                    {
                                        newBaseTitle = objSEOCat.GetXmlProperty("genxml/lang/genxml/textbox/txtcategoryname");
                                    }
                                    if (newBaseTitle != "")
                                    {
                                        BasePage.Title = newBaseTitle;
                                    }
                                    //Page KeyWords
                                    var newBaseKeyWords = objSEOCat.GetXmlProperty("genxml/lang/genxml/textbox/txtmetakeywords");
                                    if (newBaseKeyWords != "")
                                    {
                                        BasePage.KeyWords = newBaseKeyWords;
                                    }
                                    //Page Description
                                    var newBaseDescription = objSEOCat.GetXmlProperty("genxml/lang/genxml/textbox/txtmetadescription");
                                    if (newBaseDescription == "")
                                    {
                                        newBaseDescription = objSEOCat.GetXmlProperty("genxml/lang/genxml/textbox/txtcategorydesc");
                                    }
                                    if (newBaseDescription != "")
                                    {
                                        BasePage.Description = newBaseDescription;
                                    }


                                    // Remove canonical link for list.  The Open URL Rewriter (OUR) will create a url that is different to the default SEO url in NBS.
                                    // So to stop clashes it's been disable by default.  The requirment for a canonical link on a category list is more ticking the box than of being any SEO help (might even be causing confusion to Search Engines).
                                    // ** If your a SEO nutcases (or SEO companies pushing for it) then you can uncomment the code below, and you can implement the Open URL Rewriter and canonical link.

                                    //if (PortalSettings.HomeTabId == TabId)
                                    //    PageIncludes.IncludeCanonicalLink(Page, Globals.AddHTTP(PortalSettings.PortalAlias.HTTPAlias)); //home page always default of site.
                                    //else
                                    //{
                                    //    PageIncludes.IncludeCanonicalLink(Page, NBrightBuyUtils.GetListUrl(PortalId, TabId, objSEOCat.ItemID, seoname, Utils.GetCurrentCulture()));
                                    //    // Code required for OUR (if used, test to ensure it works correctly!!)
                                    //    //PageIncludes.IncludeCanonicalLink(Page, NBrightBuyUtils.GetListUrl(PortalId, TabId, objSEOCat.ItemID, "", Utils.GetCurrentCulture()));
                                    //}
                                }
                            }

                            // do special custom sort in each cateogry, this passes the catid to the SQL SPROC, whcih process the '{bycategoryproduct}' and orders by product/category seq.
                            if (_navigationdata.OrderBy.Contains("{bycategoryproduct}"))
                            {
                                _navigationdata.OrderBy = "{bycategoryproduct}" + _catid;
                            }
                        }
                        else
                        {
                            if (!_navigationdata.FilterMode)
                            {
                                _navigationdata.CategoryId = 0;                              // filter mode persist catid
                            }
                            if (_navigationdata.OrderBy.Contains("{bycategoryproduct}"))
                            {
                                _navigationdata.OrderBy = " Order by ModifiedDate DESC  ";
                            }
                        }

                        #endregion
                    }

                    // This allows the return to the same category after a returning from a entry view. + Gives support for current category in razor tokens
                    if (Utils.IsNumeric(_catid))
                    {
                        _navigationdata.CategoryId = Convert.ToInt32(_catid);
                    }

                    #endregion

                    #region "Apply provider product filter"

                    // Special filtering can be done, by using the ProductFilter interface.
                    var productfilterkey = "";
                    if (metaTokens.ContainsKey("providerfilterkey"))
                    {
                        productfilterkey = metaTokens["providerfilterkey"];
                    }
                    if (productfilterkey != "")
                    {
                        var provfilter = FilterInterface.Instance(productfilterkey);
                        if (provfilter != null)
                        {
                            strFilter = provfilter.GetFilter(strFilter, _navigationdata, ModSettings, Context);
                        }
                    }

                    #endregion

                    #region "itemlists (wishlist)"

                    // if we have a itemListName field then get the itemlist cookie.
                    if (ModSettings.Get("displaytype") == "2") // displaytype 2 = "selected list"
                    {
                        var cw = new ItemListData(PortalId, UserController.Instance.GetCurrentUserInfo().UserID);
                        if (cw.Exists && cw.ItemCount > 0)
                        {
                            strFilter = " and (";
                            foreach (var i in cw.GetItemList())
                            {
                                strFilter += " NB1.itemid = '" + i + "' or";
                            }
                            strFilter = strFilter.Substring(0, (strFilter.Length - 3)) + ") ";
                            // remove the last "or"
                        }
                        else
                        {
                            //no data in list so select false itemid to stop anything displaying
                            strFilter += " and (NB1.itemid = '-1') ";
                        }
                    }

                    #endregion

                    // insert page header text
                    NBrightBuyUtils.RazorIncludePageHeader(ModuleId, Page, Path.GetFileNameWithoutExtension(_templD) + "_head" + Path.GetExtension(_templD), _controlPath, ModSettings.ThemeFolder, ModSettings.Settings());

                    // save navigation data
                    _navigationdata.PageModuleId = Utils.RequestParam(Context, "pagemid");
                    _navigationdata.PageNumber   = Utils.RequestParam(Context, "page");
                    if (Utils.IsNumeric(_catid))
                    {
                        _navigationdata.PageName = NBrightBuyUtils.GetCurrentPageName(Convert.ToInt32(_catid));
                    }

                    // save the last active modulekey to a cookie, so it can be used by the "NBrightBuyUtils.GetReturnUrl" function
                    NBrightCore.common.Cookie.SetCookieValue(PortalId, "NBrigthBuyLastActive", "ModuleKey", ModuleKey, 1);


                    if (strFilter.Trim() == "")
                    {
                        // if at this point we have no filter, then assume we're using urlrewriter and a 404 url has been entered.
                        // rather than display all visible products in a list with no default.
                        // redirect to the product display function, so we can display a 404 and product not found.
                        RazorDisplayDataEntry(_eid);
                    }
                    else
                    {
                        strFilter += " and (NB3.Visible = 1) "; // get only visible products

                        var recordCount = ModCtrl.GetDataListCount(PortalId, ModuleId, EntityTypeCode, strFilter, EntityTypeCodeLang, Utils.GetCurrentCulture(), DebugMode);

                        _navigationdata.RecordCount = recordCount.ToString("");
                        _navigationdata.Save();

                        if (returnlimit > 0 && returnlimit < recordCount)
                        {
                            recordCount = returnlimit;
                        }

                        // **** check if we already have the template cached, if so no need for DB call or razor call ****
                        // get same cachekey used for DB return, and use for razor.
                        var razorcachekey = ModCtrl.GetDataListCacheKey(PortalId, ModuleId, EntityTypeCode, EntityTypeCodeLang, Utils.GetCurrentCulture(), strFilter, _navigationdata.OrderBy, DebugMode, "", returnlimit, pageNumber, pageSize, recordCount);
                        var cachekey      = "NBrightBuyRazorOutput" + _templD + "*" + razorcachekey + PortalId.ToString();
                        var strOut        = (String)NBrightBuyUtils.GetModCache(cachekey);
                        if (strOut == null || StoreSettings.Current.DebugMode)
                        {
                            var l = ModCtrl.GetDataList(PortalId, ModuleId, EntityTypeCode, EntityTypeCodeLang, Utils.GetCurrentCulture(), strFilter, _navigationdata.OrderBy, DebugMode, "", returnlimit, pageNumber, pageSize, recordCount);
                            strOut = NBrightBuyUtils.RazorTemplRenderList(_templD, ModuleId, razorcachekey, l, _controlPath, ModSettings.ThemeFolder, Utils.GetCurrentCulture(), ModSettings.Settings());
                        }

                        var lit = new Literal();
                        lit.Text = strOut;
                        phData.Controls.Add(lit);

                        if (_navigationdata.SingleSearchMode)
                        {
                            _navigationdata.ResetSearch();
                        }

                        if (pageSize > 0)
                        {
                            CtrlPaging.PageSize     = pageSize;
                            CtrlPaging.CurrentPage  = pageNumber;
                            CtrlPaging.TotalRecords = recordCount;
                            CtrlPaging.BindPageLinks();
                        }
                    }
                }
            }
        }
Exemplo n.º 7
0
        private void BuildSettingsDic(System.Collections.Hashtable modSettings)
        {
            var nbbSettings = NBrightBuyUtils.GetSettings(PortalSettings.Current.PortalId, Moduleid);

            _settingsDic = new Dictionary <string, string>();
            // this function will build the Settings that is passed to the templating system.
            var strCacheKey = PortalSettings.Current.PortalId.ToString("") + "*" + Moduleid.ToString("") + "*SettingsDic";
            var obj         = NBrightBuyUtils.GetModCache(strCacheKey);

            if (obj != null)
            {
                _settingsDic = (Dictionary <string, string>)obj;
            }
            if (_settingsDic.Count == 0 || StoreSettings.Current.DebugMode)
            {
                if (!_settingsDic.ContainsKey("tabid"))
                {
                    _settingsDic.Add("tabid", PortalSettings.Current.ActiveTab.TabID.ToString(""));
                }

                // add store settings (we keep store settings at module level, because these can be overwritten by the module)
                var storesettings = StoreSettings.Current.Settings(); // assign to var, so it doesn;t causes error if site settings change during loop.
                foreach (var item in storesettings)
                {
                    if (_settingsDic.ContainsKey(item.Key))
                    {
                        _settingsDic[item.Key] = item.Value;
                    }
                    else
                    {
                        _settingsDic.Add(item.Key, item.Value);
                    }
                }


                // add normal DNN Setting
                foreach (string name in modSettings.Keys)
                {
                    if (!_settingsDic.ContainsKey(name))
                    {
                        _settingsDic.Add(name, modSettings[name].ToString());
                    }
                }

                // add nbbSettings Settings
                AddToSettingDic(nbbSettings, "genxml/hidden/*");
                AddToSettingDic(nbbSettings, "genxml/textbox/*");
                AddToSettingDic(nbbSettings, "genxml/checkbox/*");
                AddToSettingDic(nbbSettings, "genxml/dropdownlist/*");
                AddToSettingDic(nbbSettings, "genxml/radiobuttonlist/*");


                // redo the moduleid key, on imported module settings this could be wrong.
                if (_settingsDic.ContainsKey("moduleid"))
                {
                    _settingsDic["moduleid"] = Moduleid.ToString("");
                }
                else
                {
                    _settingsDic.Add("moduleid", Moduleid.ToString(""));
                }

                NBrightBuyUtils.SetModCache(Moduleid, strCacheKey, _settingsDic);
            }
            else
            {
                _settingsDic = (Dictionary <string, string>)obj;
            }

            // redo the edit langauge for backoffice.
            if (_settingsDic != null)
            {
                if (_settingsDic.ContainsKey("editlanguage"))
                {
                    _settingsDic["editlanguage"] = StoreSettings.Current.EditLanguage;
                }
                else
                {
                    _settingsDic.Add("editlanguage", StoreSettings.Current.EditLanguage);
                }
            }
        }
Exemplo n.º 8
0
        private void PopulateClientData(int userId, bool debugmode = false)
        {
            _clientInfo          = new NBrightInfo(true);
            _clientInfo.ItemID   = userId;
            _clientInfo.UserId   = userId;
            _clientInfo.PortalId = PortalId;

            DataRecord = (NBrightInfo)NBrightBuyUtils.GetModCache(_cacheKey);

            if (DataRecord == null)
            {
                // get any datarecord on DB
                var objCtrl = new NBrightBuyController();
                DataRecord = objCtrl.GetByType(PortalId, -1, "CLIENT", userId.ToString(""), "", "", debugmode);
                if (DataRecord == null)
                {
                    DataRecord          = new NBrightInfo(true);
                    DataRecord.ItemID   = -1;
                    DataRecord.UserId   = userId;
                    DataRecord.PortalId = PortalId;
                    DataRecord.ModuleId = -1;
                    DataRecord.TypeCode = "CLIENT";
                    objCtrl.Update(DataRecord);
                }
                else
                {
                    _clientInfo.XMLData = DataRecord.XMLData;
                }

                NBrightBuyUtils.SetModCache(-1, _cacheKey, DataRecord);
            }
            else
            {
                _clientInfo.XMLData = DataRecord.XMLData;
            }

            _userInfo = UserController.GetUserById(PortalId, userId);
            if (_userInfo != null)
            {
                Exists = true;

                _clientInfo.ModifiedDate = _userInfo.Membership.CreatedDate;

                foreach (var propertyInfo in _userInfo.GetType().GetProperties())
                {
                    if (propertyInfo.CanRead)
                    {
                        object pv = null;
                        try
                        {
                            pv = propertyInfo.GetValue(_userInfo, null);
                            if (pv == null)
                            {
                                pv = "";
                            }
                        }
                        catch (Exception)
                        {
                            pv = "";
                        }
                        _clientInfo.SetXmlProperty("genxml/textbox/" + propertyInfo.Name.ToLower(), pv.ToString());
                    }
                }

                foreach (DotNetNuke.Entities.Profile.ProfilePropertyDefinition p in _userInfo.Profile.ProfileProperties)
                {
                    _clientInfo.SetXmlProperty("genxml/textbox/" + p.PropertyName.ToLower(), p.PropertyValue);
                }

                _clientInfo.AddSingleNode("membership", "", "genxml");
                foreach (var propertyInfo in _userInfo.Membership.GetType().GetProperties())
                {
                    if (propertyInfo.CanRead)
                    {
                        var pv = propertyInfo.GetValue(_userInfo.Membership, null);
                        if (pv != null)
                        {
                            _clientInfo.SetXmlProperty("genxml/membership/" + propertyInfo.Name.ToLower(), pv.ToString());
                        }
                    }
                }

                if (_userInfo.IsInRole(StoreSettings.ClientEditorRole))
                {
                    _clientInfo.SetXmlProperty("genxml/checkbox/clienteditorrole", "True");
                }
                else
                {
                    _clientInfo.SetXmlProperty("genxml/checkbox/clienteditorrole", "False");
                }

                DiscountCodes = GetEntityList("discountcodes");
                VoucherCodes  = GetEntityList("vouchercodes");
            }
        }
Exemplo n.º 9
0
        private void PageLoad()
        {
            var catid = 0;

            if (Utils.IsNumeric(_catid))
            {
                catid = Convert.ToInt32(_catid);
            }

            #region "Get default category into list for displaying header and footer templates on product (breadcrumb)"

            // if we have a product displaying, get the deault category for the category
            var obj = new GroupCategoryData();
            if (Utils.IsNumeric(_entryid))
            {
                if (catid == 0)
                {
                    catid = _catGrpCtrl.GetDefaultCatId(Convert.ToInt32(_entryid));
                }
            }
            else
            {
                if (catid != 0)
                {
                    obj = _catGrpCtrl.GetCategory(catid);
                }
            }
            var catl = new List <object> {
                obj
            };

            if (Utils.IsNumeric(catid) && ModSettings.Get("injectseo") == "True")
            {
                var eid       = Utils.RequestQueryStringParam(Context, "eid");
                var objSEOCat = ModCtrl.GetData(Convert.ToInt32(catid), "CATEGORYLANG", Utils.GetCurrentCulture());
                if (objSEOCat != null && eid == "")  // we may have a detail page and listonly module, in which can we need the product detail as page title
                {
                    //Page Title
                    var seoname = objSEOCat.GetXmlProperty("genxml/lang/genxml/textbox/txtseoname");
                    if (seoname == "")
                    {
                        seoname = objSEOCat.GetXmlProperty("genxml/lang/genxml/textbox/txtcategoryname");
                    }

                    var newBaseTitle = objSEOCat.GetXmlProperty("genxml/lang/genxml/textbox/txtseopagetitle");
                    if (newBaseTitle == "")
                    {
                        newBaseTitle = objSEOCat.GetXmlProperty("genxml/lang/genxml/textbox/txtseoname");
                    }
                    if (newBaseTitle == "")
                    {
                        newBaseTitle = objSEOCat.GetXmlProperty("genxml/lang/genxml/textbox/txtcategoryname");
                    }
                    if (newBaseTitle != "")
                    {
                        BasePage.Title = BasePage.Title + " > " + newBaseTitle;
                    }
                    //Page KeyWords
                    var newBaseKeyWords = objSEOCat.GetXmlProperty("genxml/lang/genxml/textbox/txtmetakeywords");
                    if (newBaseKeyWords != "")
                    {
                        BasePage.KeyWords = newBaseKeyWords;
                    }
                    //Page Description
                    var newBaseDescription = objSEOCat.GetXmlProperty("genxml/lang/genxml/textbox/txtmetadescription");
                    if (newBaseDescription == "")
                    {
                        newBaseDescription = objSEOCat.GetXmlProperty("genxml/lang/genxml/textbox/txtcategorydesc");
                    }
                    if (newBaseDescription != "")
                    {
                        BasePage.Description = newBaseDescription;
                    }
                }
            }


            #endregion

            #region "Data Repeater"


            if (_templD.Trim() != "")     // if we don;t have a template, don't do anything
            {
                var menutype = ModSettings.Get("ddlmenutype").ToLower();

                #region "Drill Down"

                if (menutype == "drilldown")
                {
                    var l = _catGrpCtrl.GetVisibleCategoriesWithUrl(catid, TabId);
                    if (l.Count == 0 && (ModSettings.Get("alwaysshow") == "True"))
                    {
                        // if we have no categories, it could be the end of branch or product view, so load the root menu
                        var catid2 = 0;
                        _catid = ModSettings.Get("defaultcatid");
                        if (Utils.IsNumeric(_catid))
                        {
                            catid2 = Convert.ToInt32(_catid);
                        }
                        l = _catGrpCtrl.GetVisibleCategoriesWithUrl(catid2, TabId);
                    }
                    rpData.DataSource = l;
                    rpData.DataBind();
                }

                #endregion

                #region "treeview"

                if (menutype == "treeview")
                {
                    var catidtree = 0;
                    if (Utils.IsNumeric(ModSettings.Get("defaultcatid")))
                    {
                        catidtree = Convert.ToInt32(ModSettings.Get("defaultcatid"));
                    }

                    var cachekey = "CatMenu*" + ModuleId.ToString("") + "*" + catid + "*" + catidtree.ToString() + "*" + Utils.GetCurrentCulture();
                    var strOut   = (String)NBrightBuyUtils.GetModCache(cachekey);
                    if (strOut == null)
                    {
                        rpData.Visible = false;
                        var catBuiler = new CatMenuBuilder(_templD, ModSettings, catid, DebugMode);
                        strOut = catBuiler.GetTreeCatList(50, catidtree, Convert.ToInt32(_tabid), ModSettings.Get("treeidentclass"), ModSettings.Get("treerootclass"));

                        // if debug , output the html used.
                        if (StoreSettings.Current.DebugModeFileOut)
                        {
                            Utils.SaveFile(PortalSettings.HomeDirectoryMapPath + "debug_treemenu.html", strOut);
                        }
                        NBrightBuyUtils.SetModCache(ModuleId, cachekey, strOut);
                    }
                    var l = new Literal {
                        Text = strOut
                    };
                    phData.Controls.Add(l);
                }

                #endregion

                #region "Accordian"

                if (menutype == "accordian")
                {
                }

                #endregion

                #region "megamenu"

                if (menutype == "megamenu")
                {
                }

                #endregion
            }

            // display header
            rpDataH.DataSource = catl;
            rpDataH.DataBind();

            // display footer
            rpDataF.DataSource = catl;
            rpDataF.DataBind();

            #endregion
        }