Changeset 2401


Ignore:
Timestamp:
2001-05-11T15:58:47+12:00 (23 years ago)
Author:
sjboddie
Message:

Made some changes to the collector so that paths/URLs/ftp addresses are
checked (pinged for HTTP/FTP) when leaving the "source data" page.
Functionality is complete I think but the interface still needs a
little work.

Location:
trunk/gsdl
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/macros/collect.dm

    r2361 r2401  
    169169<ul>
    170170<input type=radio name=p value=new checked>
    171 create an entirely new collection
     171create a new collection
    172172<br>
    173173<input type=radio name=p value=existing>
     
    444444
    445445_srcescriptextra_ {
    446 var cloneval = _cgiargbc1clone_;
     446var selectedindex = _selectedindex_;
    447447
    448448function check\_submit (gotopage) \{
    449449  var form = document.collectorform;
    450   var found = 0;
    451   var i = 0;
    452   if (!form.bc1inputdir1.value.match(/^\\s*$/)) \{
    453     if (!form.bc1inputdir1.value.match(/^\(http|ftp|file\):/)) \{
    454       i = form.sel1.selectedIndex;
    455       form.bc1inputdir1.value = form.sel1.options[i].value + form.bc1inputdir1.value;
    456     \}
    457     found = 1;
    458   \}
    459   if (!form.bc1inputdir2.value.match(/^\\s*$/)) \{
    460     if (!form.bc1inputdir2.value.match(/^\(http|ftp|file\):/)) \{
    461       i = form.sel2.selectedIndex;
    462       form.bc1inputdir2.value = form.sel2.options[i].value + form.bc1inputdir2.value;
    463     \}
    464     found = 1;
    465   \}
    466   if (!form.bc1inputdir3.value.match(/^\\s*$/)) \{
    467     if (!form.bc1inputdir3.value.match(/^\(http|ftp|file\):/)) \{
    468       i = form.sel3.selectedIndex;
    469       form.bc1inputdir3.value = form.sel3.options[i].value + form.bc1inputdir3.value;
    470     \}
    471     found = 1;
    472   \}
    473   if (!form.bc1inputdir4.value.match(/^\\s*$/)) \{
    474     if (!form.bc1inputdir4.value.match(/^\(http|ftp|file\):/)) \{
    475       i = form.sel4.selectedIndex;
    476       form.bc1inputdir4.value = form.sel4.options[i].value + form.bc1inputdir4.value;
    477     \}
    478     found = 1;
    479   \}
    480 
    481   if (!found)
    482   \{
    483     alert("At least one input source must be specified");
    484     form.bc1inputdir1.focus();
    485     return;
    486   \}
    487 
    488450  form.p.value = gotopage;
     451  form.bc1fromsrce.value = "1";
    489452  form.submit();
    490 \}
    491 
    492 function clone\_changed (changedto) \{
    493   var form = document.collectorform;
    494   if (changedto != cloneval) \{
    495     form.bc1clonechanged.value = 1;
    496   \} else \{
    497     form.bc1clonechanged.value = 0;
    498   \}
    499   menuchange();
    500453\}
    501454
     
    510463           "work properly.");
    511464  \}
     465
     466  if (form.bc1clonecol.selectedIndex == 0) \{
     467    form.bc1clone.value = "0";
     468  \} else \{
     469    form.bc1clone.value = "1";
     470  \}
     471
     472  if (form.bc1clonecol.selectedIndex == selectedindex) \{
     473    form.bc1clonechanged.value = "0";
     474  \} else \{
     475    form.bc1clonechanged.value = "1";
     476  \}
     477\}
     478
     479function more (type) \{
     480  var form = document.collectorform;
     481  if (type == "file") \{
     482    form.bc1filenum.value = form.bc1filenum.value * 2;
     483  \} else if (type == "http") \{
     484    form.bc1httpnum.value = form.bc1httpnum.value * 2;
     485  \} else if (type == "ftp") \{
     486    form.bc1ftpnum.value = form.bc1ftpnum.value * 2;
     487  \}
     488  form.p.value = "srce";
     489  form.submit();
    512490\}
    513491}
     
    518496</center>
    519497<p>_iconblankbar_
    520 
    521 <p>You can either create a completely new collection, or "clone" an existing one
    522 -- that is, base the structure of your new collection on one that exists already.
    523 <ul>
    524 <input type=radio onClick="clone_changed(0);" name=bc1clone value=0
    525 _If_("_cgiargbc1clone_" eq "0",checked)><b>Create new collection</b>
    526 <br><font color="#909090">
    527 Create a completely new collection. The collection may contain html documents (.htm, .html), plain text
    528 documents (.txt, .text), or email documents (.email).
    529 </font>
    530 </ul>
    531 <ul>_If_("_fullnamemenu_" eq "",
    532 No collections available for cloning.,_srcemenu_)
    533 </ul>
     498_If_("_badsources_" eq "1",_srcebadsources_,_srcenewcontent_)
     499}
     500
     501_srcebadsources_ {
     502<p>One or more of the input sources you specified is unavailable.
     503}
     504
     505_srcenewcontent_ {
     506<p>Either use the default structure for your new collection, or base its
     507structure on a collection that exists already.
     508
     509<p>If you use the default structure, the new collection may contain html
     510documents (.htm, .html), plain text documents (.txt, .text), MS Word
     511documents (.doc), PDF documents (.pdf) or email documents (.email).
     512
     513<p>If you base the structure on an existing collection, the files in your
     514new collection must be exactly the same type as those used to build the
     515existing one.
     516
     517<p>Base the collection on
     518_fullnamemenu_
     519<p>_iconblankbar_
    534520}
    535521
     
    550536<input type=hidden name="e" value="_decodedcompressedoptions_">
    551537<input type=hidden name="p" value="_cgiargp_">
     538<input type=hidden name="bc1fromsrce" value="0">
    552539<input type=hidden name="bc1clonechanged" value="0">
    553 <input type=hidden name="bc1aboutdesc" value="_cgiargbc1aboutdesc_">
    554 <input type=hidden name="bc1contactemail" value="_cgiargbc1contactemail_">
     540<input type=hidden name="bc1clone" value="_cgiargbc1clone_">
     541<input type=hidden name="bc1filenum" value="_cgiargbc1filenum_">
     542<input type=hidden name="bc1httpnum" value="_cgiargbc1httpnum_">
     543<input type=hidden name="bc1ftpnum" value="_cgiargbc1ftpnum_">
    555544
    556545<center>
     
    561550
    562551<h4>Input source:</h4>
    563 <nobr>_typeselect_(1,file)<input type=text name="bc1inputdir1" value="_cgiargbc1inputdir1_" size=60></nobr>
    564 <br>
    565 <nobr>_typeselect_(2,http)<input type=text name="bc1inputdir2" value="_cgiargbc1inputdir2_" size=60></nobr>
    566 <br>
    567 <nobr>_typeselect_(3,ftp)<input type=text name="bc1inputdir3" value="_cgiargbc1inputdir3_" size=60></nobr>
    568 <br>
    569 <nobr>_typeselect_(4,file)<input type=text name="bc1inputdir4" value="_cgiargbc1inputdir4_" size=60></nobr>
    570 <br>
    571 <font color="#909090">
    572 These specify where the source data is located.  There are three kinds of
    573 location:
    574 <ul>
    575 <li> a directory name on your computer system (beginning with "file://"),
    576 <li> an address beginning with "http://" for files to be downloaded from the
    577 Web,
    578 <li> an address beginning with "ftp://" for files to be downloaded using FTP
    579 (file transfer protocol).
    580 </ul>
    581 In each case, the collection will include all files of the appropriate type in
    582 the specified directory, in any directories it contains, in any directories
    583 they contain, and so on. 
    584 <p>You can specify up to four different input sources.  If you specify a
    585 filename, just that file will be included.
    586 </font>
     552
     553<table border=0>
     554<tr valign=top><td><b>file://</b></td>
     555<td>_filelist_</td>
     556</tr>
     557<tr valign=top><td><b>http://</b></td>
     558<td>_httplist_</td>
     559</tr>
     560<tr valign=top><td><b>ftp://</b></td>
     561<td>_ftplist_</td>
     562</tr></table>
     563
     564<p>If you use file:// or ftp:// to specify a file, that file will be
     565downloaded.
     566
     567<p>If you use http:// it depends on whether the URL gives you a normal web
     568page in your browser, or a list of files.  If a page, that page will be
     569downloaded -- and so will all pages it links to, and all pages they link
     570to, etc. -- provided they reside on the same site, below the URL.
     571
     572<p>If you use file:// or ftp:// to specify a folder or directory, or give a
     573http:// URL that leads to a list of files, everything in the folder and all
     574its sub-folders will be included in the collection.
     575
     576<p>You can specify sources of more than one type.  To specify several
     577sources of the same type, just click the &quot;more&quot; button to get
     578more input boxes.
    587579
    588580<p>_iconblankbar_
     
    600592
    601593</form>
    602 }
    603 
    604 _typeselect_ {<select name="sel_1_">
    605 <option value="file://" _If_("_2_" eq "file",selected)>file://
    606 <option value="http://" _If_("_2_" eq "http",selected)>http://
    607 <option value="ftp://" _If_("_2_" eq "ftp",selected)>ftp://
    608 </select>}
    609 
    610 _srcemenu_ {<input type=radio name=bc1clone onClick="clone_changed(1);" value=1
    611 _If_("_cgiargbc1clone_" eq "1",checked)><b>Clone existing collection</b>
    612 <br>_fullnamemenu_<br>
    613 <font color=#909090>
    614 This pull-down menu specifies which collection you want to clone.  The files in
    615 your new collection must be exactly the same type as those used to build
    616 the existing one.
    617 </font>
    618594}
    619595
     
    644620<input type=hidden name="p" value="_cgiargp_">
    645621<input type=hidden name="bc1cfgchanged" value="_cgiargbc1cfgchanged_">
    646 <input type=hidden name="bc1aboutdesc" value="_cgiargbc1aboutdesc_">
    647 <input type=hidden name="bc1contactemail" value="_cgiargbc1contactemail_">
    648622
    649623<center>
     
    702676// -->
    703677</script>
     678</head>
     679
    704680<form name="collectorform" method=post action="_gwcgi_">
    705681<input type=hidden name="e" value="_decodedcompressedoptions_">
    706682<input type=hidden name="p" value="_cgiargp_">
    707 <input type=hidden name="bc1aboutdesc" value="_cgiargbc1aboutdesc_">
    708 <input type=hidden name="bc1contactemail" value="_cgiargbc1contactemail_">
    709 
    710 </head>
    711683
    712684<frameset rows="*,160" border=0>
     
    764736<input type=hidden name="e" value="_decodedcompressedoptions_">
    765737<input type=hidden name="p" value="bildcancel">
    766 <input type=hidden name="bc1aboutdesc" value="_cgiargbc1aboutdesc_">
    767 <input type=hidden name="bc1contactemail" value="_cgiargbc1contactemail_">
    768738
    769739<center>
     
    813783<input type=hidden name="e" value="_decodedcompressedoptions_">
    814784<input type=hidden name="p" value="_cgiargp_">
    815 <input type=hidden name="bc1aboutdesc" value="_cgiargbc1aboutdesc_">
    816 <input type=hidden name="bc1contactemail" value="_cgiargbc1contactemail_">
    817785
    818786</form>
     
    870838<form name="collectorform" method=post action="_gwcgi_">
    871839<input type=hidden name="e" value="_decodedcompressedoptions_">
    872 <input type=hidden name="bc1aboutdesc" value="_cgiargbc1aboutdesc_">
    873 <input type=hidden name="bc1contactemail" value="_cgiargbc1contactemail_">
    874840
    875841<center>
     
    924890<input type=hidden name="e" value="_decodedcompressedoptions_">
    925891<input type=hidden name="p" value="_cgiargp_">
    926 <input type=hidden name="bc1aboutdesc" value="_cgiargbc1aboutdesc_">
    927 <input type=hidden name="bc1contactemail" value="_cgiargbc1contactemail_">
    928892
    929893</form>
     
    959923<form name="collectorform" method=post action="_gwcgi_">
    960924<input type=hidden name="e" value="_decodedcompressedoptions_">
    961 <input type=hidden name="bc1aboutdesc" value="_cgiargbc1aboutdesc_">
    962 <input type=hidden name="bc1contactemail" value="_cgiargbc1contactemail_">
    963925
    964926<center>
  • trunk/gsdl/src/recpt/collectoraction.cpp

    r2379 r2401  
    5252  disabled = true;
    5353  do_mkcol = false;
     54  badsources = false;
     55  failedsources.erase(failedsources.begin(), failedsources.end());
    5456  gsdlosc = NULL;
    5557  gsdlhomec = NULL;
     
    140142  argsinfo.addarginfo (NULL, arg_ainfo);
    141143
    142   arg_ainfo.shortname = "bc1inputdir1";
    143   arg_ainfo.longname = "collector specific";
    144   arg_ainfo.multiplechar = true;
    145   arg_ainfo.defaultstatus = cgiarginfo::weak;
    146   arg_ainfo.argdefault = "";
    147   arg_ainfo.savedarginfo = cgiarginfo::mustnot; // saved on disk
    148   argsinfo.addarginfo (NULL, arg_ainfo);
    149 
    150   arg_ainfo.shortname = "bc1inputdir2";
    151   arg_ainfo.longname = "collector specific";
    152   arg_ainfo.multiplechar = true;
    153   arg_ainfo.defaultstatus = cgiarginfo::weak;
    154   arg_ainfo.argdefault = "";
    155   arg_ainfo.savedarginfo = cgiarginfo::mustnot; // saved on disk
    156   argsinfo.addarginfo (NULL, arg_ainfo);
    157 
    158   arg_ainfo.shortname = "bc1inputdir3";
    159   arg_ainfo.longname = "collector specific";
    160   arg_ainfo.multiplechar = true;
    161   arg_ainfo.defaultstatus = cgiarginfo::weak;
    162   arg_ainfo.argdefault = "";
    163   arg_ainfo.savedarginfo = cgiarginfo::mustnot; // saved on disk
    164   argsinfo.addarginfo (NULL, arg_ainfo);
    165 
    166   arg_ainfo.shortname = "bc1inputdir4";
    167   arg_ainfo.longname = "collector specific";
    168   arg_ainfo.multiplechar = true;
    169   arg_ainfo.defaultstatus = cgiarginfo::weak;
    170   arg_ainfo.argdefault = "";
    171   arg_ainfo.savedarginfo = cgiarginfo::mustnot; // saved on disk
    172   argsinfo.addarginfo (NULL, arg_ainfo);
    173 
    174144  // only set when one of the fields was changed in
    175145  // the "collection info" page
     
    226196  arg_ainfo.argdefault = "0";
    227197  arg_ainfo.savedarginfo = cgiarginfo::must;
     198  argsinfo.addarginfo (NULL, arg_ainfo);
     199
     200  arg_ainfo.shortname = "bc1filenum";
     201  arg_ainfo.longname = "collector specific";
     202  arg_ainfo.multiplechar = true;
     203  arg_ainfo.defaultstatus = cgiarginfo::weak;
     204  arg_ainfo.argdefault = "1";
     205  arg_ainfo.savedarginfo = cgiarginfo::mustnot; // saved on disk
     206  argsinfo.addarginfo (NULL, arg_ainfo);
     207
     208  arg_ainfo.shortname = "bc1httpnum";
     209  arg_ainfo.longname = "collector specific";
     210  arg_ainfo.multiplechar = true;
     211  arg_ainfo.defaultstatus = cgiarginfo::weak;
     212  arg_ainfo.argdefault = "1";
     213  arg_ainfo.savedarginfo = cgiarginfo::mustnot; // saved on disk
     214  argsinfo.addarginfo (NULL, arg_ainfo);
     215
     216  arg_ainfo.shortname = "bc1ftpnum";
     217  arg_ainfo.longname = "collector specific";
     218  arg_ainfo.multiplechar = true;
     219  arg_ainfo.defaultstatus = cgiarginfo::weak;
     220  arg_ainfo.argdefault = "1";
     221  arg_ainfo.savedarginfo = cgiarginfo::mustnot; // saved on disk
     222  argsinfo.addarginfo (NULL, arg_ainfo);
     223
     224  arg_ainfo.shortname = "bc1fileinput";
     225  arg_ainfo.longname = "collector specific";
     226  arg_ainfo.multiplechar = true;
     227  arg_ainfo.multiplevalue = true;
     228  arg_ainfo.defaultstatus = cgiarginfo::weak;
     229  arg_ainfo.argdefault = "";
     230  arg_ainfo.savedarginfo = cgiarginfo::mustnot; // saved on disk
     231  argsinfo.addarginfo (NULL, arg_ainfo);
     232
     233  arg_ainfo.shortname = "bc1httpinput";
     234  arg_ainfo.longname = "collector specific";
     235  arg_ainfo.multiplechar = true;
     236  arg_ainfo.multiplevalue = true;
     237  arg_ainfo.defaultstatus = cgiarginfo::weak;
     238  arg_ainfo.argdefault = "";
     239  arg_ainfo.savedarginfo = cgiarginfo::mustnot; // saved on disk
     240  argsinfo.addarginfo (NULL, arg_ainfo);
     241
     242  arg_ainfo.shortname = "bc1ftpinput";
     243  arg_ainfo.longname = "collector specific";
     244  arg_ainfo.multiplechar = true;
     245  arg_ainfo.multiplevalue = true;
     246  arg_ainfo.defaultstatus = cgiarginfo::weak;
     247  arg_ainfo.argdefault = "";
     248  arg_ainfo.savedarginfo = cgiarginfo::mustnot; // saved on disk
     249  argsinfo.addarginfo (NULL, arg_ainfo);
     250
     251  // will be set when we've just come from the "source data" page
     252  arg_ainfo.shortname = "bc1fromsrce";
     253  arg_ainfo.longname = "collector specific";
     254  arg_ainfo.multiplechar = false;
     255  arg_ainfo.defaultstatus = cgiarginfo::weak;
     256  arg_ainfo.argdefault = "0";
     257  arg_ainfo.savedarginfo = cgiarginfo::mustnot;
    228258  argsinfo.addarginfo (NULL, arg_ainfo);
    229259}
     
    323353    enum source_t {default_arg, compressed_arg, cgi_arg, program_arg};
    324354    text_tmap saved_args;
    325     saved_args["bc1inputdir1"] = "";
    326     saved_args["bc1inputdir2"] = "";
    327     saved_args["bc1inputdir3"] = "";
    328     saved_args["bc1inputdir4"] = "";
    329355    saved_args["bc1fullname"] = "";
    330356    saved_args["bc1contactemail"] = "";
    331357    saved_args["bc1aboutdesc"] = "";
    332358    saved_args["bc1clone"] = "";
     359    saved_args["bc1clonecol"] = "";
     360    saved_args["bc1filenum"] = "";
     361    saved_args["bc1httpnum"] = "";
     362    saved_args["bc1ftpnum"] = "";
     363    saved_args["bc1fileinput"] = "";
     364    saved_args["bc1httpinput"] = "";
     365    saved_args["bc1ftpinput"] = "";
    333366
    334367    // update the argdb database with any arguments that were set
     
    465498      }
    466499      delete fbldc;
     500    }
     501  }
     502
     503  if (args["bc1fromsrce"] == "1") {
     504
     505    // we've just come from the "source data" page so we need to check that
     506    // input sources are valid
     507    if (!check_sources(args, logout)) {
     508      args["p"] = "srce";
    467509    }
    468510  }
     
    701743}
    702744
    703 // set the _fullnamemenu_ macro (and _warnindex_ if we're on the "srce" page)
     745// set the _fullnamemenu_ macro (and _warnindex_ and _selectedindex_ if
     746// we're on the "srce" page)
    704747void collectoraction::set_fullnamemenu (displayclass &disp, cgiargsclass &args,
    705748                    recptprotolistclass *protos, ostream &logout) {
     
    719762  text_tarray fullnames;
    720763  vector<bool> write_protected;
     764  bool is_selected = false;
    721765  int selected_index = 0;
    722766  int index = 0;
     
    727771    if ((*rprotolist_here).p != NULL) {
    728772
    729       // don't include z39.50 collection
     773      // don't include z39.50 collections
    730774      comerror_t err = noError;
    731775      if ((*rprotolist_here).p->get_protocol_name (err) == "z3950proto") {
     
    760804        else write_protected.push_back(false);
    761805
    762         if (*collist_here == currentname) selected_index = index;       
     806        if (*collist_here == currentname) {
     807          is_selected = true;
     808          selected_index = index;       
     809        }
    763810        index ++;
    764811      }
     
    773820  text_t warnindex;
    774821  text_t fullnamemenu = "<select name=\"bc1dirname\">\n";
    775   if (current_page == "srce") fullnamemenu = "<select name=\"bc1clonecol\" onChange=\"menuchange();\">\n";
     822  if (current_page == "srce") {
     823    fullnamemenu = "<select name=\"bc1clonecol\" onChange=\"menuchange();\">\n";
     824    fullnamemenu += "<option value=defaultstructure";
     825    if (!is_selected) fullnamemenu += " selected>";
     826    else fullnamemenu.push_back('>');
     827    fullnamemenu += "default structure\n";
     828  }
    776829  for (int i = 0; i < index; i ++) {
    777830    // don't want write protected collections in list on "change existing
     
    779832    if (write_protected[i] && current_page == "existing") continue;
    780833    fullnamemenu += "<option value=\"" + dirnames[i] + "\"";
    781     if (i == selected_index) fullnamemenu += " selected";
     834    if ((i == 0 && !is_selected && current_page != "srce") ||
     835    (is_selected && i == selected_index)) {
     836      fullnamemenu += " selected";
     837      selected_index++;
     838      is_selected = false;
     839    }
    782840    fullnamemenu.push_back ('>');
    783841    fullnamemenu += fullnames[i];
     
    787845    // (if creating clone collection list)
    788846    if (current_page == "srce") {
    789       if (!first) warnindex.push_back(',');
     847      if (first) warnindex += "0,";
     848      else warnindex.push_back(',');
    790849      if (uses_weird_plugin (dirnames[i])) {
    791850    warnindex += text_t (1);
     
    798857  fullnamemenu += "</select>\n";
    799858
    800   if (!first) {
    801     disp.setmacro ("fullnamemenu", "collector", fullnamemenu);
    802     if (current_page == "srce")
    803       disp.setmacro ("warnindex", "collector", warnindex);
    804   }
     859  disp.setmacro ("fullnamemenu", "collector", fullnamemenu);
     860  if (current_page == "srce") {
     861    disp.setmacro ("warnindex", "collector", warnindex);
     862    disp.setmacro ("selectedindex", "collector", text_t(selected_index));
     863  }
     864}
     865
     866// set _filelist_, _httplist_, _ftplist_ and _badsources_ macros
     867void collectoraction::set_inputsourceboxes (displayclass &disp, cgiargsclass &args,
     868                        ostream &logout) {
     869 
     870  if (badsources) disp.setmacro ("badsources", "collector", "1");
     871
     872  int numfileboxes = args["bc1filenum"].getint();
     873  int numhttpboxes = args["bc1httpnum"].getint();
     874  int numftpboxes = args["bc1ftpnum"].getint();
     875
     876  text_t filelist = get_source_box(args["bc1fileinput"], numfileboxes, "file");
     877  text_t httplist = get_source_box(args["bc1httpinput"], numhttpboxes, "http");
     878  text_t ftplist = get_source_box(args["bc1ftpinput"], numftpboxes, "ftp");
     879
     880  disp.setmacro("filelist", "collector", dm_safe(filelist));
     881  disp.setmacro("httplist", "collector", dm_safe(httplist));
     882  disp.setmacro("ftplist", "collector", dm_safe(ftplist));
     883
     884  // reset badsources and failedsources variables
     885  badsources = false;
     886  failedsources.erase(failedsources.begin(), failedsources.end());
     887}
     888
     889text_t collectoraction::get_source_box (text_t inputarg, int numboxes, text_t boxtype) {
     890
     891  text_tarray files;
     892  // this relies on filenames/URLs/ftp addresses not being able to contain
     893  // commas
     894  splitchar (inputarg.begin(), inputarg.end(), ',', files);
     895
     896  text_t rv = "<table border=0>\n";
     897  for (int i = 0; i < numboxes; i++) {
     898    rv += "<tr><td><input type=text name=\"bc1" + boxtype + "input\" value=\"";
     899    if (i < files.size()) {
     900      rv += files[i];
     901    }
     902    rv += "\" size=50></td>";
     903    if (badsources) {
     904      if ((i < files.size()) && (!files[i].empty())) {
     905    if (failedsources[files[i]] == "1") {
     906      rv += "<td width=40>no</td>";
     907    } else {
     908      rv += "<td width=40>yes</td>";
     909    }
     910      } else {
     911    rv += "<td width=40></td>";
     912      }
     913    }
     914    if (i+1 == numboxes) {
     915      rv += "<td><a href=\"javascript:more('" + boxtype + "')\">more</a></td></tr>\n";
     916    } else {
     917      rv += "<td></td></tr>\n";
     918    }
     919  }
     920  rv += "</table>\n";
     921 
     922  return rv;
    805923}
    806924
     
    836954   
    837955    // define it as a macro
    838     disp.setmacro("cfgfile","collector",dm_safe(cfgtext));
     956    disp.setmacro("cfgfile", "collector", dm_safe(cfgtext));
    839957
    840958  } else {
     
    8871005  // _gsdlhome_ - the gsdlhome path (dm_safe)
    8881006
     1007  // _filelist_ -- these three display "input source" text boxes
     1008  // _httplist_ -- for the "source data" page
     1009  // _ftplist_  --
     1010
     1011  // _badsources_ -- will be set to "1" if we've come from the
     1012  //                 "source data" page and there's a problem
     1013  //                 with the input sources
     1014
    8891015  text_t &collector_page = args["p"];
    8901016  int esrce = args["bc1esrce"].getint();
     
    10301156  if (collector_page == "bildstatus")
    10311157    set_statusline (disp, args, logout);
     1158  if (collector_page == "srce") {
     1159    set_inputsourceboxes (disp, args, logout);
     1160  }
    10321161
    10331162  disp.setmacro ("gsdlhome", "collector", dm_safe(gsdlhome));
     
    15071636  }
    15081637
    1509   if (!args["bc1inputdir1"].empty())
    1510     options += " -download \"" + args["bc1inputdir1"] + "\"";
    1511   if (!args["bc1inputdir2"].empty())
    1512     options += " -download \"" + args["bc1inputdir2"] + "\"";
    1513   if (!args["bc1inputdir3"].empty())
    1514     options += " -download \"" + args["bc1inputdir3"] + "\"";
    1515   if (!args["bc1inputdir4"].empty())
    1516     options += " -download \"" + args["bc1inputdir4"] + "\"";
     1638  text_tarray files;
     1639  text_t filevals = args["bc1fileinput"];
     1640  // this relies on filenames not being able to contain commas
     1641  splitchar (filevals.begin(), filevals.end(), ',', files);
     1642  text_tarray::const_iterator here = files.begin();
     1643  text_tarray::const_iterator end = files.end();
     1644  while (here != end) {
     1645    options += " -download \"" + *here + "\"";
     1646    here ++;
     1647  }
     1648  text_tarray https;
     1649  text_t httpvals = args["bc1httpinput"];
     1650  // this relies on URLs not being able to contain commas
     1651  splitchar (httpvals.begin(), httpvals.end(), ',', https);
     1652  here = https.begin();
     1653  end = https.end();
     1654  while (here != end) {
     1655    options += " -download \"" + *here + "\"";
     1656    here ++;
     1657  }
     1658  text_tarray ftps;
     1659  text_t ftpvals = args["bc1ftpinput"];
     1660  // this relies on ftp addresses not being able to contain commas
     1661  splitchar (ftpvals.begin(), ftpvals.end(), ',', ftps);
     1662  here = ftps.begin();
     1663  end = ftps.end();
     1664  while (here != end) {
     1665    options += " -download \"" + *here + "\"";
     1666    here ++;
     1667  }
    15171668
    15181669  if (logevents) {
     
    17071858  return header;
    17081859}
     1860
     1861bool collectoraction::check_sources (cgiargsclass &args, ostream &logout) {
     1862
     1863  bool found = false;
     1864
     1865  // check local filesystem for file:// sources
     1866  text_tarray files;
     1867  text_t filevals = args["bc1fileinput"];
     1868  // this relies on filenames not being able to contain commas
     1869  splitchar (filevals.begin(), filevals.end(), ',', files);
     1870  text_tarray::const_iterator here = files.begin();
     1871  text_tarray::const_iterator end = files.end();
     1872  while (here != end) {
     1873    text_t file = format_url(*here);
     1874    if (!file_exists(file) && !directory_exists(file)) {
     1875      failedsources[*here] = "1";
     1876      badsources = true;
     1877    }
     1878    found = true;
     1879    here ++;
     1880  }
     1881
     1882  // ping http:// sources
     1883  files.erase(files.begin(), files.end());
     1884  text_t httpvals = args["bc1httpinput"];
     1885  // this relies on URLs not being able to contain commas
     1886  splitchar (httpvals.begin(), httpvals.end(), ',', files);
     1887  here = files.begin();
     1888  end = files.end();
     1889  while (here != end) {
     1890    if (gsdl_system ("perl -S ping.pl -quiet http://" + format_url(*here), true, logout)) {
     1891      failedsources[*here] = "1";
     1892      badsources = true;
     1893    }
     1894    found = true;
     1895    here++;
     1896  }
     1897
     1898  // ping ftp:// sources
     1899  files.erase(files.begin(), files.end());
     1900  text_t ftpvals = args["bc1ftpinput"];
     1901  // this relies on FTP addresses not being able to contain commas
     1902  splitchar (ftpvals.begin(), ftpvals.end(), ',', files);
     1903  here = files.begin();
     1904  end = files.end();
     1905  while (here != end) {
     1906    if (gsdl_system ("perl -S ping.pl -quiet ftp://" + format_url(*here), true, logout)) {
     1907      failedsources[*here] = "1";
     1908      badsources = true;
     1909    }
     1910    found = true;
     1911    here++;
     1912  }
     1913
     1914  // set badsources if there weren't any sources at all
     1915  if (!found) badsources = true;
     1916
     1917  if (badsources) return false;
     1918  return true;
     1919}
     1920
     1921// format_url simply strips "http://", "ftp://", or "file://" off the
     1922// beginning of url if they're there
     1923text_t collectoraction::format_url (const text_t &url) {
     1924  text_t::const_iterator begin = url.begin();
     1925  text_t::const_iterator end = url.end();
     1926
     1927  if (url.size() >= 7) {
     1928    text_t prefix = substr(begin, begin+7);
     1929    if (prefix == "http://" || prefix == "file://") {
     1930      return substr(begin+7, end);
     1931    }
     1932  }
     1933  if (url.size() >= 6) {
     1934    if (substr(begin, begin+6) == "ftp://") {
     1935      return substr(begin+6, end);
     1936    }
     1937  }
     1938  return url;
     1939}
  • trunk/gsdl/src/recpt/collectoraction.h

    r1778 r2401  
    4545  bool do_mkcol;
    4646
     47  bool badsources;
     48  text_tmap failedsources;
     49
    4750  text_t get_button (const text_t &thispage, const text_t &color,
    4851             const text_t &type, bool enabled);
     
    5053  void set_fullnamemenu (displayclass &disp, cgiargsclass &args,
    5154             recptprotolistclass *protos, ostream &logout);
     55
     56  void set_inputsourceboxes (displayclass &disp, cgiargsclass &args,
     57                 ostream &logout);
     58
     59  text_t get_source_box (text_t inputarg, int numboxes, text_t boxtype);
    5260
    5361  void set_cfgfile (displayclass &disp, cgiargsclass &args, ostream &logout);
     
    8896  text_t get_event_header (cgiargsclass &args);
    8997
     98  bool check_sources (cgiargsclass &args, ostream &logout);
     99
     100  text_t format_url (const text_t &url);
     101
    90102public:
    91103  collectoraction ();
Note: See TracChangeset for help on using the changeset viewer.