Changeset 4107


Ignore:
Timestamp:
2003-04-08T16:21:35+12:00 (21 years ago)
Author:
mdewsnip
Message:

Many small modifications. Most important were changes to authenticate users, and minor changes to fit the modified back-end.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/langaction.cpp

    r4068 r4107  
    5555
    5656  // 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
    5960  //open the file as a read only file
    6061  ifstream readfile(logfile.getcstr(), ios::in);
     
    179180  arg_ainfo.savedarginfo = cgiarginfo::must;
    180181  argsinfo.addarginfo (&cerr, arg_ainfo);
    181 
    182182}
    183183
     
    186186
    187187bool 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";
    193192  return true;
    194193}
     
    212211  text_t lang = "";
    213212  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 opened
    220   if(!argsout) {
    221     logout << "File " << argsfile << " could not be opened\n";
    222       return;
    223   }
    224  
    225   //ensures access permissions make the file world writable
    226   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 file
    231   argsout << args;
    232   //close the argsout output stream
    233   argsout.close();
    234213
    235214  //sets the current foreign language
     
    237216    lang = args["ownchoice"];
    238217  }
    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   // }
    249218  else if (args["language"] != "") {
    250219    lang = args["language"];
     
    258227  }
    259228
    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);
    266233
    267234  // argument for page is of the form 'macrofile_pageno' so
     
    287254    }
    288255   
    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);
    290257    return;
    291258  }
     259
    292260  if (pageno == "fromsearch")
    293261    pageno = "thankyou";
     
    296264    pageno = "1";
    297265   
    298     //THIS IS ONLY COMMENTED COS CVS IS SCREWED! NEED TO UNCOMMENT @ SOME POINT!!!
    299266    //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;
    302268    if ((gsdl_system(cmd, true, logout)) != 0) {
    303269      logout << "Process " << cmd << " did not execute.../;-D\n";
     
    320286
    321287  //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);
    323289 
    324290  if (pagenos.empty() && pageno == "")
     
    330296  //if the SUBMIT TRANSLATION >> button has been pushed
    331297  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
    333303    //create the command line for submitting the translation
    334304    cmd = "perl " + filename_cat(gsdlhome, "bin", "script", "submit_translation.pl") + " ";
    335     cmd += (argsfile + " " + lang + " " + baselanguage);
    336    
     305    cmd += (baselanguage + " " + lang + " " + "arguments.arg");
     306
    337307    //give command to system to execute submission of translation
    338308    if((gsdl_system(cmd, true, logout)) != 0)
    339309      logout << "Process " << cmd << " did not execute\n";
    340    
     310
    341311    //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();
    344314     page_itr++) {
    345315      if (*page_itr == pageno) {
     
    349319    else
    350320      pageno = "thankyou";
    351    
     321
    352322    break; 
    353323      }
     
    355325  }
    356326
    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
     332void 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
    360353
    361354void langaction::define_webpage (displayclass &disp,
     
    368361  // current package whose name is stored in 'package'
    369362
    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");
    377364  ifstream readfile(formfile.getcstr(), ios::in);
    378365  if (!readfile) {
     
    380367    return;
    381368  }
    382  
    383  
     369
     370
    384371  /* ============================ START WEB-FORM HTML CODE ============================ */
    385372  text += "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></head><body>";
     
    432419     temp2 = "thankyou";
    433420       
    434        text += "<a href=\"_gwcgi_?a=lang&p=translang_";
     421       text += "<a href=\"_gwcgi_?e=_compressedoptions_&a=lang&p=translang_";
    435422       text += temp2;
    436423       text += "&baselanguage=";
     
    442429       text += "</strong></a>\n";
    443430
    444        break;   
     431       break;
    445432     }
    446433     else {
    447        text += "<a href=\"_gwcgi_?a=lang&p=translang_";
     434       text += "<a href=\"_gwcgi_?e=_compressedoptions_&a=lang&p=translang_";
    448435       text += *page_itr;
    449436       text += "&baselanguage=";
     
    473460 
    474461  // set the action for the form
    475   //  disp.setmacro("formaction", "translang", "/cgi-bin/dg5/library");
    476462  disp.setmacro("formaction", "translang", "_gwcgi_");
    477463
Note: See TracChangeset for help on using the changeset viewer.