Example #1
0
        public static Boolean ValidateLangaugeRef(int portalId, int categoryId)
        {
            var updaterequired = false;

            foreach (var lang in DnnUtils.GetCultureCodeList(portalId))
            {
                var objCtrl       = new NBrightBuyController();
                var parentCatData = GetCategoryData(categoryId, lang);
                var grpCatCtrl    = new GrpCatController(lang);
                var newGuidKey    = grpCatCtrl.GetBreadCrumb(categoryId, 0, "-", false, true);
                if (newGuidKey != "")
                {
                    newGuidKey = GetUniqueGuidKey(portalId, categoryId, Utils.UrlFriendly(newGuidKey)).ToLower();
                }
                if (parentCatData.DataLangRecord.GUIDKey != newGuidKey)
                {
                    parentCatData.DataLangRecord.SetXmlProperty("genxml/textbox/txtcategoryref", newGuidKey);
                    parentCatData.DataLangRecord.GUIDKey = newGuidKey;
                    objCtrl.Update(parentCatData.DataLangRecord);
                    updaterequired = true;
                    // need to update all children, so call validate recursive.
                    foreach (var ch in parentCatData.GetDirectChildren())
                    {
                        if (ch.ItemID != categoryId)
                        {
                            ValidateLangaugeRef(portalId, ch.ItemID);
                        }
                    }
                }
            }
            return(updaterequired);
        }
Example #2
0
 public static Boolean ValidateLangaugeRef(int portalId, int categoryId)
 {
     var updaterequired = false;
     foreach (var lang in DnnUtils.GetCultureCodeList(portalId))
     {
         var objCtrl = new NBrightBuyController();
         var parentCatData = GetCategoryData(categoryId, lang);
         var grpCatCtrl = new GrpCatController(lang);
         var newGuidKey = grpCatCtrl.GetBreadCrumb(categoryId, 0, "-", false);
         if (newGuidKey != "") newGuidKey = GetUniqueGuidKey(portalId, categoryId, Utils.UrlFriendly(newGuidKey)).ToLower();
         if (parentCatData.DataLangRecord.GUIDKey != newGuidKey)
         {
             parentCatData.DataLangRecord.SetXmlProperty("genxml/textbox/txtcategoryref", newGuidKey);
             parentCatData.DataLangRecord.GUIDKey = newGuidKey;
             objCtrl.Update(parentCatData.DataLangRecord);
             updaterequired = true;
             // need to update all children, so call validate recursive.
             foreach (var ch in parentCatData.GetDirectChildren())
             {
                 if (ch.ItemID != categoryId) ValidateLangaugeRef(portalId, ch.ItemID);
             }
         }
     }
     return updaterequired;
 }
 public CatMenuRazorBuilder(string razorTemplate,string controlPath,string theme, int currentCatId,string lang)
 {
     _lang = lang;
     _catGrpCtrl = new GrpCatController(_lang);
     _razorTemplateName = GetMenuTemplates(razorTemplate,controlPath,theme, lang);
     _currentCatId = currentCatId;
     _controlPath = controlPath;
     _theme = theme;
 }
Example #4
0
 public CatMenuRazorBuilder(string razorTemplate, string controlPath, string theme, int currentCatId, string lang)
 {
     _lang              = lang;
     _catGrpCtrl        = new GrpCatController(_lang);
     _razorTemplateName = GetMenuTemplates(razorTemplate, controlPath, theme, lang);
     _currentCatId      = currentCatId;
     _controlPath       = controlPath;
     _theme             = theme;
 }
Example #5
0
 public CatMenuBuilder(String templateBody, ModSettings modSettings, int currentCatId, Boolean debugMode)
 {
     _catGrpCtrl = new GrpCatController(Utils.GetCurrentCulture());
     _ctrlObj = new NBrightBuyController();
     _modSettings = modSettings;
     _debugMode = debugMode;
     _templateBody = GetMenuTemplates(templateBody);
     _currentCatId = currentCatId;
 }
Example #6
0
 public CatMenuBuilder(String templateBody, ModSettings modSettings, int currentCatId, Boolean debugMode)
 {
     _catGrpCtrl   = new GrpCatController(Utils.GetCurrentCulture());
     _ctrlObj      = new NBrightBuyController();
     _modSettings  = modSettings;
     _debugMode    = debugMode;
     _templateBody = GetMenuTemplates(templateBody);
     _currentCatId = currentCatId;
 }
Example #7
0
        public void Save()
        {
            _objCtrl.Update(DataRecord);
            _objCtrl.Update(DataLangRecord);

            //do reindex of cascade records.
            if (_doCascadeIndex)
            {
                var objGrpCtrl = new GrpCatController(_lang);
                objGrpCtrl.ReIndexCascade(_oldcatcascadeid);  // reindex form parnet and parents
                objGrpCtrl.ReIndexCascade(DataRecord.ItemID); // reindex self
                objGrpCtrl.Reload();
            }

            NBrightBuyUtils.ProcessEventProvider(EventActions.AfterCategorySave, DataRecord);
            // reload data so if event has altered data we use that.
            DataRecord     = _objCtrl.Get(DataRecord.ItemID);
            DataLangRecord = _objCtrl.Get(DataLangRecord.ItemID);
        }
Example #8
0
        protected void CtrlItemCommand(object source, RepeaterCommandEventArgs e)
        {
            var cArg = e.CommandArgument.ToString();
            var param = new string[3];

            var navigationData = new NavigationData(PortalId, "CategoryAdmin");
            switch (e.CommandName.ToLower())
            {
                case "entrydetail":
                    SaveAll();
                    param[1] = "eid=" + cArg;
                    param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "return":
                    param[1] = "";
                    param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "search":
                    var strXml = GenXmlFunctions.GetGenXml(rpSearch, "", "");
                    navigationData.XmlData = strXml;
                    if (StoreSettings.Current.DebugModeFileOut)
                    {
                        strXml = "<root><sql><![CDATA[" + navigationData.Criteria + "]]></sql>" + strXml + "</root>";
                        var xmlDoc = new System.Xml.XmlDocument();
                        xmlDoc.LoadXml(strXml);
                        xmlDoc.Save(PortalSettings.HomeDirectoryMapPath + "debug_search.xml");
                    }
                    navigationData.Save();
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "resetsearch":
                    // clear cookie info
                    navigationData.Delete();
                    param[2] = "catid=0";
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "addnew":
                    var strXml2 = GenXmlFunctions.GetGenXml(rpSearch, "", "");
                    navigationData.XmlData = strXml2;
                    navigationData.Save();
                    var categoryData = CategoryUtils.GetCategoryData(-1, EditLanguage);
                    if (!String.IsNullOrEmpty(Edittype) && Edittype.ToLower() == "group")
                    {
                        categoryData.GroupType = GenXmlFunctions.GetGenXmlValue(navigationData.XmlData, "genxml/dropdownlist/groupsel");
                        if (categoryData.GroupType == "") categoryData.GroupType = "cat";
                        var grpCtrl = new GrpCatController(Utils.GetCurrentCulture());
                        var grp = grpCtrl.GetGrpCategoryByRef(categoryData.GroupType);
                        if (grp != null) categoryData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlparentcatid", grp.categoryid.ToString(""));
                        categoryData.DataRecord.SetXmlProperty("genxml/checkbox/chkishidden", "False"); // don't hide property groups by default
                    }
                    categoryData.ParentItemId = _openid;
                    categoryData.Save();
                    NBrightBuyUtils.RemoveModCachePortalWide(PortalId);

                    param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "delete":
                    if (Utils.IsNumeric(cArg))
                    {
                        ModCtrl.Delete(Convert.ToInt32(cArg));
                    }
                    param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "saveall":
                    SaveAll();
                    NBrightBuyUtils.RemoveModCachePortalWide(PortalId); //clear any cache
                    param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "move":
                    SaveAll();
                    if (Utils.IsNumeric(cArg))
                    {
                        MoveRecord(Convert.ToInt32(cArg));
                    }
                    param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "open":
                    param[1] = "catid=" + cArg;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "close":
                    var catData = CategoryUtils.GetCategoryData(_openid, EditLanguage);
                    if (catData.DataRecord == null)
                        param[1] = "catid=0";
                    else
                        param[1] = "catid=" + catData.DataRecord.ParentItemId.ToString("");
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "save":
                    UpdateRecord();
                    param[1] = "eid=" + cArg;
                   param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "saveexit":
                    UpdateRecord();
                    param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;

            }
        }
        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))
                        {
                            _navigationdata.OrderBy = " Order by " + metaTokens["orderby" + _orderbyindex];
                        }
                    }
                    else
                    {
                        if (String.IsNullOrEmpty(_navigationdata.OrderBy) && metaTokens.ContainsKey("orderby"))
                        {
                            _navigationdata.OrderBy = " Order by " + metaTokens["orderby"];
                            _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 (Utils.IsNumeric(defcatid))
                    {
                        // if we have no filter use the default category
                        if (_catid == "" && strFilter.Trim() == "") _catid = defcatid;
                    }
                    else
                    {
                        defcatid = ModSettings.Get("defaultpropertyid");
                        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 + ") ";
                        }
                    }
                    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);
                                        }

                                        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;
                        }

                        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;

                                    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()));
                                    }
                                }
                            }

                            // 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"
                    {
                        if (metaTokens.ContainsKey("itemlistname")) _itemListName = metaTokens["itemlistname"];
                        if (_itemListName == "") _itemListName = Utils.RequestParam(Context, "itemlistname"); // see if we've passed a wishlist name in url
                        if (_itemListName != "")
                        {
                            var cw = new ItemListData(_itemListName);
                            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);

                    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();
                    }

                }
            }
        }
Example #10
0
        private void PageLoad()
        {
            NBrightInfo objCat = null;

            #region "Data Repeater"
            if (_templD.Trim() != "")  // if we don;t have a template, don't do anything
            {

                if (_displayentrypage)
                {
                    // get correct itemid, based on eid given
                    if (_ename != "")
                    {
                        var o = ModCtrl.GetByGuidKey(PortalId, ModuleId, EntityTypeCodeLang, _ename);
                        if (o == null)
                        {
                            o = ModCtrl.GetByGuidKey(PortalId, ModuleId, EntityTypeCode, _ename);
                            if (o != null)
                            {
                                _eid = o.ItemID.ToString("");
                            }
                        }
                        else
                        {
                            _eid = o.ParentItemId.ToString("");
                        }
                    }

                    DisplayDataEntryRepeater(_eid);

                }
                else
                {
                    #region "Order BY"
                    // get orderby from header if it's there
                    var cachekey = "GetSqlOrderBy*rpDataH" + _templH + "*" + ModuleId.ToString();
                    _strOrder = (String)Utils.GetCache(cachekey);
                    if (_strOrder == null || StoreSettings.Current.DebugMode)
                    {
                        _strOrder = GenXmlFunctions.GetSqlOrderBy(rpDataH);
                    }

                    //Default orderby if not set
                    if (String.IsNullOrEmpty(_strOrder)) _strOrder = " Order by ModifiedDate DESC  ";
                    // NOTE: This setting may be overwritten by the navigatedata class in the filter setup
                    #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(_navigationdata.PageSize)) pageSize = Convert.ToInt32(_navigationdata.PageSize);
                    if (!Utils.IsNumeric(pageSize) && Utils.IsNumeric(ModSettings.Get("pagesize"))) pageSize = Convert.ToInt32(ModSettings.Get("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 (_templateHeader != null) strPgSize = _templateHeader.GetHiddenFieldValue("searchpagesize");
                        if (_templateHeader != null && strPgSize == "") strPgSize = _templateHeader.GetHiddenFieldValue("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 = "";
                        cachekey = "GetSqlSearchFilters*rpDataH" + _templH + "*" + ModuleId.ToString();
                        var strHeaderFilter = (String)Utils.GetCache(cachekey);
                        if (strHeaderFilter == null || StoreSettings.Current.DebugMode)
                        {
                            strHeaderFilter = GenXmlFunctions.GetSqlSearchFilters(rpDataH);
                        }

                        // filter mode and will persist past category selection.
                        if ((_catid == "" && _catname == ""))
                        {
                            if (!_navigationdata.FilterMode) _navigationdata.CategoryId = ""; // filter mode persist catid

                            // if navdata is not deleted then get filter from navdata, created by productsearch module.
                            strFilter = _navigationdata.Criteria;
                            if (!strFilter.Contains(strHeaderFilter)) strFilter += " " + strHeaderFilter;
                            if (!String.IsNullOrEmpty(_navigationdata.OrderBy)) _strOrder = _navigationdata.OrderBy;

                            if (_navigationdata.Mode.ToLower() =="s") _navigationdata.ResetSearch(); // single search so clear after
                        }
                        else
                        {
                            _navigationdata.ResetSearch();

                            // 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.
                            _navigationdata.CategoryId = _catid;
                            strFilter = strHeaderFilter;
                        }

                    #endregion

                    #region "Get Category select setup"

                    //get default catid.
                    var catseo = _catid;
                    var defcatid = ModSettings.Get("defaultcatid");
                    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")
                        {
                            _catid = defcatid;
                        }
                    }
                    else
                    {
                        defcatid = ModSettings.Get("defaultpropertyid");
                        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")
                            {
                                _catid = defcatid;
                            }
                        }
                    }

                    //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 && (activeCat.categoryrefGUIDKey == _catname))
                                {
                                    var redirecturl = "";
                                    if (Utils.IsNumeric(_eid))
                                    {
                                        var prdData = ProductUtils.GetProductData(Convert.ToInt32(_eid), Utils.GetCurrentCulture());
                                        redirecturl = NBrightBuyUtils.GetEntryUrl(PortalId, _eid, _modkey, prdData.SEOName, TabId.ToString(), "", activeCat.categoryrefGUIDKey);
                                    }
                                    else
                                    {
                                        redirecturl = catGrpCtrl.GetCategoryUrl(activeCat, TabId, objCat.Lang);
                                    }

                                    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.
                        _navigationdata.CategoryId = _catid;
                        catseo = _catid;
                    }

                    if (Utils.IsNumeric(_catid))
                    {
                        var objQual = DotNetNuke.Data.DataProvider.Instance().ObjectQualifier;
                        var dbOwner = DataProvider.Instance().DatabaseOwner;
                        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;

                                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()));
                                }
                            }
                        }

                        if (_strOrder == "{bycategoryproduct}") _strOrder += _catid; // do special custom sort in each cateogry

                    }
                    else
                    {
                        if (!_navigationdata.FilterMode) _navigationdata.CategoryId = ""; // filter mode persist catid
                        if (_strOrder == "{bycategoryproduct}") _strOrder = " Order by ModifiedDate DESC  ";
                    }

                    #endregion

                    #region "Apply provider product filter"
                    // Special filtering can be done, by using the ProductFilter interface.
                    var productfilterkey = "";
                    if (_templateHeader != null) productfilterkey = _templateHeader.GetHiddenFieldValue("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 (_templateHeader != null) _itemListName = _templateHeader.GetHiddenFieldValue("itemlistname");
                    if (_itemListName != "")
                    {
                        var cw = new ItemListData(_itemListName);
                            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

                    // 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);

                    strFilter += " and (NB3.Visible = 1) "; // get only visible products

                    var recordCount = ModCtrl.GetDataListCount(PortalId, ModuleId, "PRD", strFilter, "PRDLANG", Utils.GetCurrentCulture(), DebugMode);

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

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

                    var l = ModCtrl.GetDataList(PortalId, ModuleId, "PRD", "PRDLANG", Utils.GetCurrentCulture(), strFilter, _strOrder, DebugMode, "", returnlimit, pageNumber, pageSize, recordCount);
                    rpData.DataSource = l;
                    rpData.DataBind();

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

                    if (pageSize > 0)
                    {
                        CtrlPaging.PageSize = pageSize;
                        CtrlPaging.CurrentPage = pageNumber;
                        CtrlPaging.TotalRecords = recordCount;
                        CtrlPaging.BindPageLinks();
                    }

                    // display header (Do header after the data return so the productcount works)
                    if (objCat == null)
                        base.DoDetail(rpDataH,ModuleId);
                    else
                    {
                        if (StoreSettings.Current.DebugModeFileOut) objCat.XMLDoc.Save(PortalSettings.HomeDirectoryMapPath + "debug_categoryproductheader.xml");
                        DoDetail(rpDataH, objCat);
                    }

                }
            }

            #endregion

            // display footer
            base.DoDetail(rpDataF);
        }
Example #11
0
        private Dictionary<int, string> BuildPropertyList(int displaylevels = 20, Boolean showHidden = false, Boolean showArchived = false, int parentid = 0, String catreflist = "", String prefix = "", bool displayCount = false, bool showEmpty = true, string groupref = "", string breadcrumbseparator = ">", string lang = "")
        {
            if (lang == "") lang = Utils.GetCurrentCulture();

            var rtnDic = new Dictionary<int, string>();

            var strCacheKey = "NBrightBuy_BuildPropertyList" + PortalSettings.Current.PortalId + "*" + displaylevels + "*" + showHidden.ToString(CultureInfo.InvariantCulture) + "*" + showArchived.ToString(CultureInfo.InvariantCulture) + "*" + parentid + "*" + catreflist + "*" + prefix + "*" + Utils.GetCurrentCulture() + "*" + showEmpty + "*" + displayCount + "*" + groupref + "*" + lang;

            var objCache = NBrightBuyUtils.GetModCache(strCacheKey);

            if (objCache == null | StoreSettings.Current.DebugMode)
            {
                var grpCatCtrl = new GrpCatController(lang);
                var d = new Dictionary<int, string>();
                var rtnList = new List<GroupCategoryData>();
                rtnList = grpCatCtrl.GetTreePropertyList(breadcrumbseparator);
                var strCount = "";
                foreach (var grpcat in rtnList)
                {
                    if (displayCount) strCount = " (" + grpcat.entrycount.ToString("") + ")";

                    if (grpcat.depth < displaylevels)
                    {
                        if (showEmpty || grpcat.entrycount > 0)
                        {
                            if (grpcat.ishidden == false || showHidden)
                            {
                                if (!rtnDic.ContainsKey(grpcat.categoryid))
                                {
                                    var addprefix = new String(' ', grpcat.depth).Replace(" ", prefix);
                                    if (catreflist == "")
                                        rtnDic.Add(grpcat.categoryid, addprefix + grpcat.categoryname + strCount);
                                    else
                                    {
                                        if (grpcat.categoryref != "" &&
                                            (catreflist + ",").Contains(grpcat.categoryref + ","))
                                        {
                                            rtnDic.Add(grpcat.categoryid, addprefix + grpcat.categoryname + strCount);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                NBrightBuyUtils.SetModCache(-1, strCacheKey, rtnDic);

            }
            else
            {
                rtnDic = (Dictionary<int, string>)objCache;
            }
            return rtnDic;
        }
Example #12
0
        private void CatValueOfDataBind(object sender, EventArgs e)
        {
            var lc = (Literal)sender;
            var container = (IDataItemContainer)lc.NamingContainer;
            try
            {
                lc.Visible = visibleStatus.DefaultIfEmpty(true).First();

                var id = 0;
                try
                {
                    id = (int) DataBinder.Eval(container.DataItem, "ItemId");
                }
                catch (Exception)
                {
                    id = (int) DataBinder.Eval(container.DataItem, "categoryid");
                }
                var grpCatCtrl = new GrpCatController(Utils.GetCurrentCulture());
                var objCInfo = grpCatCtrl.GetCurrentCategoryInfo(PortalSettings.Current.PortalId, lc.Page.Request, id);
                if (objCInfo != null)
                {
                    lc.Text = objCInfo.GetXmlProperty(lc.Text);
                }
                else
                {
                    lc.Text = "";
                }
            }
            catch (Exception ex)
            {
                lc.Text = "";
            }
        }
Example #13
0
        private void CatDefaultDataBind(object sender, EventArgs e)
        {
            var lc = (Literal)sender;
            var name = lc.Text;
            lc.Text = "";
            var container = (IDataItemContainer)lc.NamingContainer;
            try
            {
                lc.Visible = visibleStatus.DefaultIfEmpty(true).First();
                var moduleId = DataBinder.Eval(container.DataItem, "ModuleId");
                var id = Convert.ToString(DataBinder.Eval(container.DataItem, "ItemId"));
                var lang = Convert.ToString(DataBinder.Eval(container.DataItem, "lang"));

                if (Utils.IsNumeric(id) && Utils.IsNumeric(moduleId))
                {
                    var moduleKey = "";
                    // if we have no catid in url, we're going to need a default category from module.
                    var settings = new System.Collections.Hashtable();
                    var modSettings = new ModSettings(Convert.ToInt32(moduleId), settings);
                    moduleKey = modSettings.Get("modulekey");

                    var grpCatCtrl = new GrpCatController(Utils.GetCurrentCulture());
                    var objCInfo = grpCatCtrl.GetCurrentCategoryData(PortalSettings.Current.PortalId, lc.Page.Request, Convert.ToInt32(id), modSettings.Settings(), moduleKey);
                    if (objCInfo != null)
                    {
                        GroupCategoryData objPcat;
                        switch (name.ToLower())
                        {
                            case "categorydesc":
                                lc.Text = objCInfo.categorydesc;
                                break;
                            case "message":
                                lc.Text = System.Web.HttpUtility.HtmlDecode(objCInfo.message);
                                break;
                            case "archived":
                                lc.Text = objCInfo.archived.ToString(CultureInfo.InvariantCulture);
                                break;
                            case "breadcrumb":
                                lc.Text = objCInfo.breadcrumb;
                                break;
                            case "categoryid":
                                lc.Text = objCInfo.categoryid.ToString("");
                                break;
                            case "categoryname":
                                lc.Text = objCInfo.categoryname;
                                break;
                            case "categoryref":
                                lc.Text = objCInfo.categoryref;
                                break;
                            case "depth":
                                lc.Text = objCInfo.depth.ToString("");
                                break;
                            case "disabled":
                                lc.Text = objCInfo.disabled.ToString(CultureInfo.InvariantCulture) ;
                                break;
                            case "entrycount":
                                lc.Text = objCInfo.entrycount.ToString("");
                                break;
                            case "grouptyperef":
                                lc.Text = objCInfo.grouptyperef;
                                break;
                            case "imageurl":
                                lc.Text = objCInfo.imageurl;
                                break;
                            case "ishidden":
                                lc.Text = objCInfo.ishidden.ToString(CultureInfo.InvariantCulture);
                                break;
                            case "isvisible":
                                lc.Text = objCInfo.isvisible.ToString(CultureInfo.InvariantCulture) ;
                                break;
                            case "metadescription":
                                lc.Text = objCInfo.metadescription;
                                break;
                            case "metakeywords":
                                lc.Text = objCInfo.metakeywords;
                                break;
                            case "parentcatid":
                                lc.Text = objCInfo.parentcatid.ToString("");
                                break;
                            case "parentcategoryname":
                                objPcat = grpCatCtrl.GetCategory(objCInfo.parentcatid);
                                lc.Text = objPcat.categoryname;
                                break;
                            case "parentcategoryref":
                                objPcat = grpCatCtrl.GetCategory(objCInfo.parentcatid);
                                lc.Text = objPcat.categoryref;
                                break;
                            case "parentcategorydesc":
                                objPcat = grpCatCtrl.GetCategory(objCInfo.parentcatid);
                                lc.Text = objPcat.categorydesc;
                                break;
                            case "parentcategorybreadcrumb":
                                objPcat = grpCatCtrl.GetCategory(objCInfo.parentcatid);
                                lc.Text = objPcat.breadcrumb;
                                break;
                            case "parentcategoryguidkey":
                                objPcat = grpCatCtrl.GetCategory(objCInfo.parentcatid);
                                lc.Text = objPcat.categoryrefGUIDKey;
                                break;
                            case "recordsortorder":
                                lc.Text = objCInfo.recordsortorder.ToString("");
                                break;
                            case "seoname":
                                lc.Text = objCInfo.seoname;
                                if (lc.Text == "") lc.Text = objCInfo.categoryname;
                                break;
                            case "seopagetitle":
                                lc.Text = objCInfo.seopagetitle ;
                                break;
                            case "url":
                                lc.Text = objCInfo.url ;
                                break;
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                lc.Text = ex.ToString();
            }
        }
Example #14
0
        private void CatBreadCrumbDataBind(object sender, EventArgs e)
        {
            var lc = (Literal)sender;
            var container = (IDataItemContainer)lc.NamingContainer;
            try
            {
                var grpCatCtrl = new GrpCatController(Utils.GetCurrentCulture());

                lc.Visible = visibleStatus.DefaultIfEmpty(true).First();

                if (visibleStatus.DefaultIfEmpty(true).First())
                {

                    var xmlDoc = new XmlDocument();
                    xmlDoc.LoadXml("<root>" + lc.Text + "</root>");
                    var xmlNod = xmlDoc.SelectSingleNode("root/tag");

                    var catid = -1;
                    if (container.DataItem is NBrightInfo)
                    {
                        // Must be displaying a product or category with (NBrightInfo), so get categoryid
                        var objCInfo = (NBrightInfo) container.DataItem;
                        if (String.IsNullOrEmpty(objCInfo.TypeCode) || objCInfo.TypeCode == "PRD") // no type is list header, so use catid in url if there.
                        {
                            //Is product so get categoryid
                            var id = Convert.ToString(DataBinder.Eval(container.DataItem, "ItemId"));
                            var targetModuleKey = "";
                            if (xmlNod != null && xmlNod.Attributes != null && xmlNod.Attributes["targetmodulekey"] != null) targetModuleKey = xmlNod.Attributes["targetmodulekey"].InnerText;
                            var obj = grpCatCtrl.GetCurrentCategoryData(PortalSettings.Current.PortalId, lc.Page.Request, Convert.ToInt32(id), _settings, targetModuleKey);
                            if (obj != null) catid = obj.categoryid;
                        }
                        else if (objCInfo.TypeCode == "CATEGORYLANG") // no type is list header, so use catid in url if there.
                        {
                            catid = objCInfo.ParentItemId;

                        }
                        else
                        {
                            catid = objCInfo.ItemID;
                        }
                    }

                    if (container.DataItem is GroupCategoryData)
                    {
                        // GroupCategoryData class, so use categoryid
                        var id = Convert.ToString(DataBinder.Eval(container.DataItem, "categoryid"));
                        if (Utils.IsNumeric(id)) catid = Convert.ToInt32(id);
                    }

                    var intLength = 400;
                    var intShortLength = -1;
                    var isLink = false;
                    var separator = ">";
                    var aslist = false;

                    if (xmlNod != null && xmlNod.Attributes != null)
                    {
                        if (xmlNod.Attributes["length"] != null)
                        {
                            if (Utils.IsNumeric(xmlNod.Attributes["length"].InnerText))
                            {
                                intLength = Convert.ToInt32(xmlNod.Attributes["length"].InnerText);
                            }
                        }
                        if (xmlNod.Attributes["links"] != null) isLink = true;
                        if (xmlNod.Attributes["short"] != null)
                        {
                            if (Utils.IsNumeric(xmlNod.Attributes["short"].InnerText))
                            {
                                intShortLength = Convert.ToInt32(xmlNod.Attributes["short"].InnerText);
                            }
                        }
                        if (xmlNod.Attributes["separator"] != null) separator = xmlNod.Attributes["separator"].InnerText;
                        if (xmlNod.Attributes["aslist"] != null && xmlNod.Attributes["aslist"].InnerText.ToLower() == "true") aslist = true;
                    }

                    if (catid > 0) // check we have a catid
                    {
                        if (isLink)
                        {
                            var defTabId = PortalSettings.Current.ActiveTab.TabID;
                            if (_settings.ContainsKey("ddllisttabid") && Utils.IsNumeric(_settings["ddllisttabid"])) defTabId = Convert.ToInt32(_settings["ddllisttabid"]);
                            lc.Text = grpCatCtrl.GetBreadCrumbWithLinks(catid, defTabId, intShortLength, separator, aslist);
                        }
                        else
                        {
                            lc.Text = grpCatCtrl.GetBreadCrumb(catid, intShortLength, separator, aslist);
                        }

                        if ((lc.Text.Length > intLength) && (!aslist))
                        {
                            lc.Text = lc.Text.Substring(0, (intLength - 3)) + "...";
                        }
                    }
                }
            }
            catch (Exception)
            {
                lc.Text = "";
            }
        }
Example #15
0
        public void AddCategory(int categoryid)
        {
            if (Info != null)
            {
                var strGuid = categoryid.ToString("") + "x" + Info.ItemID.ToString("");
                var objCtrl = new NBrightBuyController();
                var nbi = objCtrl.GetByGuidKey(_portalId, -1, "CATXREF", strGuid);
                if (nbi == null)
                {
                    nbi = new NBrightInfo();
                    nbi.ItemID = -1;
                    nbi.PortalId = _portalId;
                    nbi.ModuleId = -1;
                    nbi.TypeCode = "CATXREF";
                    nbi.XrefItemId = categoryid;
                    nbi.ParentItemId = Info.ItemID;
                    nbi.XMLData = null;
                    nbi.TextData = null;
                    nbi.Lang = null;
                    nbi.GUIDKey = strGuid;
                    var newitemid = objCtrl.Update(nbi);
                    nbi = objCtrl.Get(newitemid);
                    nbi.XMLData = "<genxml><sort>" + newitemid.ToString() + "</sort></genxml>";
                    objCtrl.Update(nbi);

                    //add all cascade xref
                    var objGrpCtrl = new GrpCatController(_lang, true);
                    var parentcats = objGrpCtrl.GetCategory(categoryid);
                    if (parentcats != null)
                    {
                        foreach (var p in parentcats.Parents)
                        {
                            strGuid = p.ToString("") + "x" + Info.ItemID.ToString("");
                            var obj = objCtrl.GetByGuidKey(_portalId, -1, "CATCASCADE", strGuid);
                            if (obj == null)
                            {
                                nbi = new NBrightInfo();
                                nbi.ItemID = -1;
                                nbi.PortalId = _portalId;
                                nbi.ModuleId = -1;
                                nbi.XrefItemId = p;
                                nbi.ParentItemId = Info.ItemID;
                                nbi.TypeCode = "CATCASCADE";
                                nbi.GUIDKey = strGuid;
                                newitemid = objCtrl.Update(nbi);
                                nbi = objCtrl.Get(newitemid);
                                nbi.XMLData = "<genxml><sort>" + newitemid.ToString() + "</sort></genxml>";
                                objCtrl.Update(nbi);
                            }
                        }
                    }
                }
            }
        }
Example #16
0
        public static List<NBrightInfo> GetCatList(int parentid = 0, string groupref = "", String lang = "")
        {
            if (lang == "") lang = Utils.GetCurrentCulture();

            var strFilter = "";
            if (groupref == "" || groupref == "0") // Because we've introduced Properties (for non-category groups) we will only display these if cat is not selected.
                strFilter += " and [XMLData].value('(genxml/dropdownlist/ddlgrouptype)[1]','nvarchar(max)') != 'cat' ";
            else
            {
                if (groupref == "cat") strFilter = " and NB1.ParentItemId = " + parentid + " "; // only category have multipel levels.
                strFilter += " and [XMLData].value('(genxml/dropdownlist/ddlgrouptype)[1]','nvarchar(max)') = '" + groupref + "' ";
            }

            var objCtrl = new NBrightBuyController();
            var levelList = objCtrl.GetDataList(PortalSettings.Current.PortalId, -1, "CATEGORY", "CATEGORYLANG", lang, strFilter, " order by [XMLData].value('(genxml/hidden/recordsortorder)[1]','decimal(10,2)') ", true);

            var grpCtrl = new GrpCatController(lang);

            foreach (var c in levelList)
            {
                var g = grpCtrl.GetCategory(c.ItemID);
                if (g != null) c.SetXmlProperty("genxml/entrycount", g.entrycount.ToString(""));
            }

            return levelList;
        }
Example #17
0
        protected void CtrlItemCommand(object source, RepeaterCommandEventArgs e)
        {
            var cArg = e.CommandArgument.ToString();
            var param = new string[3];

            var navigationData = new NavigationData(PortalId, "CategoryAdmin");
            switch (e.CommandName.ToLower())
            {
                case "entrydetail":
                    SaveAll();
                    param[1] = "eid=" + cArg;
                    param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "return":
                    param[1] = "";
                    param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "search":
                    var strXml = GenXmlFunctions.GetGenXml(rpSearch, "", "");
                    navigationData.XmlData = strXml;
                    if (StoreSettings.Current.DebugModeFileOut)
                    {
                        strXml = "<root><sql><![CDATA[" + navigationData.Criteria + "]]></sql>" + strXml + "</root>";
                        var xmlDoc = new System.Xml.XmlDocument();
                        xmlDoc.LoadXml(strXml);
                        xmlDoc.Save(PortalSettings.HomeDirectoryMapPath + "debug_search.xml");
                    }
                    navigationData.Save();
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "resetsearch":
                    // clear cookie info
                    navigationData.Delete();
                    param[2] = "catid=0";
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "addnew":
                    var strXml2 = GenXmlFunctions.GetGenXml(rpSearch, "", "");
                    navigationData.XmlData = strXml2;
                    navigationData.Save();
                    var categoryData = CategoryUtils.GetCategoryData(-1, EditLanguage);
                    if (!String.IsNullOrEmpty(Edittype) && Edittype.ToLower() == "group")
                    {
                        categoryData.GroupType = GenXmlFunctions.GetGenXmlValue(navigationData.XmlData, "genxml/dropdownlist/groupsel");
                        if (categoryData.GroupType == "") categoryData.GroupType = "cat";
                        var grpCtrl = new GrpCatController(Utils.GetCurrentCulture());
                        var grp = grpCtrl.GetGrpCategoryByRef(categoryData.GroupType);
                        if (grp != null) categoryData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlparentcatid", grp.categoryid.ToString(""));
                        categoryData.DataRecord.SetXmlProperty("genxml/checkbox/chkishidden", "False"); // don't hide property groups by default
                    }
                    categoryData.ParentItemId = _openid;
                    categoryData.Save();
                    NBrightBuyUtils.RemoveModCachePortalWide(PortalId);

                    param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "delete":
                    if (Utils.IsNumeric(cArg))
                    {
                        var catid = Convert.ToInt32(cArg);
                        if (catid > 0)
                        {
                            var delCatData = CategoryUtils.GetCategoryData(catid, EditLanguage);
                            if (delCatData.Exists && delCatData.GetDirectChildren().Count == 0) // only delete end leaf
                            {
                                var productidlist = new ArrayList();
                                foreach (var dc in delCatData.GetDirectArticles())
                                {
                                    productidlist.Add(dc.ParentItemId);
                                }

                                var parentCatList = new List<CategoryData>();
                                var loopCat = CategoryUtils.GetCategoryData(catid, EditLanguage);
                                while (loopCat.Exists && loopCat.ParentItemId > 0)
                                {
                                    loopCat = CategoryUtils.GetCategoryData(loopCat.ParentItemId, EditLanguage);
                                    parentCatList.Add(loopCat);
                                }

                                foreach (var pCat in parentCatList)
                                {
                                    foreach (var prodxref in pCat.GetCascadeArticles())
                                    {
                                        if (productidlist.Contains(prodxref.ParentItemId))
                                        {
                                            // delete CATCASCADE record
                                           ModCtrl.Delete(prodxref.ItemID);
                                        }
                                    }

                                }

                                foreach (var dc in delCatData.GetDirectArticles())
                                {
                                    // delete CATXREF record
                                    ModCtrl.Delete(dc.ParentItemId);
                                }
                                // delete CATEGORY record (constrants remove LANG records.)
                                ModCtrl.Delete(catid);
                            }
                            else
                            {
                                NBrightBuyUtils.SetNotfiyMessage(ModuleId, "onlyleafcat", NotifyCode.fail);
                            }
                        }
                    }
                    param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "saveall":
                    SaveAll();
                    NBrightBuyUtils.RemoveModCachePortalWide(PortalId); //clear any cache
                    param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "move":
                    SaveAll();
                    if (Utils.IsNumeric(cArg))
                    {
                        MoveRecord(Convert.ToInt32(cArg));
                    }
                    param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "open":
                    param[1] = "catid=" + cArg;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "close":
                    var catData = CategoryUtils.GetCategoryData(_openid, EditLanguage);
                    if (catData.DataRecord == null)
                        param[1] = "catid=0";
                    else
                        param[1] = "catid=" + catData.DataRecord.ParentItemId.ToString("");
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "save":
                    UpdateRecord();
                    param[1] = "eid=" + cArg;
                   param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "saveexit":
                    UpdateRecord();
                    param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;

            }
        }
Example #18
0
        private List <MenuNode> GetCatNodeXml(string currentTabId, int categoryInjectTabId, int parentItemId = 0, bool recursive = true, int depth = 0, MenuNode pnode = null, string defaultListPage = "")
        {
            var nodes = new List <MenuNode>();
            //[TODO: Add images onto DDRMenu]
            //var objS = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "SETTINGS", "NBrightBuySettings");
            //var imgFolder = objS.GetXmlProperty("genxml/textbox/txtuploadfolder");
            //var defimgsize = objS.GetXmlProperty("genxml/textbox/txtsmallimgsize");

            //var l = objCtrl.GetList(PortalSettings.Current.PortalId, -1, "CATEGORY", strFilter, strOrderBy, 0, 0, 0, 0, "CATEGORYLANG", Utils.GetCurrentCulture());

            var grpCatCtrl = new GrpCatController(Utils.GetCurrentCulture());

            var l = grpCatCtrl.GetCategories(parentItemId);

            foreach (var obj in l)
            {
                if (!obj.ishidden)
                {
                    var n = new MenuNode();

                    n.Parent = pnode;

                    n.TabId = categoryInjectTabId;
                    n.Text  = obj.categoryname;
                    n.Title = obj.categorydesc;

                    var tabid = "";
                    if (Utils.IsNumeric(defaultListPage))
                    {
                        tabid = defaultListPage;
                    }
                    if (tabid == "")
                    {
                        tabid = currentTabId;
                    }
                    if (Utils.IsNumeric(tabid))
                    {
                        n.Url = grpCatCtrl.GetCategoryUrl(obj, Convert.ToInt32((tabid)));
                    }

                    n.Enabled = true;
                    if (obj.disabled)
                    {
                        n.Enabled = false;
                    }
                    n.Selected = false;
                    // redundant with caching
                    //if (_catid == obj.categoryid.ToString("")) n.Selected = true;
                    n.Breadcrumb = false;
                    //if (_catid == obj.categoryid.ToString("")) n.Breadcrumb = true;
                    n.Separator  = false;
                    n.LargeImage = "";
                    n.Icon       = "";
                    var img = obj.imageurl;
                    if (img != "")
                    {
                        n.LargeImage = img;
                        n.Icon       = StoreSettings.NBrightBuyPath() + "/NBrightThumb.ashx?w=50&h=50&src=/" + img.TrimStart('/');
                    }
                    n.Keywords    = obj.metakeywords;
                    n.Description = obj.metadescription;
                    n.CommandName = "";
                    //n.CommandArgument = string.Format("entrycount={0}|moduleid={1}", obj.GetXmlProperty("genxml/hidden/entrycount"), obj.ModuleId.ToString(""));
                    n.CommandArgument = obj.entrycount.ToString(""); // not used, so we use it to store the entry count

                    if (recursive && depth < 5)                      //stop infinate loop, only allow 50 sub levels
                    {
                        depth += 1;
                        var childrenNodes = GetCatNodeXml(tabid, categoryInjectTabId, obj.categoryid, true, depth, n, defaultListPage);
                        if (childrenNodes.Count > 0)
                        {
                            n.Children = childrenNodes;
                        }
                    }

                    nodes.Add(n);
                }
            }

            return(nodes);
        }
        private Dictionary<int, string> BuildCatList(int displaylevels = 20, Boolean showHidden = false, Boolean showArchived = false, int parentid = 0, String catreflist = "", String prefix = "", bool displayCount = false, bool showEmpty = true, string groupref = "", string breadcrumbseparator = ">", string lang = "")
        {
            if (lang == "") lang = Utils.GetCurrentCulture();

            var rtnDic = new Dictionary<int, string>();

            var grpCatCtrl = new GrpCatController(lang);
            var d = new Dictionary<int, string>();
            var rtnList = new List<GroupCategoryData>();
            rtnList = grpCatCtrl.GetTreeCategoryList(rtnList, 0, parentid, groupref, breadcrumbseparator);
            var strCount = "";
            foreach (var grpcat in rtnList)
            {
                if (displayCount) strCount = " (" + grpcat.entrycount.ToString("") + ")";

                if (grpcat.depth < displaylevels)
                {
                    if (showEmpty || grpcat.entrycount > 0)
                    {
                        if (grpcat.ishidden == false || showHidden)
                        {
                            var addprefix = new String(' ', grpcat.depth).Replace(" ", prefix);
                            if (catreflist == "")
                                rtnDic.Add(grpcat.categoryid, addprefix + grpcat.categoryname + strCount);
                            else
                            {
                                if (grpcat.categoryref != "" &&
                                    (catreflist + ",").Contains(grpcat.categoryref + ","))
                                {
                                    rtnDic.Add(grpcat.categoryid, addprefix + grpcat.categoryname + strCount);
                                }
                            }
                        }
                    }
                }
            }
            return rtnDic;
        }
Example #20
0
        /// <summary>
        /// Select categories linked to product, by groupref
        /// </summary>
        /// <param name="groupref">groupref for select, "" = all, "cat"= Category only, "!cat" = all non-category, "{groupref}"=this group only</param>
        /// <param name="cascade">get all cascade records to get all parent categories</param>
        /// <returns></returns>
        public List<GroupCategoryData> GetCategories(String groupref = "",Boolean cascade = false)
        {
            if (Info == null) return new List<GroupCategoryData>(); // stop throwing an error no product exists,

            var objGrpCtrl = new GrpCatController(_lang);
            var catl = objGrpCtrl.GetProductCategories(Info.ItemID, groupref, cascade);
            if (Utils.IsNumeric(DataRecord.GetXmlProperty("genxml/defaultcatid")) && catl.Count > 0)
            {
                var objl = catl.Where(i => i.isdefault == true);
                foreach (var i in objl)
                {
                    i.isdefault = false;
                }
                var dcatid = Convert.ToInt32(DataRecord.GetXmlProperty("genxml/defaultcatid"));
                var obj = catl.Where(i => i.categoryid == dcatid);
                var groupCategoryDatas = obj as GroupCategoryData[] ?? obj.ToArray();
                if (groupCategoryDatas.Any()) groupCategoryDatas.First().isdefault = true;
            }
            return catl;
        }
Example #21
0
 public GroupCategoryData GetDefaultCategory()
 {
     if (Utils.IsNumeric(DataRecord.GetXmlProperty("genxml/defaultcatid")))
     {
         var objGrpCtrl = new GrpCatController(_lang);
         var obj = objGrpCtrl.GetCategory(Convert.ToInt32(DataRecord.GetXmlProperty("genxml/defaultcatid")));
         if (obj != null) return obj;
     }
     var catl = GetCategories();
     if (catl.Any()) return catl[0];
     return null;
 }
Example #22
0
 private void CatBreakOfDataBind(object sender, EventArgs e)
 {
     var lc = (Literal)sender;
     var container = (IDataItemContainer)lc.NamingContainer;
     try
     {
         lc.Visible = visibleStatus.DefaultIfEmpty(true).First();
         var id = 0;
         try
         {
             id = (int) DataBinder.Eval(container.DataItem, "ItemId");
         }
         catch (Exception)
         {
             id = (int) DataBinder.Eval(container.DataItem, "categoryid");
         }
             var grpCatCtrl = new GrpCatController(Utils.GetCurrentCulture());
             var objCInfo = grpCatCtrl.GetCurrentCategoryInfo(PortalSettings.Current.PortalId, lc.Page.Request, Convert.ToInt32(id));
             if (objCInfo != null)
             {
                 lc.Text = objCInfo.GetXmlProperty(lc.Text);
                 lc.Text = System.Web.HttpUtility.HtmlEncode(lc.Text);
                 lc.Text = lc.Text.Replace(Environment.NewLine, "<br/>");
             }
             else
             {
                 lc.Text = "";
             }
     }
     catch (Exception)
     {
         lc.Text = "";
     }
 }
Example #23
0
 public Boolean HasProperty(String propertyref)
 {
     var objGrpCtrl = new GrpCatController(_lang);
     var l = objGrpCtrl.GetProductCategories(Info.ItemID, "!cat");
     return l.Any(i => (i.categoryref == propertyref || i.propertyref == propertyref));
 }
Example #24
0
        private void CatDefaultNameDataBind(object sender, EventArgs e)
        {
            var lc = (Literal)sender;
            var container = (IDataItemContainer)lc.NamingContainer;
            try
            {
                lc.Visible = visibleStatus.DefaultIfEmpty(true).First();
                var moduleId = DataBinder.Eval(container.DataItem, "ModuleId");
                var id = Convert.ToString(DataBinder.Eval(container.DataItem, "ItemId"));
                var lang = Convert.ToString(DataBinder.Eval(container.DataItem, "lang"));

                if (Utils.IsNumeric(id) && Utils.IsNumeric(moduleId))
                {
                    var grpCatCtrl = new GrpCatController(Utils.GetCurrentCulture());
                    var objCInfo = grpCatCtrl.GetCurrentCategoryData(PortalSettings.Current.PortalId, lc.Page.Request, Convert.ToInt32(id));
                    if (objCInfo != null)
                    {
                        lc.Text = objCInfo.categoryname;
                    }
                }

            }
            catch (Exception ex)
            {
                lc.Text = ex.ToString();
            }
        }
Example #25
0
        private List<MenuNode> GetCatNodeXml(string currentTabId, int parentItemId = 0, bool recursive = true, int depth = 0, MenuNode pnode = null, string defaultListPage = "")
        {
            var nodes = new List<MenuNode>();
            //[TODO: Add images onto DDRMenu]
            //var objS = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "SETTINGS", "NBrightBuySettings");
            //var imgFolder = objS.GetXmlProperty("genxml/textbox/txtuploadfolder");
            //var defimgsize = objS.GetXmlProperty("genxml/textbox/txtsmallimgsize");

            //var l = objCtrl.GetList(PortalSettings.Current.PortalId, -1, "CATEGORY", strFilter, strOrderBy, 0, 0, 0, 0, "CATEGORYLANG", Utils.GetCurrentCulture());

            var grpCatCtrl = new GrpCatController(Utils.GetCurrentCulture());

            var l = grpCatCtrl.GetCategories(parentItemId);

            foreach (var obj in l)
            {
                if (!obj.ishidden)
                {

                    var n = new MenuNode();

                    n.Parent = pnode;

                    n.TabId = obj.categoryid;
                    n.Text = obj.categoryname;
                    n.Title = obj.categorydesc;

                    var tabid = "";
                    if (Utils.IsNumeric(defaultListPage)) tabid = defaultListPage;
                    if (tabid == "") tabid = currentTabId;
                    if (Utils.IsNumeric(tabid)) n.Url = grpCatCtrl.GetCategoryUrl(obj, Convert.ToInt32((tabid)));

                    n.Enabled = true;
                    if (obj.disabled) n.Enabled = false;
                    n.Selected = false;
                    if (_catid == obj.categoryid.ToString("")) n.Selected = true;
                    n.Breadcrumb = false;
                    if (_catid == obj.categoryid.ToString("")) n.Breadcrumb = true;
                    n.Separator = false;
                    n.LargeImage = "";
                    n.Icon = "";
                    var img = obj.imageurl;
                    if (img != "")
                    {
                        n.LargeImage = img;
                        n.Icon = StoreSettings.NBrightBuyPath() + "/NBrightThumb.ashx?w=50&amp;h=50&amp;src=/" + img;
                    }
                    n.Keywords = obj.metakeywords;
                    n.Description = obj.metadescription;
                    n.CommandName = "";
                    //n.CommandArgument = string.Format("entrycount={0}|moduleid={1}", obj.GetXmlProperty("genxml/hidden/entrycount"), obj.ModuleId.ToString(""));
                    n.CommandArgument = obj.entrycount.ToString(""); // not used, so we use it to store the entry count

                    if (recursive && depth < 50) //stop infinate loop, only allow 50 sub levels
                    {
                        depth += 1;
                        var childrenNodes = GetCatNodeXml(tabid, obj.categoryid, true, depth, n, defaultListPage);
                        if (childrenNodes.Count > 0)
                        {
                            n.Children = childrenNodes;
                        }
                    }

                    nodes.Add(n);
                }

            }

            return nodes;
        }
Example #26
0
        private Dictionary<int, string> GetPropertyList(XmlNode xmlNod)
        {
            var displaylevels = 20;
            var parentref = "";
            var prefix = "..";
            var showhidden = "False";
            var showarchived = "False";
            var showempty = "True";
            var showHidden = false;
            var showArchived = false;
            var catreflist = "";
            var parentid = 0;
            var displaycount = "False";
            var displayCount = false;
            var showEmpty = true;
            var groupref = "";
            var filtermode = "";
            List<int> validCatList = null;
            var modulekey = "";
            var redirecttabid = "";
            var tabid = "";
            var lang = Utils.GetCurrentCulture();

            if (xmlNod.Attributes != null)
            {
                if (xmlNod.Attributes["displaylevels"] != null)
                {
                    if (Utils.IsNumeric(xmlNod.Attributes["displaylevels"].Value)) displaylevels = Convert.ToInt32(xmlNod.Attributes["displaylevels"].Value);
                }

                if (xmlNod.Attributes["parentref"] != null) parentref = xmlNod.Attributes["parentref"].Value;
                if (xmlNod.Attributes["showhidden"] != null) showhidden = xmlNod.Attributes["showhidden"].Value;
                if (xmlNod.Attributes["showarchived"] != null) showarchived = xmlNod.Attributes["showarchived"].Value;
                if (xmlNod.Attributes["showempty"] != null) showempty = xmlNod.Attributes["showempty"].Value;
                if (xmlNod.Attributes["displaycount"] != null) displaycount = xmlNod.Attributes["displaycount"].Value;
                if (xmlNod.Attributes["prefix"] != null) prefix = xmlNod.Attributes["prefix"].Value;
                if (xmlNod.Attributes["groupref"] != null) groupref = xmlNod.Attributes["groupref"].Value;
                if (xmlNod.Attributes["filtermode"] != null) filtermode = xmlNod.Attributes["filtermode"].Value;
                if (xmlNod.Attributes["modulekey"] != null) modulekey = xmlNod.Attributes["modulekey"].Value;
                if (xmlNod.Attributes["lang"] != null) lang = xmlNod.Attributes["lang"].Value;

                if (showhidden.ToLower() == "true") showHidden = true;
                if (showarchived.ToLower() == "true") showArchived = true;
                if (showempty.ToLower() == "false") showEmpty = false;
                if (displaycount.ToLower() == "true") displayCount = true;
                if (xmlNod.Attributes["catreflist"] != null) catreflist = xmlNod.Attributes["catreflist"].Value;
                var grpCatCtrl = new GrpCatController(lang);
                if (parentref != "")
                {
                    var p = grpCatCtrl.GetGrpCategoryByRef(parentref);
                    if (p != null) parentid = p.categoryid;
                }
                var catid = "";
                if (filtermode != "")
                {
                    var navigationData = new NavigationData(PortalSettings.Current.PortalId, modulekey);
                    catid = Utils.RequestQueryStringParam(HttpContext.Current.Request, "catid");
                    if (String.IsNullOrEmpty(catid)) catid = navigationData.CategoryId;
                    if (Utils.IsNumeric(catid))
                    {
                        validCatList = GetCateoriesInProductList(Convert.ToInt32(catid));
                    }
                }

            }

            var rtnList = BuildPropertyList(displaylevels, showHidden, showArchived, parentid, catreflist, prefix, displayCount, showEmpty, groupref, ">", lang);

            if (validCatList != null)
            {
                var nonValid = new List<int>();
                // we have a filter on the list, so remove any categories not in valid list.
                foreach (var k in rtnList)
                {
                    if (!validCatList.Contains(k.Key)) nonValid.Add(k.Key);
                }
                foreach (var k in nonValid)
                {
                    rtnList.Remove(k);
                }
            }

            return rtnList;
        }
Example #27
0
        public static int GetCategoryIdFromUrl(int portalId, System.Web.HttpRequest request)
        {
            var categoryid = -1;
            var grpCatCtrl = new GrpCatController(Utils.GetCurrentCulture());

            var qrycatid = Utils.RequestQueryStringParam(request, "catid");
            if (Utils.IsNumeric(qrycatid)) categoryid = Convert.ToInt32(qrycatid);
            if (categoryid == -1 )
            {
                var qrycatref = Utils.RequestQueryStringParam(request, "catref");
                if (qrycatref != "")
                {
                    var catrefData = grpCatCtrl.GetCategoryByRef(portalId, qrycatref);
                    if (catrefData != null) categoryid = catrefData.categoryid;
                }
            }
            return categoryid;
        }
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            _catGrpCtrl = new GrpCatController(Utils.GetCurrentCulture());

            if (ModSettings.Get("themefolder") == "")  // if we don't have module setting jump out
            {
                rpDataH.ItemTemplate = new GenXmlTemplate("NO MODULE SETTINGS");
                return;
            }

            try
            {
                _targetModuleKey = "";
                _targetModuleKey = ModSettings.Get("targetmodulekey");

                _entryid = Utils.RequestQueryStringParam(Context, "eid");
                _catid = Utils.RequestQueryStringParam(Context, "catid");
                _catname = Utils.RequestQueryStringParam(Context, "catref");
                if (_catid == "" && _catname != "") _catid = CategoryUtils.GetCatIdFromName(_catname);

                var navigationdata = new NavigationData(PortalId, _targetModuleKey);
                if (Utils.IsNumeric(_catid)) navigationdata.Delete(); // if a category button has been clicked (in url) then clear search;
                if (Utils.IsNumeric(navigationdata.CategoryId) && navigationdata.FilterMode) _catid = navigationdata.CategoryId;
                if (Utils.IsNumeric(_entryid))
                {
                    // Get catid from product
                    var prodData = ProductUtils.GetProductData(Convert.ToInt32(_entryid), Utils.GetCurrentCulture());
                    var catDef = prodData.GetDefaultCategory();
                    if (catDef != null) _catid = catDef.categoryid.ToString("");
                }
                if (_catid == "") _catid = ModSettings.Get("defaultcatid");

                _templH = ModSettings.Get("txtdisplayheader");
                _templD = ModSettings.Get("txtdisplaybody");
                _templDfoot = ModSettings.Get("txtdisplaybodyfoot");
                _templF = ModSettings.Get("txtdisplayfooter");

                _tabid = ModSettings.Get("ddllisttabid");
                if (!Utils.IsNumeric(_tabid)) _tabid = TabId.ToString("");

                // Get Display Header
                var rpDataHTempl = ModCtrl.GetTemplateData(ModSettings, _templH, Utils.GetCurrentCulture(), DebugMode);

                rpDataH.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataHTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);
                _templateHeader = (GenXmlTemplate)rpDataH.ItemTemplate;

                // insert page header text
                NBrightBuyUtils.IncludePageHeaders(ModCtrl, ModuleId, Page, _templateHeader, ModSettings.Settings(), null, DebugMode);

                // Get Display Body
                var rpDataTempl = ModCtrl.GetTemplateData(ModSettings, _templD, Utils.GetCurrentCulture(), DebugMode);
                rpData.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);

                // Get Display Footer
                var rpDataFTempl = ModCtrl.GetTemplateData(ModSettings, _templF, Utils.GetCurrentCulture(), DebugMode);
                rpDataF.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataFTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);

            }
            catch (Exception exc)
            {
                if (UserInfo.IsSuperUser) rpDataF.ItemTemplate = new GenXmlTemplate(exc.Message, ModSettings.Settings());
                // catch any error and allow processing to continue, output error as footer template.
            }
        }
Example #29
0
        private void MoveRecord(int itemId)
        {
            var selecteditemid = GenXmlFunctions.GetField(rpDataH, "selecteditemid");
            if (Utils.IsNumeric(selecteditemid))
            {
                var movData = CategoryUtils.GetCategoryData(itemId, StoreSettings.Current.EditLanguage);
                var selData = CategoryUtils.GetCategoryData(Convert.ToInt32(selecteditemid), StoreSettings.Current.EditLanguage);
                var fromParentItemid = selData.DataRecord.ParentItemId;
                var toParentItemid = movData.DataRecord.ParentItemId;
                var reindex = toParentItemid != fromParentItemid;

                var objGrpCtrl = new GrpCatController(StoreSettings.Current.EditLanguage);
                var movGrp = objGrpCtrl.GetGrpCategory(movData.Info.ItemID);
                if (!movGrp.Parents.Contains(selData.Info.ItemID)) // cannot move a category into itself (i.e. move parent into sub-category)
                {
                    selData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlparentcatid", toParentItemid.ToString(""));
                    selData.DataRecord.ParentItemId = toParentItemid;
                    selData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlgrouptype", movData.DataRecord.GetXmlProperty("genxml/dropdownlist/ddlgrouptype"));
                    var strneworder = movData.DataRecord.GetXmlProperty("genxml/hidden/recordsortorder");
                    var selorder = selData.DataRecord.GetXmlProperty("genxml/hidden/recordsortorder");
                    if (!Utils.IsNumeric(strneworder)) strneworder = "1";
                    if (!Utils.IsNumeric(selorder)) selorder = "1";
                    var neworder = Convert.ToDouble(strneworder, CultureInfo.GetCultureInfo("en-US"));
                    if (Convert.ToDouble(strneworder, CultureInfo.GetCultureInfo("en-US")) < Convert.ToDouble(selorder, CultureInfo.GetCultureInfo("en-US")))
                        neworder = neworder - 0.5;
                    else
                        neworder = neworder + 0.5;
                    selData.DataRecord.SetXmlProperty("genxml/hidden/recordsortorder", neworder.ToString(""), TypeCode.Double);
                    ModCtrl.Update(selData.DataRecord);

                    FixRecordSortOrder(toParentItemid.ToString("")); //reindex all siblings (this is so we get a int on the recordsortorder)
                    FixRecordGroupType(selData.Info.ItemID.ToString(""), selData.DataRecord.GetXmlProperty("genxml/dropdownlist/ddlgrouptype"));

                    if (reindex)
                    {
                        objGrpCtrl.ReIndexCascade(fromParentItemid); // reindex from parent and parents.
                        objGrpCtrl.ReIndexCascade(selData.Info.ItemID); // reindex select and parents
                    }
                    NBrightBuyUtils.RemoveModCachePortalWide(PortalId); //clear any cache
                }
            }
        }
Example #30
0
 public Boolean IsInCategory(String categoryref)
 {
     var objGrpCtrl = new GrpCatController(_lang);
     var l = objGrpCtrl.GetProductCategories(Info.ItemID, "cat",true);
     return l.Any(i => i.categoryref == categoryref);
 }
Example #31
0
        public void Save()
        {
            var objCtrl = new NBrightBuyController();
            objCtrl.Update(DataRecord);
            objCtrl.Update(DataLangRecord);

            //do reindex of cascade records.
            if (_doCascadeIndex)
            {
                var objGrpCtrl = new GrpCatController(_lang);
                objGrpCtrl.ReIndexCascade(_oldcatcascadeid); // reindex form parnet and parents
                objGrpCtrl.ReIndexCascade(DataRecord.ItemID); // reindex self
                objGrpCtrl.Reload();
            }

            NBrightBuyUtils.ProcessEventProvider(EventActions.AfterCategorySave, DataRecord);
        }
        private String CopyAllCatXref(HttpContext context,Boolean moverecords = false)
        {
            var strOut = NBrightBuyUtils.GetResxMessage("general_fail");
            try
            {
                var settings = GetAjaxFields(context);
                var strFilter = " and XrefItemId = {Settings:itemid} ";

                strFilter = Utils.ReplaceSettingTokens(strFilter, settings);

                var newcatid = "";
                if (settings.ContainsKey("selectedcatid")) newcatid = settings["selectedcatid"];

                if (Utils.IsNumeric(newcatid) && settings.ContainsKey("itemid"))
                {
                    var objCtrl = new NBrightBuyController();
                    var objList = objCtrl.GetList(PortalSettings.Current.PortalId, -1, "CATXREF", strFilter);

                    foreach (var obj in objList)
                    {
                        var strGuid = newcatid + "x" + obj.ParentItemId.ToString("");
                        var nbi = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "CATXREF", strGuid);
                        if (nbi == null)
                        {
                            if (!moverecords) obj.ItemID = -1;
                            obj.XrefItemId = Convert.ToInt32(newcatid);
                            obj.GUIDKey = strGuid;
                            obj.XMLData = null;
                            obj.TextData = null;
                            obj.Lang = null;
                            objCtrl.Update(obj);
                            //add all cascade xref
                            var objGrpCtrl = new GrpCatController(_lang, true);
                            var parentcats = objGrpCtrl.GetCategory(Convert.ToInt32(newcatid));
                            foreach (var p in parentcats.Parents)
                            {
                                strGuid = p.ToString("") + "x" + obj.ParentItemId.ToString("");
                                nbi = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "CATCASCADE", strGuid);
                                if (nbi == null)
                                {
                                    obj.XrefItemId = p;
                                    obj.TypeCode = "CATCASCADE";
                                    obj.GUIDKey = strGuid;
                                    objCtrl.Update(obj);
                                }
                            }
                        }
                    }

                    if (moverecords) DeleteAllCatXref(context);

                    strOut = NBrightBuyUtils.GetResxMessage();
                }

            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
            return strOut;
        }
Example #33
0
        public void RemoveCategory(int categoryid)
        {
            var objCtrl = new NBrightBuyController();
            if (Utils.IsNumeric(DataRecord.GetXmlProperty("genxml/defaultcatid")) && categoryid == Convert.ToInt32(DataRecord.GetXmlProperty("genxml/defaultcatid")))
            {
                DataRecord.SetXmlProperty("genxml/defaultcatid", "");
                objCtrl.Update(DataRecord);
            }

            var parentitemid = Info.ItemID.ToString("");
            var xrefitemid = categoryid.ToString("");
            var objQual = DotNetNuke.Data.DataProvider.Instance().ObjectQualifier;
            var dbOwner = DotNetNuke.Data.DataProvider.Instance().DatabaseOwner;
            var stmt = "delete from " + dbOwner + "[" + objQual + "NBrightBuy] where typecode = 'CATXREF' and XrefItemId = " + xrefitemid + " and parentitemid = " + parentitemid;
            objCtrl.ExecSql(stmt);
            //remove all cascade xref
            var objGrpCtrl = new GrpCatController(_lang, true);
            var parentcats = objGrpCtrl.GetCategory(Convert.ToInt32(xrefitemid));
            if (parentcats != null)
            {
                foreach (var p in parentcats.Parents)
                {
                    var xreflist = objCtrl.GetList(_portalId, -1, "CATXREF", " and NB1.parentitemid = " + parentitemid);
                    if (xreflist != null)
                    {
                        var deleterecord = true;
                        foreach (var xref in xreflist)
                        {
                            var catid = xref.XrefItemId;
                            var xrefparentcats = objGrpCtrl.GetCategory(Convert.ToInt32(catid));
                            if (xrefparentcats != null && xrefparentcats.Parents.Contains(p))
                            {
                                deleterecord = false;
                                break;
                            }
                        }
                        if (deleterecord)
                        {
                            stmt = "delete from " + dbOwner + "[" + objQual + "NBrightBuy] where typecode = 'CATCASCADE' and XrefItemId = " + p.ToString("") + " and parentitemid = " + parentitemid;
                            objCtrl.ExecSql(stmt);
                        }

                    }
                }
            }
        }