Changeset 4107 for trunk/gsdl/src/recpt
- Timestamp:
- 2003-04-08T16:21:35+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/langaction.cpp
r4068 r4107 55 55 56 56 // file 'logfile' contains all the page numbers, one number per line 57 text_t logfile = filename_cat(dir, "package_forms", lang, "pageno.log"); 58 57 // text_t logfile = filename_cat(dir, "package_forms", lang, "pageno.log"); 58 text_t logfile = filename_cat(dir, "pageno.log"); 59 59 60 //open the file as a read only file 60 61 ifstream readfile(logfile.getcstr(), ios::in); … … 179 180 arg_ainfo.savedarginfo = cgiarginfo::must; 180 181 argsinfo.addarginfo (&cerr, arg_ainfo); 181 182 182 } 183 183 … … 186 186 187 187 bool langaction::check_cgiargs (cgiargsinfoclass &/*argsinfo*/, cgiargsclass &args, 188 ostream &logout) { 189 // authenticate the user before allowing modifications 190 // args["uan"] = 1; 191 // args["ug"] = "langadmin"; 192 188 recptprotolistclass *protos, ostream &logout) { 189 // authenticate the user before allowing modifications (if authentication is available) 190 args["uan"] = 1; 191 args["ug"] = "langadmin"; 193 192 return true; 194 193 } … … 212 211 text_t lang = ""; 213 212 text_t baselanguage = ""; 214 215 //creates output stream to argsfile (dir is gsdlhome/tmp/lang)216 text_t argsfile = filename_cat(dir, "arguments.arg");217 ofstream argsout(argsfile.getcstr(), ios::out);218 219 //informs user and returns if output stream not opened220 if(!argsout) {221 logout << "File " << argsfile << " could not be opened\n";222 return;223 }224 225 //ensures access permissions make the file world writable226 text_t changemode = "chmod a+w ";227 changemode += argsfile;228 gsdl_system(changemode, false, logout);229 230 //write out the cgiargsclass passes as a parameter to the subroutine to the argsout file231 argsout << args;232 //close the argsout output stream233 argsout.close();234 213 235 214 //sets the current foreign language … … 237 216 lang = args["ownchoice"]; 238 217 } 239 // else if (args["hiddenlanguage"] != "") {240 // lang = args["hiddenlanguage"];241 // }242 // else {243 // lang = args["language"];244 // }245 246 // else if (args["tlng"] != "") {247 // lang = args["tlng"];248 // }249 218 else if (args["language"] != "") { 250 219 lang = args["language"]; … … 258 227 } 259 228 260 //sets current base language 261 // if (args["baselanguage"] != "") { 262 // baselanguage = args["baselanguage"]; 263 //} 264 265 logout << "Lang: " << lang << " Baselanguage: " << baselanguage << endl; 229 // logout << "Lang: " << lang << " Baselanguage: " << baselanguage << endl; 230 text_t translation = baselanguage + "-" + lang; 231 logout << "Translation: " << translation << endl; 232 text_t trans_dir = filename_cat(dir, translation); 266 233 267 234 // argument for page is of the form 'macrofile_pageno' so … … 287 254 } 288 255 289 define_webpage(disp, protos, logout, pageno, lang, dir, pagenos, text, baselanguage);256 define_webpage(disp, protos, logout, pageno, lang, trans_dir, pagenos, text, baselanguage); 290 257 return; 291 258 } 259 292 260 if (pageno == "fromsearch") 293 261 pageno = "thankyou"; … … 296 264 pageno = "1"; 297 265 298 //THIS IS ONLY COMMENTED COS CVS IS SCREWED! NEED TO UNCOMMENT @ SOME POINT!!!299 266 //calls the translator file to create HTML files 300 301 cmd = "perl " + filename_cat(gsdlhome, "bin", "script", "translator.pl") + " " + lang + " " + baselanguage; 267 cmd = "perl " + filename_cat(gsdlhome, "bin", "script", "translator.pl") + " " + baselanguage + " " + lang; 302 268 if ((gsdl_system(cmd, true, logout)) != 0) { 303 269 logout << "Process " << cmd << " did not execute.../;-D\n"; … … 320 286 321 287 //if no more pages will set pageno to thankyou script 322 pagenos = get_pagenos( dir, lang, logout);288 pagenos = get_pagenos(trans_dir, lang, logout); 323 289 324 290 if (pagenos.empty() && pageno == "") … … 330 296 //if the SUBMIT TRANSLATION >> button has been pushed 331 297 if (text_t_substring(submitargs,submit)) { 332 298 //creates output stream to argsfile 299 text_t argsfile = filename_cat(trans_dir, "arguments.arg"); 300 logout << "Argsfile: " << argsfile << endl; 301 write_args_file(args, argsfile, logout); 302 333 303 //create the command line for submitting the translation 334 304 cmd = "perl " + filename_cat(gsdlhome, "bin", "script", "submit_translation.pl") + " "; 335 cmd += ( argsfile + " " + lang + " " + baselanguage);336 305 cmd += (baselanguage + " " + lang + " " + "arguments.arg"); 306 337 307 //give command to system to execute submission of translation 338 308 if((gsdl_system(cmd, true, logout)) != 0) 339 309 logout << "Process " << cmd << " did not execute\n"; 340 310 341 311 //increments which page is displayed when translation is submitted 342 for (text_tarray::iterator page_itr = pagenos.begin(); 343 page_itr != pagenos.end(); 312 for (text_tarray::iterator page_itr = pagenos.begin(); 313 page_itr != pagenos.end(); 344 314 page_itr++) { 345 315 if (*page_itr == pageno) { … … 349 319 else 350 320 pageno = "thankyou"; 351 321 352 322 break; 353 323 } … … 355 325 } 356 326 357 pagenos = get_pagenos(dir, lang, logout); 358 define_webpage(disp, protos, logout, pageno, lang, dir, pagenos, text, baselanguage); 359 } 327 pagenos = get_pagenos(trans_dir, lang, logout); 328 define_webpage(disp, protos, logout, pageno, lang, trans_dir, pagenos, text, baselanguage); 329 } 330 331 332 void langaction::write_args_file (cgiargsclass &args, text_t argsfile, ostream &logout) 333 { 334 ofstream argsout(argsfile.getcstr(), ios::out); 335 336 //informs user and returns if output stream not opened 337 if(!argsout) { 338 logout << "File " << argsfile << " could not be opened\n"; 339 return; 340 } 341 342 //ensures access permissions make the file world writable 343 text_t changemode = "chmod a+w "; 344 changemode += argsfile; 345 gsdl_system(changemode, false, logout); 346 347 //write out the cgiargsclass passes as a parameter to the subroutine to the argsout file 348 argsout << args; 349 //close the argsout output stream 350 argsout.close(); 351 } 352 360 353 361 354 void langaction::define_webpage (displayclass &disp, … … 368 361 // current package whose name is stored in 'package' 369 362 370 text_t formfile; 371 if (pageno == "picklanguage") 372 formfile = filename_cat(dir, "package_forms"); 373 else 374 formfile = filename_cat(dir, "package_forms", lang); 375 formfile += ("/" + pageno + ".lang"); 376 363 text_t formfile = filename_cat(dir, pageno + ".lang"); 377 364 ifstream readfile(formfile.getcstr(), ios::in); 378 365 if (!readfile) { … … 380 367 return; 381 368 } 382 383 369 370 384 371 /* ============================ START WEB-FORM HTML CODE ============================ */ 385 372 text += "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></head><body>"; … … 432 419 temp2 = "thankyou"; 433 420 434 text += "<a href=\"_gwcgi_? a=lang&p=translang_";421 text += "<a href=\"_gwcgi_?e=_compressedoptions_&a=lang&p=translang_"; 435 422 text += temp2; 436 423 text += "&baselanguage="; … … 442 429 text += "</strong></a>\n"; 443 430 444 break; 431 break; 445 432 } 446 433 else { 447 text += "<a href=\"_gwcgi_? a=lang&p=translang_";434 text += "<a href=\"_gwcgi_?e=_compressedoptions_&a=lang&p=translang_"; 448 435 text += *page_itr; 449 436 text += "&baselanguage="; … … 473 460 474 461 // set the action for the form 475 // disp.setmacro("formaction", "translang", "/cgi-bin/dg5/library");476 462 disp.setmacro("formaction", "translang", "_gwcgi_"); 477 463
Note:
See TracChangeset
for help on using the changeset viewer.