UpdateLanguageString() public method

public UpdateLanguageString ( string key, string value, string writingSystemId, bool isCollectionValue ) : void
key string
value string
writingSystemId string
isCollectionValue bool
return void
Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <remarks>I (jh) found this labelled UpdateSingleTextVariableThrougoutDom but it actually only updated the datadiv, so I changed the name.</remarks>
        /// <param name="key"></param>
        /// <param name="writingSystemId"></param>
        /// <param name="form"></param>
        private void UpdateSingleTextVariableInDataDiv(string key, string writingSystemId, string form)
        {
            XmlNode node =
                _dataDiv.SelectSingleNode(String.Format("div[@data-book='{0}' and @lang='{1}']", key,
                                                        writingSystemId));

            _dataset.UpdateLanguageString(key, form, writingSystemId, false);

            if (null == node)
            {
                if (!string.IsNullOrEmpty(form))
                {
                    Debug.WriteLine("creating in datadiv: {0}[{1}]={2}", key, writingSystemId, form);
                    Debug.WriteLine("nop: " + _dataDiv.OuterXml);
                    AddDataDivBookVariable(key, writingSystemId, form);
                }
            }
            else
            {
                if (string.IsNullOrEmpty(form))                 //a null value removes the entry entirely
                {
                    node.ParentNode.RemoveChild(node);
                }
                else
                {
                    node.InnerXml = form;
                }
                //Debug.WriteLine("updating in datadiv: {0}[{1}]={2}", key, languageForm.WritingSystemId,
                //				languageForm.Form);
                //Debug.WriteLine("now: " + _dataDiv.OuterXml);
            }
        }
Esempio n. 2
0
        private void UpdateSingleTextVariableThroughoutDOM(string key, MultiTextBase multiText)
        {
            //Debug.WriteLine("before: " + dataDiv.OuterXml);

            if (multiText.Count == 0)
            {
                RemoveDataDivElementIfEmptyValue(key, null);
            }
            foreach (LanguageForm languageForm in multiText.Forms)
            {
                XmlNode node =
                    _dataDiv.SelectSingleNode(String.Format("div[@data-book='{0}' and @lang='{1}']", key,
                                                            languageForm.WritingSystemId));

                _dataset.UpdateLanguageString(key, languageForm.Form, languageForm.WritingSystemId, false);

                if (null == node)
                {
                    if (!string.IsNullOrEmpty(languageForm.Form))
                    {
                        Debug.WriteLine("creating in datadiv: {0}[{1}]={2}", key, languageForm.WritingSystemId,
                                        languageForm.Form);
                        Debug.WriteLine("nop: " + _dataDiv.OuterXml);
                        AddDataDivBookVariable(key, languageForm.WritingSystemId, languageForm.Form);
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(languageForm.Form))                     //a null value removes the entry entirely
                    {
                        node.ParentNode.RemoveChild(node);
                    }
                    else
                    {
                        node.InnerXml = languageForm.Form;
                    }
                    //Debug.WriteLine("updating in datadiv: {0}[{1}]={2}", key, languageForm.WritingSystemId,
                    //				languageForm.Form);
                    //Debug.WriteLine("now: " + _dataDiv.OuterXml);
                }
            }
        }
Esempio n. 3
0
        public void SetLicenseMetdata(Metadata metadata)
        {
            var data          = new DataSet();
            var itemsToDelete = new HashSet <Tuple <string, string> >();

            GatherDataItemsFromXElement(data, _dom.RawDom, itemsToDelete);

            string copyright = WebUtility.HtmlEncode(metadata.CopyrightNotice);

            data.UpdateLanguageString("copyright", copyright, "*", false);

            string description = metadata.License.GetDescription("en");

            data.UpdateLanguageString("licenseDescription", description, "en", false);

            string licenseUrl = metadata.License.Url;

            data.UpdateLanguageString("licenseUrl", licenseUrl, "*", false);

            string licenseNotes = metadata.License.RightsStatement;

            data.UpdateLanguageString("licenseNotes", WebUtility.HtmlEncode(licenseNotes), "*", false);

            string licenseImageName = metadata.License.GetImage() == null ? "" : "license.png";

            data.UpdateGenericLanguageString("licenseImage", licenseImageName, false);


            UpdateDomFromDataSet(data, "*", _dom.RawDom, itemsToDelete);

            //UpdateDomFromDataSet() is not able to remove items yet, so we do it explicity

            RemoveDataDivElementIfEmptyValue("licenseDescription", description);
            RemoveDataDivElementIfEmptyValue("licenseImage", licenseImageName);
            RemoveDataDivElementIfEmptyValue("licenseUrl", licenseUrl);
            RemoveDataDivElementIfEmptyValue("copyright", copyright);
            RemoveDataDivElementIfEmptyValue("licenseNotes", licenseNotes);
        }
Esempio n. 4
0
        public void SetLicenseMetdata(Metadata metadata)
        {
            var data = new DataSet();
            GatherDataItemsFromXElement(data,  _dom.RawDom);

            string copyright = metadata.CopyrightNotice;
            data.UpdateLanguageString("copyright", copyright, "*", false);

            string description = metadata.License.GetDescription("en");
            data.UpdateLanguageString("licenseDescription", description, "en", false);

            string licenseUrl = metadata.License.Url;
            data.UpdateLanguageString("licenseUrl", licenseUrl, "*", false);

            string licenseNotes = metadata.License.RightsStatement;
            data.UpdateLanguageString("licenseNotes", licenseNotes, "*", false);

            string licenseImageName = metadata.License.GetImage() == null ? "" : "license.png";
            data.UpdateGenericLanguageString("licenseImage", licenseImageName, false);

            UpdateDomFromDataSet(data, "*", _dom.RawDom);

            //UpdateDomFromDataSet() is not able to remove items yet, so we do it explicity

            RemoveDataDivElementIfEmptyValue("licenseDescription", description);
            RemoveDataDivElementIfEmptyValue("licenseImage", licenseImageName);
            RemoveDataDivElementIfEmptyValue("licenseUrl", licenseUrl);
            RemoveDataDivElementIfEmptyValue("copyright", copyright);
            RemoveDataDivElementIfEmptyValue("licenseNotes", licenseNotes);
        }