Changeset 3625 for trunk/gsdl/src/recpt/pageaction.cpp
- Timestamp:
- 2002-12-05T14:47:11+13:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/pageaction.cpp
r3546 r3625 93 93 } 94 94 95 // for UNESCO ONLY96 #if 097 // the following hack resets the language argument to English if98 // attempting to display the homepage in a language other than99 // English or French - we do this because English and French are the100 // only languages currently supported by the home page101 if (args["p"] == "home" && args["l"] != "en" && args["l"] != "fr" && args["l"] != "es") args["l"] = "en";102 #endif103 104 95 return true; 105 96 } … … 358 349 } 359 350 351 void pageaction::set_language_encoding_macros(displayclass &disp, cgiargsclass &args, 352 recptprotolistclass *protos, ColInfoResponse_t *cinfo, 353 ostream &logout) { 354 // _languageoption_ 355 // Create the "interface language" selection box for the preferences 356 // pages. You can use something like "format PreferenceLanguages 357 // en|fr|zn" from within a collect.cfg file to use only a subset of 358 // the available languages for any given collection (for 359 // collection-specific preferences pages). This facility is kind of 360 // ugly though and should be replaced by something better when the 361 // configuration files are tidied up (as should all the other 362 // "format Preference..." options). 363 text_t &arg_l = args["l"]; 364 const recptconf &configinfo = recpt->get_configinfo(); 365 // put languages in another map to sort them by longname 366 text_tmap languages; 367 languageinfo_tmap::const_iterator thislang = configinfo.languages.begin(); 368 languageinfo_tmap::const_iterator endlang = configinfo.languages.end(); 369 while (thislang != endlang) { 370 languages[(*thislang).second.longname] = (*thislang).first; 371 thislang++; 372 } 373 text_tmap::iterator tlang = languages.begin(); 374 text_tmap::iterator elang = languages.end(); 375 376 text_t languageoption; 377 bool collection_specific = false; 378 379 if (cinfo != NULL) { 380 text_tmap::const_iterator it = cinfo->format.find ("PreferenceLanguages"); 381 if ((it != cinfo->format.end()) && (!(*it).second.empty())) { 382 collection_specific = true; 383 text_tset pref_langs; 384 splitchar ((*it).second.begin(), (*it).second.end(), '|', pref_langs); 385 if (pref_langs.size() > 1) { 386 while (tlang != elang) { 387 if (pref_langs.find((*tlang).second) != pref_langs.end()) { 388 languageoption += "<option value=\"" + (*tlang).second + "\""; 389 if ((*tlang).second == arg_l) languageoption += " selected"; 390 languageoption += ">" + (*tlang).first + "\n"; 391 } 392 tlang ++; 393 } 394 } 395 } 396 } 397 398 if (!collection_specific) { 399 while (tlang != elang) { 400 languageoption += "<option value=\"" + (*tlang).second + "\""; 401 if ((*tlang).second == arg_l) languageoption += " selected"; 402 languageoption += ">" + (*tlang).first + "\n"; 403 tlang ++; 404 } 405 } 406 407 if (!languageoption.empty()) { 408 languageoption = "<select name=\"l\" onChange=\"updatel();\">\n" + languageoption; 409 languageoption += "</select>\n"; 410 disp.setmacro ("languageoption", args["p"], languageoption); 411 } 412 413 // _encodingoption_ 414 // create the "encoding" selection box for the preferences page 415 if (configinfo.encodings.size() > 1) { 416 text_t &arg_w = args["w"]; 417 text_t encodingoption; 418 text_tmap::const_iterator thisenc = configinfo.encodings.begin(); 419 text_tmap::const_iterator endenc = configinfo.encodings.end(); 420 while (thisenc != endenc) { 421 encodingoption += "<option value=\"" + (*thisenc).second + "\""; 422 if ((*thisenc).second == arg_w) encodingoption += " selected"; 423 encodingoption += ">" + (*thisenc).first + "\n"; 424 thisenc ++; 425 } 426 427 encodingoption = "<select name=\"w\" onChange=\"updatew();\">\n" + encodingoption; 428 encodingoption += "</select>\n"; 429 disp.setmacro ("encodingoption", args["p"], encodingoption); 430 } 431 } 432 360 433 void pageaction::define_internal_macros (displayclass &disp, cgiargsclass &args, 361 434 recptprotolistclass *protos, ostream &logout) { … … 379 452 // _PreferencesDocsFromWeb_ set to 1 if corresponding format option is set 380 453 454 455 // if page is "preferences" or "homepref" 381 456 // _languageoption_ interface languages to select from (dependant on PreferenceLanguages) 382 457 383 458 // _encodingoption_ encodings to select from 459 384 460 385 461 // if page is "about" … … 470 546 if (status_disabled) disp.setmacro ("textgoadmin", "home", ""); 471 547 if (collector_disabled) disp.setmacro ("textgocollector", "home", ""); 472 } 473 474 else if (arg_p == "preferences") { 548 549 } else if (arg_p == "homepref") { 550 551 // set _languageoption_ and _encodingoption_ 552 set_language_encoding_macros(disp, args, protos, cinfo, logout); 553 554 } else if (arg_p == "preferences") { 475 555 if (collectproto == NULL) {return;} 556 557 // set _languageoption_ and _encodingoption_ 558 set_language_encoding_macros(disp, args, protos, cinfo, logout); 559 476 560 // _collectionoption_ 477 561 … … 514 598 if ((it == cinfo->format.end()) || ((*it).second == "true")) 515 599 disp.setmacro ("PreferenceDocsFromWeb", "preferences", "1"); 516 }517 518 // _languageoption_519 // Create the "interface language" selection box for the preferences page.520 // You can use something like "format PreferenceLanguages en|fr|zn" from within521 // a collect.cfg file to use only a subset of the available languages for522 // any given collection. This facility is kind of ugly though and should be523 // replaced by something better when the configuration files are tidied up (as524 // should all the other "format Preference..." options).525 526 text_t &arg_l = args["l"];527 const recptconf &configinfo = recpt->get_configinfo();528 // put languages in another map to sort them by longname529 text_tmap languages;530 languageinfo_tmap::const_iterator thislang = configinfo.languages.begin();531 languageinfo_tmap::const_iterator endlang = configinfo.languages.end();532 while (thislang != endlang) {533 languages[(*thislang).second.longname] = (*thislang).first;534 thislang++;535 }536 text_tmap::iterator tlang = languages.begin();537 text_tmap::iterator elang = languages.end();538 539 text_t languageoption;540 it = cinfo->format.find ("PreferenceLanguages");541 if ((it != cinfo->format.end()) && (!(*it).second.empty())) {542 text_tset pref_langs;543 splitchar ((*it).second.begin(), (*it).second.end(), '|', pref_langs);544 if (pref_langs.size() > 1) {545 while (tlang != elang) {546 if (pref_langs.find((*tlang).second) != pref_langs.end()) {547 languageoption += "<option value=\"" + (*tlang).second + "\"";548 if ((*tlang).second == arg_l) languageoption += " selected";549 languageoption += ">" + (*tlang).first + "\n";550 }551 tlang ++;552 }553 }554 555 } else {556 while (tlang != elang) {557 languageoption += "<option value=\"" + (*tlang).second + "\"";558 if ((*tlang).second == arg_l) languageoption += " selected";559 languageoption += ">" + (*tlang).first + "\n";560 tlang ++;561 }562 }563 if (!languageoption.empty()) {564 languageoption = "<select name=\"l\" onChange=\"updatel();\">\n" + languageoption;565 languageoption += "</select>\n";566 disp.setmacro ("languageoption", "preferences", languageoption);567 }568 569 // _encodingoption_570 // create the "encoding" selection box for the preferences page571 if (configinfo.encodings.size() > 1) {572 text_t &arg_w = args["w"];573 text_t encodingoption;574 text_tmap::const_iterator thisenc = configinfo.encodings.begin();575 text_tmap::const_iterator endenc = configinfo.encodings.end();576 while (thisenc != endenc) {577 encodingoption += "<option value=\"" + (*thisenc).second + "\"";578 if ((*thisenc).second == arg_w) encodingoption += " selected";579 encodingoption += ">" + (*thisenc).first + "\n";580 thisenc ++;581 }582 583 encodingoption = "<select name=\"w\" onChange=\"updatew();\">\n" + encodingoption;584 encodingoption += "</select>\n";585 disp.setmacro ("encodingoption", "preferences", encodingoption);586 600 } 587 601
Note:
See TracChangeset
for help on using the changeset viewer.