Esempio n. 1
0
        // unsure about location! (maybe another service)
        public string GetMultiStoreContentProperty(int contentId, string propertyAlias, ILocalization localization, bool globalOverrulesStore = false)
        {
            var examineNode = Helpers.GetNodeFromExamine(contentId, "GetMultiStoreItem::" + propertyAlias);

            if (localization == null)
            {
                localization = StoreHelper.CurrentLocalization;
            }
            var multiStoreAlias = StoreHelper.CreateMultiStorePropertyAlias(propertyAlias, localization.StoreAlias);
            var multiStoreMultiCurrencyAlias = StoreHelper.CreateFullLocalizedPropertyAlias(propertyAlias, localization);

            if (examineNode != null)
            {
                if (multiStoreAlias.StartsWith("description"))
                {
                    multiStoreAlias = "RTEItem" + multiStoreAlias;
                    propertyAlias   = "RTEItem" + propertyAlias;
                }

                if (globalOverrulesStore && examineNode.Fields.ContainsKey(propertyAlias))
                {
                    return(examineNode.Fields[propertyAlias] ?? string.Empty);
                }

                if (examineNode.Fields.ContainsKey(multiStoreMultiCurrencyAlias))
                {
                    return(examineNode.Fields[multiStoreMultiCurrencyAlias] ?? string.Empty);
                }

                if (examineNode.Fields.ContainsKey(multiStoreAlias))
                {
                    return(examineNode.Fields[multiStoreAlias] ?? string.Empty);
                }

                if (examineNode.Fields.ContainsKey(propertyAlias))
                {
                    return(examineNode.Fields[propertyAlias] ?? string.Empty);
                }

                Log.Instance.LogDebug("GetMultiStoreContentProperty Fallback to node after this");
            }

            var node = new Node(contentId);

            if (node.Name != null)
            {
                var property = node.GetProperty(propertyAlias);
                if (globalOverrulesStore && property != null && !string.IsNullOrEmpty(property.Value))
                {
                    return(property.Value);
                }
                var propertyMultiStoreMultiCurrency = node.GetProperty(multiStoreMultiCurrencyAlias);
                if (propertyMultiStoreMultiCurrency != null && !string.IsNullOrEmpty(propertyMultiStoreMultiCurrency.Value))
                {
                    return(propertyMultiStoreMultiCurrency.Value);
                }
                var propertyMultistore = node.GetProperty(multiStoreAlias);
                if (propertyMultistore != null && !string.IsNullOrEmpty(propertyMultistore.Value))
                {
                    return(propertyMultistore.Value);
                }
                if (property != null)
                {
                    return(property.Value);
                }
            }
            return(string.Empty);
        }