/// <summary>
    /// Returns WHERE condition for given site.
    /// </summary>
    private string GetWhereConditionInternal()
    {
        int    siteId = (SiteID > 0) ? SiteID : SiteContext.CurrentSiteID;
        string retval = string.Format("CultureID IN (SELECT CultureID FROM CMS_SiteCulture WHERE SiteID = {0})", siteId);

        if (!string.IsNullOrEmpty(AdditionalWhereCondition))
        {
            retval = SqlHelper.AddWhereCondition(retval, AdditionalWhereCondition, "AND");
        }

        // Add supported cultures
        if (!String.IsNullOrEmpty(SupportedCultures))
        {
            StringBuilder sb = new StringBuilder(retval);

            sb.Append(" AND CultureCode IN (");

            List <string> suppCultures = SupportedCultures.Split(new[] { Environment.NewLine }, StringSplitOptions.None).ToList();

            sb.Append(String.Join(",", suppCultures.Select(t => "'" + SqlHelper.GetSafeQueryString(t) + "'")));

            sb.Append(")");

            retval = sb.ToString();
        }

        return(retval);
    }
Exemplo n.º 2
0
        /// <summary>
        /// private list of supported CultureInfo,
        /// </summary>
        private IEnumerable <CultureInfo> GetSupportedCultures()
        {
            // if the user didn't specify manually list of supported cultures,
            // then create cultures list with reference to supported cultures defined in localization settings in startup</para>
            if (string.IsNullOrWhiteSpace(SupportedCultures))
            {
                return(_ops.Value.SupportedCultures);
            }

            //if the user will specify supported cultures manually, then this list will be created accordingly
            var cList = new List <CultureInfo>();

            foreach (var c in SupportedCultures.Split(new[] { ',', '|', ';', ' ' }, System.StringSplitOptions.RemoveEmptyEntries))
            {
                cList.Add(new CultureInfo(c));
            }

            return(cList);
        }
Exemplo n.º 3
0
    /// <summary>
    /// Returns WHERE condition for given site.
    /// </summary>
    private string GetWhereConditionInternal()
    {
        // If site id is -1 return all cultures
        if (SiteID < 0)
        {
            return(string.Empty);
        }

        StringBuilder sb = new StringBuilder("CultureID IN (SELECT CultureID FROM CMS_SiteCulture WHERE SiteID = ");

        if (SiteID > 0)
        {
            sb.Append(SiteID);
        }
        else
        {
            sb.Append(CMSContext.CurrentSiteID);
        }
        sb.Append(")");

        // Add supported cultures
        if (!String.IsNullOrEmpty(SupportedCultures))
        {
            sb.Append(" AND CultureCode IN (");
            string[] suppCultures = SupportedCultures.Split(new string[1] {
                Environment.NewLine
            }, StringSplitOptions.None);
            foreach (string s in suppCultures)
            {
                sb.Append("'");
                sb.Append(s);
                sb.Append("', ");
            }
            sb.Remove(sb.Length - 2, 2);
            sb.Append(")");
        }

        return(sb.ToString());
    }