Changeset 1856
- Timestamp:
- 2001-01-23T10:58:19+13:00 (23 years ago)
- Location:
- trunk/gsdl
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/etc/main.cfg
r1811 r1856 28 28 # Set logcgiargs to true to keep a log of usage information in 29 29 # $GSDLHOME/etc/usage.txt. 30 logcgiargs false30 logcgiargs true 31 31 32 32 # Set usecookies to true to use cookies to identify users (cookie 33 33 # information will be written to the usage log if logcgiargs is 34 34 # true). 35 usecookies false35 usecookies true 36 36 37 37 # LogDateFormat sets the format that timestamps will be stored in the usage … … 75 75 port.dm home.dm collect.dm 76 76 77 78 # Define the interface languages and encodings supported by this receptionist 79 80 # An "Encoding" line defines an encoding to be used by the receptionist 81 # options are: 82 # shortname -- Identifier for the given encoding. The shortname option is 83 # mandatory and must be unique for each "Encoding" line. 84 # longname -- The display name of the given encoding. If longname isn't set 85 # it will default to using shortname instead. 86 87 # type -- The type of encoding. Note that for most encodings this 88 # value is the directory name under which the map file for 89 # this encoding resides in the Greenstone unicode/MAPPINGS 90 # directory (e.g. 'WINDOWS', 'ISO_8859' etc.). It may also 91 # take the values 'GB' and 'UTF8'. 92 # mapfile -- The name of the map file for use when converting between 93 # utf8 and the given encoding. The mapfile option is mandatory 94 # for all encoding types with the exception of GB and UTF8. 95 # label -- The standard label to which you must set the value of 96 # "charset" within http headers or html meta tags to get a web 97 # browser to use the given encoding. The label option is 98 # mandatory. 99 Encoding shortname=utf8 "longname=Unicode (UTF-8)" type=UTF8 label=UTF-8 100 Encoding shortname=iso1 "longname=Western (ISO-8859-1)" type=ISO_8859 mapfile=1.TXT label=ISO-8859-1 101 Encoding shortname=w1251 "longname=Cyrillic (Windows-1251)" type=WINDOWS mapfile=1251.TXT label=windows-1251 102 Encoding shortname=w1256 "longname=Arabic (Windows-1256)" type=WINDOWS mapfile=1256.TXT label=windows-1256 103 Encoding shortname=gb "longname=Simplified Chinese (GBK)" type=GB label=GBK 104 Encoding shortname=koi8r "longname=Cyrillic (KOI8-R)" type=CYRILLIC mapfile=koi8_r.txt label=koi8-r 105 106 107 # A "Language" line defines an interface language to be used by the 108 # interface. Note that it is possible to display only a subset of the 109 # specified languages on the preferences page for a given collection by 110 # using the "PreferenceLanguages" format option in your collect.cfg 111 # configuration file. 112 # options are: 113 # shortname -- ISO 639 two letter language symbol. The shortname 114 option is mandatory. 115 # longname -- The display name for the given language. If longname 116 isn't set it will default to using shortname instead. 117 # default_encoding -- The encoding to use by default when using the given 118 # interface language. This should be set to the 119 # "shortname" of a valid "Encoding" line 120 Language shortname=en longname=English default_encoding=iso1 121 Language shortname=fr longname=French default_encoding=iso1 122 Language shortname=zh longname=Chinese default_encoding=gb 123 Language shortname=de longname=German default_encoding=iso1 124 Language shortname=es longname=Spanish default_encoding=iso1 125 Language shortname=mi longname=Maori default_encoding=iso1 126 Language shortname=ar longname=Arabic default_encoding=w1256 127 Language shortname=pt longname=Portuguese default_encoding=iso1 128 Language shortname=nl longname=Dutch default_encoding=iso1 129 130 77 131 # Define any additional page parameters to be used by the above macro files 78 132 # (the current default page parameters are c (collection) and l (language) … … 113 167 # set a default value for the built-in "p" cgi argument 114 168 cgiarg shortname=p argdefault=home 169 -
trunk/gsdl/macros/english.dm
r1806 r1856 627 627 _textdigitlib_ {the digital library} 628 628 _textweb_ {the web} 629 _textlangeng_ {English}630 _textlanggerman_ {German}631 _textlangfrench_ {French}632 _textlangspanish_ {Spanish}633 _textlangmaori_ {M_amn_ori}634 _textlangchinese_ {Chinese}635 _textlangarabic_ {Arabic}636 _textlangportuguese_ {Portuguese}637 _textlangdutch_ {Dutch}638 629 _textgraphical_ {Graphical} 639 630 _texttextual_ {Textual} -
trunk/gsdl/macros/pref.dm
r1838 r1856 200 200 function updatel () \{ 201 201 value = document.PrefForm.l.options[document.PrefForm.l.selectedIndex].value; 202 location.href = location.href + "& l=" + value + getargs();202 location.href = location.href + "&nl=1&l=" + value + getargs(); 203 203 \} 204 204 … … 210 210 function updatew () \{ 211 211 value = document.PrefForm.w.options[document.PrefForm.w.selectedIndex].value; 212 location.href = location.href + "&n w=" + value + getargs();212 location.href = location.href + "&nl=0&nw=" + value + getargs(); 213 213 \} 214 214 } … … 330 330 } 331 331 332 # set from within pageaction 332 333 _languageoption_ {} 333 334 _enlanguageoption_ {<option value="en"_If_("_cgiargl_",, selected)_If_("_cgiargl_" eq "en", selected)>_textlangeng_} 335 _delanguageoption_ {<option value="de"_If_("_cgiargl_" eq "de", selected)>_textlanggerman_} 336 _frlanguageoption_ {<option value="fr"_If_("_cgiargl_" eq "fr", selected)>_textlangfrench_} 337 _eslanguageoption_ {<option value="es"_If_("_cgiargl_" eq "es", selected)>_textlangspanish_} 338 _milanguageoption_ {<option value="mi"_If_("_cgiargl_" eq "mi", selected)>_textlangmaori_} 339 _zhlanguageoption_ {<option value="zh"_If_("_cgiargl_" eq "zh", selected)>_textlangchinese_} 340 _arlanguageoption_ {<option value="ar"_If_("_cgiargl_" eq "ar", selected)>_textlangarabic_} 341 _ptlanguageoption_ {<option value="pt"_If_("_cgiargl_" eq "pt", selected)>_textlangportuguese_} 342 _nllanguageoption_ {<option value="nl"_If_("_cgiargl_" eq "nl", selected)>_textlangdutch_} 343 344 _encodingoption_ { 345 _textencoding_ 346 <select name="w" onChange="updatew();"> 347 <option value="w" _If_("_cgiargw_" eq "w",selected)>Western (ISO-8859-1) 348 <option value="u" _If_("_cgiargw_" eq "u",selected)>UTF-8 349 <option value="g" _If_("_cgiargw_" eq "g",selected)>GBK 350 <option value="a" _If_("_cgiargw_" eq "a",selected)>Arabic (windows 1256) 351 <option value="c" _If_("_cgiargw_" eq "c",selected)>Cyrillic (windows 1251) 352 </select> 353 } 334 _encodingoption_ {} 354 335 355 336 _formatoption_ { … … 365 346 _navigationbar_ 366 347 </center> 348 367 349 <blockquote> 368 350 … … 409 391 410 392 <p> 411 _ languageoption_412 413 <p> 414 _ encodingoption_393 _If_(_languageoption_,_textlanguage__languageoption_) 394 395 <p> 396 _If_(_encodingoption_,_textencoding__encodingoption_) 415 397 416 398 <p> -
trunk/gsdl/src/recpt/librarymain.cpp
r1838 r1856 111 111 #endif 112 112 113 // Read main.cfg to get all the "Encoding" lines and add corresponding converters. 114 // It might be possible to move this to somewhere like receptionist::configure, depending 115 // on whether we need the converters before then (I don't think we do). 116 text_tarray cfgline; 117 text_t maincfg = filename_cat (gsdlhome, "etc", "main.cfg"); 118 if (file_exists (maincfg)) { 119 char *maincfgc = maincfg.getcstr(); 120 #ifdef GSDL_USE_IOS_H 121 ifstream confin (maincfgc, ios::in | ios::nocreate); 122 #else 123 ifstream confin (maincfgc, ios::in); 124 #endif 125 delete maincfgc; 126 127 if (confin) { 128 text_t subkey, subvalue, shortname; 129 text_tset saved; 130 text_tmap tmp; 131 text_t::const_iterator cfglinesub_here; 132 text_tarray::const_iterator cfgline_here; 133 text_tarray::const_iterator cfgline_end; 134 while (read_cfg_line(confin, cfgline) >= 0) { 135 if (cfgline.size () >= 4 && cfgline[0] == "Encoding") { 136 tmp.erase(tmp.begin(), tmp.end()); 137 cfgline_here = cfgline.begin(); 138 cfgline_end = cfgline.end(); 139 while (cfgline_here != cfgline_end) { 140 cfglinesub_here = getdelimitstr((*cfgline_here).begin(), 141 (*cfgline_here).end(), '=', subkey); 142 if (subkey == "shortname") { 143 shortname = substr (cfglinesub_here, (*cfgline_here).end()); 144 } else { 145 tmp[subkey] = substr (cfglinesub_here, (*cfgline_here).end()); 146 } 147 cfgline_here++; 148 } 149 // we just use the saved set to prevent multiple encodings being added 150 // that use the same shortname (i.e. any encodings after the first with 151 // the same name will be ignored). 152 if (!shortname.empty() && saved.find(shortname) == saved.end()) { 153 saved.insert(shortname); 154 155 if (tmp["type"] == "UTF8") { 156 utf8inconvertclass *utf8inconvert = new utf8inconvertclass(); 157 utf8outconvertclass *utf8outconvert = new utf8outconvertclass(); 158 recpt.add_converter (shortname, utf8inconvert, utf8outconvert); 159 160 } else if (tmp["type"] == "GB") { 161 mapinconvertclass *gbinconvert = new mapinconvertclass(); 162 gbinconvert->setmapfile (gsdlhome, "gbku", 0x25a1); 163 mapoutconvertclass *gboutconvert = new mapoutconvertclass(); 164 gboutconvert->setmapfile (gsdlhome, "ugbk", 0xa1f5); 165 recpt.add_converter (shortname, gbinconvert, gboutconvert); 166 167 } else { 168 if (!tmp["mapfile"].empty()) { 169 170 if (tmp["type"] == "ISO_8859" && tmp["mapfile"] == "1.TXT") { 171 // iso-8859-1 is a special case as it'll always be 172 // supported by the standard converter class and 173 // therefore doesn't need to use its mapping file 174 inconvertclass *inconvert = new inconvertclass(); 175 rzwsoutconvertclass *outconvert = new rzwsoutconvertclass(); 176 recpt.add_converter (shortname, inconvert, outconvert); 177 178 } else { 179 text_t mapfile = filename_cat (gsdlhome, "unicode", "MAPPINGS", tmp["type"], tmp["mapfile"]); 180 if (file_exists (mapfile)) { 181 simplemapinconvertclass *inconvert = new simplemapinconvertclass(); 182 inconvert->setmapfile (mapfile); 183 simplemapoutconvertclass *outconvert = new simplemapoutconvertclass(); 184 outconvert->setmapfile (mapfile); 185 recpt.add_converter (shortname, inconvert, outconvert); 186 } 187 } 188 } 189 } 190 } 191 } 192 } 193 confin.close (); 194 } 195 } 196 197 113 198 // add other converters 114 utf8inconvertclass utf8inconvert;115 utf8outconvertclass utf8outconvert;116 recpt.add_converter ("u", &utf8inconvert, &utf8outconvert);117 118 mapinconvertclass gbinconvert;119 gbinconvert.setmapfile (gsdlhome, "gbku", 0x25a1);120 mapoutconvertclass gboutconvert;121 gboutconvert.setmapfile (gsdlhome, "ugbk", 0xa1f5);122 recpt.add_converter ("g", &gbinconvert, &gboutconvert);199 // utf8inconvertclass utf8inconvert; 200 // utf8outconvertclass utf8outconvert; 201 // recpt.add_converter ("u", &utf8inconvert, &utf8outconvert); 202 203 // mapinconvertclass gbinconvert; 204 // gbinconvert.setmapfile (gsdlhome, "gbku", 0x25a1); 205 // mapoutconvertclass gboutconvert; 206 // gboutconvert.setmapfile (gsdlhome, "ugbk", 0xa1f5); 207 // recpt.add_converter ("g", &gbinconvert, &gboutconvert); 123 208 124 209 // arabic 125 text_t mapfile = filename_cat (gsdlhome, "unicode", "MAPPINGS");126 mapfile = filename_cat (mapfile, "WINDOWS", "1256.TXT");127 simplemapinconvertclass arinconvert;128 arinconvert.setmapfile (mapfile);129 simplemapoutconvertclass aroutconvert;130 aroutconvert.setmapfile (mapfile);131 recpt.add_converter ("a", &arinconvert, &aroutconvert);210 // text_t mapfile = filename_cat (gsdlhome, "unicode", "MAPPINGS"); 211 // mapfile = filename_cat (mapfile, "WINDOWS", "1256.TXT"); 212 // simplemapinconvertclass arinconvert; 213 // arinconvert.setmapfile (mapfile); 214 // simplemapoutconvertclass aroutconvert; 215 // aroutconvert.setmapfile (mapfile); 216 // recpt.add_converter ("a", &arinconvert, &aroutconvert); 132 217 133 218 // cyrillic 134 mapfile = filename_cat (gsdlhome, "unicode", "MAPPINGS");135 mapfile = filename_cat (mapfile, "WINDOWS", "1251.TXT");136 simplemapinconvertclass cyinconvert;137 cyinconvert.setmapfile (mapfile);138 simplemapoutconvertclass cyoutconvert;139 cyoutconvert.setmapfile (mapfile);140 recpt.add_converter ("c", &cyinconvert, &cyoutconvert);219 // mapfile = filename_cat (gsdlhome, "unicode", "MAPPINGS"); 220 // mapfile = filename_cat (mapfile, "WINDOWS", "1251.TXT"); 221 // simplemapinconvertclass cyinconvert; 222 // cyinconvert.setmapfile (mapfile); 223 // simplemapoutconvertclass cyoutconvert; 224 // cyoutconvert.setmapfile (mapfile); 225 // recpt.add_converter ("c", &cyinconvert, &cyoutconvert); 141 226 142 227 // hindi -
trunk/gsdl/src/recpt/pageaction.cpp
r1759 r1856 187 187 // _languageoption_ interface languages to select from (dependant on PreferenceLanguages) 188 188 189 // _encodingoption_ will be overridden to "" if chinese language interface isn't specified189 // _encodingoption_ encodings to select from 190 190 191 191 // if page is "about" … … 283 283 284 284 // _languageoption_ 285 // this is kind of a hack (another one!!). note that there're potential 286 // problems here as no checking is done anywhere to make sure language 287 // is set to a valid value. this does allow us to set which languages 288 // should go in the preference selection box (from collect.cfg) however 289 // and that's sufficient for current requirements 290 291 // currently supported languages (_languageoption_ will default to all 292 // these languages unless PreferenceLanguages is set 293 text_tarray languages; 294 languages.push_back ("en"); 295 languages.push_back ("fr"); 296 languages.push_back ("de"); 297 languages.push_back ("es"); 298 languages.push_back ("mi"); 299 languages.push_back ("zh"); 300 languages.push_back ("ar"); 301 languages.push_back ("pt"); 302 languages.push_back ("nl"); 303 text_tarray::const_iterator this_lang = languages.begin(); 304 text_tarray::const_iterator end_lang = languages.end(); 305 306 text_t languageoption = "_textlanguage_\n<select name=\"l\" onChange=\"updatel();\">\n"; 285 // Create the "interface language" selection box for the preferences page. 286 // You can use something like "format PreferenceLanguages en|fr|zn" from within 287 // a collect.cfg file to use only a subset of the available languages for 288 // any given collection. This facility is kind of ugly though and should be 289 // replaced by something better when the configuration files are tidied up (as 290 // should all the other "format Preference..." options). 291 292 text_t &arg_l = args["l"]; 293 const recptconf &configinfo = recpt->get_configinfo(); 294 // put languages in another map to sort them by longname 295 text_tmap languages; 296 languageinfo_tmap::const_iterator thislang = configinfo.languages.begin(); 297 languageinfo_tmap::const_iterator endlang = configinfo.languages.end(); 298 while (thislang != endlang) { 299 languages[(*thislang).second.longname] = (*thislang).first; 300 thislang++; 301 } 302 text_tmap::iterator tlang = languages.begin(); 303 text_tmap::iterator elang = languages.end(); 304 305 text_t languageoption; 307 306 it = cinfo->format.find ("PreferenceLanguages"); 308 307 if ((it != cinfo->format.end()) && (!(*it).second.empty())) { … … 310 309 splitchar ((*it).second.begin(), (*it).second.end(), '|', pref_langs); 311 310 if (pref_langs.size() > 1) { 312 while (this_lang != end_lang) { 313 if (pref_langs.find(*this_lang) != pref_langs.end()) 314 languageoption += "_" + *this_lang + "languageoption_\n"; 315 this_lang ++; 311 while (tlang != elang) { 312 if (pref_langs.find((*tlang).second) != pref_langs.end()) { 313 languageoption += "<option value=\"" + (*tlang).second + "\""; 314 if ((*tlang).second == arg_l) languageoption += " selected"; 315 languageoption += ">" + (*tlang).first + "\n"; 316 } 317 tlang ++; 316 318 } 317 languageoption += "</select>\n"; 318 disp.setmacro ("languageoption", "preferences", languageoption); 319 } 320 321 // _encodingoption_ 322 323 if (pref_langs.find("zh") == pref_langs.end()) 324 disp.setmacro ("encodingoption", "preferences", ""); 319 } 325 320 326 321 } else { 327 while (this_lang != end_lang) { 328 languageoption += "_" + *this_lang + "languageoption_\n"; 329 this_lang ++; 330 } 322 while (tlang != elang) { 323 languageoption += "<option value=\"" + (*tlang).second + "\""; 324 if ((*tlang).second == arg_l) languageoption += " selected"; 325 languageoption += ">" + (*tlang).first + "\n"; 326 tlang ++; 327 } 328 } 329 if (!languageoption.empty()) { 330 languageoption = "<select name=\"l\" onChange=\"updatel();\">\n" + languageoption; 331 331 languageoption += "</select>\n"; 332 332 disp.setmacro ("languageoption", "preferences", languageoption); 333 } 334 335 // _encodingoption_ 336 // create the "encoding" selection box for the preferences page 337 text_t &arg_w = args["w"]; 338 // put encodings in another map to sort them by longname 339 text_tmap encodings; 340 encodinginfo_tmap::const_iterator thisenc = configinfo.encodings.begin(); 341 encodinginfo_tmap::const_iterator endenc = configinfo.encodings.end(); 342 while (thisenc != endenc) { 343 encodings[(*thisenc).second.longname] = (*thisenc).first; 344 thisenc++; 345 } 346 text_tmap::iterator tenc = encodings.begin(); 347 text_tmap::iterator eenc = encodings.end(); 348 349 text_t encodingoption; 350 while (tenc != eenc) { 351 encodingoption += "<option value=\"" + (*tenc).second + "\""; 352 if ((*tenc).second == arg_w) encodingoption += " selected"; 353 encodingoption += ">" + (*tenc).first + "\n"; 354 tenc ++; 355 } 356 357 if (!encodingoption.empty()) { 358 encodingoption = "<select name=\"w\" onChange=\"updatew();\">\n" + encodingoption; 359 encodingoption += "</select>\n"; 360 disp.setmacro ("encodingoption", "preferences", encodingoption); 333 361 } 334 362 -
trunk/gsdl/src/recpt/receptionist.cpp
r1838 r1856 65 65 EmailUserEvents = false; 66 66 67 languages.erase(languages.begin(), languages.end()); 68 encodings.erase(encodings.begin(), encodings.end()); 69 67 70 // these default page parameters can always be overriden 68 71 // in the configuration file … … 84 87 info_loaded = false; 85 88 info.clear(); 89 } 90 91 void languageinfo_t::clear () { 92 longname.clear(); 93 defaultencoding.clear(); 94 } 95 96 void encodinginfo_t::clear () { 97 longname.clear(); 98 label.clear(); 86 99 } 87 100 … … 112 125 ainfo.longname = "encoding"; 113 126 ainfo.multiplechar = true; 114 ainfo.defaultstatus = cgiarginfo:: weak;115 ainfo.argdefault = " w";127 ainfo.defaultstatus = cgiarginfo::none; 128 ainfo.argdefault = ""; 116 129 ainfo.savedarginfo = cgiarginfo::must; 117 130 argsinfo.addarginfo (NULL, ainfo); … … 142 155 ainfo.savedarginfo = cgiarginfo::must; 143 156 argsinfo.addarginfo (NULL, ainfo); 144 157 158 ainfo.shortname = "nl"; 159 ainfo.longname = "new language"; 160 ainfo.multiplechar = false; 161 ainfo.defaultstatus = cgiarginfo::none; 162 ainfo.argdefault = "0"; 163 ainfo.savedarginfo = cgiarginfo::mustnot; 164 argsinfo.addarginfo (NULL, ainfo); 165 145 166 // the GSDL_UID (cookie) 146 167 ainfo.shortname = "z"; … … 293 314 cfgline_here++; 294 315 } 316 } 317 318 } else if (key == "Encoding") { 319 text_t subkey, subvalue; 320 text_t shortname, longname, label; 321 text_t::const_iterator cfglinesub_here; 322 text_tarray::const_iterator cfgline_here = cfgline.begin(); 323 text_tarray::const_iterator cfgline_end = cfgline.end(); 324 while (cfgline_here != cfgline_end) { 325 cfglinesub_here = getdelimitstr((*cfgline_here).begin(), 326 (*cfgline_here).end(), '=', subkey); 327 if (subkey == "shortname") { 328 shortname = substr (cfglinesub_here, (*cfgline_here).end()); 329 } else if (subkey == "longname") { 330 longname = substr (cfglinesub_here, (*cfgline_here).end()); 331 } else if (subkey == "label") { 332 label = substr (cfglinesub_here, (*cfgline_here).end()); 333 } 334 cfgline_here++; 335 } 336 if (!shortname.empty() && !label.empty()) { 337 encodinginfo_t enc; 338 if (longname.empty()) enc.longname = shortname; 339 else enc.longname = longname; 340 enc.label = label; 341 configinfo.encodings[shortname] = enc; 342 } 343 344 } else if (key == "Language") { 345 text_t subkey, subvalue; 346 text_t shortname, longname, defaultencoding; 347 text_t::const_iterator cfglinesub_here; 348 text_tarray::const_iterator cfgline_here = cfgline.begin(); 349 text_tarray::const_iterator cfgline_end = cfgline.end(); 350 while (cfgline_here != cfgline_end) { 351 cfglinesub_here = getdelimitstr((*cfgline_here).begin(), 352 (*cfgline_here).end(), '=', subkey); 353 if (subkey == "shortname") { 354 shortname = substr (cfglinesub_here, (*cfgline_here).end()); 355 } else if (subkey == "longname") { 356 longname = substr (cfglinesub_here, (*cfgline_here).end()); 357 } else if (subkey == "default_encoding") { 358 defaultencoding = substr (cfglinesub_here, (*cfgline_here).end()); 359 } 360 cfgline_here++; 361 } 362 if (!shortname.empty()) { 363 languageinfo_t lang; 364 if (longname.empty()) lang.longname = shortname; 365 else lang.longname = longname; 366 lang.defaultencoding = defaultencoding; 367 configinfo.languages[shortname] = lang; 295 368 } 296 369 } … … 400 473 convertinfoclass::iterator converthere = converters.begin (); 401 474 convertinfoclass::iterator convertend = converters.end (); 402 text_t defaultconvertname;403 475 while (converthere != convertend) { 404 476 assert ((*converthere).second.outconverter != NULL); 405 477 if ((*converthere).second.outconverter != NULL) { 406 478 (*converthere).second.outconverter->set_rzws(1); 407 if (defaultconvertname.empty())408 defaultconvertname = (*converthere).second.name;409 479 } 410 480 converthere++; 411 }412 413 // set default converter if no good one has been defined414 if (!defaultconvertname.empty()) {415 cgiarginfo *ainfo = argsinfo.getarginfo ("w");416 if (ainfo->argdefault != "w") {417 if ((ainfo != NULL) && (converters.get_outconverter(ainfo->argdefault) == NULL)) {418 ainfo->defaultstatus = cgiarginfo::good;419 ainfo->argdefault = defaultconvertname;420 }421 }422 481 } 423 482 … … 470 529 } 471 530 531 // get the default encoding for the given language - if it fails for any 532 // reason return "" 533 text_t receptionist::get_default_encoding (const text_t &language) { 534 535 // make sure language is valid 536 if (configinfo.languages.find(language) == configinfo.languages.end()) return ""; 537 538 text_t default_encoding = configinfo.languages[language].defaultencoding; 539 540 // make sure the encoding is valid 541 if (configinfo.encodings.find(default_encoding) == configinfo.encodings.end()) return ""; 542 543 return default_encoding; 544 } 472 545 473 546 // parse_cgi_args parses cgi arguments into an argument class. … … 476 549 bool receptionist::parse_cgi_args (const text_t &argstr, cgiargsclass &args, 477 550 ostream &logout, text_tmap &fcgienv) { 478 outconvertclass text_t2ascii;479 551 480 552 // get an initial list of cgi arguments … … 491 563 if (configinfo.usecookies) get_cookie(args["z"], fcgienv); 492 564 565 // if we're changing languages, set the encoding to the default for the new language 566 if (args["nl"] == "1") { 567 args["nw"] = get_default_encoding(args["l"]); 568 } 569 493 570 // get the input encoding 571 // if encoding isn't set, set it to the default for the current language 572 if ((args.getarg("w") == NULL) || args["w"].empty()) { 573 args["w"] = get_default_encoding(args["l"]); 574 } 575 494 576 text_t &arg_w = args["w"]; 577 495 578 inconvertclass defaultinconvert; 496 579 inconvertclass *inconvert = converters.get_inconverter (arg_w); … … 520 603 } else { 521 604 // the action was not found!! 605 outconvertclass text_t2ascii; 522 606 logout << text_t2ascii << "Error: the action \"" << args["a"] 523 607 << "\" could not be found.\n"; … … 744 828 // add the encoding information 745 829 if (response == content) { 746 if (args["w"] == "u") { 747 response_data += "; charset=UTF-8"; 748 } else if (args["w"] == "g") { 749 response_data += "; charset=GBK"; 750 } else if (args["w"] == "a") { 751 response_data += "; charset=windows-1256"; 752 } else if (args["w"] == "c") { 753 response_data += "; charset=windows-1251"; 830 if (configinfo.encodings.find(args["w"]) != configinfo.encodings.end()) { 831 response_data += "; charset=" + configinfo.encodings[args["w"]].label; 754 832 } else { 755 response_data += "; charset=ISO-8859-1"; 833 // default to latin 1 834 response_data += "; charset=ISO-8859-1"; 756 835 } 757 836 -
trunk/gsdl/src/recpt/receptionist.h
r1779 r1856 60 60 }; 61 61 62 struct languageinfo_t { 63 void clear(); 64 languageinfo_t () {clear();} 65 66 text_t longname; 67 text_t defaultencoding; 68 }; 69 70 struct encodinginfo_t { 71 void clear(); 72 encodinginfo_t () {clear();} 73 74 text_t longname; 75 text_t label; 76 }; 77 62 78 typedef map<text_t, collectioninfo_t, lttext_t> colinfo_tmap; 79 typedef map<text_t, languageinfo_t, lttext_t> languageinfo_tmap; 80 typedef map<text_t, encodinginfo_t, lttext_t> encodinginfo_tmap; 63 81 64 82 enum events_t {Disabled, CollectorEvents, AllEvents}; … … 91 109 text_t macroprecedence; 92 110 111 languageinfo_tmap languages; 112 encodinginfo_tmap encodings; 113 93 114 void clear (); 94 115 recptconf () {clear();} … … 118 139 bool get_cookie (text_t &cookie, text_tmap &fcgienv); 119 140 bool get_cookie (text_tmap &fcgienv); 141 142 // get the default encoding for the given language - if it fails for any 143 // reason, return "" 144 text_t get_default_encoding (const text_t &language); 120 145 121 146 virtual void define_general_macros (cgiargsclass &args, outconvertclass &outconvert,
Note:
See TracChangeset
for help on using the changeset viewer.