[723] | 1 | /**********************************************************************
|
---|
| 2 | *
|
---|
| 3 | * buildaction.cpp -- building collections
|
---|
[1285] | 4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
[723] | 5 | *
|
---|
| 6 | * A component of the Greenstone digital library software
|
---|
| 7 | * from the New Zealand Digital Library Project at the
|
---|
| 8 | * University of Waikato, New Zealand.
|
---|
| 9 | *
|
---|
| 10 | * This program is free software; you can redistribute it and/or modify
|
---|
| 11 | * it under the terms of the GNU General Public License as published by
|
---|
| 12 | * the Free Software Foundation; either version 2 of the License, or
|
---|
| 13 | * (at your option) any later version.
|
---|
| 14 | *
|
---|
| 15 | * This program is distributed in the hope that it will be useful,
|
---|
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 18 | * GNU General Public License for more details.
|
---|
| 19 | *
|
---|
| 20 | * You should have received a copy of the GNU General Public License
|
---|
| 21 | * along with this program; if not, write to the Free Software
|
---|
| 22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 23 | *
|
---|
| 24 | *********************************************************************/
|
---|
| 25 |
|
---|
| 26 | #include "OIDtools.h"
|
---|
| 27 | #include "fileutil.h"
|
---|
[822] | 28 | #include "htmlutils.h"
|
---|
[1177] | 29 | #include "gsdltools.h"
|
---|
[723] | 30 | #include "buildaction.h"
|
---|
| 31 |
|
---|
| 32 | ///////////////
|
---|
| 33 | // buildaction
|
---|
| 34 | ///////////////
|
---|
| 35 |
|
---|
| 36 | buildaction::buildaction () {
|
---|
| 37 | // this action uses cgi variable "a"
|
---|
| 38 | cgiarginfo arg_ainfo;
|
---|
| 39 | arg_ainfo.shortname = "a";
|
---|
| 40 | arg_ainfo.longname = "action";
|
---|
| 41 | arg_ainfo.multiplechar = true;
|
---|
| 42 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
| 43 | arg_ainfo.argdefault = "bc"; // build collection
|
---|
| 44 | arg_ainfo.savedarginfo = cgiarginfo::must;
|
---|
| 45 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
| 46 |
|
---|
| 47 | // "bca"
|
---|
| 48 | arg_ainfo.shortname = "bca";
|
---|
| 49 | arg_ainfo.longname = "build collection action";
|
---|
| 50 | arg_ainfo.multiplechar = true;
|
---|
| 51 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
| 52 | arg_ainfo.argdefault = "editcol";
|
---|
| 53 | arg_ainfo.savedarginfo = cgiarginfo::mustnot;
|
---|
| 54 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
| 55 |
|
---|
| 56 |
|
---|
| 57 | // "mess"
|
---|
| 58 | arg_ainfo.shortname = "mess";
|
---|
| 59 | arg_ainfo.longname = "macro name of text for the message page";
|
---|
| 60 | arg_ainfo.multiplechar = true;
|
---|
| 61 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
| 62 | arg_ainfo.argdefault = "";
|
---|
| 63 | arg_ainfo.savedarginfo = cgiarginfo::mustnot;
|
---|
| 64 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
| 65 |
|
---|
| 66 | // "head"
|
---|
| 67 | arg_ainfo.shortname = "head";
|
---|
| 68 | arg_ainfo.longname = "macro name of text to use as header for the message page";
|
---|
| 69 | arg_ainfo.multiplechar = true;
|
---|
| 70 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
| 71 | arg_ainfo.argdefault = "";
|
---|
| 72 | arg_ainfo.savedarginfo = cgiarginfo::mustnot;
|
---|
| 73 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
| 74 |
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | bool buildaction::check_cgiargs (cgiargsinfoclass &/*argsinfo*/, cgiargsclass &args,
|
---|
| 78 | ostream &/*logout*/) {
|
---|
[1129] | 79 |
|
---|
| 80 | text_t &arg_bca = args["bca"];
|
---|
| 81 | if (!((arg_bca == "buildstatus") || (arg_bca == "collog") || (arg_bca == "blankpage")
|
---|
| 82 | || ((arg_bca == "buildcol") && (args["wizard"] == "buildexec"))))
|
---|
[723] | 83 | {
|
---|
| 84 | // authenticate the user if authentication is avaiable
|
---|
| 85 | args["uan"] = 1;
|
---|
| 86 | args["ug"] = "colbuilder";
|
---|
| 87 | }
|
---|
| 88 | return true;
|
---|
| 89 | }
|
---|
| 90 |
|
---|
[760] | 91 | void buildaction::get_cgihead_info (cgiargsclass &/*args*/, recptprotolistclass * /*protos*/,
|
---|
| 92 | response_t &response,text_t &response_data,
|
---|
| 93 | ostream &/*logout*/) {
|
---|
[723] | 94 |
|
---|
| 95 | response = content;
|
---|
| 96 | response_data = "text/html";
|
---|
| 97 | }
|
---|
| 98 |
|
---|
[760] | 99 | void buildaction::define_internal_macros (displayclass &disp, cgiargsclass &args,
|
---|
| 100 | recptprotolistclass *protos, ostream &logout) {
|
---|
[723] | 101 |
|
---|
[822] | 102 | // make sure we know about a receptionist
|
---|
| 103 | if (recpt == NULL) {
|
---|
[1270] | 104 | logout << "The build action does not contain information\n"
|
---|
[822] | 105 | << "about any receptionists. The method set_receptionist\n"
|
---|
[963] | 106 | << "was probably not called from the module which instantiated\n"
|
---|
[1270] | 107 | << "this build action.\n";
|
---|
[822] | 108 | return;
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | recptprotolistclass *rprotolist = recpt->get_recptprotolist_ptr ();
|
---|
| 112 | if (rprotolist == NULL) return;
|
---|
| 113 |
|
---|
[723] | 114 | // build up javascript and HTML code useful in web forms
|
---|
| 115 | text_t first_dirname = "";
|
---|
| 116 | text_t fullnamelist = "var fullnamelist = new Array(";
|
---|
| 117 | text_t dirnamelist = "var dirnamelist = new Array(";
|
---|
[1172] | 118 | text_t fullnamemenu = "<input type=hidden name=\"bc1fullnameindex\"";
|
---|
| 119 | fullnamemenu += " value=\"_bcargfullnameindex_\">\n";
|
---|
| 120 | fullnamemenu += "<select name=\"bc1fullnamemenu\" onChange=fullnameindex_changed()>\n";
|
---|
[723] | 121 | int rcount = 1;
|
---|
| 122 | int fcount = 1;
|
---|
| 123 | int starting_fullname_index = 0;
|
---|
| 124 | disp.setmacro("bcargfirsttime","build","false");
|
---|
| 125 |
|
---|
[760] | 126 | recptprotolistclass::iterator rprotolist_here = protos->begin();
|
---|
| 127 | recptprotolistclass::iterator rprotolist_end = protos->end();
|
---|
[723] | 128 | while (rprotolist_here != rprotolist_end) {
|
---|
| 129 | if ((*rprotolist_here).p != NULL) {
|
---|
| 130 | text_tarray collist;
|
---|
| 131 | comerror_t err;
|
---|
| 132 | (*rprotolist_here).p->get_collection_list (collist, err, logout);
|
---|
| 133 | if (err == noError) {
|
---|
| 134 | text_tarray::iterator collist_here = collist.begin();
|
---|
| 135 | text_tarray::iterator collist_end = collist.end();
|
---|
| 136 |
|
---|
| 137 | if (rcount>1) { fullnamelist += ","; }
|
---|
| 138 | fullnamelist += "new Array(";
|
---|
| 139 |
|
---|
| 140 | FilterResponse_t response;
|
---|
| 141 | text_tset metadata;
|
---|
| 142 | metadata.insert ("collectionname");
|
---|
| 143 |
|
---|
| 144 | int ccount = 1;
|
---|
| 145 |
|
---|
| 146 | while (collist_here != collist_end) {
|
---|
| 147 |
|
---|
[1270] | 148 | ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr ((*rprotolist_here).p, *collist_here, logout);
|
---|
| 149 | if (cinfo != NULL) {
|
---|
[723] | 150 | text_t collectionname = *collist_here;
|
---|
[1270] | 151 | if (!cinfo->collectionmeta["collectionname"].empty())
|
---|
[723] | 152 | {
|
---|
| 153 | // get collection name from the collection cfg file
|
---|
[1270] | 154 | collectionname = cinfo->collectionmeta["collectionname"];
|
---|
[723] | 155 | }
|
---|
| 156 | else
|
---|
| 157 | {
|
---|
| 158 | if (get_info ("collection", *collist_here, metadata, false, (*rprotolist_here).p,
|
---|
| 159 | response, logout))
|
---|
| 160 | {
|
---|
| 161 | // get collection name from gdbm file
|
---|
| 162 | collectionname = response.docInfo[0].metadata["collectionname"].values[0];
|
---|
| 163 | }
|
---|
| 164 | }
|
---|
| 165 |
|
---|
| 166 | if (ccount>1) { fullnamelist += ","; dirnamelist += ","; }
|
---|
| 167 | fullnamelist += (text_t)"\"" + collectionname + "\"";
|
---|
| 168 | dirnamelist += (text_t)"\"" + *collist_here + "\"";
|
---|
| 169 |
|
---|
[1172] | 170 | fullnamemenu += "<option value=\"" + collectionname;
|
---|
| 171 | fullnamemenu.push_back ('"');
|
---|
| 172 | if (args["bc1dirname"].empty())
|
---|
[723] | 173 | {
|
---|
| 174 | if ((rcount==1) && (ccount==1))
|
---|
| 175 | {
|
---|
| 176 | fullnamemenu += " selected";
|
---|
| 177 | first_dirname = *collist_here;
|
---|
| 178 | starting_fullname_index = 0;
|
---|
| 179 | }
|
---|
| 180 | }
|
---|
| 181 | else
|
---|
| 182 | {
|
---|
| 183 | if (args["bc1dirname"] == *collist_here)
|
---|
| 184 | {
|
---|
| 185 | fullnamemenu += " selected";
|
---|
| 186 | first_dirname = *collist_here;
|
---|
| 187 | starting_fullname_index = fcount-1;
|
---|
| 188 | }
|
---|
| 189 | }
|
---|
| 190 | fullnamemenu += (text_t)">" + collectionname;
|
---|
| 191 |
|
---|
| 192 | // check to see if the "collection" is writable
|
---|
| 193 | text_t cfg_fname
|
---|
[963] | 194 | = filename_cat(gsdlhome, "collect", *collist_here, "etc", "collect.cfg");
|
---|
[723] | 195 | if (!file_writable(cfg_fname))
|
---|
| 196 | {
|
---|
| 197 | fullnamemenu += " <b>(write protected)</b>";
|
---|
| 198 | }
|
---|
| 199 |
|
---|
| 200 | fullnamemenu += "\n";
|
---|
| 201 |
|
---|
| 202 | if (args["bca"]=="buildcol")
|
---|
| 203 | {
|
---|
[1172] | 204 | if (((args["bc1dirname"].empty()) && (rcount==1) && (ccount==1))
|
---|
[723] | 205 | || (args["bc1dirname"]==*collist_here))
|
---|
| 206 | {
|
---|
[1270] | 207 | disp.setmacro("bcargingsdlarea","build",cinfo->building["ingsdlarea"]);
|
---|
| 208 | disp.setmacro("bcargcopydir","build",cinfo->building["copydir"]);
|
---|
[723] | 209 |
|
---|
[1270] | 210 | if (cinfo->buildDate==0) // not built
|
---|
[723] | 211 | {
|
---|
| 212 | // assume that's because this is the first build ever for the collection
|
---|
| 213 | args["bc1copydata"]="true";
|
---|
| 214 | disp.setmacro("bcargcopydata","build","true");
|
---|
| 215 | disp.setmacro("bcargfirsttime","build","true"); // override value
|
---|
| 216 | }
|
---|
| 217 | }
|
---|
| 218 | }
|
---|
| 219 |
|
---|
| 220 | ccount++;
|
---|
| 221 | fcount++;
|
---|
| 222 | }
|
---|
| 223 | collist_here ++;
|
---|
| 224 | }
|
---|
| 225 |
|
---|
| 226 | fullnamelist += ")";
|
---|
| 227 | }
|
---|
| 228 | rcount ++;
|
---|
| 229 | }
|
---|
| 230 | fullnamelist += ");\n";
|
---|
| 231 | dirnamelist += ");\n";
|
---|
| 232 |
|
---|
| 233 | fullnamemenu += "</select>\n";
|
---|
| 234 | rprotolist_here ++;
|
---|
| 235 | }
|
---|
| 236 |
|
---|
| 237 | if ((args["bca"]=="newcol") || (args["bca"]=="editcol"))
|
---|
| 238 | {
|
---|
| 239 | disp.setmacro ("fullnamelist", "build", fullnamelist);
|
---|
| 240 | }
|
---|
| 241 |
|
---|
[1172] | 242 | if ((args["bca"]=="delcol") || (args["bca"]=="editcol") ||
|
---|
| 243 | (args["bca"]=="buildcol") || (args["bca"]=="collog"))
|
---|
[723] | 244 | {
|
---|
| 245 | disp.setmacro ("dirnamelist", "build", dirnamelist);
|
---|
| 246 | disp.setmacro ("fullnamemenu", "build", fullnamemenu);
|
---|
| 247 | disp.setmacro ("bcargfullnameindex", "build", starting_fullname_index);
|
---|
| 248 | }
|
---|
| 249 |
|
---|
| 250 |
|
---|
| 251 | // define special "wizard" form value so webform building process can
|
---|
| 252 | // keep track of which page it is on
|
---|
| 253 | text_t wizard_value
|
---|
| 254 | = (args["wizard"] == "") ? (text_t)"textinfo" : args["wizard"];
|
---|
| 255 | text_t hiddenargs
|
---|
| 256 | = "<input type=\"hidden\" name=\"wizard\" value=\""+wizard_value+"\">\n";
|
---|
| 257 | disp.setmacro ("hiddenargs", "build", hiddenargs);
|
---|
| 258 | disp.setmacro ("wizard", "build", wizard_value);
|
---|
| 259 |
|
---|
| 260 | // cache any cgi arguments starting "newcol:" (from previous webform)
|
---|
| 261 | cgiargsclass::const_iterator args_here = args.begin();
|
---|
| 262 | cgiargsclass::const_iterator args_end = args.end();
|
---|
| 263 | while (args_here != args_end) {
|
---|
| 264 | // define macro if args came from a previous col building webpage
|
---|
| 265 | text_t args_entry = (*args_here).first;
|
---|
| 266 |
|
---|
| 267 | if (substr(args_entry.begin(),args_entry.begin()+3) == "bc1")
|
---|
| 268 | {
|
---|
| 269 | text_t bc1name = substr(args_entry.begin()+3,args_entry.end());
|
---|
| 270 | text_t cached_cgiarg = "bcarg" + bc1name;
|
---|
[1177] | 271 | disp.setmacro(cached_cgiarg, "build", dm_safe(args[args_entry]));
|
---|
[723] | 272 | }
|
---|
| 273 | args_here++;
|
---|
| 274 | }
|
---|
| 275 |
|
---|
[822] | 276 | // set macro cfgperm based on whether config file can be read or no
|
---|
| 277 | text_t dirname = (args["bc1dirname"] == "") ? first_dirname : args["bc1dirname"];
|
---|
[963] | 278 | text_t cfg_fname = filename_cat(gsdlhome, "collect", dirname, "etc", "collect.cfg");
|
---|
[984] | 279 | text_t cfgperm = (file_writable(cfg_fname)) ? text_t("read/write") : text_t("readonly");
|
---|
[822] | 280 | disp.setmacro("cfgperm","build",cfgperm);
|
---|
| 281 |
|
---|
[723] | 282 | // if edit collection, read in collect.cfg file
|
---|
| 283 | if (args["bca"]=="editcol")
|
---|
| 284 | {
|
---|
| 285 | text_t dirname
|
---|
| 286 | = (args["bc1dirname"] == "") ? first_dirname : args["bc1dirname"];
|
---|
| 287 |
|
---|
| 288 | // read in collect.cfg
|
---|
| 289 | text_t cfg_fname
|
---|
[963] | 290 | = filename_cat(gsdlhome, "collect", dirname, "etc", "collect.cfg");
|
---|
[1170] | 291 |
|
---|
| 292 | #ifdef GSDL_USE_IOS_H
|
---|
[723] | 293 | ifstream cfg_ifs (cfg_fname.getcstr(), ios::in | ios::nocreate);
|
---|
[1170] | 294 | #else
|
---|
| 295 | ifstream cfg_ifs (cfg_fname.getcstr(), ios::in);
|
---|
| 296 | #endif
|
---|
| 297 |
|
---|
[723] | 298 | if (cfg_ifs)
|
---|
[822] | 299 | {
|
---|
| 300 | // read in collect.cfg
|
---|
[723] | 301 | text_t cfg_text = "";
|
---|
| 302 |
|
---|
| 303 | char c;
|
---|
| 304 | cfg_ifs.get(c);
|
---|
| 305 | while (!cfg_ifs.eof ()) {
|
---|
| 306 | cfg_text.push_back(c);
|
---|
[822] | 307 | if (c=='\\') { cfg_text.push_back('\\'); }
|
---|
[723] | 308 | cfg_ifs.get(c);
|
---|
| 309 | }
|
---|
| 310 |
|
---|
| 311 | cfg_ifs.close();
|
---|
[822] | 312 | if (cfgperm=="readonly") cfg_text = html_safe(cfg_text);
|
---|
[723] | 313 |
|
---|
| 314 | // define it as a macro
|
---|
| 315 | disp.setmacro("cfgfile","build",cfg_text);
|
---|
| 316 | }
|
---|
| 317 | else
|
---|
| 318 | {
|
---|
| 319 | text_t error_mess = "Unable to read configuration file: "+cfg_fname;
|
---|
| 320 | disp.setmacro("cfgfile","build",error_mess);
|
---|
| 321 | }
|
---|
| 322 | }
|
---|
[822] | 323 |
|
---|
| 324 | // if view log, read in collect.bld file
|
---|
| 325 | if (args["bca"]=="collog")
|
---|
| 326 | {
|
---|
| 327 | text_t dirname
|
---|
| 328 | = (args["bc1dirname"] == "") ? first_dirname : args["bc1dirname"];
|
---|
| 329 |
|
---|
| 330 | // read in collect.bld
|
---|
[1305] | 331 | text_t bld_fname = filename_cat(gsdlhome, "etc", dirname+ ".bld");
|
---|
[1170] | 332 |
|
---|
| 333 | #ifdef GSDL_USE_IOS_H
|
---|
[822] | 334 | ifstream bld_ifs (bld_fname.getcstr(), ios::in | ios::nocreate);
|
---|
[1170] | 335 | #else
|
---|
| 336 | ifstream bld_ifs (bld_fname.getcstr(), ios::in);
|
---|
| 337 | #endif
|
---|
| 338 |
|
---|
[822] | 339 | if (bld_ifs)
|
---|
| 340 | {
|
---|
| 341 | text_t bld_text = "";
|
---|
| 342 |
|
---|
| 343 | char c;
|
---|
| 344 | bld_ifs.get(c);
|
---|
| 345 | while (!bld_ifs.eof ()) {
|
---|
| 346 | bld_text.push_back(c);
|
---|
| 347 | if (c=='\\') { bld_text.push_back('\\'); }
|
---|
| 348 | bld_ifs.get(c);
|
---|
| 349 | }
|
---|
| 350 |
|
---|
| 351 | bld_ifs.close();
|
---|
| 352 | bld_text = html_safe(bld_text);
|
---|
| 353 |
|
---|
| 354 | // define it as a macro
|
---|
| 355 | disp.setmacro("bldfile","build",bld_text);
|
---|
| 356 | }
|
---|
| 357 | else
|
---|
| 358 | {
|
---|
| 359 | text_t error_mess = "Log file currently empty.";
|
---|
| 360 | disp.setmacro("bldfile","build",error_mess);
|
---|
| 361 | }
|
---|
| 362 | }
|
---|
[723] | 363 | }
|
---|
| 364 |
|
---|
[760] | 365 | bool buildaction::do_action (cgiargsclass &args, recptprotolistclass * /*protos*/,
|
---|
| 366 | browsermapclass * /*browsers*/, displayclass &disp,
|
---|
[723] | 367 | outconvertclass &outconvert, ostream &textout,
|
---|
| 368 | ostream &logout) {
|
---|
| 369 |
|
---|
[963] | 370 | // make sure we know about a receptionist
|
---|
| 371 | if (recpt == NULL) {
|
---|
| 372 | logout << "The page action does not contain information\n"
|
---|
| 373 | << "about any receptionists. The method set_receptionist\n"
|
---|
| 374 | << "was probably not called from the module which instantiated\n"
|
---|
| 375 | << "this page action.\n";
|
---|
| 376 | return false;
|
---|
| 377 | }
|
---|
[723] | 378 |
|
---|
| 379 | if (args["bca"] == "newcol") {
|
---|
[760] | 380 | return do_newcol (args, disp, outconvert, textout, logout);
|
---|
[723] | 381 | }
|
---|
| 382 | else if (args["bca"] == "editcol") {
|
---|
[760] | 383 | return do_editcol (args, disp, outconvert, textout, logout);
|
---|
[723] | 384 | }
|
---|
| 385 | else if (args["bca"] == "buildcol") {
|
---|
[760] | 386 | return do_buildcol (args, disp, outconvert, textout, logout);
|
---|
[723] | 387 | }
|
---|
| 388 | else if (args["bca"] == "buildstatus") {
|
---|
[760] | 389 | return do_buildstatus (args, disp, outconvert, textout, logout);
|
---|
[723] | 390 | }
|
---|
| 391 | else if (args["bca"] == "delcol") {
|
---|
[760] | 392 | return do_delcol (args, disp, outconvert, textout, logout);
|
---|
[723] | 393 | }
|
---|
[822] | 394 | else if (args["bca"] == "collog") {
|
---|
| 395 | return do_collog (args, disp, outconvert, textout, logout);
|
---|
| 396 | }
|
---|
[723] | 397 | else if (args["bca"] == "mess") {
|
---|
[760] | 398 | return do_mess (args, disp, outconvert, textout, logout);
|
---|
[723] | 399 | }
|
---|
| 400 |
|
---|
| 401 | // default (bca == blankpage)
|
---|
| 402 | textout << outconvert << "<html><body bgcolor=#ffffff></body></html>\n";
|
---|
| 403 |
|
---|
| 404 | return true;
|
---|
| 405 | }
|
---|
| 406 |
|
---|
| 407 |
|
---|
| 408 |
|
---|
[760] | 409 | bool buildaction::do_newcol (cgiargsclass &args, displayclass &disp,
|
---|
| 410 | outconvertclass &outconvert, ostream &textout,
|
---|
| 411 | ostream &/*logout*/) {
|
---|
[723] | 412 |
|
---|
| 413 | text_tarray wizard_split;
|
---|
| 414 | const text_t& wizard = (args["wizard"] == "") ? (text_t)"textinfo" : args["wizard"];
|
---|
| 415 | splitchar(wizard.begin(),wizard.end(),':',wizard_split);
|
---|
| 416 | const text_t& wizard_last = wizard_split.back();
|
---|
| 417 |
|
---|
| 418 | text_t content = "_build:content" + wizard_last + "_\n";
|
---|
| 419 | text_t headmess = "_build:header_(_build:headmess" + wizard_last + "_)\n";
|
---|
| 420 |
|
---|
| 421 | textout << outconvert << disp << (headmess) << (content) << ("_build:wizardfooter_\n");
|
---|
| 422 |
|
---|
| 423 | return true;
|
---|
| 424 | }
|
---|
| 425 |
|
---|
| 426 |
|
---|
[760] | 427 | bool buildaction::do_editcol (cgiargsclass &/*args*/, displayclass &disp,
|
---|
| 428 | outconvertclass &outconvert, ostream &textout,
|
---|
| 429 | ostream &/*logout*/) {
|
---|
[723] | 430 |
|
---|
| 431 | textout << outconvert << disp << ("_build:header_(_build:headmesseditcol_)\n")
|
---|
| 432 | << ("_build:contenteditcol_\n")
|
---|
| 433 | << ("_build:wizardfooter_\n");
|
---|
| 434 |
|
---|
| 435 | return true;
|
---|
| 436 | }
|
---|
| 437 |
|
---|
[760] | 438 | bool buildaction::do_buildcol (cgiargsclass &args, displayclass &disp,
|
---|
| 439 | outconvertclass &outconvert, ostream &textout,
|
---|
| 440 | ostream &logout) {
|
---|
[723] | 441 |
|
---|
| 442 | text_tarray wizard_split;
|
---|
[1148] | 443 | const text_t wizard = (args["wizard"].empty()) ? "buildcol" : args["wizard"];
|
---|
[723] | 444 | splitchar(wizard.begin(),wizard.end(),':',wizard_split);
|
---|
[1148] | 445 | const text_t wizard_last = wizard_split.back();
|
---|
[723] | 446 |
|
---|
| 447 | if (wizard_last != "buildframe")
|
---|
| 448 | {
|
---|
| 449 | text_t headmess = "_build:header_(_build:headmess" + wizard_last + "_)\n";
|
---|
| 450 | text_t content = "_build:content" + wizard_last + "_\n";
|
---|
| 451 |
|
---|
| 452 | textout << outconvert << disp << headmess << content << "_build:wizardfooter_\n";
|
---|
| 453 | }
|
---|
| 454 | else
|
---|
| 455 | {
|
---|
[1170] | 456 | text_t dirname = (args["bc1dirname"] == "") ?
|
---|
| 457 | "unknown" : args["bc1dirname"];
|
---|
| 458 |
|
---|
[723] | 459 | text_t tmpname = dirname+"_XXXXXX";
|
---|
[1148] | 460 | char *cstr_tmpname = tmpname.getcstr();
|
---|
[1170] | 461 |
|
---|
| 462 | if (GSDL_MKTEMP (cstr_tmpname)==NULL)
|
---|
[1148] | 463 | logout << "Failed to create temporary filename" << endl;
|
---|
| 464 |
|
---|
| 465 | delete cstr_tmpname;
|
---|
| 466 |
|
---|
[723] | 467 | disp.setmacro("bcargtmpname","build",tmpname);
|
---|
| 468 |
|
---|
| 469 |
|
---|
| 470 | text_t headmess = "_build:frameheader_(_build:headmess" + wizard_last + "_)\n";
|
---|
| 471 | text_t content = "_build:content" + wizard_last + "_\n";
|
---|
| 472 |
|
---|
| 473 | textout << outconvert << disp << headmess << content << "_build:framefooter_\n";
|
---|
[1177] | 474 | text_t cmd = "perl \"" +
|
---|
| 475 | filename_cat(gsdlhome, "cgi-bin", "webpage_buildcol.pl") + "\"";
|
---|
| 476 | cmd += " \"httpbuild="+args["httpbuild"]+"\"";
|
---|
| 477 | cmd += " \"bc1copydata="+args["bc1copydata"]+"\"";
|
---|
| 478 | cmd += " \"bc1doimport="+args["bc1doimport"]+"\"";
|
---|
| 479 | cmd += " \"bc1dobuild="+args["bc1dobuild"]+"\"";
|
---|
| 480 | cmd += " \"bc1dirname="+args["bc1dirname"]+"\" \"bc1tmpname="+tmpname+"\"";
|
---|
| 481 | // run webpage_buildcol.pl in background on unix systems
|
---|
| 482 | #if !defined (__WIN32__)
|
---|
| 483 | cmd += " &";
|
---|
| 484 | #endif
|
---|
| 485 |
|
---|
[1172] | 486 | char *cstr_cmd = cmd.getcstr();
|
---|
[1177] | 487 |
|
---|
| 488 | #if defined (__WIN32__)
|
---|
| 489 | gsdl_system (cstr_cmd, logout);
|
---|
| 490 | #else
|
---|
| 491 | system (cstr_cmd);
|
---|
| 492 | #endif
|
---|
| 493 |
|
---|
[1172] | 494 | delete cstr_cmd;
|
---|
[723] | 495 | }
|
---|
| 496 |
|
---|
| 497 | return true;
|
---|
| 498 | }
|
---|
| 499 |
|
---|
[760] | 500 | bool buildaction::do_buildstatus (cgiargsclass &args, displayclass &disp,
|
---|
| 501 | outconvertclass &outconvert, ostream &textout,
|
---|
| 502 | ostream &/*logout*/) {
|
---|
[723] | 503 |
|
---|
| 504 | disp.setmacro("contentpara","buildstatus", args["mess"]);
|
---|
| 505 |
|
---|
| 506 | textout << outconvert << disp << ("_buildstatus:header_\n")
|
---|
| 507 | << ("_buildstatus:content_\n")
|
---|
| 508 | << ("_buildstatus:footer_\n");
|
---|
| 509 |
|
---|
| 510 | return true;
|
---|
| 511 | }
|
---|
| 512 |
|
---|
[760] | 513 | bool buildaction::do_delcol (cgiargsclass &/*args*/, displayclass &disp,
|
---|
| 514 | outconvertclass &outconvert, ostream &textout,
|
---|
| 515 | ostream &/*logout*/) {
|
---|
[723] | 516 |
|
---|
| 517 | textout << outconvert << disp << ("_build:header_(_build:headmessdelcol_)\n")
|
---|
| 518 | << ("_build:contentdelcol_\n")
|
---|
| 519 | << ("_build:footer_\n");
|
---|
| 520 |
|
---|
| 521 | return true;
|
---|
| 522 | }
|
---|
| 523 |
|
---|
| 524 |
|
---|
[822] | 525 | bool buildaction::do_collog (cgiargsclass &/*args*/, displayclass &disp,
|
---|
| 526 | outconvertclass &outconvert, ostream &textout,
|
---|
| 527 | ostream &/*logout*/) {
|
---|
| 528 | textout << outconvert << disp << ("_build:header_(_build:headmesscollog_)\n")
|
---|
| 529 | << ("_build:contentcollog_\n")
|
---|
| 530 | << ("_build:wizardfooter_\n");
|
---|
| 531 |
|
---|
| 532 | return true;
|
---|
| 533 | }
|
---|
| 534 |
|
---|
[760] | 535 | bool buildaction::do_mess (cgiargsclass &args, displayclass &disp,
|
---|
| 536 | outconvertclass &outconvert, ostream &textout,
|
---|
| 537 | ostream &/*logout*/) {
|
---|
[723] | 538 |
|
---|
| 539 | disp.setmacro("contentpara","buildmess", args["mess"]);
|
---|
| 540 | disp.setmacro("headmess","buildmess", args["head"]);
|
---|
| 541 | textout << outconvert << disp << ("_build:header_(_buildmess:headmess_)\n")
|
---|
| 542 | << ("_buildmess:content_\n")
|
---|
| 543 | << ("_build:footer_\n");
|
---|
| 544 |
|
---|
| 545 | return true;
|
---|
| 546 | }
|
---|