Changeset 3723


Ignore:
Timestamp:
2003-02-05T16:14:53+13:00 (21 years ago)
Author:
kde2
Message:

Submission of interface translation agency

File:
1 edited

Legend:

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

    r3715 r3723  
    4949 *========================*/
    5050
    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 line
    57   text_t logfile = filename_cat(dir, "package_forms", "oldpages.log");
    58  
    59   //open the file as a read only file
    60   ifstream readfile(logfile.getcstr(), ios::in);
    61  
    62   // if file isn't opened, print error and return
    63   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_tarray
    69   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 }
    10051// gets the list of packages/files that contain the content of the web-forms
    10152text_tarray get_pagenos(text_t dir, ostream &logout)
     
    203154  package = "";
    204155
    205   // this action uses cgi variables "a", and "p"
    206156  cgiarginfo arg_ainfo;
    207157
    208158  arg_ainfo.shortname = "l";
    209   arg_ainfo.longname = "language";
     159  arg_ainfo.longname = "interface language";
    210160  arg_ainfo.multiplechar = true;
    211161  arg_ainfo.defaultstatus = cgiarginfo::weak;
    212162  arg_ainfo.argdefault = "en";
    213163  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
    215182}
    216183
     
    263230  //write out the cgiargsclass passes as a parameter to the subroutine to the argsout file
    264231  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 
    278232  //close the argsout output stream
    279233  argsout.close();
    280  
    281   if (args["nextlink"] != "") {
    282     add_visited_page(dir,logout,args["nextlink"]);
    283   }
    284 
     234 
    285235  //sets the current foreign language
    286236  if (args["ownchoice"] != "") {
    287237    lang = args["ownchoice"];
    288238  }
    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
    296253  //sets current base language
    297   if (args["baselanguage"] != "") {
    298     baselanguage = args["baselanguage"];
    299   }
    300 
     254  //  if (args["baselanguage"] != "") {
     255  //  baselanguage = args["baselanguage"];
     256  //}
     257 
    301258  // argument for page is of the form 'macrofile_pageno' so
    302259  // we need to split the argument to get the proper page content
     
    308265    pageno = splitarray[splitarray.size()-1];
    309266
    310   if (pageno == "fromsearch") {
     267  //if are entering page from macro search
     268  if (args["macroname"] != "") {
    311269    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;
    318273    logout << "COMMAND: " << cmd.getcstr() <<endl;
    319 
     274   
    320275    if ((gsdl_system(cmd, true, logout)) != 0) {
    321276      logout << "Process " << cmd.getcstr() << " did not execute.../;-D\n";
    322277      return;
    323278    }
    324 
     279   
    325280    define_webpage(disp, protos, logout, pageno, lang, dir, pagenos, text, baselanguage);
    326281    return;
    327282  }
     283  if (pageno == "fromsearch")
     284    pageno = "thankyou";
    328285
    329286  if (pageno == "picklanguage") {
    330287    pageno = "1";
    331288   
     289    //THIS IS ONLY COMMENTED COS CVS IS SCREWED! NEED TO UNCOMMENT @ SOME POINT!!!
    332290    //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    }
    338297  }
    339298
     
    375334     page_itr != pagenos.end();
    376335     page_itr++) {
    377       logout << pageno.getcstr() << " page number before" <<endl;
    378  
    379336      if (*page_itr == pageno) {
    380337    page_itr++;
     
    386343    break; 
    387344      }
    388 
    389       logout << pageno.getcstr() << " page number after" <<endl;
    390345    }
    391     add_visited_page(dir,logout,pageno);
    392346  }
    393347
    394348  pagenos = get_pagenos(dir,logout);
    395   logout << "PAGENOS... " << pagenos.size() <<endl;
    396349  define_webpage(disp, protos, logout, pageno, lang, dir, pagenos, text, baselanguage);
    397350}
     
    423376  text += pageno;
    424377  text += "\">\n";
    425 
     378  text += "\n<input type=hidden name=\"e\" value=\"_decodedcompressedoptions_\">";
     379 
    426380  text += "_texttranshead_";       
    427381
    428  
    429382  //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 
    434385    text += "<center><strong> _textcurrpage_ ";
    435386    text += pageno;
     
    439390  }
    440391 
    441   utf8outconvertclass text_tutf8;
    442 
    443392  //read in HTML from file
    444393  while(readfile.getline(temp, BUFFSIZE-1)) {
    445394    text_t t_temp = temp;
    446395    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;
    469396    text += "\n";
    470397  }
     
    472399 
    473400  //if not a special case page display translation info
    474   if ((pageno != "thankyou") && (pageno != "picklanguage")) {
     401  if ((pageno != "thankyou") && (pageno != "picklanguage") && (pageno != "fromsearch")) {
    475402    text += "<center><strong> _textcurrpage_ ";
    476403    text += pageno;
     
    478405    text += pagenos.size();
    479406    text += "</strong><br>\n";
    480    
    481  
    482    text_tarray oldpages;
    483    
    484    // file 'logfile' contains all the page numbers, one number per line
    485    text_t logfile = filename_cat(dir, "package_forms", "oldpages.log");
    486    
    487    //open the file as a read only file
    488    ifstream reader(logfile.getcstr(), ios::in);
    489    
    490    // if file isn't opened, print error and return
    491    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_tarray
    496    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    }
    508407
    509408   text_t temp2 = "";
     
    512411    page_itr != pagenos.end();
    513412    page_itr++) {
    514      
    515      logout << "TEMP2 " << temp2.getcstr() <<endl;
    516      logout << "PAGENO " << pageno.getcstr() <<endl;
    517 
     413   
    518414     if (*page_itr == pageno) {
    519415       page_itr++;
     
    523419     temp2 = "thankyou";
    524420       
    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
    528431       break;   
    529432     }
     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     }
    530444   }
    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 
    548453  /* ============================ END WEB-FORM HTML CODE ============================ */
    549454 
     
    551456  // THE FOLLOWING MACROS ARE DEFINED IN translang.dm MACRO FILE
    552457  // set the formcontent  as the content of the form-page
     458 
     459  logout << text.getcstr() <<endl;
     460
    553461  disp.setmacro("formcontent", "translang", text);
    554462 
     
    561469  navigationbar += "<tr valign=top><td rowspan=2 align=left>_imagecollection_</td>";
    562470  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";
    565476  navigationbar += "<!-- End of Navigation Bar -->\n";
    566477  disp.setmacro ("navigationbar", "translang", navigationbar);
     
    574485  text_t &arg_p = args["p"];
    575486 
    576   textout << outconvert << disp << ("_" + arg_p + ":header_\n")
     487  outconvertclass text2utf8;
     488
     489  textout << text2utf8 << disp << ("_" + arg_p + ":header_\n")
    577490      << ("_" + arg_p + ":content_\n")
    578491      << ("_" + arg_p + ":footer_\n");
    579492
    580   logout << outconvert << disp << ("_" + arg_p + ":header_\n");
    581 
    582493  return true;
    583494}
Note: See TracChangeset for help on using the changeset viewer.