Ejemplo n.º 1
0
        public void Globalization_ResKeyParser()
        {
            string className, name, src;

            var ok = SenseNetResourceManager.ParseResourceKey(src = "$Resources:ClassName,Key", out className, out name);

            Assert.IsTrue(ok, "Failed to parse: " + src);
            Assert.IsTrue(className == "ClassName", String.Format("ClassName is '{0}', expected: 'ClassName', src: {1}", className, src));
            Assert.IsTrue(name == "Key", String.Format("Name is '{0}', expected: 'Key', src: {1}", name, src));

            ok = SenseNetResourceManager.ParseResourceKey(src = "$   Resources:   ClassName  ,  Key   ", out className, out name);
            Assert.IsTrue(ok, "Failed to parse: " + src);
            Assert.IsTrue(className == "ClassName", String.Format("ClassName is '{0}', expected: 'ClassName', src: {1}", className, src));
            Assert.IsTrue(name == "Key", String.Format("Name is '{0}', expected: 'Key', src: {1}", name, src));

            ok = SenseNetResourceManager.ParseResourceKey(src = "$ClassName,Key", out className, out name);
            Assert.IsTrue(ok, "Failed to parse: " + src);
            Assert.IsTrue(className == "ClassName", String.Format("ClassName is '{0}', expected: 'ClassName', src: {1}", className, src));
            Assert.IsTrue(name == "Key", String.Format("Name is '{0}', expected: 'Key', src: {1}", name, src));

            ok = SenseNetResourceManager.ParseResourceKey(src = "$      ClassName   ,   Key   ", out className, out name);
            Assert.IsTrue(ok, "Failed to parse: " + src);
            Assert.IsTrue(className == "ClassName", String.Format("ClassName is '{0}', expected: 'ClassName', src: {1}", className, src));
            Assert.IsTrue(name == "Key", String.Format("Name is '{0}', expected: 'Key', src: {1}", name, src));
        }
Ejemplo n.º 2
0
        public void ContentQuery_ChoiceFieldLocalizedOptions_Sorting()
        {
            ContentTypeInstaller.InstallContentType(@"<?xml version='1.0' encoding='utf-8'?>
				<ContentType name='ContentQuery_ChoiceField' parentType='GenericContent' handler='SenseNet.ContentRepository.GenericContent' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'>
					<Fields>
						<Field name='ChoiceTest' type='Choice'>
							<Configuration>
								<AllowExtraValue>true</AllowExtraValue>
								<AllowMultiple>true</AllowMultiple>
								<Options>
									<Option value='2'>$TestChoice,Text3</Option>
									<Option value='0'>$TestChoice,Text1</Option>
									<Option value='3'>Text4</Option>
									<Option value='1'>$TestChoice,Text2</Option>
								</Options>
							</Configuration>
						</Field>
					</Fields>
				</ContentType>"                );

            SaveResources("TestChoice", @"<?xml version=""1.0"" encoding=""utf-8""?>
                <Resources>
                  <ResourceClass name=""TestChoice"">
                    <Languages>
                      <Language cultureName=""en"">
                        <data name=""Text1"" xml:space=""preserve""><value>C-Text-1</value></data>
                        <data name=""Text2"" xml:space=""preserve""><value>A-Text-2</value></data>
                        <data name=""Text3"" xml:space=""preserve""><value>B-Text-3</value></data>
                      </Language>
                      <Language cultureName=""hu"">
                        <data name=""Text1"" xml:space=""preserve""><value>C-Szöveg-1</value></data>
                        <data name=""Text2"" xml:space=""preserve""><value>A-Szöveg-2</value></data>
                        <data name=""Text3"" xml:space=""preserve""><value>B-Szöveg-3</value></data>
                      </Language>
                    </Languages>
                  </ResourceClass>
                </Resources>");

            SenseNetResourceManager.Reset();

            CreateTestContentForChoiceFieldLocalizedOptions_Sorting("Ordering-", "2;3;~other.other text", 3);
            CreateTestContentForChoiceFieldLocalizedOptions_Sorting("Ordering-", "1", 2);
            CreateTestContentForChoiceFieldLocalizedOptions_Sorting("Ordering-", "3", 4);
            CreateTestContentForChoiceFieldLocalizedOptions_Sorting("Ordering-", "~other.other text 3", 9);
            CreateTestContentForChoiceFieldLocalizedOptions_Sorting("Ordering-", "0", 1);
            CreateTestContentForChoiceFieldLocalizedOptions_Sorting("Ordering-", "~other.other text 2", 8);
            CreateTestContentForChoiceFieldLocalizedOptions_Sorting("Ordering-", "~other.cccc", 7);
            CreateTestContentForChoiceFieldLocalizedOptions_Sorting("Ordering-", "~other.aaaa", 5);
            CreateTestContentForChoiceFieldLocalizedOptions_Sorting("Ordering-", "~other.bbbb", 6);

            var result = ContentQuery.Query("+Name:'Ordering-*' .AUTOFILTERS:OFF .SORT:ChoiceTest");

            Assert.AreEqual(9, result.Count);
            var indexes = String.Join(" ", result.Nodes.Select(n => n.Index.ToString()));

            Assert.AreEqual("1 2 3 4 5 6 7 8 9", indexes);
        }
Ejemplo n.º 3
0
        protected void SetDefaultsInternal()
        {
            _allowMultiple   = false;
            _allowExtraValue = false;

            _options = new List <ChoiceOption>
            {
                new ChoiceOption(YesValue, SenseNetResourceManager.GetResourceKey("Ctd", "Enum-FieldSettingContent-YesNo-Yes")),
                new ChoiceOption(NoValue, SenseNetResourceManager.GetResourceKey("Ctd", "Enum-FieldSettingContent-YesNo-No"))
            };
        }
Ejemplo n.º 4
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            var voting = Node.LoadNode(Content.Id) as Voting;

            if (voting == null)
            {
                Controls.Add(new Literal {
                    Text = "Error with loading the content with ID: " + Content.Id
                });
                return;
            }

            var dt = new DataTable();

            dt.Columns.AddRange(new[] {
                new DataColumn("Question", typeof(String)),
                new DataColumn("Count", typeof(Double))
            });

            var sum = voting.Result.Sum(item => Convert.ToDouble(item.Value));

            var formatString = string.Concat("N",
                                             DecimalsInResult < 0 || DecimalsInResult > 5
                                                    ? 0
                                                    : DecimalsInResult);

            foreach (var item in voting.Result)
            {
                string classname;
                string keyname;
                var    itemText = item.Key;
                if (SenseNetResourceManager.ParseResourceKey(itemText, out classname, out keyname))
                {
                    itemText = SenseNetResourceManager.Current.GetString(classname, keyname);
                }

                dt.Rows.Add(new[] {
                    itemText,
                    sum == 0 || Convert.ToInt32(item.Value) == 0 ? 0.ToString() : ((Convert.ToDouble(item.Value) / sum) * 100).ToString(formatString)
                });
            }

            var lv = FindControl("ResultList") as ListView;

            if (lv != null)
            {
                lv.DataSource = dt.DefaultView;
                lv.DataBind();
            }
        }
Ejemplo n.º 5
0
        public override void SetData(object data)
        {
            var displayName = data as string;

            _innerData = displayName;
            string className;
            string name;

            if (SenseNetResourceManager.ParseResourceKey(displayName, out className, out name))
            {
                var rescontrol = GetResourceEditorLinkControl();
                if (rescontrol != null)
                {
                    // write resourcesJSON to hidden textbox
                    var resourcesData = new SenseNet.Portal.ResourceEditorController.ResourceKeyData
                    {
                        Datas = ResourceEditorController.GetResources(className, name).Select(p => new SenseNet.Portal.ResourceEditorController.ResourceData {
                            Lang = p.Key, Value = p.Value
                        }).ToList(),
                        Name = displayName
                    };
                    var resourcesJSON = new JavaScriptSerializer().Serialize(resourcesData);
                    GetResourcesBoxControl().Text = resourcesJSON;

                    // send optionsJSON to client when clicked
                    string currentlang  = CultureInfo.CurrentUICulture.Name;
                    string currentlangp = CultureInfo.CurrentUICulture.Parent == null ? string.Empty : CultureInfo.CurrentUICulture.Parent.Name;
                    string dialogtitle  = SenseNetResourceManager.Current.GetString("Controls", "FieldControl-EditValue-Title");
                    var    title        = string.Format(dialogtitle, this.Field.DisplayName);

                    var optionsJSon = "{'link':$(this), 'currentlang':'" + currentlang + "','currentlangp':'" + currentlangp + "','title':'" + title + "'}";

                    rescontrol.OnClientClick = "SN.ResourceEditor.editResource('" + className + "','" + name + "'," + optionsJSon + "); return false;";
                    rescontrol.Text          = SenseNetResourceManager.Current.GetString(className, name);
                }
                var innerControl = GetInnerControl() as TextBox;
                innerControl.Style.Add("display", "none");
            }
            else
            {
                var resourceDiv = GetResourceDivControl();
                if (resourceDiv != null)
                {
                    resourceDiv.Visible = false;
                }
            }

            base.SetData(data);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Returns object data which is a transfer object.
        /// </summary>
        public virtual object GetData(bool localized)
        {
            if (!LocalizationEnabled || !localized || !SenseNetResourceManager.Running)
            {
                return(Value);
            }
            if (!(Value is string stringData))
            {
                return(Value);
            }

            return(SenseNetResourceManager.ParseResourceKey(stringData, out var className, out var name)
                ? SenseNetResourceManager.Current.GetString(className, name)
                : Value);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// HTML encodes a text to make it safe (xss-free) for displaying in markup. The only exception is
        /// if the text is a recognisable Sense/Net resource editor markup.
        /// </summary>
        /// <param name="text">A text to make HTML-safe</param>
        /// <returns>An HTML encoded text.</returns>
        public static string GetSafeText(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(string.Empty);
            }

            // resource editor markup is always safe as it contains only our markup (a link tag) and a sanitized display text
            if (PortalContext.Current.IsResourceEditorAllowed && SenseNetResourceManager.IsEditorMarkup(text))
            {
                return(text);
            }

            // encode the text to make it safe for displaying
            return(HttpUtility.HtmlEncode(text));
        }
Ejemplo n.º 8
0
        private void RenderBreadCrumbItems(HtmlTextWriter writer, string href, string menuText, bool renderLink)
        {
            var isEditor = PortalContext.Current.IsResourceEditorAllowed && SenseNetResourceManager.IsEditorMarkup(menuText);
            var text     = UITools.GetSafeText(menuText);

            if (renderLink && !isEditor)
            {
                writer.Write(string.Format("<a class=\"{0} {1}\" href=\"{2}\"><span>{3}</span></a>", ItemCssClass,
                                           LinkCssClass, href, text));
            }
            else
            {
                writer.Write(string.Format("<span class=\"{0} {1}\"><span>{2}</span></span>", ItemCssClass,
                                           ActiveItemCssClass, text));
            }
        }
Ejemplo n.º 9
0
        public string GetLocalizedValue(CultureInfo cultureInfo = null)
        {
            if (!LocalizationEnabled || !SenseNetResourceManager.Running)
            {
                return(GetStoredValue());
            }
            string className, name;
            var    stringData = this.GetStoredValue();

            if (SenseNetResourceManager.ParseResourceKey(stringData, out className, out name))
            {
                if (cultureInfo == null)
                {
                    return(SenseNetResourceManager.Current.GetString(className, name));
                }
                return(SenseNetResourceManager.Current.GetString(className, name, cultureInfo));
            }
            return(stringData);
        }
Ejemplo n.º 10
0
        public static string GetOptionLocalizedText(IEnumerable <ChoiceOption> options, string langKey)
        {
            // If there is no option for the specified language (this may happen if
            // the language key is missing from the option list of the Language field
            // in the Site CTD), use the language code itself.
            var choiceOption = options?.FirstOrDefault(o => o.Value == langKey);
            var text         = choiceOption == null ? langKey : choiceOption.StoredText;

            // choiceOption.Text contains the localized value, but since we are in resource editing mode, it will be a generated link to edit it
            // so let's manually resolve the localized text, because we don't want that link in the resource editor itself
            string className;
            string name;

            if (SenseNetResourceManager.ParseResourceKey(text, out className, out name))
            {
                var localizedText = SenseNetResourceManager.Current.GetObjectOrNull(className, name, CultureInfo.CurrentUICulture, false) as string;
                return(string.IsNullOrEmpty(localizedText) ? text : localizedText);
            }
            return(text);
        }
Ejemplo n.º 11
0
        private static string GetValidName(string title, bool removeResourceClass = true)
        {
            // check for resource key
            string className, key;

            if (removeResourceClass && SenseNetResourceManager.ParseResourceKey(title, out className, out key))
            {
                if (key.StartsWith("Category_"))
                {
                    key = key.Remove(0, 9);
                }

                title = key;
            }

            var name = title;

            name = new Regex(ContentNaming.InvalidNameCharsPattern).Replace(name, string.Empty);
            name = name.Replace(" ", string.Empty);
            return(name);
        }
Ejemplo n.º 12
0
        //========================================================================= Data handling

        /// <summary>
        /// Returns object data which is a transfer object.
        /// </summary>
        public virtual object GetData(bool localized = true)
        {
            if (!LocalizationEnabled || !localized || !SenseNetResourceManager.Running)
            {
                return(Value);
            }
            var stringData = Value as string;

            if (stringData == null)
            {
                return(Value);
            }

            string className, name;

            if (SenseNetResourceManager.ParseResourceKey(stringData, out className, out name))
            {
                return(SenseNetResourceManager.Current.GetString(className, name));
            }

            return(Value);
        }
Ejemplo n.º 13
0
        private void InstallResourceFile(string fileName, string xml)
        {
            var localizationFolder = Node.LoadNode("/Root/Localization");

            if (localizationFolder == null)
            {
                localizationFolder = new SystemFolder(Repository.Root, "Resources")
                {
                    Name = "Localization"
                };
                localizationFolder.Save();
            }
            var resourceNode = new Resource(localizationFolder)
            {
                Name = fileName
            };

            resourceNode.Binary.SetStream(RepositoryTools.GetStreamFromString(xml));
            resourceNode.Save();

            SenseNetResourceManager.Reset();
        }
Ejemplo n.º 14
0
        public static string GetStringByExpression(this SenseNetResourceManager resourceManager, string expression)
        {
            if (string.IsNullOrEmpty(expression))
            {
                return(expression);
            }

            if (!expression.StartsWith(SenseNetResourceManager.ResourceStartKey) ||
                !expression.EndsWith(SenseNetResourceManager.ResourceEndKey))
            {
                return(null);
            }

            expression = expression.Replace(" ", "");
            expression = expression.Replace(SenseNetResourceManager.ResourceStartKey, "");
            expression = expression.Replace(SenseNetResourceManager.ResourceEndKey, "");

            if (expression.Contains("Resources:"))
            {
                expression = expression.Remove(expression.IndexOf("Resources:", StringComparison.Ordinal), 10);
            }

            var expressionFields = ResourceExpressionBuilder.ParseExpression(expression);

            if (expressionFields == null)
            {
                var context = HttpContext.Current;
                var msg     = $"{expression} is not a valid string resource format.";
                if (context == null)
                {
                    throw new ApplicationException(msg);
                }
                return(string.Format(msg));
            }

            return(resourceManager.GetString(expressionFields.ClassKey, expressionFields.ResourceKey));
        }
Ejemplo n.º 15
0
        public override object GetData()
        {
            if (this.ControlMode == FieldControlControlMode.Browse || this.ReadOnly)
            {
                return(_innerData);
            }

            var nameAvailableControl = GetNameAvailableControl();

            // name control is available
            var nameControlAvailable = false;

            if (nameAvailableControl != null)
            {
                if (nameAvailableControl.Text != "0")
                {
                    nameControlAvailable = true;
                }
            }

            var displayName  = string.Empty;
            var innerControl = GetInnerControl() as TextBox;

            displayName = innerControl.Text;

            string className;
            string name;

            if (SenseNetResourceManager.ParseResourceKey(displayName, out className, out name))
            {
                // get resources
                var allresStr = GetResourcesBoxControl().Text;

                // if resources JSON is empty, we just entered a resource key into displayname control, but it does not yet come from the resource editor
                if (!string.IsNullOrEmpty(allresStr))
                {
                    var ser    = new JavaScriptSerializer();
                    var allres = ser.Deserialize <SenseNet.Portal.ResourceEditorController.ResourceKeyData>(allresStr);

                    // value comes from the resource editor ui
                    displayName = allres.Name;

                    // if the entered value is a resource key, then update corresponding resources
                    if (SenseNetResourceManager.ParseResourceKey(displayName, out className, out name))
                    {
                        ResourceEditorController.SaveResource(className, name, allres.Datas);
                    }
                }
            }

            if (!nameControlAvailable && (this.Content.Id == 0 || AlwaysUpdateName))
            {
                // content name should be set automatically generated from displayname
                var newName = ContentNamingHelper.GetNameFromDisplayName(this.Content.Name, displayName);
                if (newName.Length > 0)
                {
                    this.Content["Name"] = newName;
                }
            }

            return(displayName);
        }
Ejemplo n.º 16
0
        public static void ParseOptions(XPathNavigator node, List <ChoiceOption> options, ChoiceFieldSetting fieldSetting, out string enumTypeName)
        {
            options.Clear();
            enumTypeName = string.Empty;

            foreach (XPathNavigator optionElement in node.SelectChildren(XPathNodeType.Element))
            {
                if (optionElement.Name == "Enum")
                {
                    enumTypeName = optionElement.GetAttribute("type", "");
                    var enumType = TypeHandler.GetType(enumTypeName);
                    if (enumType == null)
                    {
                        throw new ContentRegistrationException("Enum");
                    }

                    var resClassName = optionElement.GetAttribute("resourceClass", "");
                    if (string.IsNullOrEmpty(resClassName))
                    {
                        resClassName = CtdResourceClassName;
                    }

                    var names  = Enum.GetNames(enumType);
                    var values = Enum.GetValues(enumType).Cast <int>().ToArray();
                    for (var i = 0; i < names.Length; i++)
                    {
                        var resKey = fieldSetting == null ? string.Empty : fieldSetting.GetResourceKey(names[i]);
                        var text   = string.IsNullOrEmpty(resKey) ? names[i] : SenseNetResourceManager.GetResourceKey(resClassName, resKey);
                        var c      = new ChoiceOption(values[i].ToString(), text);
                        options.Add(c);
                    }
                }
                else
                {
                    var text = optionElement.InnerXml;
                    var key  = optionElement.GetAttribute("value", "");

                    if (text.Length == 0 && key.Length == 0)
                    {
                        key = options.Count.ToString();
                    }
                    if (text.Length == 0)
                    {
                        text = key;
                    }
                    if (key.Length == 0)
                    {
                        key = text;
                    }

                    bool enabled;
                    if (!Boolean.TryParse(optionElement.GetAttribute("enabled", ""), out enabled))
                    {
                        enabled = true;
                    }

                    var selected = false;
                    Boolean.TryParse(optionElement.GetAttribute("selected", ""), out selected);

                    options.Add(new ChoiceOption(key, text, enabled, selected));
                }
            }
        }
Ejemplo n.º 17
0
        public override IEnumerable <IndexFieldInfo> GetIndexFieldInfos(SnCR.Field snField, out string textExtract)
        {
            string className, name;

            if (SenseNetResourceManager.Running && snField.LocalizationEnabled && snField.IsLocalized && SenseNetResourceManager.ParseResourceKey(snField.GetStoredValue(), out className, out name))
            {
                var strings = SenseNetResourceManager.Current.GetStrings(className, name);
                textExtract = string.Join(" ", strings);
                return(CreateFieldInfo(snField.Name, strings));
            }
            var data        = snField.GetData();
            var stringValue = data == null ? String.Empty : data.ToString().ToLower();

            textExtract = stringValue;

            return(CreateFieldInfo(snField.Name, stringValue));
        }
Ejemplo n.º 18
0
        public override IEnumerable <IndexFieldInfo> GetIndexFieldInfos(SnCR.Field snField, out string textExtract)
        {
            var data = snField.GetData() ?? string.Empty;

            var stringData = data as string;

            if (stringData != null)
            {
                textExtract = stringData.ToLower();
                return(CreateFieldInfo(snField.Name, textExtract));
            }

            var listData = data as IEnumerable <string>;

            if (listData != null)
            {
                // words to choice field
                var wordList = new List <string>();
                // words to sort field
                var sortList = new List <string>();
                // words to full text field
                var localizedWords = new List <string>();
                foreach (var inputWord in listData)
                {
                    // process every word
                    var cfs = snField.FieldSetting as SnCR.Fields.ChoiceFieldSetting;
                    if (cfs != null)
                    {
                        // field with ChoiceFieldSetting
                        var optionKey = cfs.Options.Where(x => x.Value == inputWord).Select(x => x.StoredText).FirstOrDefault();
                        if (optionKey != null)
                        {
                            // identified option
                            var optionTerm = "$" + inputWord.ToLower();
                            wordList.Add(optionTerm);
                            sortList.Add(optionTerm);
                            string className;
                            string name;
                            var    localized = SenseNetResourceManager.ParseResourceKey(optionKey, out className, out name);
                            if (localized && className != null && name != null)
                            {
                                // localized texts: add all known mutations
                                var lw = SenseNetResourceManager.Current.GetStrings(className, name);
                                localizedWords.AddRange(lw.Select(x => x.ToLower()));
                            }
                            else
                            {
                                // not localized: add the word
                                localizedWords.Add(optionKey.ToLower());
                            }
                        }
                        else
                        {
                            // unidentified option: extra value
                            if (inputWord.StartsWith(SnCR.Fields.ChoiceField.EXTRAVALUEPREFIX))
                            {
                                // drives ordering (additional '~' hides this information)
                                sortList.Add("~" + inputWord);
                                // add
                                var splitted = inputWord.Split('.');
                                wordList.Add(splitted[0]);
                                localizedWords.Add(splitted[1].ToLower());
                            }
                            else
                            {
                                // add as a lowercase word
                                wordList.Add(inputWord.ToLower());
                                localizedWords.Add(inputWord.ToLower());
                            }
                        }
                    }
                    else
                    {
                        // field with another field setting
                        wordList.Add(inputWord.ToLower());
                    }
                }
                sortList.Sort();
                var sortTerm = String.Join("-", sortList);
                textExtract = String.Join(" ", localizedWords);
                wordList.AddRange(localizedWords);
                return(CreateFieldInfo(snField.Name, wordList, sortTerm));
            }

            var enumerableData = data as System.Collections.IEnumerable;

            if (enumerableData != null)
            {
                var words = new List <string>();
                foreach (var item in enumerableData)
                {
                    words.Add(Convert.ToString(item, System.Globalization.CultureInfo.InvariantCulture).ToLower());
                }
                var wordArray = words.ToArray();
                textExtract = String.Join(" ", wordArray);
                return(CreateFieldInfo(snField.Name, words));
            }

            throw new NotSupportedException(String.Concat("Cannot create index from this type: ", data.GetType().FullName,
                                                          ". Indexable data can be string, IEnumerable<string> or IEnumerable."));
        }
Ejemplo n.º 19
0
        public void ContentQuery_ChoiceFieldLocalizedOptions()
        {
            ContentTypeInstaller.InstallContentType(@"<?xml version='1.0' encoding='utf-8'?>
				<ContentType name='ContentQuery_ChoiceField' parentType='GenericContent' handler='SenseNet.ContentRepository.GenericContent' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'>
					<Fields>
						<Field name='ChoiceTest' type='Choice'>
							<Configuration>
								<AllowExtraValue>true</AllowExtraValue>
								<AllowMultiple>true</AllowMultiple>
								<Options>
									<Option value='0'>$TestChoice,Text1</Option>
									<Option value='1'>$TestChoice,Text2</Option>
									<Option value='2'>$TestChoice,Text3</Option>
									<Option value='3'>Text4</Option>
								</Options>
							</Configuration>
						</Field>
					</Fields>
				</ContentType>"                );

            SaveResources("TestChoice", @"<?xml version=""1.0"" encoding=""utf-8""?>
                <Resources>
                  <ResourceClass name=""TestChoice"">
                    <Languages>
                      <Language cultureName=""en"">
                        <data name=""Text1"" xml:space=""preserve""><value>Text-1</value></data>
                        <data name=""Text2"" xml:space=""preserve""><value>Text-2</value></data>
                        <data name=""Text3"" xml:space=""preserve""><value>Text-3</value></data>
                      </Language>
                      <Language cultureName=""hu"">
                        <data name=""Text1"" xml:space=""preserve""><value>Szöveg-1</value></data>
                        <data name=""Text2"" xml:space=""preserve""><value>Szöveg-2</value></data>
                        <data name=""Text3"" xml:space=""preserve""><value>Szöveg-3</value></data>
                      </Language>
                    </Languages>
                  </ResourceClass>
                </Resources>");

            SenseNetResourceManager.Reset();

            //var x = SenseNetResourceManager.Current.GetString("$TestChoice,Text1");
            //var y = SenseNetResourceManager.Current.GetStrings("TestChoice", "Text1");

            Content content = Content.CreateNew("ContentQuery_ChoiceField", TestRoot, Guid.NewGuid().ToString());

            content.ContentHandler["ChoiceTest"] = "2;3;~other.other text";

            content.Save();

            Assert.IsTrue(ContentQuery.Query("'Szöveg-3' .AUTOFILTERS:OFF").Count > 0);
            Assert.IsTrue(ContentQuery.Query("'Text-3' .AUTOFILTERS:OFF").Count > 0);
            Assert.IsTrue(ContentQuery.Query("'Text4' .AUTOFILTERS:OFF").Count > 0);
            Assert.IsTrue(ContentQuery.Query("'other text' .AUTOFILTERS:OFF").Count > 0);

            Assert.IsTrue(ContentQuery.Query("ChoiceTest:$2 .AUTOFILTERS:OFF").Count > 0);
            Assert.IsTrue(ContentQuery.Query("ChoiceTest:$3 .AUTOFILTERS:OFF").Count > 0);
            Assert.IsTrue(ContentQuery.Query("ChoiceTest:@0 .AUTOFILTERS:OFF", null, "~other").Count > 0);
            Assert.IsTrue(ContentQuery.Query("+ChoiceTest:@0 +ChoiceTest:@1 .AUTOFILTERS:OFF", null, "~other", "other text").Count > 0);

            var x = ContentQuery.Query("ChoiceTest:@0 .AUTOFILTERS:OFF", null, "Text-3").Count;

            Assert.IsTrue(ContentQuery.Query("ChoiceTest:@0 .AUTOFILTERS:OFF", null, "Text-3").Count > 0);
            Assert.IsTrue(ContentQuery.Query("ChoiceTest:@0 .AUTOFILTERS:OFF", null, "Szöveg-3").Count > 0);
            Assert.IsTrue(ContentQuery.Query("ChoiceTest:@0 .AUTOFILTERS:OFF", null, "Text4").Count > 0);
            Assert.IsTrue(ContentQuery.Query("ChoiceTest:@0 .AUTOFILTERS:OFF", null, "other text").Count > 0);
        }