/// <summary>
        ///   Includes page urls on the sitemap
        /// </summary>
        /// <remarks>
        ///   Pages that are included:
        ///   - are not deleted
        ///   - are not disabled
        ///   - are normal pages (not links,...)
        ///   - are visible (based on date and permissions)
        /// </remarks>
        public override List <SitemapUrl> GetUrls(int portalId, PortalSettings ps, string version)
        {
            //Logger.Error("Opencontent sitemap generation page : start");



            //var objTabs = new TabController();
            OpenSitemapUrl pageUrl = null;
            var            urls    = new List <SitemapUrl>();

            useLevelBasedPagePriority = bool.Parse(PortalController.GetPortalSetting("SitemapLevelMode", portalId, "False"));
            minPagePriority           = float.Parse(PortalController.GetPortalSetting("SitemapMinPriority", portalId, "0.1"), CultureInfo.InvariantCulture);
            includeHiddenPages        = bool.Parse(PortalController.GetPortalSetting("SitemapIncludeHidden", portalId, "False"));

            this.ps = ps;
            var Locales = ps.ContentLocalizationEnabled ?
                          LocaleController.Instance.GetPublishedLocales(ps.PortalId).Values :
                          LocaleController.Instance.GetLocales(ps.PortalId).Values;

            bool MultiLanguage = Locales.Count > 1;


            var currentLanguage = ps.CultureCode;

            if (string.IsNullOrEmpty(currentLanguage))
            {
                currentLanguage = Localization.GetPageLocale(ps).Name;
            }
            var languagePublished = LocaleController.Instance.GetLocale(ps.PortalId, currentLanguage).IsPublished;
            var tabs = TabController.Instance.GetTabsByPortal(portalId).Values
                       .Where(t => /* !t.IsSystem && */ !ps.ContentLocalizationEnabled || (languagePublished && t.CultureCode.Equals(currentLanguage, StringComparison.InvariantCultureIgnoreCase)));

            foreach (TabInfo objTab in tabs)
            {
                if (objTab.CultureCode == currentLanguage || objTab.IsNeutralCulture)
                {
                    if (!objTab.IsDeleted && !objTab.DisableLink && objTab.TabType == TabType.Normal &&
                        (Null.IsNull(objTab.StartDate) || objTab.StartDate < DateTime.Now) &&
                        (Null.IsNull(objTab.EndDate) || objTab.EndDate > DateTime.Now) &&
                        IsTabPublic(objTab.TabPermissions)
                        )
                    {
                        var allowIndex = true;
                        if ((!objTab.TabSettings.ContainsKey("AllowIndex") || !bool.TryParse(objTab.TabSettings["AllowIndex"].ToString(), out allowIndex) || allowIndex) &&
                            (includeHiddenPages || objTab.IsVisible))
                        {
                            // modules urls
                            var rules = OpenContentUrlProvider.GetRules(portalId);
                            foreach (var rule in rules.Where(r => r.TabId == objTab.TabID && r.InSitemap == true))
                            {
                                if (rule.CultureCode == null || rule.CultureCode == currentLanguage)
                                {
                                    string[] pars = rule.Parameters.Split('&');
                                    pageUrl = GetPageUrl(objTab, MultiLanguage ? currentLanguage : null, pars);
                                    // if module support ML
                                    //pageUrl.Alternates.AddRange(GetAlternates(objTab.TabID, pars));
                                    urls.Add(pageUrl);
                                    //Logger.Error("Opencontent sitemap generation page : " + pageUrl.Url);
                                }
                            }
                        }
                    }
                }
            }


            return(urls);
        }
        public override List <UrlRule> GetRules(int PortalId)
        {
            var rules = OpenContentUrlProvider.GetRules(PortalId);

            return(rules.Select(r => new UrlRule()
            {
                CultureCode = r.CultureCode,
                TabId = r.TabId,
                RuleType = UrlRuleType.Module,
                Parameters = r.Parameters,
                Action = UrlRuleAction.Rewrite,
                Url = CleanupUrl(r.Url),
                RemoveTab = !includePageName
            }).ToList());

            /*
             * Dictionary<string, Locale> dicLocales = LocaleController.Instance.GetLocales(PortalId);
             * List<UrlRule> Rules = new List<UrlRule>();
             * OpenContentController occ = new OpenContentController();
             *
             * ModuleController mc = new ModuleController();
             * ArrayList modules = mc.GetModulesByDefinition(PortalId, "OpenContent");
             * //foreach (ModuleInfo module in modules.OfType<ModuleInfo>().GroupBy(m => m.ModuleID).Select(g => g.First())){
             * foreach (ModuleInfo module in modules.OfType<ModuleInfo>())
             * {
             *  OpenContentSettings settings = new OpenContentSettings(module.ModuleSettings);
             *  int MainTabId = settings.DetailTabId > 0 ? settings.DetailTabId : (settings.TabId > 0 ? settings.TabId : module.TabID);
             *  int MainModuleId = settings.IsOtherModule ? settings.ModuleId : module.ModuleID;
             *
             *  if (settings.Template != null && settings.Template.IsListTemplate && ( !settings.IsOtherModule || settings.DetailTabId > 0) )
             *  {
             *      var physicalTemplateFolder = settings.TemplateDir.PhysicalFullDirectory+ "\\";
             *
             *      HandlebarsEngine hbEngine = new HandlebarsEngine();
             *      if (!string.IsNullOrEmpty(settings.Manifest.DetailUrl))
             *      {
             *          hbEngine.Compile(settings.Manifest.DetailUrl);
             *      }
             *      foreach (KeyValuePair<string, Locale> key in dicLocales)
             *      {
             *          string CultureCode = key.Value.Code;
             *          string RuleCultureCode = (dicLocales.Count > 1 ? CultureCode : null);
             *
             *          //var contents = occ.GetContents(MainModuleId);
             *          var ds = DataSourceManager.GetDataSource(settings.Manifest.DataSource);
             *          var dsContext = new DataSourceContext()
             *          {
             *              ModuleId = MainModuleId,
             *              TemplateFolder = settings.TemplateDir.FolderPath,
             *              Config = settings.Manifest.DataSourceConfig
             *          };
             *          IEnumerable<IDataItem> dataList = new List<IDataItem>();
             *          dataList = ds.GetAll(dsContext, null).Items;
             *
             *
             *
             *          if (dataList.Count() > 1000)
             *          {
             *              continue;
             *          }
             *          foreach (IDataItem content in dataList)
             *          {
             *
             *              string url = "content-" + content.Id;
             *              if (!string.IsNullOrEmpty(settings.Manifest.DetailUrl))
             *              {
             *                  //string dataJson = content.Data;
             *                  try
             *                  {
             *
             *                      ModelFactory mf = new ModelFactory(content, settings.Data, physicalTemplateFolder, settings.Template.Manifest, settings.Template, settings.Template.Main, module, PortalId, CultureCode, MainTabId, MainModuleId);
             *                      dynamic model = mf.GetModelAsDynamic(true);
             *
             *                      url = CleanupUrl(hbEngine.Execute(model));
             *                      //title = OpenContentUtils.CleanupUrl(dyn.Title);
             *                  }
             *                  catch (Exception ex)
             *                  {
             *                      Log.Logger.Error("Failed to generate url for opencontent item " + content.Id, ex);
             *                  }
             *              }
             *
             *              if (!string.IsNullOrEmpty(url))
             *              {
             *                  var rule = new UrlRule
             *                  {
             *                      CultureCode = RuleCultureCode,
             *                      TabId = MainTabId,
             *                      RuleType = UrlRuleType.Module,
             *                      Parameters = "id=" + content.Id,
             *                      Action = UrlRuleAction.Rewrite,
             *                      Url = CleanupUrl(url),
             *                      RemoveTab = !includePageName
             *                  };
             *                  if (Rules.Any(r => r.Url == rule.Url && r.CultureCode == rule.CultureCode && r.TabId == rule.TabId))
             *                  {
             *                      rule.Url = content.Id + "-" + CleanupUrl(url);
             *                  }
             *                  bool RuleExist = Rules.Any(r => r.RuleType == rule.RuleType && r.CultureCode == rule.CultureCode && r.TabId == rule.TabId && r.Parameters == rule.Parameters && r.Action == rule.Action);
             *
             *                  if (!RuleExist) Rules.Add(rule);
             *
             *              }
             *          }
             *      }
             *  }
             * }
             * return Rules;
             */
        }