Ejemplo n.º 1
0
        protected override DriverResult Display(LocalizationPart part, string displayType, dynamic shapeHelper)
        {
            var masterId = part.MasterContentItem != null
                   ? part.MasterContentItem.Id
                   : part.Id;
            var localizations   = _cultureService.GetLocalizations(part, VersionOptions.Latest).ToList();
            var siteCulture     = _cultureService.GetSiteCulture();
            var selectedCulture = part.Culture != null ? part.Culture.Culture : (part.Id == 0 ? siteCulture : null);
            var sC           = _cultureService.ListCultures();
            var siteCultures = sC.Where(c => c.Culture != null)
                               .Select(c => c.Culture)
                               .Where(s => !localizations.Select(l => l.Culture.Culture).Contains(s));

            return(Combined(
                       ContentShape("Parts_ExLocalization_ContentTranslations",
                                    () => shapeHelper.Parts_ExLocalization_ContentTranslations(MasterId: masterId, Localizations: localizations.Where(c => c.Culture.Culture != selectedCulture))),
                       ContentShape("Parts_ExLocalization_ContentTranslations_Summary",
                                    () => shapeHelper.Parts_ExLocalization_ContentTranslations_Summary(MasterId: masterId,
                                                                                                       ShowAddTranslation: _cultureService.ListCultures().Select(c => c.Culture).Where(s => s != siteCulture && !localizations.Select(l => l.Culture.Culture).Contains(s)).Any(),
                                                                                                       SelectedCulture: selectedCulture,
                                                                                                       ContentItem: part.ContentItem,
                                                                                                       SiteCultures: siteCultures,
                                                                                                       Localizations: localizations.Where(c => c.Culture.Culture != selectedCulture))),
                       ContentShape("Parts_ExLocalization_ContentTranslations_SummaryAdmin",
                                    () => shapeHelper.Parts_ExLocalization_ContentTranslations_SummaryAdmin(MasterId: masterId,
                                                                                                            MasterContentItem: part.MasterContentItem,
                                                                                                            ShowAddTranslation: _cultureService.ListCultures().Select(c => c.Culture).Where(s => s != siteCulture && !localizations.Select(l => l.Culture.Culture).Contains(s)).Any(),
                                                                                                            SelectedCulture: selectedCulture,
                                                                                                            SiteCultures: siteCultures,
                                                                                                            ContentItem: part.ContentItem,
                                                                                                            Localizations: localizations.Where(c => c.Culture.Culture != selectedCulture)))
                       ));
        }
Ejemplo n.º 2
0
        public CurrencyRecord GetCurrencyByCulture(string culture, string xcurrency)
        {
            var cult = _cultureService.ListCultures().Where(c => c.Culture == culture).FirstOrDefault();

            if (cult == null)
            {
                cult = _cultureService.ListCultures().Where(c => c.Culture == "en-MY").First();
            }

            var country =
                _linkCountryCultureRecord.Table.Where(l => l.CultureRecord.Culture == cult.Culture)
                .Select(l => l.CountryRecord)
                .First();
            var currency = (string.IsNullOrWhiteSpace(xcurrency))?
                           _linkCountryCurrencyRecord.Table.Where(u => u.CountryRecord.Id == country.Id)
                           .Select(u => u.CurrencyRecord)
                           .First():
                           GetAllCurrecies().Where(aa => aa.Code.ToLower() == xcurrency.Trim()).First();

            return(currency);
        }
Ejemplo n.º 3
0
        protected override DriverResult Display(CookieCulturePickerPart part, string displayType, dynamic shapeHelper)
        {
            var urlHelper          = new UrlHelper(_orchardServices.WorkContext.HttpContext.Request.RequestContext);
            var cookieCultureItems = new List <CookieCultureItemViewModel>();
            // Is content item shown?
            var contentItem    = _cultureService.GetCurrentContentItem();
            var currentCulture = _cultureService.GetCurrentCulture();
            var returnUrl      = _orchardServices.WorkContext.HttpContext.Request.Url.LocalPath;
            var localizations  = contentItem != null?_cultureService.GetLocalizations(contentItem.As <LocalizationPart>(), VersionOptions.Latest).ToList() : null;

            if (!string.IsNullOrWhiteSpace(returnUrl) && returnUrl.IndexOf("/NotTranslated", StringComparison.OrdinalIgnoreCase) > 0)
            {
                returnUrl = urlHelper.Content("~/");
            }

            foreach (var cultureItem in _cultureService.ListCultures())
            {
                var cookieCultureItem = new CookieCultureItemViewModel
                {
                    CultureItem = cultureItem,
                    Current     = string.Equals(currentCulture, cultureItem.Culture, StringComparison.OrdinalIgnoreCase),
                    ReturnUrl   = returnUrl,
                    Rel         = contentItem == null ? "nofollow" : null
                };
                if (localizations != null)
                {
                    var localizedContentItem = localizations.Where(p => string.Equals(p.Culture.Culture, cultureItem.Culture, StringComparison.OrdinalIgnoreCase)).Select(p => p.ContentItem).FirstOrDefault();
                    var metadata             = localizedContentItem != null?localizedContentItem.ContentManager.GetItemMetadata(localizedContentItem) : null;

                    if (metadata != null && metadata.DisplayRouteValues != null)
                    {
                        cookieCultureItem.ReturnUrl = urlHelper.Content(urlHelper.RouteUrl(metadata.DisplayRouteValues));
                    }
                    else
                    {
                        cookieCultureItem.ReturnUrl = urlHelper.RouteUrl(new { Area = "RM.Localization", Action = "NotTranslated", Controller = "LocalizedHome", Culture = cultureItem.Culture, Id = contentItem.Id });
                        cookieCultureItem.Rel       = "nofollow";
                    }
                }
                cookieCultureItems.Add(cookieCultureItem);
            }

            if (part.Style == Styles[1])
            {
                return(ContentShape("Parts_CookieCulturePicker", () => shapeHelper.Parts_DropdownCookieCulturePicker(Cultures: cookieCultureItems, CurrentCulture: currentCulture)));
            }
            else
            {
                return(ContentShape("Parts_CookieCulturePicker", () => shapeHelper.Parts_InlineListCookieCulturePicker(Cultures: cookieCultureItems, CurrentCulture: currentCulture)));
            }
        }
Ejemplo n.º 4
0
        protected override DriverResult Display(CookieCulturePickerPart part, string displayType, dynamic shapeHelper)
        {
            var userCultures = _curentUserCulturesProvider.GetCulturesForCurrentUser();
            var l            = _cultureService.ListCultures().Where(c => userCultures.Contains(c.Culture));

            var result = ContentShape("Parts_CookieCulturePicker",
                                      () => shapeHelper.Parts_CookieCulturePicker(
                                          Cultures: l, CurrentCulture: _cultureService.GetCurrentCulture()
                                          )
                                      );

            return(result);

            //var result = ContentShape("Parts_CookieCulturePicker",
            //        () => shapeHelper.Parts_CookieCulturePicker(
            //            Cultures: _cultureService.ListCultures(), CurrentCulture: _cultureService.GetCurrentCulture()
            //            )
            //    );
        }
Ejemplo n.º 5
0
        public void GetNavigation(NavigationBuilder builder)
        {
            var cultures           = _cultureService.ListCultures();
            var currentCultureName = _cultureService.GetCurrentCulture();
            var currentCulture     = cultures.FirstOrDefault(x => x.Culture == currentCultureName);

            builder.Add(T(currentCulture != null ? currentCulture.FullName : currentCultureName), "-2", menu => {
                menu.AddClass("section-dashboard");
                menu.LinkToFirstChild(false);
                foreach (var c in cultures)
                {
                    if (c.Culture == currentCultureName)
                    {
                        continue;
                    }
                    menu.Add(T(c.FullName), item => item.Action("SetCulture", "CookieCulture", new { Area = "RM.Localization", culture = c.Culture, returnUrl = _workContextAccessor.GetContext().HttpContext.Request.ToUrlString() }));
                }
                menu.Add(T("Reset"), item => item.Action("ResetCulture", "CookieCulture", new { Area = "RM.Localization", returnUrl = _workContextAccessor.GetContext().HttpContext.Request.ToUrlString() }));
            }, null);
        }