UpdateGenericLanguageString() 공개 메소드

public UpdateGenericLanguageString ( string key, string value, bool isCollectionValue ) : void
key string
value string
isCollectionValue bool
리턴 void
예제 #1
0
        /// <summary>
        /// Create or update the data div with all the data-book values in the document
        /// </summary>
        /// <param name="elementToReadFrom">This is either the whole document, or a page div that we just edited and want to read from.</param>
        private void UpdateVariablesAndDataDiv(XmlNode elementToReadFrom)
        {
            Debug.WriteLine("before update: " + _dataDiv.OuterXml);

            DataSet incomingData = SynchronizeDataItemsFromContentsOfElement(elementToReadFrom);

            incomingData.UpdateGenericLanguageString("contentLanguage1", _collectionSettings.Language1Iso639Code, false);
            incomingData.UpdateGenericLanguageString("contentLanguage2",
                                                     String.IsNullOrEmpty(MultilingualContentLanguage2)
                                                                                                 ? null
                                                                                                 : MultilingualContentLanguage2, false);
            incomingData.UpdateGenericLanguageString("contentLanguage3",
                                                     String.IsNullOrEmpty(MultilingualContentLanguage3)
                                                                                                 ? null
                                                                                                 : MultilingualContentLanguage3, false);

            //Debug.WriteLine("xyz: " + _dataDiv.OuterXml);
            foreach (var v in incomingData.TextVariables)
            {
                if (!v.Value.IsCollectionValue)
                {
                    UpdateSingleTextVariableThroughoutDOM(v.Key, v.Value.TextAlternatives);
                }
            }
            Debug.WriteLine("after update: " + _dataDiv.OuterXml);

            UpdateTitle();            //this may change our "bookTitle" variable if the title is based on a template that reads other variables (e.g. "Primer Term2-Week3")
        }
예제 #2
0
        private static DataSet GatherDataItemsFromCollectionSettings(CollectionSettings collectionSettings)
        {
            var data = new DataSet();

            data.WritingSystemAliases.Add("N1", collectionSettings.Language2Iso639Code);
            data.WritingSystemAliases.Add("N2", collectionSettings.Language3Iso639Code);

//            if (makeGeneric)
//            {
//                data.WritingSystemCodes.Add("V", collectionSettings.Language2Iso639Code);
//                    //This is not an error; we don't want to use the verncular when we're just previewing a book in a non-verncaulr collection
//                data.AddGenericLanguageString("iso639Code", collectionSettings.Language1Iso639Code, true);
//                    //review: maybe this should be, like 'xyz"
//                data.AddGenericLanguageString("nameOfLanguage", "(Your Language Name)", true);
//                data.AddGenericLanguageString("nameOfNationalLanguage1", "(Region Lang)", true);
//                data.AddGenericLanguageString("nameOfNationalLanguage2", "(National Lang)", true);
//                data.AddGenericLanguageString("country", "Your Country", true);
//                data.AddGenericLanguageString("province", "Your Province", true);
//                data.AddGenericLanguageString("district", "Your District", true);
//                data.AddGenericLanguageString("languageLocation", "(Language Location)", true);
//            }
//            else
            {
                data.WritingSystemAliases.Add("V", collectionSettings.Language1Iso639Code);
                data.AddLanguageString("nameOfLanguage", collectionSettings.Language1Name, "*", true);
                data.AddLanguageString("nameOfNationalLanguage1",
                                       collectionSettings.GetLanguage2Name(collectionSettings.Language2Iso639Code), "*", true);
                data.AddLanguageString("nameOfNationalLanguage2",
                                       collectionSettings.GetLanguage3Name(collectionSettings.Language2Iso639Code), "*", true);
                data.UpdateGenericLanguageString("iso639Code", collectionSettings.Language1Iso639Code, true);
                data.UpdateGenericLanguageString("country", collectionSettings.Country, true);
                data.UpdateGenericLanguageString("province", collectionSettings.Province, true);
                data.UpdateGenericLanguageString("district", collectionSettings.District, true);
                string location = "";
                if (!String.IsNullOrEmpty(collectionSettings.District))
                {
                    location += collectionSettings.District + @", ";
                }
                if (!String.IsNullOrEmpty(collectionSettings.Province))
                {
                    location += collectionSettings.Province + @", ";
                }

                if (!String.IsNullOrEmpty(collectionSettings.Country))
                {
                    location += collectionSettings.Country;
                }

                location = location.TrimEnd(new[] { ' ' }).TrimEnd(new[] { ',' });

                data.UpdateGenericLanguageString("languageLocation", location, true);
            }
            return(data);
        }
예제 #3
0
        /// <summary>
        /// Create or update the data div with all the data-book values in the document
        /// </summary>
        /// <param name="elementToReadFrom">This is either the whole document, or a page div that we just edited and want to read from.</param>
        private void UpdateVariablesAndDataDiv(XmlNode elementToReadFrom, BookInfo info = null)
        {
            Debug.WriteLine("before update: " + _dataDiv.OuterXml);

            var     itemsToDelete = new HashSet <Tuple <string, string> >();
            DataSet incomingData  = SynchronizeDataItemsFromContentsOfElement(elementToReadFrom, itemsToDelete);

            incomingData.UpdateGenericLanguageString("contentLanguage1", _collectionSettings.Language1Iso639Code, false);
            incomingData.UpdateGenericLanguageString("contentLanguage2",
                                                     String.IsNullOrEmpty(MultilingualContentLanguage2)
                                                                                                 ? null
                                                                                                 : MultilingualContentLanguage2, false);
            incomingData.UpdateGenericLanguageString("contentLanguage3",
                                                     String.IsNullOrEmpty(MultilingualContentLanguage3)
                                                                                                 ? null
                                                                                                 : MultilingualContentLanguage3, false);

            //Debug.WriteLine("xyz: " + _dataDiv.OuterXml);
            foreach (var v in incomingData.TextVariables)
            {
                if (!v.Value.IsCollectionValue)
                {
                    UpdateSingleTextVariableInDataDiv(v.Key, v.Value.TextAlternatives);
                }
            }
            foreach (var tuple in itemsToDelete)
            {
                UpdateSingleTextVariableInDataDiv(tuple.Item1, tuple.Item2, "");
            }
            Debug.WriteLine("after update: " + _dataDiv.OuterXml);

            UpdateTitle(info);            //this may change our "bookTitle" variable if the title is based on a template that reads other variables (e.g. "Primer Term2-Week3")
            UpdateIsbn(info);
            UpdateTags(info);
            UpdateCredits(info);
        }
예제 #4
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);
        }
예제 #5
0
        private static DataSet GatherDataItemsFromCollectionSettings(CollectionSettings collectionSettings)
        {
            var data = new DataSet();

            data.WritingSystemAliases.Add("N1", collectionSettings.Language2Iso639Code);
            data.WritingSystemAliases.Add("N2", collectionSettings.Language3Iso639Code);

            //            if (makeGeneric)
            //            {
            //                data.WritingSystemCodes.Add("V", collectionSettings.Language2Iso639Code);
            //                    //This is not an error; we don't want to use the verncular when we're just previewing a book in a non-verncaulr collection
            //                data.AddGenericLanguageString("iso639Code", collectionSettings.Language1Iso639Code, true);
            //                    //review: maybe this should be, like 'xyz"
            //                data.AddGenericLanguageString("nameOfLanguage", "(Your Language Name)", true);
            //                data.AddGenericLanguageString("nameOfNationalLanguage1", "(Region Lang)", true);
            //                data.AddGenericLanguageString("nameOfNationalLanguage2", "(National Lang)", true);
            //                data.AddGenericLanguageString("country", "Your Country", true);
            //                data.AddGenericLanguageString("province", "Your Province", true);
            //                data.AddGenericLanguageString("district", "Your District", true);
            //                data.AddGenericLanguageString("languageLocation", "(Language Location)", true);
            //            }
            //            else
            {
                data.WritingSystemAliases.Add("V", collectionSettings.Language1Iso639Code);
                data.AddLanguageString("nameOfLanguage", collectionSettings.Language1Name, "*", true);
                data.AddLanguageString("nameOfNationalLanguage1",
                                       collectionSettings.GetLanguage2Name(collectionSettings.Language2Iso639Code), "*", true);
                data.AddLanguageString("nameOfNationalLanguage2",
                                       collectionSettings.GetLanguage3Name(collectionSettings.Language2Iso639Code), "*", true);
                data.UpdateGenericLanguageString("iso639Code", collectionSettings.Language1Iso639Code, true);
                data.UpdateGenericLanguageString("country", collectionSettings.Country, true);
                data.UpdateGenericLanguageString("province", collectionSettings.Province, true);
                data.UpdateGenericLanguageString("district", collectionSettings.District, true);
                string location = "";
                if (!String.IsNullOrEmpty(collectionSettings.District))
                    location += collectionSettings.District + @", ";
                if (!String.IsNullOrEmpty(collectionSettings.Province))
                    location += collectionSettings.Province;

                location = location.TrimEnd(new[] {' '}).TrimEnd(new[] {','});

                if (!String.IsNullOrEmpty(collectionSettings.Country))
                {
                    location += "<br/>" + collectionSettings.Country;
                }

                data.UpdateGenericLanguageString("languageLocation", location, true);
            }
            return data;
        }
예제 #6
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);
        }
예제 #7
0
 public void Set(string key, string value, bool isCollectionValue)
 {
     _dataset.UpdateGenericLanguageString(key, value, isCollectionValue);
     UpdateSingleTextVariableInDataDiv(key, _dataset.TextVariables[key].TextAlternatives);
 }