Пример #1
0
        public string GetCategoryUrl(GroupCategoryData groupCategoryInfo, int tabid, String categorylangauge = "")
        {
            // if diabled return a javascript void
            if (groupCategoryInfo.disabled)
            {
                return("javascript:void(0)");
            }

            //set a default url
            var url = "";

            // get friendly url if possible
            if (groupCategoryInfo.categoryname != "")
            {
                var tab = CBO.FillObject <DotNetNuke.Entities.Tabs.TabInfo>(DotNetNuke.Data.DataProvider.Instance().GetTab(tabid));
                if (tab != null)
                {
                    var newBaseName = groupCategoryInfo.seoname;
                    newBaseName = Utils.UrlFriendly(newBaseName);
                    var ctrl = Utils.RequestParam(HttpContext.Current, "ctrl");
                    if (ctrl != "")
                    {
                        ctrl = "&ctrl=" + ctrl;
                    }
                    var language = categorylangauge;
                    if (language == "")
                    {
                        language = Utils.GetCurrentCulture();
                    }
                    if (StoreSettings.Current.GetBool(StoreSettingKeys.friendlyurlids))
                    {
                        url = DotNetNuke.Services.Url.FriendlyUrl.FriendlyUrlProvider.Instance().FriendlyUrl(tab, "~/Default.aspx?TabId=" + tab.TabID.ToString("") + "&catref=" + Utils.UrlFriendly(groupCategoryInfo.categoryrefGUIDKey) + ctrl + "&language=" + language);
                    }
                    else
                    {
                        // check if we are calling from BO with a ctrl param
                        url = DotNetNuke.Services.Url.FriendlyUrl.FriendlyUrlProvider.Instance().FriendlyUrl(tab, "~/Default.aspx?TabId=" + tab.TabID.ToString("") + "&catid=" + groupCategoryInfo.categoryid.ToString("") + ctrl + "&language=" + language, newBaseName + ".aspx");
                    }

                    url = url.Replace("[catid]/", "");     // remove the injection token from the url, if still there. (Should be removed redirected to new page)
                }
            }
            return(url);
        }
Пример #2
0
        private String BuildTreePropertyList(String rtnList, int level, int parentid, string groupref, int tabid, int displaylevels = 50, String identClass = "nbrightbuy_catmenu", String styleClass = "", String activeClass = "active")
        {
            if (level > displaylevels) return rtnList; // stop infinate loop

            // header
            if (level == 0)
                rtnList += "<ul class='" + identClass + " " + styleClass + "'>";
            else
                rtnList += "<ul>";

            var activeCat = _catGrpCtrl.GetCategory(_currentCatId);
            if (activeCat == null) activeCat = new GroupCategoryData();
            var depth = 0;
            var levelList = _catGrpCtrl.GetGrpCategories(parentid, ""); // force this to always categories
            foreach (GroupCategoryData grpcat in levelList)
            {
                if (grpcat.isvisible)
                {
                    // update cat info
                    grpcat.url = _catGrpCtrl.GetCategoryUrl(grpcat, tabid);
                    grpcat.depth = level; //make base 1, to pick up the

                    var openClass = "";
                    if (activeCat.Parents.Contains(grpcat.categoryid) || grpcat.categoryid == _currentCatId) openClass = " open ";

                    if (_currentCatId == grpcat.categoryid)
                        rtnList += "<li class='" + activeClass + openClass + "'>";
                    else
                    {
                        if (openClass == "")
                            rtnList += "<li>";
                        else
                            rtnList += "<li class='" + openClass + "'>";
                    }

                    //body
                    if (_razorTemplateName.Count > grpcat.depth) depth = grpcat.depth;
                    rtnList += NBrightBuyUtils.RazorTemplRender(_razorTemplateName[depth], -1, "", grpcat, _controlPath, _theme, _lang, StoreSettings.Current.Settings());

                    rtnList = BuildTreeCatList(rtnList, level + 1, grpcat.categoryid, groupref, tabid, displaylevels);

                    rtnList += "</li>";

                }
            }

            //footer
            rtnList += "</ul>";

            return rtnList;
        }
Пример #3
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
        }
Пример #4
0
        private List <GroupCategoryData> GetGrpCatListFromDatabase(String lang = "")
        {
            // this process seems to be creating an error on DB connection after the cache is release.
            //[TODO: re-write this code to stop DB conection failure. For now Module level caching has been increased to 2 days to stop this processing re-running]

            var          objCtrl    = new NBrightBuyController();
            const string strOrderBy = " order by [XMLData].value('(genxml/hidden/recordsortorder)[1]','decimal(10,2)') ";
            var          grpcatList = new List <GroupCategoryData>();

            var l   = objCtrl.GetList(_portalId, -1, "CATEGORY", "", strOrderBy, 0, 0, 0, 0, "", "");
            var lg  = objCtrl.GetList(_portalId, -1, "CATEGORYLANG", "and NB1.lang = '" + lang + "'", "", 0, 0, 0, 0, "", "");
            var lx  = objCtrl.GetList(_portalId, -1, "CATCASCADE", "", "", 0, 0, 0, 0, "", "");
            var lx2 = objCtrl.GetList(_portalId, -1, "CATXREF", "", "", 0, 0, 0, 0, "", "");

            lx.AddRange(lx2);
            foreach (var i in l)
            {
                var grpcat = new GroupCategoryData();
                grpcat.categoryid      = i.ItemID;
                grpcat.recordsortorder = i.GetXmlPropertyDouble("genxml/hidden/recordsortorder");
                grpcat.imageurl        = i.GetXmlProperty("genxml/hidden/imageurl");
                grpcat.categoryref     = i.GetXmlProperty("genxml/textbox/txtcategoryref");
                grpcat.propertyref     = i.GetXmlProperty("genxml/textbox/propertyref");
                grpcat.archived        = i.GetXmlPropertyBool("genxml/checkbox/chkarchived");
                grpcat.ishidden        = i.GetXmlPropertyBool("genxml/checkbox/chkishidden");
                grpcat.disabled        = i.GetXmlPropertyBool("genxml/checkbox/chkdisable");
                grpcat.grouptyperef    = i.GetXmlProperty("genxml/dropdownlist/ddlgrouptype");
                grpcat.attributecode   = i.GetXmlProperty("genxml/dropdownlist/ddlattrcode");
                grpcat.parentcatid     = i.ParentItemId;
                grpcat.entrycount      = GetEntryCount(lx, grpcat.categoryid);
                if (GroupsDictionary.ContainsKey(grpcat.grouptyperef))
                {
                    grpcat.groupname = GroupsDictionary[grpcat.grouptyperef];
                }

                // get the language data
                var langItem = GetLangData(lg, grpcat.categoryid);
                if (langItem != null)
                {
                    grpcat.categoryname = langItem.GetXmlProperty("genxml/textbox/txtcategoryname");
                    grpcat.categorydesc = langItem.GetXmlProperty("genxml/textbox/txtcategorydesc");
                    grpcat.seoname      = langItem.GetXmlProperty("genxml/textbox/txtseoname");
                    if (grpcat.seoname == "")
                    {
                        grpcat.seoname = langItem.GetXmlProperty("genxml/textbox/txtcategoryname");
                    }
                    grpcat.metadescription    = langItem.GetXmlProperty("genxml/textbox/txtmetadescription");
                    grpcat.metakeywords       = langItem.GetXmlProperty("genxml/textbox/txtmetakeywords");
                    grpcat.seopagetitle       = langItem.GetXmlProperty("genxml/textbox/txtseopagetitle");
                    grpcat.message            = langItem.GetXmlProperty("genxml/edt/message");
                    grpcat.categoryrefGUIDKey = langItem.GUIDKey;
                }

                //get parents
                var p = GetParentList(l, grpcat.categoryid);
                foreach (var pi in p)
                {
                    grpcat.Parents.Add(pi.ItemID);
                }

                grpcatList.Add(grpcat);
            }

            // we don;t have the depth number at this point, so use recussive call to calc it.
            CalcCategoryDepthList(grpcatList, 0, 0);

            return(grpcatList);
        }
Пример #5
0
        private String BuildTreeCatList(String rtnList, int level, int parentid, string groupref, int tabid, int displaylevels = 50, String identClass = "nbrightbuy_catmenu", String styleClass = "", String activeClass = "active")
        {
            if (level > displaylevels)
            {
                return(rtnList);                       // stop infinate loop
            }
            // header
            if (level == 0)
            {
                rtnList += "<ul class='" + identClass + " " + styleClass + "'>";
            }
            else
            {
                rtnList += "<ul>";
            }

            var activeCat = _catGrpCtrl.GetCategory(_currentCatId);

            if (activeCat == null)
            {
                activeCat = new GroupCategoryData();
            }
            var depth     = 0;
            var levelList = _catGrpCtrl.GetGrpCategories(parentid, "cat"); // force this to always categories

            foreach (GroupCategoryData grpcat in levelList)
            {
                if (grpcat.isvisible)
                {
                    // update cat info
                    grpcat.url   = _catGrpCtrl.GetCategoryUrl(grpcat, tabid);
                    grpcat.depth = level; //make base 1, to pick up the

                    var openClass = "";
                    if (activeCat.Parents.Contains(grpcat.categoryid) || grpcat.categoryid == _currentCatId)
                    {
                        openClass = " open ";
                    }

                    if (_currentCatId == grpcat.categoryid)
                    {
                        rtnList += "<li class='" + activeClass + openClass + "'>";
                    }
                    else
                    {
                        if (openClass == "")
                        {
                            rtnList += "<li>";
                        }
                        else
                        {
                            rtnList += "<li class='" + openClass + "'>";
                        }
                    }

                    //body
                    if (_templateBody.Count > grpcat.depth)
                    {
                        depth = grpcat.depth;
                    }
                    rtnList += GenXmlFunctions.RenderRepeater(grpcat, _templateBody[depth], "", "XMLData", "", StoreSettings.Current.Settings());

                    rtnList = BuildTreeCatList(rtnList, level + 1, grpcat.categoryid, groupref, tabid, displaylevels);

                    rtnList += "</li>";
                }
            }

            //footer
            rtnList += "</ul>";

            return(rtnList);
        }
Пример #6
0
        private List<GroupCategoryData> GetGrpCatListFromDatabase(String lang = "")
        {
            // this process seems to be creating an error on DB connection after the cache is release.
            //[TODO: re-write this code to stop DB conection failure. For now Module level caching has been increased to 2 days to stop this processing re-running]

            var objCtrl = new NBrightBuyController();
            const string strOrderBy = " order by [XMLData].value('(genxml/hidden/recordsortorder)[1]','decimal(10,2)') ";
            var grpcatList = new List<GroupCategoryData>();

            var l = objCtrl.GetList(PortalSettings.Current.PortalId, -1, "CATEGORY", "", strOrderBy, 0, 0, 0, 0, "", "");
            var lg = objCtrl.GetList(PortalSettings.Current.PortalId, -1, "CATEGORYLANG", "and NB1.lang = '" + lang + "'", "", 0, 0, 0, 0, "", "");
            var lx = objCtrl.GetList(PortalSettings.Current.PortalId, -1, "CATCASCADE", "", "", 0, 0, 0, 0, "", "");
            var lx2 = objCtrl.GetList(PortalSettings.Current.PortalId, -1, "CATXREF", "", "", 0, 0, 0, 0, "", "");
            lx.AddRange(lx2);
            foreach (var i in l)
            {
                var grpcat = new GroupCategoryData();
                grpcat.categoryid = i.ItemID;
                grpcat.recordsortorder = i.GetXmlPropertyDouble("genxml/hidden/recordsortorder");
                grpcat.imageurl = i.GetXmlProperty("genxml/hidden/imageurl");
                grpcat.categoryref = i.GetXmlProperty("genxml/textbox/txtcategoryref");
                grpcat.propertyref = i.GetXmlProperty("genxml/textbox/propertyref");
                grpcat.archived = i.GetXmlPropertyBool("genxml/checkbox/chkarchived");
                grpcat.ishidden = i.GetXmlPropertyBool("genxml/checkbox/chkishidden");
                grpcat.disabled = i.GetXmlPropertyBool("genxml/checkbox/chkdisable");
                grpcat.grouptyperef = i.GetXmlProperty("genxml/dropdownlist/ddlgrouptype");
                grpcat.parentcatid = i.ParentItemId;
                grpcat.entrycount = GetEntryCount(lx, grpcat.categoryid);
                if (GroupsDictionary.ContainsKey(grpcat.grouptyperef)) grpcat.groupname = GroupsDictionary[grpcat.grouptyperef];

                // get the language data
                var langItem =  GetLangData(lg,grpcat.categoryid);
                if (langItem != null)
                {
                    grpcat.categoryname = langItem.GetXmlProperty("genxml/textbox/txtcategoryname");
                    grpcat.categorydesc = langItem.GetXmlProperty("genxml/textbox/txtcategorydesc");
                    grpcat.seoname = langItem.GetXmlProperty("genxml/textbox/txtseoname");
                    if (grpcat.seoname == "") grpcat.seoname = langItem.GetXmlProperty("genxml/textbox/txtcategoryname");
                    grpcat.metadescription = langItem.GetXmlProperty("genxml/textbox/txtmetadescription");
                    grpcat.metakeywords = langItem.GetXmlProperty("genxml/textbox/txtmetakeywords");
                    grpcat.seopagetitle = langItem.GetXmlProperty("genxml/textbox/txtseopagetitle");
                    grpcat.message = langItem.GetXmlProperty("genxml/edt/message");
                    grpcat.categoryrefGUIDKey = langItem.GUIDKey;
                }

                //get parents
                var p = GetParentList(l,grpcat.categoryid);
                foreach (var pi in p)
                    grpcat.Parents.Add(pi.ItemID);

                grpcatList.Add(grpcat);
            }

            // we don;t have the depth number at this point, so use recussive call to calc it.
            CalcCategoryDepthList(grpcatList, 0, 0);

            return grpcatList;
        }
Пример #7
0
        public string GetCategoryUrl(GroupCategoryData groupCategoryInfo, int tabid)
        {
            // if diabled return a javascript void
            if (groupCategoryInfo.disabled) return "javascript:void(0)";

            //set a default url
            var url = "";

            // get friendly url if possible
                if (groupCategoryInfo.categoryname != "")
                {
                    var tab = CBO.FillObject<DotNetNuke.Entities.Tabs.TabInfo>(DotNetNuke.Data.DataProvider.Instance().GetTab(tabid));
                    if (tab != null)
                    {
                        var newBaseName = groupCategoryInfo.seoname;
                        newBaseName = Utils.UrlFriendly(newBaseName);
                        var ctrl = Utils.RequestParam(HttpContext.Current, "ctrl");
                        if (ctrl != "") ctrl = "&ctrl=" + ctrl;
                        if (StoreSettings.Current.GetBool(StoreSettingKeys.friendlyurlids))
                        {
                            url = DotNetNuke.Services.Url.FriendlyUrl.FriendlyUrlProvider.Instance().FriendlyUrl(tab, "~/Default.aspx?TabId=" + tab.TabID.ToString("") + "&catref=" + Utils.UrlFriendly(groupCategoryInfo.categoryrefGUIDKey) + ctrl + "&language=" + Utils.GetCurrentCulture());
                        }
                        else
                        {
                            // check if we are calling from BO with a ctrl param
                            url = DotNetNuke.Services.Url.FriendlyUrl.FriendlyUrlProvider.Instance().FriendlyUrl(tab, "~/Default.aspx?TabId=" + tab.TabID.ToString("") + "&catid=" + groupCategoryInfo.categoryid.ToString("") + ctrl + "&language=" + Utils.GetCurrentCulture(), newBaseName + ".aspx");
                        }

                        url = url.Replace("[catid]/", ""); // remove the injection token from the url, if still there. (Should be removed redirected to new page)

                    }
                }
            return url;
        }