Changeset 3723 for trunk/gsdl/src/recpt
- Timestamp:
- 2003-02-05T16:14:53+13:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/langaction.cpp
r3715 r3723 49 49 *========================*/ 50 50 51 void add_visited_page (text_t dir, ostream & logout, text_t pageno) {52 53 text_tarray oldpages;54 bool visited = false;55 56 // file 'logfile' contains all the page numbers, one number per line57 text_t logfile = filename_cat(dir, "package_forms", "oldpages.log");58 59 //open the file as a read only file60 ifstream readfile(logfile.getcstr(), ios::in);61 62 // if file isn't opened, print error and return63 if (!readfile) {64 logout << "IN File " << logfile.getcstr() << " could not be found.\n";65 return;66 }67 68 // go through file, pushing each page number on to the end of a text_tarray69 while (readfile.getline(temp, BUFFSIZE-1)) {70 text_t t_temp = temp;71 oldpages.push_back(temp);72 if (strcmp(pageno.getcstr(),t_temp.getcstr()) == 0) {73 visited = true;74 }75 }76 readfile.close();77 78 if (visited == false) {79 ofstream writefile(logfile.getcstr(), ios::out);80 81 for (text_tarray::iterator page_itr = oldpages.begin();82 page_itr != oldpages.end();83 page_itr++) {84 85 writefile << *page_itr <<endl;86 }87 time_t seconds;88 seconds = time(NULL);89 90 if (pageno == "2")91 writefile << "1" <<endl;92 93 writefile << pageno <<endl;94 95 logout << "ADDING PAGE " << pageno.getcstr() << " " << seconds <<endl;96 97 writefile.close();98 }99 }100 51 // gets the list of packages/files that contain the content of the web-forms 101 52 text_tarray get_pagenos(text_t dir, ostream &logout) … … 203 154 package = ""; 204 155 205 // this action uses cgi variables "a", and "p"206 156 cgiarginfo arg_ainfo; 207 157 208 158 arg_ainfo.shortname = "l"; 209 arg_ainfo.longname = " language";159 arg_ainfo.longname = "interface language"; 210 160 arg_ainfo.multiplechar = true; 211 161 arg_ainfo.defaultstatus = cgiarginfo::weak; 212 162 arg_ainfo.argdefault = "en"; 213 163 arg_ainfo.savedarginfo = cgiarginfo::must; 214 argsinfo.addarginfo (NULL, arg_ainfo); 164 argsinfo.addarginfo (&cerr, arg_ainfo); 165 166 arg_ainfo.shortname = "bl"; 167 arg_ainfo.longname = "base language"; 168 arg_ainfo.multiplechar = true; 169 arg_ainfo.defaultstatus = cgiarginfo::weak; 170 arg_ainfo.argdefault = "english"; 171 arg_ainfo.savedarginfo = cgiarginfo::must; 172 argsinfo.addarginfo (&cerr, arg_ainfo); 173 174 arg_ainfo.shortname = "tlng"; 175 arg_ainfo.longname = "translation language"; 176 arg_ainfo.multiplechar = true; 177 arg_ainfo.defaultstatus = cgiarginfo::weak; 178 arg_ainfo.argdefault = "french"; 179 arg_ainfo.savedarginfo = cgiarginfo::must; 180 argsinfo.addarginfo (&cerr, arg_ainfo); 181 215 182 } 216 183 … … 263 230 //write out the cgiargsclass passes as a parameter to the subroutine to the argsout file 264 231 argsout << args; 265 266 // utf8outconvertclass text_tutf8;267 268 // for (cgiargsclass::iterator args_itr = args.begin();269 // args_itr != args.end();270 // args_itr++) {271 272 // if(text_t_substring(*args_itr->first, pageno, logout)) {273 // argsout << text_t2utf8 << "\"" << args_itr->first << "\"=\n\""274 // << (args_itr->second).value << "\"\n";275 // }276 // }277 278 232 //close the argsout output stream 279 233 argsout.close(); 280 281 if (args["nextlink"] != "") { 282 add_visited_page(dir,logout,args["nextlink"]); 283 } 284 234 285 235 //sets the current foreign language 286 236 if (args["ownchoice"] != "") { 287 237 lang = args["ownchoice"]; 288 238 } 289 else if (args["hiddenlanguage"] != "") { 290 lang = args["hiddenlanguage"]; 291 } 292 else { 293 lang = args["language"]; 294 } 295 239 // else if (args["hiddenlanguage"] != "") { 240 // lang = args["hiddenlanguage"]; 241 // } 242 // else { 243 // lang = args["language"]; 244 // } 245 else if (args["tlng"] != "") { 246 lang = args["tlng"]; 247 } 248 249 if (args["bl"] != "") { 250 baselanguage = args["bl"]; 251 } 252 296 253 //sets current base language 297 if (args["baselanguage"] != "") {298 baselanguage = args["baselanguage"];299 }300 254 // if (args["baselanguage"] != "") { 255 // baselanguage = args["baselanguage"]; 256 //} 257 301 258 // argument for page is of the form 'macrofile_pageno' so 302 259 // we need to split the argument to get the proper page content … … 308 265 pageno = splitarray[splitarray.size()-1]; 309 266 310 if (pageno == "fromsearch") { 267 //if are entering page from macro search 268 if (args["macroname"] != "") { 311 269 text_t macroname = args["macroname"]; 312 text_t macrotext = args["macrotext"]; 313 314 logout << "macro data " << macroname.getcstr() << macrotext.getcstr() <<endl; 315 316 //calls the translator file to create HTML files 317 cmd = "perl " + filename_cat(gsdlhome, "bin", "script", "fromsearch.pl") + " " + macroname + " " + macrotext; 270 271 //calls the translator file to create HTML files 272 cmd = "perl " + filename_cat(gsdlhome, "bin", "script", "fromsearch.pl") + " " + macroname + " " + lang + " " + baselanguage; 318 273 logout << "COMMAND: " << cmd.getcstr() <<endl; 319 274 320 275 if ((gsdl_system(cmd, true, logout)) != 0) { 321 276 logout << "Process " << cmd.getcstr() << " did not execute.../;-D\n"; 322 277 return; 323 278 } 324 279 325 280 define_webpage(disp, protos, logout, pageno, lang, dir, pagenos, text, baselanguage); 326 281 return; 327 282 } 283 if (pageno == "fromsearch") 284 pageno = "thankyou"; 328 285 329 286 if (pageno == "picklanguage") { 330 287 pageno = "1"; 331 288 289 //THIS IS ONLY COMMENTED COS CVS IS SCREWED! NEED TO UNCOMMENT @ SOME POINT!!! 332 290 //calls the translator file to create HTML files 333 // cmd = "perl " + filename_cat(gsdlhome, "bin", "script", "translator.pl") + " " + lang + " " + baselanguage; 334 // if ((gsdl_system(cmd, true, logout)) != 0) { 335 // logout << "Process " << cmd.getcstr() << " did not execute.../;-D\n"; 336 // return; 337 // } 291 292 cmd = "perl " + filename_cat(gsdlhome, "bin", "script", "translator.pl") + " " + lang + " " + baselanguage; 293 if ((gsdl_system(cmd, true, logout)) != 0) { 294 logout << "Process " << cmd.getcstr() << " did not execute.../;-D\n"; 295 return; 296 } 338 297 } 339 298 … … 375 334 page_itr != pagenos.end(); 376 335 page_itr++) { 377 logout << pageno.getcstr() << " page number before" <<endl;378 379 336 if (*page_itr == pageno) { 380 337 page_itr++; … … 386 343 break; 387 344 } 388 389 logout << pageno.getcstr() << " page number after" <<endl;390 345 } 391 add_visited_page(dir,logout,pageno);392 346 } 393 347 394 348 pagenos = get_pagenos(dir,logout); 395 logout << "PAGENOS... " << pagenos.size() <<endl;396 349 define_webpage(disp, protos, logout, pageno, lang, dir, pagenos, text, baselanguage); 397 350 } … … 423 376 text += pageno; 424 377 text += "\">\n"; 425 378 text += "\n<input type=hidden name=\"e\" value=\"_decodedcompressedoptions_\">"; 379 426 380 text += "_texttranshead_"; 427 381 428 429 382 //if not a special case page display translation info 430 if ((pageno != "thankyou") && (pageno !="picklanguage")) { 431 432 logout << "PAGENOS " << pagenos.size() <<endl; 433 383 if ((pageno != "thankyou") && (pageno !="picklanguage") && (pageno != "fromsearch")) { 384 434 385 text += "<center><strong> _textcurrpage_ "; 435 386 text += pageno; … … 439 390 } 440 391 441 utf8outconvertclass text_tutf8;442 443 392 //read in HTML from file 444 393 while(readfile.getline(temp, BUFFSIZE-1)) { 445 394 text_t t_temp = temp; 446 395 text += t_temp; 447 448 //logout << t_temp.getcstr() <<endl;449 450 // text_t2utf8.setinput(&t_temp);451 // char *buffer = new char[t_temp.size()];452 // size_t num_chars;453 // convertclass::status_t status;454 // text_t2utf8.convert(buffer, t_temp.size(), num_chars, status);455 // logout << buffer <<endl;456 // delete buffer;457 458 // for (cgiargsclass::iterator args_itr = args.begin();459 // args_itr != args.end();460 // args_itr++) {461 462 // if(text_t_substring(*args_itr->first, pageno, logout)) {463 // argsout << text_t2utf8 << "\"" << args_itr->first << "\"=\n\""464 // << (args_itr->second).value << "\"\n";465 // }466 // }467 468 // logout << t_temp.getcstr() <<endl;469 396 text += "\n"; 470 397 } … … 472 399 473 400 //if not a special case page display translation info 474 if ((pageno != "thankyou") && (pageno != "picklanguage") ) {401 if ((pageno != "thankyou") && (pageno != "picklanguage") && (pageno != "fromsearch")) { 475 402 text += "<center><strong> _textcurrpage_ "; 476 403 text += pageno; … … 478 405 text += pagenos.size(); 479 406 text += "</strong><br>\n"; 480 481 482 text_tarray oldpages;483 484 // file 'logfile' contains all the page numbers, one number per line485 text_t logfile = filename_cat(dir, "package_forms", "oldpages.log");486 487 //open the file as a read only file488 ifstream reader(logfile.getcstr(), ios::in);489 490 // if file isn't opened, print error and return491 if (!reader) {492 logout << "IN File " << logfile.getcstr() << " could not be found.\n";493 }494 495 // go through file, pushing each page number on to the end of a text_tarray496 while (reader.getline(temp, BUFFSIZE-1)) {497 text += "<a href=\"_gwcgi_?a=lang&p=translang_";498 text += temp;499 text += "&baselanguage=";500 text += baselanguage;501 text += "&language=";502 text += lang;503 text += "\"><strong>";504 text += temp;505 text += "</strong></a>\n";506 507 }508 407 509 408 text_t temp2 = ""; … … 512 411 page_itr != pagenos.end(); 513 412 page_itr++) { 514 515 logout << "TEMP2 " << temp2.getcstr() <<endl; 516 logout << "PAGENO " << pageno.getcstr() <<endl; 517 413 518 414 if (*page_itr == pageno) { 519 415 page_itr++; … … 523 419 temp2 = "thankyou"; 524 420 525 logout << "TEMP2 " << temp2.getcstr() <<endl; 526 logout << "PAGENO " << pageno.getcstr() <<endl; 527 421 text += "<a href=\"_gwcgi_?a=lang&p=translang_"; 422 text += temp2; 423 text += "&baselanguage="; 424 text += baselanguage; 425 text += "&language="; 426 text += lang; 427 text += "\"><strong>"; 428 text += "NEXT>>"; 429 text += "</strong></a>\n"; 430 528 431 break; 529 432 } 433 else { 434 text += "<a href=\"_gwcgi_?a=lang&p=translang_"; 435 text += *page_itr; 436 text += "&baselanguage="; 437 text += baselanguage; 438 text += "&language="; 439 text += lang; 440 text += "\"><strong>"; 441 text += *page_itr; 442 text += "</strong></a>\n"; 443 } 530 444 } 531 532 text += "<a href=\"_gwcgi_?a=lang&p=translang_"; 533 text += temp2; 534 text += "&baselanguage="; 535 text += baselanguage; 536 text += "&language="; 537 text += lang; 538 text += "&nextlink="; 539 text += pageno; 540 text += "\"><strong>"; 541 text += "NEXT>>"; 542 text += "</strong></a>\n"; 543 544 text += "</body></html>\n"; 545 546 reader.close(); 547 } 445 } 446 447 if (pageno == "fromsearch") 448 text += "<center><strong> _textcurrpage_ 1 _textof_ 1</strong><br>\n"; 449 450 text += "</body></html>\n"; 451 452 548 453 /* ============================ END WEB-FORM HTML CODE ============================ */ 549 454 … … 551 456 // THE FOLLOWING MACROS ARE DEFINED IN translang.dm MACRO FILE 552 457 // set the formcontent as the content of the form-page 458 459 logout << text.getcstr() <<endl; 460 553 461 disp.setmacro("formcontent", "translang", text); 554 462 … … 561 469 navigationbar += "<tr valign=top><td rowspan=2 align=left>_imagecollection_</td>"; 562 470 navigationbar += "<td align=right>_javalinks_</td><td>"; 563 navigationbar += "_imageserch_</td></tr></table>"; 564 navigationbar += "\n</nobr>\n"; 471 472 //PUT THIS LINE BACK IN TO RE CREATE THE LINK TO THE MACRO SEARCH FACILITY 473 // if (pageno != "picklanguage") 474 // navigationbar += "_imageserch_"; 475 navigationbar += "</td></tr></table>\n</nobr>\n"; 565 476 navigationbar += "<!-- End of Navigation Bar -->\n"; 566 477 disp.setmacro ("navigationbar", "translang", navigationbar); … … 574 485 text_t &arg_p = args["p"]; 575 486 576 textout << outconvert << disp << ("_" + arg_p + ":header_\n") 487 outconvertclass text2utf8; 488 489 textout << text2utf8 << disp << ("_" + arg_p + ":header_\n") 577 490 << ("_" + arg_p + ":content_\n") 578 491 << ("_" + arg_p + ":footer_\n"); 579 492 580 logout << outconvert << disp << ("_" + arg_p + ":header_\n");581 582 493 return true; 583 494 }
Note:
See TracChangeset
for help on using the changeset viewer.