Changeset 11998


Ignore:
Timestamp:
2006-07-04T15:23:58+12:00 (18 years ago)
Author:
davidb
Message:

First cut at 'The Depositor' -- Greenstone support for institutional
repositories

Location:
trunk/gsdl/src/recpt
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/Makefile.in

    r11441 r11998  
    5555       -I../../packages/mg/lib -I../../packages/mg/src/text \
    5656           -I../../packages/expat/include \
     57           -I../../packages/cgicc/include \
    5758       -I../mgpp/lib -I../mgpp/text -I../..
    5859else
     
    6162       -I../../packages/mg/lib -I../../packages/mg/src/text \
    6263           -I../../packages/expat/include \
     64           -I../../packages/cgicc/include \
    6365           -I../../packages/fcgi/include -I../mgpp/lib \
    6466       -I../mgpp/text -I../..
     
    9395LDFLAGS = @LDFLAGS@
    9496GDBM_LIBS=@GDBM_LIBPATH@ -lgdbm
    95 LIBS = $(GDBM_LIBS) $(LC_LIBS) @LIBS@
     97LIBS = $(GDBM_LIBS) $(LC_LIBS) -L../../packages/cgicc/lib -lcgicc @LIBS@
    9698GSDLOS = @gsdlos@
    9799INSTALL = @INSTALL@
     
    109111
    110112# in case gdbm.h/libgdbm.a are in a non-standard place...
    111 GDBM_OBJS=argdb.o authenaction.o collectoraction.o infodbclass.o userdb.o usersaction.o historydb.o librarymain.o nullproto.o queryaction.o z3950proto.o
     113GDBM_OBJS=argdb.o authenaction.o collectoraction.o depositoraction.o wizardaction.o infodbclass.o userdb.o usersaction.o historydb.o librarymain.o nullproto.o queryaction.o z3950proto.o
    112114
    113115ifeq ($(USE_CORBA), 1)
     
    154156                userdb.h usersaction.h vlistbrowserclass.h hlistbrowserclass.h \
    155157        datelistbrowserclass.h invbrowserclass.h pagedbrowserclass.h \
    156         htmlbrowserclass.h phindbrowserclass.h historydb.h collectoraction.h \
     158        htmlbrowserclass.h phindbrowserclass.h historydb.h collectoraction.h depositoraction.h wizardaction.h \
    157159        phindaction.h summarise.h highlighttext.h gtiaction.h
    158160
     
    176178        vlistbrowserclass.cpp hlistbrowserclass.cpp datelistbrowserclass.cpp \
    177179        invbrowserclass.cpp pagedbrowserclass.cpp htmlbrowserclass.cpp \
    178         phindbrowserclass.cpp  historydb.cpp collectoraction.cpp argdb.cpp \
     180        phindbrowserclass.cpp  historydb.cpp collectoraction.cpp depositoraction.cpp wizardaction.cpp argdb.cpp \
    179181        browseactiontools.h formattools.cpp phindaction.cpp summarise.cpp \
    180182        highlighttext.cpp gtiaction.cpp
     
    210212        hlistbrowserclass.o datelistbrowserclass.o invbrowserclass.o \
    211213        pagedbrowserclass.o htmlbrowserclass.o phindbrowserclass.o \
    212         historydb.o $(Z_COMOBJS) collectoraction.o phindaction.o \
     214        historydb.o $(Z_COMOBJS) collectoraction.o depositoraction.o wizardaction.o phindaction.o \
    213215        summarise.o highlighttext.o gtiaction.o
    214216
  • trunk/gsdl/src/recpt/cgiutils.cpp

    r11259 r11998  
    2626#include "cgiutils.h"
    2727#include "gsdlunicode.h"
     28#include "fileutil.h"
    2829#include "unitool.h" // in mg, for output_utf8_char
     30
    2931
    3032static unsigned short hexdigit (unsigned short c) {
     
    120122  text_t::const_iterator end = argstr.end();
    121123  text_t key, value;
    122  
     124
     125  text_tset multivalue;
     126
     127 
    123128  // extract out the key=value pairs
    124129  while (here != end) {
     
    140145      // again before use) - it should use an array instead
    141146      const cgiarginfo *info = argsinfo.getarginfo (key);
    142       if (info != NULL && info->multiplevalue) {
    143     text_t newvalue = args[key];
    144     if (args.lookupcgiarg(key).source == cgiarg_t::cgi_arg) newvalue += ",";
    145     newvalue += encode_commas(value);
    146     args.setarg (key, newvalue, cgiarg_t::cgi_arg);
    147 
    148       } else {
    149     args.setarg (key, value, cgiarg_t::cgi_arg);
     147
     148      if (info==NULL) {
     149    if (args.getarg(key)==NULL) {
     150      args.setarg (key, encode_commas(value), cgiarg_t::cgi_arg);
     151    }
     152    else {
     153      text_t newvalue = args[key];
     154
     155      newvalue += "," + encode_commas(value);
     156      args.setarg (key, newvalue, cgiarg_t::cgi_arg);
     157    }
     158      }
     159      else {
     160    if (info->multiplevalue) {
     161
     162      text_t newvalue = args[key];
     163      if (args.lookupcgiarg(key).source == cgiarg_t::cgi_arg) newvalue += ",";
     164      newvalue += encode_commas(value);
     165      args.setarg (key, newvalue, cgiarg_t::cgi_arg);
     166
     167    } else {
     168      args.setarg (key, value, cgiarg_t::cgi_arg);
     169    }
    150170      }
    151171    }
  • trunk/gsdl/src/recpt/cgiwrapper.cpp

    r9620 r11998  
    4242#endif
    4343
     44#include "cgicc/Cgicc.h"
     45
     46using namespace cgicc;
     47extern Cgicc* formData;
     48
     49
    4450#ifdef USE_FASTCGI
    4551#include "fcgiapp.h"
     
    467473  char *aURIStr;
    468474  if (!isfastcgi) {
    469     char *request_method_str = getenv("REQUEST_METHOD");
    470     char *content_length_str = getenv("CONTENT_LENGTH");
    471     if (request_method_str != NULL && strcmp(request_method_str, "POST") == 0 &&
    472     content_length_str != NULL)  {
    473       // POST form data
    474       int content_length = text_t(content_length_str).getint();
    475       if (content_length > 0) {
    476     char c;
    477     do {
    478       cin.get(c);
    479       if (cin.eof()) break;
    480       argstr.push_back (c);
    481       --content_length;
    482     } while (content_length > 0);
     475
     476   
     477    // Iterate through the vector, and synthesis argstr
     478    bool first = true;
     479
     480    for(const_form_iterator iter = formData->getElements().begin();
     481    iter != formData->getElements().end();
     482    ++iter) {
     483     
     484      const char* name_cstr = iter->getName().c_str();
     485      const char* value_cstr = iter->getValue().c_str();
     486      if (first) {
     487   
     488    argstr = name_cstr;
     489    argstr.append("=");
     490    argstr.append(value_cstr);
     491    first = false;
    483492      }
    484      
    485     } else {
    486       aURIStr = getenv("QUERY_STRING");
    487       if ((request_method_str != NULL && strcmp(request_method_str, "GET") == 0)
    488       || aURIStr != NULL) {
    489     // GET form data
    490     if (aURIStr != NULL) argstr = aURIStr;
    491       } else {
    492     // debugging from command line
    493     debug = true;
     493      else {
     494    argstr.append("&");
     495    argstr.append(name_cstr);
     496    argstr.append("=");
     497    argstr.append(value_cstr);
    494498      }
    495     }
     499    }   
    496500  }
    497501
  • trunk/gsdl/src/recpt/collectoraction.cpp

    r11166 r11998  
    5656#endif
    5757
    58 collectoraction::collectoraction () {
    59 
    60   recpt = NULL;
    61   disabled = true;
     58collectoraction::collectoraction ()
     59  : wizardaction()
     60{
     61  macro_prefix = "bc1";
     62
    6263  do_mkcol = false;
    6364  badsources = false;
    6465  failedsources.erase(failedsources.begin(), failedsources.end());
    65   gsdlosc = NULL;
    66   gsdlhomec = NULL;
    67   pathc = NULL;
    6866
    6967  cgiarginfo arg_ainfo;
     
    245243
    246244collectoraction::~collectoraction () {
    247   if (gsdlosc != NULL) delete []gsdlosc;
    248   if (gsdlhomec != NULL) delete []gsdlhomec;
    249   if (pathc != NULL) delete []pathc;
    250245}
    251246
    252247
    253 void collectoraction::configure (const text_t &key, const text_tarray &cfgline) {
    254   if ((key == "collector") && (cfgline.size() == 1) &&
    255       (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
    256     disabled = false;
    257   } else {
    258     // call the parent class to deal with the things which
    259     // are not dealt with here
    260     action::configure (key, cfgline);
    261   }
    262 }
    263 
    264 
    265 bool collectoraction::init (ostream & /*logout*/) {
    266 
    267   // set up GSDLOS, GSDLHOME and PATH environment variables
    268   text_t gsdlos, path;
    269   unsigned int path_separator = ':';
    270 #if defined (__WIN32__)
    271   gsdlos = "windows";
    272   path_separator = ';';
    273 
    274   path = filename_cat (gsdlhome, "bin", "windows", "perl", "bin;");
    275 
    276 #else
    277   struct utsname *buf = new struct utsname();
    278   int i = uname (buf);
    279   if (i == -1) gsdlos = "linux"; // uname failed
    280   else gsdlos.setcstr (buf->sysname);
    281   delete buf;
    282   lc (gsdlos);
    283 #endif
    284 
    285   pathc = getenv ("PATH");
    286   path += filename_cat (gsdlhome, "bin", gsdlos);
    287   path.push_back (path_separator);
    288   path += filename_cat (gsdlhome, "bin", "script");
    289   if (pathc != NULL) {
    290     path.push_back (path_separator);
    291     path += pathc;
    292   }
    293   path = "PATH=" + path;
    294 
    295   gsdlos = "GSDLOS=" + gsdlos;
    296   text_t setgsdlhome = "GSDLHOME=" + gsdlhome;
    297 
    298   // these will be cleaned up in the destructor
    299   gsdlosc = gsdlos.getcstr();
    300   gsdlhomec = setgsdlhome.getcstr();
    301   pathc = path.getcstr();
    302  
    303   putenv (gsdlosc);
    304   putenv (gsdlhomec);
    305   putenv (pathc);
    306 
    307   return true;
    308 }
    309248
    310249bool collectoraction::check_cgiargs (cgiargsinfoclass &argsinfo, cgiargsclass &args,
     
    335274    // clean up any old builds left laying about in the tmp directory
    336275    // (note that it's possible this could take some time if there's a huge
    337     // partially built collection laying about so we'll make it an asynchronous
     276    // partially built collecton laying about so we'll make it an asynchronous
    338277    // system call)
    339278    gsdl_system ("perl -S cleantmp.pl", false, logout);
     
    710649}
    711650
    712 void collectoraction::get_cgihead_info (cgiargsclass &/*args*/, recptprotolistclass * /*protos*/,
    713                     response_t &response,text_t &response_data,
    714                     ostream &/*logout*/) {
    715   response = content;
    716   response_data = "text/html";
    717 }
    718651
    719652// return html for buttons used in collector bar
     
    728661// will be hyperlinked
    729662
    730 text_t collectoraction::get_button(const text_t &thispage, const text_t &color,
    731                     const text_t &type, bool enabled) {
    732 
    733   if ((color != "green" && color != "grey" && color != "yellow") ||
    734       (type != "info" && type != "srce" && type != "conf" && type != "bild" && type != "view"))
    735     return g_EmptyText;
    736 
    737   text_t href = "_http"+type+"_";
    738   text_t target = "";
    739   if (thispage == "info" || thispage == "srce" || thispage == "conf" ||
    740       thispage == "bildcancel" || thispage == "bildfail") {
    741     // call the check submit macro instead of linking directly to the page
    742     href="\"javascript:check_submit('"+type+"');\"";
    743   } else if (type == "view") {
    744     // view button is special case as it needs a target=_top
    745     target = " target=_top";
    746   }
    747  
    748   text_t tdclass = "collectorbar"+color;
    749   if (enabled) {
    750     // link to the appropriate page
    751     return "<td class="+tdclass+"><a href="+href+target+">_text"+type+"_</a></td>";
    752   }
    753   else {
    754     // just display the text
    755     return "<td class="+tdclass+">_text"+type+"_</td>";
    756   }
    757 }
    758 
     663// Wendy left a comment suggesting this be move, but where to
     664// was not specified.  Into wizardaction.cpp?
    759665
    760666// set the _fullnamemenu_ macro (and _warnindex_ and _selectedindex_ if
     
    771677
    772678  text_t &current_page = args["p"];
    773   text_t currentname = args["bc1dirname"];
    774   if (current_page == "srce") currentname = args["bc1clonecol"];
     679  text_t currentname = args[macro_prefix+"dirname"];
     680  if (current_page == "srce") currentname = args[macro_prefix + "clonecol"];
    775681
    776682  text_tarray dirnames;
     
    825731
    826732  bool first = true;
     733
    827734  text_t warnindex;
    828   text_t fullnamemenu = "<select name=\"bc1dirname\">\n";
     735  text_t fullnamemenu = "<select name=\""+macro_prefix+"dirname\" onChange=\"menuchange();\">\n";
     736
    829737  if (current_page == "srce") {
    830     fullnamemenu = "<select name=\"bc1clonecol\" onChange=\"menuchange();\">\n";
     738    fullnamemenu = "<select name=\""+macro_prefix+"clonecol\" onChange=\"menuchange();\">\n";
    831739    fullnamemenu += "<option value=defaultstructure";
    832740    if (!is_selected) fullnamemenu += " selected>";
     
    834742    fullnamemenu += "_collector:textdefaultstructure_\n";
    835743  }
     744
     745  fullnamemenu += "<option value=\"\"></option>\n";
     746
    836747  for (int i = 0; i < index; ++i) {
    837748    // don't want write protected collections in list on "change existing
     
    863774  }
    864775  fullnamemenu += "</select>\n";
    865 
    866   disp.setmacro ("fullnamemenu", "collector", fullnamemenu);
     776  text_t action_name = get_action_name();
     777  disp.setmacro ("fullnamemenu", action_name, fullnamemenu);
    867778  if (current_page == "srce") {
    868     disp.setmacro ("warnindex", "collector", warnindex);
    869     disp.setmacro ("selectedindex", "collector", text_t(selected_index));
     779    disp.setmacro ("warnindex",action_name , warnindex);
     780    disp.setmacro ("selectedindex", action_name, text_t(selected_index));
    870781  }
    871782}
     783
    872784
    873785// set _sourcelist_ and _badsources_ macros
     
    1005917}
    1006918
    1007 // set the _statusline_ macro
    1008 void collectoraction::set_statusline (displayclass &disp, cgiargsclass &args, ostream & /*logout*/) {
    1009 
    1010   // the build command creates .bld.download, .bld.import, and .bld.build files (in that
    1011   // order) and deletes them (also in that order) when each stage is complete. the .bld
    1012   // file is the concatenation of all these files.
    1013   text_t bld_file = filename_cat (gsdlhome, "tmp", args["bc1tmp"], args["bc1dirname"] + ".bld");
    1014   text_t statusline;
    1015 
    1016   if (file_exists (bld_file + ".download")) {
    1017     statusline = "_collector:textdownloadingfiles_<br>\n";
    1018     statusline += dm_safe(file_tail(bld_file + ".download", 1, 0));
    1019   } else if (file_exists (bld_file + ".import")) {
    1020     statusline = "_collector:textimportingcollection_<br>\n";
    1021     statusline += dm_safe(file_tail(bld_file + ".import", 1, 0));
    1022   } else if (file_exists (bld_file + ".build")) {
    1023     statusline = "_collector:textbuildingcollection_<br>\n";
    1024     statusline += dm_safe(file_tail(bld_file + ".build", 1, 0));
    1025   } else {
    1026     statusline += "_collector:textcreatingcollection_<br>\n";
    1027     statusline += dm_safe(file_tail(bld_file, 1, 0));
    1028   }
    1029 
    1030   disp.setmacro ("statusline", "collector", statusline);
    1031 
    1032 }
    1033919
    1034920void collectoraction::define_internal_macros (displayclass &disp, cgiargsclass &args,
     
    1065951
    1066952  // set the collectorbar macro
    1067   text_t collectorbar = "<table class=collectorbar border=0 cellspacing=4 cellpadding=0><tr>\n";
     953  text_t collectorbar = "<table class=wizardbar border=0 cellspacing=4 cellpadding=0><tr>\n";
    1068954
    1069955  if (collector_page == "new") {
    1070956    collectorbar += "<td>_icongreyarrow_</td>\n";
    1071     collectorbar += get_button (collector_page, "green", "info", true);
    1072     collectorbar += "<td>_icongreyarrow_</td>\n";
    1073     collectorbar += get_button (collector_page, "grey", "srce", false);
    1074     collectorbar += "<td>_icongreyarrow_</td>\n";
    1075     collectorbar += get_button (collector_page, "grey", "conf", false);
    1076     collectorbar += "<td>_icongreyarrow_</td>\n";
    1077     collectorbar += get_button (collector_page, "grey", "bild", false);
    1078     collectorbar += "<td>_icongreyarrow_</td>\n";
    1079     collectorbar += get_button (collector_page, "grey", "view", false);
     957    collectorbar += get_button (args,collector_page, "green", "info", true);
     958    collectorbar += "<td>_icongreyarrow_</td>\n";
     959    collectorbar += get_button (args,collector_page, "grey", "srce", false);
     960    collectorbar += "<td>_icongreyarrow_</td>\n";
     961    collectorbar += get_button (args,collector_page, "grey", "conf", false);
     962    collectorbar += "<td>_icongreyarrow_</td>\n";
     963    collectorbar += get_button (args,collector_page, "grey", "bild", false);
     964    collectorbar += "<td>_icongreyarrow_</td>\n";
     965    collectorbar += get_button (args,collector_page, "grey", "view", false);
    1080966
    1081967  } else if (collector_page == "info") {
    1082968    collectorbar += "<td>_icongreyarrow_</td>\n";
    1083     collectorbar += get_button (collector_page, "yellow", "info", false);
    1084     collectorbar += "<td>_icongreyarrow_</td>\n";
    1085     collectorbar += get_button (collector_page, "green", "srce", true);
    1086     collectorbar += "<td>_icongreyarrow_</td>\n";
    1087     collectorbar += get_button (collector_page, "grey", "conf", false);
    1088     collectorbar += "<td>_icongreyarrow_</td>\n";
    1089     collectorbar += get_button (collector_page, "grey", "bild", false);
    1090     collectorbar += "<td>_icongreyarrow_</td>\n";
    1091     collectorbar += get_button (collector_page, "grey", "view", false);
     969    collectorbar += get_button (args,collector_page, "yellow", "info", false);
     970    collectorbar += "<td>_icongreyarrow_</td>\n";
     971    collectorbar += get_button (args,collector_page, "green", "srce", true);
     972    collectorbar += "<td>_icongreyarrow_</td>\n";
     973    collectorbar += get_button (args,collector_page, "grey", "conf", false);
     974    collectorbar += "<td>_icongreyarrow_</td>\n";
     975    collectorbar += get_button (args,collector_page, "grey", "bild", false);
     976    collectorbar += "<td>_icongreyarrow_</td>\n";
     977    collectorbar += get_button (args,collector_page, "grey", "view", false);
    1092978    collectorbar += "</tr><tr><td></td><td align=center>_icongreyuparrow_</td><td colspan=8></td>\n";
    1093979
     
    1097983      // if we came from the "change an existing collection" page previous button(s)
    1098984      // are disabled
    1099       collectorbar += get_button (collector_page, "grey", "info", false);
     985      collectorbar += get_button (args,collector_page, "grey", "info", false);
    1100986    } else {
    1101       collectorbar += get_button (collector_page, "yellow", "info", true);
    1102     }
    1103     collectorbar += "<td>_icongreyarrow_</td>\n";
    1104     collectorbar += get_button (collector_page, "yellow", "srce", false);
    1105     collectorbar += "<td>_icongreyarrow_</td>\n";
    1106     collectorbar += get_button (collector_page, "green", "conf", true);
    1107     collectorbar += "<td>_icongreyarrow_</td>\n";
    1108     collectorbar += get_button (collector_page, "green", "bild", true);
    1109     collectorbar += "<td>_icongreyarrow_</td>\n";
    1110     collectorbar += get_button (collector_page, "grey", "view", false);
     987      collectorbar += get_button (args,collector_page, "yellow", "info", true);
     988    }
     989    collectorbar += "<td>_icongreyarrow_</td>\n";
     990    collectorbar += get_button (args,collector_page, "yellow", "srce", false);
     991    collectorbar += "<td>_icongreyarrow_</td>\n";
     992    collectorbar += get_button (args,collector_page, "green", "conf", true);
     993    collectorbar += "<td>_icongreyarrow_</td>\n";
     994    collectorbar += get_button (args,collector_page, "green", "bild", true);
     995    collectorbar += "<td>_icongreyarrow_</td>\n";
     996    collectorbar += get_button (args,collector_page, "grey", "view", false);
    1111997    collectorbar += "</tr><tr><td colspan=3></td><td align=center>_icongreyuparrow_</td><td colspan=6></td>\n";
    1112998
     
    11161002    // page
    11171003    if (esrce == 1 || econf == 1) {
    1118       collectorbar += get_button (collector_page, "grey", "info", false);
     1004      collectorbar += get_button (args,collector_page, "grey", "info", false);
    11191005    } else {
    1120       collectorbar += get_button (collector_page, "yellow", "info", true);
     1006      collectorbar += get_button (args,collector_page, "yellow", "info", true);
    11211007    }
    11221008    collectorbar += "<td>_icongreyarrow_</td>\n";
    11231009    if (econf == 1) {
    1124       collectorbar += get_button (collector_page, "grey", "srce", false);
     1010      collectorbar += get_button (args,collector_page, "grey", "srce", false);
    11251011    } else {
    1126       collectorbar += get_button (collector_page, "yellow", "srce", true);
    1127     }
    1128     collectorbar += "<td>_icongreyarrow_</td>\n";
    1129     collectorbar += get_button (collector_page, "yellow", "conf", false);
    1130     collectorbar += "<td>_icongreyarrow_</td>\n";
    1131     collectorbar += get_button (collector_page, "green", "bild", true);
    1132     collectorbar += "<td>_icongreyarrow_</td>\n";
    1133     collectorbar += get_button (collector_page, "grey", "view", false);
     1012      collectorbar += get_button (args,collector_page, "yellow", "srce", true);
     1013    }
     1014    collectorbar += "<td>_icongreyarrow_</td>\n";
     1015    collectorbar += get_button (args,collector_page, "yellow", "conf", false);
     1016    collectorbar += "<td>_icongreyarrow_</td>\n";
     1017    collectorbar += get_button (args,collector_page, "green", "bild", true);
     1018    collectorbar += "<td>_icongreyarrow_</td>\n";
     1019    collectorbar += get_button (args,collector_page, "grey", "view", false);
    11341020    collectorbar += "</tr><tr><td colspan=5></td><td align=center>_icongreyuparrow_</td><td colspan=4></td>\n";
    11351021
     
    11371023    collectorbar += "<td>_icongreyarrow_</td>\n";
    11381024    // all previous buttons grey after build was completed
    1139     collectorbar += get_button (collector_page, "grey", "info", false);
    1140     collectorbar += "<td>_icongreyarrow_</td>\n";
    1141     collectorbar += get_button (collector_page, "grey", "srce", false);
    1142     collectorbar += "<td>_icongreyarrow_</td>\n";
    1143     collectorbar += get_button (collector_page, "grey", "conf", false);
    1144     collectorbar += "<td>_icongreyarrow_</td>\n";
    1145     collectorbar += get_button (collector_page, "yellow", "bild", false);
    1146     collectorbar += "<td>_icongreyarrow_</td>\n";
    1147     collectorbar += get_button (collector_page, "green", "view", true);
     1025    collectorbar += get_button (args,collector_page, "grey", "info", false);
     1026    collectorbar += "<td>_icongreyarrow_</td>\n";
     1027    collectorbar += get_button (args,collector_page, "grey", "srce", false);
     1028    collectorbar += "<td>_icongreyarrow_</td>\n";
     1029    collectorbar += get_button (args,collector_page, "grey", "conf", false);
     1030    collectorbar += "<td>_icongreyarrow_</td>\n";
     1031    collectorbar += get_button (args,collector_page, "yellow", "bild", false);
     1032    collectorbar += "<td>_icongreyarrow_</td>\n";
     1033    collectorbar += get_button (args,collector_page, "green", "view", true);
    11481034    collectorbar += "</tr><tr><td colspan=7></td><td align=center>_icongreyuparrow_</td><td colspan=2></td>\n";
    11491035
     
    11531039    // page
    11541040    if (esrce == 1 || econf == 1) {
    1155       collectorbar += get_button (collector_page, "grey", "info", false);
     1041      collectorbar += get_button (args,collector_page, "grey", "info", false);
    11561042    } else {
    1157       collectorbar += get_button (collector_page, "yellow", "info", true);
     1043      collectorbar += get_button (args,collector_page, "yellow", "info", true);
    11581044    }
    11591045    collectorbar += "<td>_icongreyarrow_</td>\n";
    11601046    if (econf == 1) {
    1161       collectorbar += get_button (collector_page, "grey", "srce", false);
     1047      collectorbar += get_button (args,collector_page, "grey", "srce", false);
    11621048    } else {
    1163       collectorbar += get_button (collector_page, "yellow", "srce", true);
    1164     }
    1165     collectorbar += "<td>_icongreyarrow_</td>\n";
    1166     collectorbar += get_button (collector_page, "yellow", "conf", true);
    1167     collectorbar += "<td>_icongreyarrow_</td>\n";
    1168     collectorbar += get_button (collector_page, "yellow", "bild", true);
    1169     collectorbar += "<td>_icongreyarrow_</td>\n";
    1170     collectorbar += get_button (collector_page, "grey", "view", false);
     1049      collectorbar += get_button (args,collector_page, "yellow", "srce", true);
     1050    }
     1051    collectorbar += "<td>_icongreyarrow_</td>\n";
     1052    collectorbar += get_button (args,collector_page, "yellow", "conf", true);
     1053    collectorbar += "<td>_icongreyarrow_</td>\n";
     1054    collectorbar += get_button (args,collector_page, "yellow", "bild", true);
     1055    collectorbar += "<td>_icongreyarrow_</td>\n";
     1056    collectorbar += get_button (args,collector_page, "grey", "view", false);
    11711057  }
    11721058
     
    12071093  disp.setmacro ("gsdlhome", "collector", dm_safe(gsdlhome));
    12081094}
     1095
    12091096
    12101097bool collectoraction::do_action (cgiargsclass &args, recptprotolistclass * /*protos*/,
     
    14391326}
    14401327
    1441 // if sw = 0 replace all carriage returns in intext with the string "\n"
    1442 // else replace all occurances of "\n" with a carriage return
    1443 text_t collectoraction::carriage_replace (const text_t &intext, int sw) {
    1444    
    1445   text_t outtext;
    1446   text_t::const_iterator here = intext.begin();
    1447   text_t::const_iterator end = intext.end();
    1448   while (here != end) {
    1449     if (sw == 0) {
    1450       if (*here == '\n') {
    1451     if ((here+1) != end && *(here+1) == '\r') ++here;
    1452     outtext += "\\n";
    1453       } else if (*here == '\r') {
    1454     if ((here+1) != end && *(here+1) == '\n') ++here;
    1455     outtext += "\\n";
    1456       } else {
    1457     outtext.push_back (*here);
    1458       }
    1459     } else if (*here == '\\' && (here+1) != end && *(here+1) == 'n') {
    1460       outtext.push_back ('\n');
    1461       ++here;
    1462     } else {
    1463       outtext.push_back (*here);
    1464     }
    1465     ++here;
    1466   }
    1467   return outtext;
    1468 }
    1469 
    1470 // create a short directory name from fullname
    1471 text_t collectoraction::get_directory_name (const text_t &fullname) {
    1472 
    1473   text_t shortname;
    1474   if (fullname.empty()) {
    1475     shortname = "coll";
    1476 
    1477   } else {
    1478    
    1479     // first make all lowercase and remove any dodgy characters
    1480     // (i.e. anything not [a-z]
    1481     text_t::const_iterator here = fullname.begin();
    1482     text_t::const_iterator end = fullname.end();
    1483     while (here != end) {
    1484       if ((*here >= 'A' && *here <= 'Z') || (*here >= 'a' && *here <= 'z') ||
    1485       (*here == ' ')) {
    1486     if (*here >= 'A' && *here <= 'Z') shortname.push_back (*here+32);
    1487     else if (*here == ' ') {
    1488       while ((*(here+1)) == ' ') ++here;
    1489       shortname.push_back (*here);
    1490     } else shortname.push_back (*here);
    1491       }
    1492       ++here;
    1493     }
    1494 
    1495     text_tarray words;
    1496     splitchar (shortname.begin(), shortname.end(), ' ', words);
    1497     int num_words = words.size();
    1498 
    1499     if (num_words == 0) {
    1500       shortname = "coll";
    1501 
    1502     } else {
    1503 
    1504       shortname.clear();
    1505       int use_words = (num_words <= 6) ? num_words : 6;
    1506       unsigned int substr_len = 6 / use_words;
    1507      
    1508       for (int i = 0; i < use_words; ++i) {
    1509     if (words[i].size() < substr_len) shortname += words[i];
    1510     else shortname += substr (words[i].begin(), words[i].begin()+substr_len);
    1511       }
    1512     }
    1513   }
    1514 
    1515   // check to see if shortname is unique
    1516   text_t fulldirname = filename_cat (gsdlhome, "collect", shortname);
    1517   if (directory_exists (fulldirname)) {
    1518     int version = 0;
    1519     text_t newname;
    1520     do {
    1521       ++version;
    1522       newname = shortname;
    1523       newname.push_back ('v');
    1524       newname.appendint (version);
    1525       fulldirname = filename_cat (gsdlhome, "collect", newname);
    1526     } while (directory_exists (fulldirname));
    1527 
    1528     shortname = newname;
    1529   }
    1530  
    1531   return shortname;
    1532 }
    1533 
    1534 // tests if collection is write protected (currently just checks if
    1535 // collect.cfg file is writable
    1536 bool collectoraction::collection_protected (const text_t &collection) {
    1537   text_t cfgfile = filename_cat(gsdlhome, "collect", collection, "etc", "collect.cfg");
    1538   if (file_writable(cfgfile)) return false;
    1539   return true;
    1540 }
    1541 
    1542 // assigns a temporary directory name for this collector session
    1543 // and creates temporary directory
    1544 // returns false if it couldn't create the directory
    1545 bool collectoraction::assign_tmpname (cgiargsclass &args, ostream &logout) {
    1546 
    1547   int i = 0;
    1548   text_t tmpname = "tbuild";
    1549   while (directory_exists (filename_cat (gsdlhome, "tmp", tmpname + text_t(i)))) {
    1550     ++i;
    1551   }
    1552   tmpname.appendint (i);
    1553 
    1554   text_t fulltmpdir = filename_cat (gsdlhome, "tmp", tmpname);
    1555   if (!mk_dir (fulltmpdir)) {
    1556     outconvertclass text_t2ascii;
    1557     logout << text_t2ascii << "collectoraction::assign_tmpname unable to create directory ("
    1558        << fulltmpdir << ")\n";
    1559     return false;
    1560   }
    1561 
    1562   args["bc1tmp"] = tmpname;
    1563   return true;
    1564 }
    1565 
    15661328void collectoraction::gsdl_mkcol (cgiargsclass &args, ostream &logout) {
    15671329
     
    15691331  if (!directory_exists (tmpdir)) {
    15701332    message = "tmpfail";
     1333    cerr << "WE CANNOT CREATE THE DIRECTORY!!! " << endl;
    15711334    return;
    15721335  }
     
    16051368  text_t mkcol_cmd = "perl -S mkcol.pl -optionfile \"" + optionfile;
    16061369  mkcol_cmd += "\" " + collection;
     1370
     1371
    16071372  gsdl_system (mkcol_cmd, true, logout);
    16081373
     
    16271392}
    16281393
    1629 void collectoraction::gsdl_build (cgiargsclass &args, ostream &logout) {
    1630 
    1631   outconvertclass text_t2ascii;
    1632 
    1633   text_t tmpdir = filename_cat (gsdlhome, "tmp", args["bc1tmp"]);
    1634   if (!directory_exists (tmpdir)) {
    1635     message = "tmpfail";
    1636     return;
    1637   }
    1638  
    1639   text_t &collection = args["bc1dirname"];
    1640   if (collection.empty()) {
    1641     message = "nocollection";
    1642     return;
    1643   }
    1644 
    1645   // check for a .build file - if it exists then we've already built
    1646   // the collection (or are in the process of building it)
    1647   text_t buildfile = filename_cat (tmpdir, ".build");
    1648   if (file_exists (buildfile)) {
    1649     return;
    1650   } else {
    1651     // create the .build file (this file is just a place holder to let any future
    1652     // pages know that we've already been here)
    1653     char *buildfilec = buildfile.getcstr();
    1654     ofstream bfile_out (buildfilec);
    1655     delete []buildfilec;
    1656     if (bfile_out) {
    1657       bfile_out << "collection building\n";
    1658       bfile_out.close();
    1659     } else {
    1660       message = "tmpfail";
    1661       return;
    1662     }
    1663   }
    1664 
    1665   const recptconf &rcinfo = recpt->get_configinfo ();
    1666 
    1667   // create the event header file if LogEvents, EmailEvents or
    1668   // EmailUserEvents options are turned on.
    1669   bool logevents =
    1670     (rcinfo.LogEvents == CollectorEvents || rcinfo.LogEvents == AllEvents ||
    1671      rcinfo.EmailEvents == CollectorEvents || rcinfo.EmailEvents == AllEvents ||
    1672      rcinfo.EmailUserEvents);
    1673   text_t ehead_file = filename_cat (tmpdir, "ehead.txt");
    1674   if (logevents) {
    1675     if (!create_event_header_file (ehead_file, args, logout)) {
    1676       logevents = false;
    1677     }
    1678   }
    1679    
    1680   text_t collectdir = get_collectdir (args);
    1681 
    1682   // set up build options
    1683   text_t options = "-make_writable -remove_import -out \"";
    1684   options += filename_cat (tmpdir, collection + ".bld");
    1685   options += "\" -collectdir \"" + collectdir + "\" -statsfile \"";
    1686   options += filename_cat(collectdir, collection, "etc", "import.log") + "\"";
    1687 
    1688   if (args["bc1esrce"] == 1) {
    1689     // we're adding data to an existing collection
    1690     options += " -save_archives -append";
    1691   }
    1692 
    1693   text_tarray inputvalues, inputtypes;
    1694   splitchar (args["bc1input"].begin(), args["bc1input"].end(), ',', inputvalues);
    1695   splitchar (args["bc1inputtype"].begin(), args["bc1inputtype"].end(), ',', inputtypes);
    1696   int numvalues = inputvalues.size();
    1697   int numtypes = inputtypes.size();
    1698   for (int i = 0; i < numvalues; ++i) {
    1699     if (!inputvalues[i].empty()) {
    1700       text_t type = "file://"; // default
    1701       if (i < numtypes) type = inputtypes[i];
    1702       options += " -download \"" +
    1703     remove_trailing_slashes(type + format_url(decode_commas(inputvalues[i]))) + "\"";
    1704     }
    1705   }
    1706 
    1707   if (logevents) {
    1708     if (rcinfo.LogEvents == CollectorEvents || rcinfo.LogEvents == AllEvents)
    1709       options += " -log_events";
    1710     if (rcinfo.EmailEvents == CollectorEvents || rcinfo.EmailEvents == AllEvents) {
    1711       options += " -mail_server " + rcinfo.MailServer;
    1712       options += " -email_events " + rcinfo.maintainer;
    1713       if (rcinfo.EmailUserEvents) options += "," + args["bc1contactemail"];
    1714     } else if (rcinfo.EmailUserEvents) {
    1715       options += " -mail_server " + rcinfo.MailServer;
    1716       options += " -email_events " + args["bc1contactemail"];
    1717     }
    1718     options += " -event_header " + ehead_file;
    1719   }
    1720 
    1721   text_t optionfile = filename_cat (tmpdir, "build.opt");
    1722   char *optionfilec = optionfile.getcstr();
    1723   ofstream ofile_out (optionfilec);
    1724   delete []optionfilec;
    1725   if (!ofile_out) {
    1726     message = "tmpfail";
    1727     return;
    1728   }
    1729   ofile_out << text_t2ascii << options << "\n";
    1730   ofile_out.close();
    1731 
    1732   // if we're altering an existing collection we need to kill off
    1733   // the existing collection server - we do this for the local library
    1734   // (and any other persistent version of the library) as the existing
    1735   // gdbm file can't be deleted while the collection server holds it open
    1736   if ((args["bc1econf"] == 1) || (args["bc1esrce"] == 1)) {
    1737     remove_colservr (collection, logout);
    1738   }   
    1739 
    1740   // set up the build command - build.bat has some issues with quoting
    1741   // on win2k when gsdlhome contains spaces so we'll avoid using
    1742   // "perl -S" here in favor of calling the "build" perl script explicitly
    1743   text_t build_cmd = "perl \"" + filename_cat (gsdlhome, "bin", "script", "build");
    1744   build_cmd += "\" -optionfile \"" + optionfile + "\" " + collection;
    1745   // run build command in background (i.e. asynchronously)
    1746   gsdl_system (build_cmd, false, logout);
    1747 }
    1748 
    1749 void collectoraction::gsdl_cancel_build (cgiargsclass &args, ostream &logout) {
    1750   // I really wanted to do what this perl script does from within the library
    1751   // c++ code. I ran into some problems though (like how do you write a portable
    1752   // "rm -r" in c++?). One day I'll spend some time sorting it out ... maybe.
    1753   text_t cancel_cmd = "perl -S cancel_build.pl -collectdir \"";
    1754   cancel_cmd += filename_cat (gsdlhome, "tmp", args["bc1tmp"]) + "\" ";
    1755   cancel_cmd += args["bc1dirname"];
    1756   // To be on the safe side we'll make this a synchronous call
    1757   // so that all tidying up is done before the user has a chance
    1758   // to do anything else (like start rebuilding their collection).
    1759   // This means that for a big collection where there's lots of
    1760   // stuff to delete etc. it might take a while before the "build
    1761   // cancelled" page appears.
    1762   gsdl_system (cancel_cmd, true, logout);
    1763 }
    1764 
    1765 text_t collectoraction::get_collectdir (cgiargsclass &args)
    1766 {
    1767   if ((args["bc1econf"] == 1) || (args["bc1esrce"] == 1)) {
    1768     // we're adding to a collection in place
    1769     return filename_cat(gsdlhome, "collect"); 
    1770   }
    1771   else {
    1772     return filename_cat (gsdlhome, "tmp", args["bc1tmp"]);
    1773   }
    1774 }
    1775 
    1776 // checks to see if any of the plugins in pluginset occur in
    1777 // collections configuration file
    1778 bool collectoraction::uses_weird_plugin (const text_t &collection) {
    1779 
    1780   text_tset pluginset;
    1781   pluginset.insert ("HBPlug");
    1782 
    1783   text_t cfgfile_content;
    1784   text_t cfgfile_name = filename_cat (gsdlhome, "collect", collection, "etc", "collect.cfg");
    1785   text_t pluginstr, pluginname;
    1786 
    1787   if (read_file (cfgfile_name, cfgfile_content)) {
    1788     text_t::const_iterator here = cfgfile_content.begin();
    1789     text_t::const_iterator end = cfgfile_content.end();
    1790     while (here != end) {
    1791       here = findchar (here, end, 'p');
    1792       if (here == end) break;
    1793       if ((here+6 < end) && (substr (here, here+6) == "plugin")) {
    1794     getdelimitstr (here+6, end, '\n', pluginstr);
    1795     text_t::const_iterator hp = pluginstr.begin();
    1796     text_t::const_iterator ep = pluginstr.end();
    1797     bool found = false;
    1798     // remove any leading whitespace, trailing options etc.
    1799     while (hp != ep) {
    1800       if (*hp == '\t' || *hp == ' ' || *hp == '\n') {
    1801         if (found) break;
    1802       } else {
    1803         pluginname.push_back (*hp);
    1804         found = true;
    1805       }
    1806       ++hp;
    1807     }
    1808     text_tset::const_iterator it = pluginset.find (pluginname);
    1809     if (it != pluginset.end()) return true; // found matching plugin
    1810     pluginname.clear();
    1811       }
    1812       ++here;
    1813     }
    1814   }
    1815   return false;
    1816 }
    1817 
    1818 // create and initialize a new collection server and
    1819 // add it to the null protocol.
    1820 void collectoraction::create_colserver (const text_t &collection, ostream &logout) {
    1821 
    1822   recptprotolistclass *protos = recpt->get_recptprotolist_ptr();
    1823   recptprotolistclass::iterator rprotolist_here = protos->begin();
    1824   recptprotolistclass::iterator rprotolist_end = protos->end();
    1825   while (rprotolist_here != rprotolist_end) {
    1826     comerror_t err = noError;
    1827     if ((*rprotolist_here).p != NULL) {
    1828       if ((*rprotolist_here).p->get_protocol_name (err) == "nullproto") {
    1829     // create collection server and add it to nullproto
    1830     (*rprotolist_here).p->add_collection (collection, recpt, gsdlhome, gsdlhome);
    1831     // make sure gsdlhome is configured
    1832     text_tarray tmp;
    1833     tmp.push_back (gsdlhome);
    1834     (*rprotolist_here).p->configure ("gsdlhome", tmp, err);
    1835     // re-initialize the null protocol
    1836     if (!(*rprotolist_here).p->init (err, logout)) {
    1837       logout << "collectoraction::create_colserver: nullproto init failed\n";
    1838     }
    1839     return;
    1840       }
    1841     }
    1842     ++rprotolist_here;
    1843   }
    1844 
    1845   logout << "collectoraction::create_colserver: no valid nullproto found\n";
    1846 }
    1847 
    1848 // delete a collection server from the null protocol
    1849 void collectoraction::remove_colservr (const text_t &collection, ostream &logout) {
    1850 
    1851   recpt->uncache_collection (collection);
    1852 
    1853   recptprotolistclass *protos = recpt->get_recptprotolist_ptr();
    1854   recptprotolistclass::iterator rprotolist_here = protos->begin();
    1855   recptprotolistclass::iterator rprotolist_end = protos->end();
    1856   while (rprotolist_here != rprotolist_end) {
    1857     comerror_t err = noError;
    1858     if ((*rprotolist_here).p != NULL) {
    1859       if ((*rprotolist_here).p->get_protocol_name (err) == "nullproto") {
    1860     (*rprotolist_here).p->remove_collection (collection, logout);
    1861     return;
    1862       }
    1863     }
    1864     ++rprotolist_here;
    1865   }
    1866 
    1867   logout << "collectoraction::create_colserver: no valid nullproto found\n";
    1868 }
    1869 
    1870 bool collectoraction::create_event_header_file (const text_t &filename, cgiargsclass &args,
    1871                         ostream &logout) {
    1872 
    1873   outconvertclass text_t2ascii;
    1874   char *filenamec = filename.getcstr();
    1875   ofstream eheadfile (filenamec);
    1876   delete []filenamec;
    1877 
    1878   if (eheadfile) {
    1879     eheadfile << text_t2ascii << get_event_header (args);
    1880     eheadfile.close();
    1881     return true;
    1882   }
    1883    
    1884   logout << text_t2ascii << "collectoraction::create_event_header ERROR: Couldn't create "
    1885      << "Event Header file " << filename << ". Event logging disabled\n";
    1886   return false;
    1887 }
    1888 
    1889 text_t collectoraction::get_event_header (cgiargsclass &args) {
    1890   text_t header = "Greenstone Username: " + args["un"] + "\n";
    1891   header += "Collection: " + args["bc1dirname"] + "\n";
    1892   header += "Collection Creator: " + args["bc1contactemail"] + "\n";
    1893   header += "GSDLHOME: " + gsdlhome + "\n";
    1894   header += "Build Location: " + get_collectdir(args) + "\n";
    1895 
    1896   return header;
    1897 }
    18981394
    18991395bool collectoraction::check_sources (cgiargsclass &args, ostream &logout) {
     
    19461442}
    19471443
    1948 // format_url simply strips "http://", "ftp://", or "file://" off the
    1949 // beginning of url if they're there
    1950 text_t collectoraction::format_url (const text_t &url) {
    1951   text_t::const_iterator begin = url.begin();
    1952   text_t::const_iterator end = url.end();
    1953 
    1954   if (url.size() >= 7) {
    1955     text_t prefix = substr(begin, begin+7);
    1956     if (prefix == "http://" || prefix == "file://") {
    1957       return substr(begin+7, end);
    1958     }
    1959   }
    1960   if (url.size() >= 6) {
    1961     if (substr(begin, begin+6) == "ftp://") {
    1962       return substr(begin+6, end);
    1963     }
    1964   }
    1965   return url;
     1444text_t collectoraction::get_button(cgiargsclass &args, const text_t &thispage,
     1445                   const text_t &color,
     1446                   const text_t &type, bool enabled)
     1447{
     1448
     1449  if ((color != "green" && color != "grey" && color != "yellow") ||
     1450      (type != "info" && type != "srce" && type != "conf" && type != "bild" && type != "view"))
     1451    return g_EmptyText;
     1452
     1453  text_t href = "_http"+type+"_";
     1454  text_t target = "";
     1455
     1456  if (thispage == "info" || thispage == "srce" || thispage == "conf" ||
     1457      thispage == "bildcancel" || thispage == "bildfail") {
     1458    // call the check submit macro instead of linking directly to the page
     1459    href="\"javascript:check_submit('"+type+"');\"";
     1460  } else if (type == "view") {
     1461    // view button is special case as it needs a target=_top
     1462    target = " target=_top";
     1463  }
     1464
     1465  text_t tdclass = "wizardbar"+color;
     1466  if (enabled) {
     1467    // link to the appropriate page
     1468    return "<td class="+tdclass+"><a href="+href+target+">_text"+type+"_</a></td>";
     1469  }
     1470  else {
     1471    // just display the text
     1472    return "<td class="+tdclass+">_text"+type+"_</td>";
     1473  }
    19661474}
    19671475
    1968 text_t collectoraction::remove_trailing_slashes (text_t str) {
    1969 
    1970   while (*(str.end()-1) == '\\') {
    1971     str.pop_back();
    1972   }
    1973   return str;
    1974 }
    1975 
    19761476#endif //GSDL_USE_COLLECTOR_ACTION
  • trunk/gsdl/src/recpt/collectoraction.h

    r7371 r11998  
    3030#define COLLECTORACTION_H
    3131
    32 #include "action.h"
     32#include "wizardaction.h"
    3333#include "receptionist.h"
    3434
    35 class collectoraction : public action {
     35class collectoraction : public wizardaction {
    3636 
    3737protected:
    38 
    39   bool disabled;
    40   receptionist *recpt;
    41   char *gsdlosc;
    42   char *gsdlhomec;
    43   char *pathc;
    44 
    45   text_t message;
    46   char failcode;
    4738
    4839  bool do_mkcol;
     
    5142  text_tmap failedsources;
    5243
    53   text_t get_button (const text_t &thispage, const text_t &color,
    54              const text_t &type, bool enabled);
     44  void set_fullnamemenu (displayclass &disp, cgiargsclass &args,
     45             recptprotolistclass *protos, ostream &logout);
    5546
    56   void set_fullnamemenu (displayclass &disp, cgiargsclass &args,
    57              recptprotolistclass *protos, ostream &logout);
    5847
    5948  void set_inputsourceboxes (displayclass &disp, cgiargsclass &args,
     
    6554  void set_cfgfile (displayclass &disp, cgiargsclass &args, ostream &logout);
    6655
    67   void set_statusline (displayclass &disp, cgiargsclass &args, ostream &logout);
    6856
    6957  void update_cfgfile_clone (cgiargsclass &args, ostream &logout);
     
    7361  void update_cfgfile_complete (cgiargsclass &args, ostream &logout);
    7462
    75   text_t carriage_replace (const text_t &intext, int sw);
    76 
    77   text_t get_directory_name (const text_t &fullname);
    78 
    79   bool collection_protected (const text_t &collection);
    80 
    81   bool assign_tmpname (cgiargsclass &args, ostream &logout);
    8263
    8364  void gsdl_mkcol (cgiargsclass &args, ostream &logout);
    8465
    85   void gsdl_build (cgiargsclass &args, ostream &logout);
    8666
    87   void gsdl_cancel_build (cgiargsclass &args, ostream &logout);
    88 
    89   text_t get_collectdir (cgiargsclass &args);
    90 
    91   bool uses_weird_plugin (const text_t &collection);
    92 
    93   void create_colserver (const text_t &collection, ostream &logout);
    94 
    95   void remove_colservr (const text_t &collection, ostream &logout);
    96 
    97   bool create_event_header_file (const text_t &filename, cgiargsclass &args,
    98                  ostream &logout);
    99 
    100   text_t get_event_header (cgiargsclass &args);
    10167
    10268  bool check_sources (cgiargsclass &args, ostream &logout);
    10369
    104   text_t format_url (const text_t &url);
     70  text_t get_button (cgiargsclass &args, const text_t &thispage,
     71             const text_t &color,
     72             const text_t &type, bool enabled);
    10573
    106   text_t remove_trailing_slashes (text_t str);
    10774
    10875public:
     
    11077  virtual ~collectoraction ();
    11178
    112   void configure (const text_t &key, const text_tarray &cfgline);
    113 
    114   bool init (ostream &logout);
    115 
    116   void set_receptionist (receptionist *therecpt) {recpt=therecpt;}
    117 
    11879  text_t get_action_name () {return "collector";}
    11980
    12081  bool check_cgiargs (cgiargsinfoclass &argsinfo, cgiargsclass &args,
    12182              recptprotolistclass *protos, ostream &logout);
    122 
    123   void get_cgihead_info (cgiargsclass &args, recptprotolistclass *protos,
    124              response_t &response,text_t &response_data,
    125              ostream &logout);
    12683
    12784  void define_internal_macros (displayclass &disp, cgiargsclass &args,
     
    13289          outconvertclass &outconvert, ostream &textout,
    13390          ostream &logout);
     91
    13492};
    13593
  • trunk/gsdl/src/recpt/documentaction.cpp

    r11771 r11998  
    619619  if (get_info (inlink, args["c"], args["l"], metadata, false, collectproto, response, logout)) {
    620620    if (!response.docInfo[0].metadata["section"].values[0].empty()) {
     621#ifndef DOCHANDLE
    621622      outlink = "_httpdocument_&amp;d=" + response.docInfo[0].metadata["section"].values[0];
     623#else
     624      outlink = "_httpdocumenthandle_("+args["c"]+","+response.docInfo[0].metadata["section"].values[0]+")";
     625#endif
     626
    622627      return true;
    623628    }
     
    642647      if (get_info (inlink, *col_here, args["l"], metadata, false, collectproto, response, logout)) {
    643648    if (!response.docInfo[0].metadata["section"].values[0].empty()) {
     649#ifndef DOCHANDLE
    644650      outlink = "_httpdocument_&amp;c=" + *col_here + "&amp;d=" +
    645651        response.docInfo[0].metadata["section"].values[0];
     652#else
     653      outlink = "_httpdocumenthandle_("+*col_here+","+response.docInfo[0].metadata["section"].values[0]+")";
     654#endif
     655
    646656      return true;
    647657    }
     
    10031013        << "<frameset rows=\"68,*\" noresize border=0>\n"
    10041014        << "<frame scrolling=no frameborder=0 src=\"_gwcgi_?_optsite_e=_compressedoptions_&a=p&p=nav\">\n"
     1015#ifndef DOCHANDLE
    10051016        << "<frame name=\"documenttop\" frameborder=0 src=\"_gwcgi_?_optsite_e=_compressedoptions_&a=d&d="
    10061017        << args["d"] << "\">"
     1018#else
     1019        << "<frame name=\"documenttop\" frameborder=0 src=\"_httpdocumenthandle_("
     1020        << args["c"] << "," << args["d"] << ")\">"
     1021#endif
    10071022        << "<noframes>\n"
    10081023        << "<p>You must have a frame enabled browser to view this.</p>\n"
     
    12971312  // work out values for next link
    12981313  if (haschildren) {
     1314#ifndef DOCHANLE
    12991315    disp.setmacro ("httpnextarrow", "document", "_httpdocument_&amp;cl=" + args["cl"] +
    13001316           "&amp;d=" + arg_d + ".fc");
     1317#else
     1318    disp.setmacro ("httpnextarrow", "document", "_httpdocumenthandle_("+args["c"]+","+arg_d + ".fc)";
     1319
     1320#endif
     1321
    13011322  } else {
    13021323    text_tarray::const_iterator h = next_siblings.begin();
     
    13041325    while (h != e) {
    13051326      if (!(*h).empty()) {
     1327#ifndef DOCHANLE
    13061328    disp.setmacro ("httpnextarrow", "document", "_httpdocument_&amp;cl=" + args["cl"] +
    13071329               "&amp;d=" + *h);
     1330#else
     1331    disp.setmacro ("httpnextarrow", "document", "_httpdocumenthandle_("+args["c"]+","+*h+")";
     1332
     1333#endif
     1334
    13081335    break;
    13091336      }
     
    13141341  // work out value for previous link
    13151342  if (!previous_sibling.empty()) {
     1343#ifndef DOCHANDLE
    13161344    disp.setmacro ("httpprevarrow", "document", "_httpdocument_&amp;cl=" + args["cl"] +
    13171345           "&amp;d=" + previous_sibling);
     1346#else
     1347    disp.setmacro ("httpprevarrow", "document", "_httpdocumenthandle_("+args["c"]+","+ previous_sibling+")");
     1348
     1349#endif
     1350
    13181351  } else {
    13191352    if (countchar(arg_d.begin(), arg_d.end(), '.')) {
     1353#ifndef DOCHANDLE
    13201354      disp.setmacro ("httpprevarrow", "document", "_httpdocument_&amp;cl=" + args["cl"] +
    13211355             "&amp;d=" + get_parent(arg_d));
     1356#else
     1357      disp.setmacro ("httpprevarrow", "document", "_httpdocumenthandle_("+args["c"]+","+get_parent(arg_d)+")");
     1358
     1359#endif
     1360
    13221361    }
    13231362  }
  • trunk/gsdl/src/recpt/gsdl_modules_cfg.h

    r11252 r11998  
    5353#define GSDL_USE_BROWSE_ACTION
    5454#define GSDL_USE_COLLECTOR_ACTION
     55#define GSDL_USE_DEPOSITOR_ACTION
    5556#define GSDL_USE_EXTLINK_ACTION
    5657#undef  GSDL_USE_GTI_ACTION
  • trunk/gsdl/src/recpt/librarymain.cpp

    r10018 r11998  
    8585#include "tipaction.h"
    8686#include "collectoraction.h"
     87#include "depositoraction.h"
    8788#include "browseaction.h"
    8889#include "phindaction.h"
     
    107108#endif //GSDL_USE_CLASSIFIER_BROWSER
    108109
     110#include "cgicc/Cgicc.h"
     111using namespace cgicc;
     112
     113Cgicc* formData;
     114
    109115int main () {
    110116  receptionist recpt;
     
    115121#endif
    116122  text_t       gsdlhome;
     123
     124  formData = new Cgicc();
    117125
    118126  cservers = new collectset(gsdlhome);
     
    200208#endif
    201209
     210#ifdef GSDL_USE_DEPOSITOR_ACTION
     211  depositoraction *adepositoraction = new depositoraction();
     212  adepositoraction->set_receptionist (&recpt);
     213  recpt.add_action(adepositoraction);
     214#endif
     215
    202216#ifdef GSDL_USE_BROWSE_ACTION
    203217  browseaction *abrowseaction = new browseaction();
     
    276290  thisAction = recpt.get_actionmap_ptr()->begin();
    277291  recpt.get_actionmap_ptr()->erase(thisAction, endAction);
     292
     293  delete formData;
    278294  return 0;
    279295}
  • trunk/gsdl/src/recpt/pageaction.cpp

    r11986 r11998  
    4545  status_disabled = true;
    4646  collector_disabled = true;
     47  depositor_disabled = true;
    4748  translator_disabled = true;
    4849  gliapplet_disabled = true;
     
    586587  // if page is "home" or "homehelp"
    587588  // _textgocollector_     set to "" if collector is disabled in main.cfg
     589  // _textgodepositor_     set to "" if depositor is disabled in main.cfg
    588590  // _textgoadmin_         set to "" if status is disabled in main.cfg
    589591  // _textgotranslator_    set to "" if translator is disabled in main.cfg
     
    669671    if (status_disabled) disp.setmacro ("textgoadmin", "home", "");
    670672    if (collector_disabled) disp.setmacro ("textgocollector", "home", "");
     673    if (depositor_disabled) disp.setmacro ("textgodepositor", "home", "");
    671674    if (translator_disabled) disp.setmacro ("textgotranslator", "home", "");
    672675
     
    912915         (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
    913916    collector_disabled = false;
    914   } else if ((key == "translator") && (cfgline.size() == 1) &&
     917  }
     918 else if ((key == "depositor") && (cfgline.size() == 1) &&
     919         (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
     920    depositor_disabled = false;
     921  }
     922    else if ((key == "translator") && (cfgline.size() == 1) &&
    915923         (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
    916924    translator_disabled = false;
  • trunk/gsdl/src/recpt/pageaction.h

    r9931 r11998  
    9595  bool status_disabled;
    9696  bool collector_disabled;
     97  bool depositor_disabled;
    9798  bool translator_disabled;
    9899  bool gliapplet_disabled;
Note: See TracChangeset for help on using the changeset viewer.