[160] | 1 | /**********************************************************************
|
---|
| 2 | *
|
---|
| 3 | * pageaction.cpp --
|
---|
| 4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
| 5 | *
|
---|
[533] | 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.
|
---|
[160] | 9 | *
|
---|
[533] | 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 | *
|
---|
[160] | 24 | *********************************************************************/
|
---|
| 25 |
|
---|
[471] | 26 | #include "OIDtools.h"
|
---|
[160] | 27 | #include "pageaction.h"
|
---|
[172] | 28 | #include "receptionist.h"
|
---|
[284] | 29 | #include <time.h>
|
---|
[160] | 30 |
|
---|
[284] | 31 | pageaction::pageaction () {
|
---|
[160] | 32 |
|
---|
[1759] | 33 | status_disabled = true;
|
---|
| 34 | collector_disabled = true;
|
---|
[284] | 35 | recpt = NULL;
|
---|
| 36 |
|
---|
[452] | 37 | // this action uses cgi variables "a", "p", and "hp"
|
---|
[160] | 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;
|
---|
[165] | 43 | arg_ainfo.argdefault = "p";
|
---|
[160] | 44 | arg_ainfo.savedarginfo = cgiarginfo::must;
|
---|
| 45 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
| 46 |
|
---|
| 47 | arg_ainfo.shortname = "p";
|
---|
| 48 | arg_ainfo.longname = "page";
|
---|
| 49 | arg_ainfo.multiplechar = true;
|
---|
| 50 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
[771] | 51 | arg_ainfo.argdefault = "home";
|
---|
[511] | 52 | arg_ainfo.savedarginfo = cgiarginfo::must;
|
---|
[160] | 53 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
[452] | 54 |
|
---|
| 55 | arg_ainfo.shortname = "hp";
|
---|
| 56 | arg_ainfo.longname = "html page";
|
---|
| 57 | arg_ainfo.multiplechar = true;
|
---|
| 58 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
| 59 | arg_ainfo.argdefault = "";
|
---|
| 60 | arg_ainfo.savedarginfo = cgiarginfo::mustnot;
|
---|
| 61 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
[160] | 62 | }
|
---|
| 63 |
|
---|
| 64 | pageaction::~pageaction () {
|
---|
| 65 | }
|
---|
| 66 |
|
---|
[261] | 67 | bool pageaction::check_cgiargs (cgiargsinfoclass &/*argsinfo*/, cgiargsclass &/*args*/,
|
---|
| 68 | ostream &/*logout*/) {
|
---|
[160] | 69 | // don't want to check anything yet.
|
---|
| 70 | return true;
|
---|
| 71 | }
|
---|
| 72 |
|
---|
[761] | 73 | void pageaction::get_cgihead_info (cgiargsclass &/*args*/, recptprotolistclass * /*protos*/,
|
---|
| 74 | response_t &response,text_t &response_data,
|
---|
| 75 | ostream &/*logout*/) {
|
---|
[160] | 76 | response = content;
|
---|
| 77 | response_data = "text/html";
|
---|
| 78 | }
|
---|
| 79 |
|
---|
[761] | 80 | void pageaction::set_homeextra_macro (displayclass &disp, recptprotolistclass *protos,
|
---|
| 81 | ostream &logout) {
|
---|
| 82 | text_t homeextra = "<center><table width=_pagewidth_><tr valign=top>\n";
|
---|
[1276] | 83 | bool found_valid_col = false;
|
---|
[761] | 84 |
|
---|
| 85 | recptprotolistclass::iterator rprotolist_here = protos->begin();
|
---|
| 86 | recptprotolistclass::iterator rprotolist_end = protos->end();
|
---|
| 87 | while (rprotolist_here != rprotolist_end) {
|
---|
| 88 | if ((*rprotolist_here).p != NULL) {
|
---|
| 89 |
|
---|
| 90 | text_tarray collist;
|
---|
| 91 | comerror_t err;
|
---|
| 92 | (*rprotolist_here).p->get_collection_list (collist, err, logout);
|
---|
| 93 | if (err == noError) {
|
---|
| 94 | text_tarray::iterator collist_here = collist.begin();
|
---|
| 95 | text_tarray::iterator collist_end = collist.end();
|
---|
[1247] | 96 |
|
---|
| 97 | int count = 0;
|
---|
| 98 | bool first = true;
|
---|
[761] | 99 | while (collist_here != collist_end) {
|
---|
[1270] | 100 | ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr ((*rprotolist_here).p, *collist_here, logout);
|
---|
[761] | 101 |
|
---|
[1270] | 102 | if (cinfo != NULL) {
|
---|
| 103 | if (cinfo->isPublic && (cinfo->buildDate > 0)) {
|
---|
[1912] | 104 |
|
---|
| 105 | text_t coll_type = "&ct=";
|
---|
| 106 | if (cinfo->buildType == "mgpp") {
|
---|
| 107 | coll_type += "1";
|
---|
| 108 | }
|
---|
| 109 | else {
|
---|
| 110 | coll_type += "0";
|
---|
| 111 | }
|
---|
[1276] | 112 | found_valid_col = true;
|
---|
[1860] | 113 | FilterResponse_t response;
|
---|
[761] | 114 | text_tset metadata;
|
---|
| 115 | metadata.insert ("collectionname");
|
---|
| 116 | metadata.insert ("iconcollection");
|
---|
| 117 | metadata.insert ("iconcollectionsmall");
|
---|
| 118 | text_t collectionname = *collist_here;
|
---|
| 119 | text_t alt = collectionname;
|
---|
[1860] | 120 |
|
---|
[761] | 121 | if (get_info ("collection", *collist_here, metadata, false,
|
---|
| 122 | (*rprotolist_here).p, response, logout)) {
|
---|
| 123 | if (!response.docInfo[0].metadata["collectionname"].values[0].empty())
|
---|
| 124 | alt = response.docInfo[0].metadata["collectionname"].values[0];
|
---|
| 125 |
|
---|
[1860] | 126 | text_t iconurl;
|
---|
| 127 | iconurl.clear();
|
---|
| 128 |
|
---|
[1877] | 129 | if (!response.docInfo[0].metadata["iconcollectionsmall"].values[0].empty()) {
|
---|
| 130 | iconurl = response.docInfo[0].metadata["iconcollectionsmall"].values[0];
|
---|
| 131 | } else if (!response.docInfo[0].metadata["iconcollection"].values[0].empty()) {
|
---|
| 132 | iconurl = response.docInfo[0].metadata["iconcollection"].values[0];
|
---|
| 133 | }
|
---|
[1860] | 134 |
|
---|
| 135 | if (!iconurl.empty())
|
---|
| 136 | {
|
---|
| 137 | // check to see URL is local to colserver
|
---|
| 138 | text_t::iterator iconurl_head = iconurl.begin();
|
---|
| 139 | text_t iconhead = substr(iconurl_head,iconurl_head+16);
|
---|
| 140 | if (iconhead=="_httpcollection_")
|
---|
| 141 | {
|
---|
| 142 | // local and using _httpcollection_
|
---|
| 143 | text_t icontail = substr(iconurl_head+16,iconurl.end());
|
---|
| 144 | iconurl = "http://" + cinfo->httpdomain
|
---|
| 145 | + cinfo->httpprefix + "/collect/"
|
---|
| 146 | + *collist_here + "/" + icontail;
|
---|
| 147 | }
|
---|
| 148 | else if (iconurl[0]=='/')
|
---|
| 149 | {
|
---|
| 150 | // local but with full path
|
---|
| 151 | iconurl = "http://" + cinfo->httpdomain + iconurl;
|
---|
| 152 | }
|
---|
| 153 |
|
---|
| 154 | collectionname
|
---|
| 155 | = "<img width=150 border=1 src=\"" + iconurl + "\" alt=\"" + alt + "\">";
|
---|
| 156 | }
|
---|
| 157 | else
|
---|
| 158 | {
|
---|
| 159 | collectionname = alt;
|
---|
| 160 | }
|
---|
| 161 |
|
---|
[761] | 162 | }
|
---|
[1247] | 163 | if ((count%3 == 0) && (!first))
|
---|
| 164 | homeextra += "</tr><tr valign=top>\n";
|
---|
[970] | 165 |
|
---|
[2113] | 166 | comerror_t err;
|
---|
[1860] | 167 | text_t optsite = "";
|
---|
[2113] | 168 | text_t site_name = (*rprotolist_here).p->get_site_name (err);
|
---|
[1860] | 169 | if (!site_name.empty()) { optsite = "site="+site_name+"&"; }
|
---|
| 170 |
|
---|
[1912] | 171 | text_t link = "<a href=\"_gwcgi_?"+optsite+"a=p&p=about&c=" + *collist_here + coll_type+"\">";
|
---|
[761] | 172 |
|
---|
[1270] | 173 | if (!cinfo->receptionist.empty())
|
---|
| 174 | link = "<a href=\"" + cinfo->receptionist + "\">";
|
---|
[761] | 175 |
|
---|
[1247] | 176 | homeextra += "<td>" + link + collectionname + "</a></td>\n";
|
---|
[761] | 177 |
|
---|
| 178 | count ++;
|
---|
[1247] | 179 | first = false;
|
---|
[761] | 180 | }
|
---|
| 181 | }
|
---|
| 182 | collist_here ++;
|
---|
| 183 | }
|
---|
[1347] | 184 |
|
---|
[1247] | 185 | for (; count%3 != 0; count ++) homeextra += "<td></td>\n";
|
---|
[761] | 186 | }
|
---|
| 187 | }
|
---|
[1347] | 188 | homeextra += "</td></tr>\n<tr>\n";
|
---|
[761] | 189 | rprotolist_here ++;
|
---|
| 190 | }
|
---|
[1276] | 191 |
|
---|
| 192 | if (!found_valid_col) {
|
---|
| 193 | homeextra += "<td>No valid (i.e. built and public) collections are available</td>\n";
|
---|
| 194 | }
|
---|
| 195 | homeextra += "</tr></table></center>\n";
|
---|
| 196 | disp.setmacro ("homeextra", "home", homeextra);
|
---|
[761] | 197 | }
|
---|
| 198 |
|
---|
[2329] | 199 | void pageaction::set_collectionlist_macro (displayclass &disp, recptprotolistclass *protos,
|
---|
| 200 | ostream &logout) {
|
---|
| 201 |
|
---|
| 202 | text_t collectionlist;
|
---|
| 203 | int count = 0;
|
---|
| 204 |
|
---|
| 205 | recptprotolistclass::iterator rprotolist_here = protos->begin();
|
---|
| 206 | recptprotolistclass::iterator rprotolist_end = protos->end();
|
---|
| 207 | while (rprotolist_here != rprotolist_end) {
|
---|
| 208 | if ((*rprotolist_here).p != NULL) {
|
---|
| 209 |
|
---|
| 210 | text_tarray collist;
|
---|
| 211 | comerror_t err;
|
---|
| 212 | (*rprotolist_here).p->get_collection_list (collist, err, logout);
|
---|
| 213 | if (err == noError) {
|
---|
| 214 | text_tarray::iterator collist_here = collist.begin();
|
---|
| 215 | text_tarray::iterator collist_end = collist.end();
|
---|
| 216 |
|
---|
| 217 | while (collist_here != collist_end) {
|
---|
| 218 | ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr ((*rprotolist_here).p, *collist_here, logout);
|
---|
| 219 |
|
---|
| 220 | if (cinfo != NULL) {
|
---|
| 221 | if (cinfo->isPublic && (cinfo->buildDate > 0)) {
|
---|
| 222 |
|
---|
| 223 | count ++;
|
---|
| 224 |
|
---|
| 225 | text_t coll_type = "&ct=";
|
---|
| 226 | if (cinfo->buildType == "mgpp") {
|
---|
| 227 | coll_type += "1";
|
---|
| 228 | }
|
---|
| 229 | else {
|
---|
| 230 | coll_type += "0";
|
---|
| 231 | }
|
---|
| 232 | FilterResponse_t response;
|
---|
| 233 | text_tset metadata;
|
---|
| 234 | metadata.insert ("collectionname");
|
---|
| 235 | text_t collectionname = *collist_here;
|
---|
| 236 |
|
---|
| 237 | if (get_info ("collection", *collist_here, metadata, false,
|
---|
| 238 | (*rprotolist_here).p, response, logout)) {
|
---|
| 239 | if (!response.docInfo[0].metadata["collectionname"].values[0].empty()) {
|
---|
| 240 | collectionname = response.docInfo[0].metadata["collectionname"].values[0];
|
---|
| 241 | }
|
---|
| 242 | }
|
---|
| 243 |
|
---|
| 244 | comerror_t err;
|
---|
| 245 | text_t optsite = "";
|
---|
| 246 | text_t site_name = (*rprotolist_here).p->get_site_name (err);
|
---|
| 247 | if (!site_name.empty()) { optsite = "site="+site_name+"&"; }
|
---|
| 248 |
|
---|
| 249 | text_t link = "<a href=\"_gwcgi_?"+optsite+"a=p&p=about&c=" + *collist_here + coll_type+"\">";
|
---|
| 250 |
|
---|
| 251 | if (!cinfo->receptionist.empty())
|
---|
| 252 | link = "<a href=\"" + cinfo->receptionist + "\">";
|
---|
| 253 |
|
---|
| 254 | collectionlist += "<li>" + link + collectionname + "</a>\n";
|
---|
| 255 | }
|
---|
| 256 | }
|
---|
| 257 | collist_here ++;
|
---|
| 258 | }
|
---|
| 259 | }
|
---|
| 260 | }
|
---|
| 261 | rprotolist_here ++;
|
---|
| 262 | }
|
---|
| 263 |
|
---|
| 264 | if (count == 1) {
|
---|
| 265 | collectionlist = "<p>This Greenstone installation contains 1 collection\n<ul>" +
|
---|
| 266 | collectionlist + "</ul>\n";
|
---|
| 267 | } else if (count > 1) {
|
---|
| 268 | collectionlist = "<p>This Greenstone installation contains " + text_t(count) +
|
---|
| 269 | " collections\n<ul>" + collectionlist + "</ul>\n";
|
---|
| 270 | }
|
---|
| 271 |
|
---|
| 272 | disp.setmacro ("collectionlist", "homehelp", collectionlist);
|
---|
| 273 | }
|
---|
| 274 |
|
---|
[761] | 275 | void pageaction::define_internal_macros (displayclass &disp, cgiargsclass &args,
|
---|
| 276 | recptprotolistclass *protos, ostream &logout) {
|
---|
| 277 |
|
---|
[284] | 278 | // define_internal_macros sets the following macros:
|
---|
| 279 |
|
---|
[866] | 280 | // _numdocs_ the number of documents in the collection
|
---|
| 281 |
|
---|
| 282 | // _builddate_ the date last built
|
---|
| 283 |
|
---|
[471] | 284 | // if page is "home"
|
---|
| 285 | // _homeextra_ this is the list of available collections and collection info
|
---|
| 286 | // to be displayed on the home page
|
---|
[284] | 287 |
|
---|
[471] | 288 |
|
---|
[866] | 289 | // if page is "preferences"
|
---|
| 290 | // _collectionoption_ collections to search/browse (if cross-collection-searching is on)
|
---|
| 291 |
|
---|
| 292 | // _htmloptions_ set to _htmloptionson_ if DocumentUseHTML is set
|
---|
| 293 |
|
---|
[867] | 294 | // _PreferencesDocsFromWeb_ set to 1 if corresponding format option is set
|
---|
[866] | 295 |
|
---|
[867] | 296 | // _languageoption_ interface languages to select from (dependant on PreferenceLanguages)
|
---|
| 297 |
|
---|
[1856] | 298 | // _encodingoption_ encodings to select from
|
---|
[867] | 299 |
|
---|
[471] | 300 | // if page is "about"
|
---|
[866] | 301 | // _textsubcollections_ the text on which subcollections make up the collection (if
|
---|
| 302 | // cross-collection searching is being used
|
---|
[471] | 303 |
|
---|
| 304 | // _textbrowseoptions_ the 'how to find information' text in the about and help pages
|
---|
| 305 |
|
---|
| 306 | // _numbrowseoptions_ the number of browsing options
|
---|
| 307 |
|
---|
| 308 |
|
---|
| 309 | // if page is "help"
|
---|
| 310 | // _textbrowseoptions_ the 'how to find information' text in the about and help pages
|
---|
| 311 |
|
---|
| 312 | // _numbrowseoptions_ the number of browsing options
|
---|
| 313 |
|
---|
[875] | 314 | // _topicreadingdocs_ this section of the help text differs depending on what type of
|
---|
| 315 | // _textreadingdocs_ collection it is (e.g. html collection, bibliographic collection etc.)
|
---|
| 316 | // _texthelpreadingdocs_
|
---|
| 317 |
|
---|
[1759] | 318 | // _textgocollector_ set to "" if collector is disabled in main.cfg
|
---|
| 319 | // _textgoadmin_ set to "" if status is disabled in main.cfg
|
---|
| 320 |
|
---|
[2329] | 321 |
|
---|
| 322 | // if page is "homehelp"
|
---|
| 323 | // _collectionlist_ list of available collections to be displayed on the homehelp page
|
---|
[471] | 324 |
|
---|
[1270] | 325 | if (recpt == NULL) {
|
---|
| 326 | logout << "ERROR (pageaction::define_internal_macros): This action does not contain\n"
|
---|
| 327 | << " information about any receptionists. The method set_receptionist was\n"
|
---|
| 328 | << " probably not called from the module which instantiated this action.\n";
|
---|
| 329 | return;
|
---|
| 330 | }
|
---|
| 331 |
|
---|
[471] | 332 | text_t &arg_p = args["p"];
|
---|
[866] | 333 | text_t &arg_c = args["c"];
|
---|
[1270] | 334 | ColInfoResponse_t *cinfo = NULL;
|
---|
[471] | 335 |
|
---|
[866] | 336 | recptproto* collectproto = protos->getrecptproto (arg_c, logout);
|
---|
[793] | 337 | if (collectproto != NULL) {
|
---|
[1270] | 338 | cinfo = recpt->get_collectinfo_ptr (collectproto, arg_c, logout);
|
---|
[2370] | 339 |
|
---|
[1270] | 340 | disp.setmacro ("numdocs", "Global", cinfo->numDocs);
|
---|
[793] | 341 | unsigned long current_time = time(NULL);
|
---|
[1270] | 342 | unsigned long builddate = (current_time - cinfo->buildDate) / 86400;
|
---|
[793] | 343 | disp.setmacro ("builddate", "Global", builddate);
|
---|
[2370] | 344 |
|
---|
| 345 | text_t numbytes;
|
---|
| 346 | if ((cinfo->numBytes/(1024*1024)) > 1) {
|
---|
| 347 | numbytes = (text_t)(cinfo->numBytes/(1024*1024)) + " Mb";
|
---|
| 348 | } else if ((cinfo->numBytes/1024) > 1) {
|
---|
| 349 | numbytes = (text_t)(cinfo->numBytes/1024) + " kb";
|
---|
| 350 | } else {
|
---|
| 351 | numbytes = (text_t)cinfo->numBytes + " bytes";
|
---|
| 352 | }
|
---|
| 353 | disp.setmacro("numbytes", "Global", numbytes);
|
---|
[793] | 354 | }
|
---|
| 355 |
|
---|
[1759] | 356 | if (arg_p == "home") {
|
---|
| 357 | set_homeextra_macro (disp, protos, logout);
|
---|
| 358 | if (status_disabled) disp.setmacro ("textgoadmin", "home", "");
|
---|
| 359 | if (collector_disabled) disp.setmacro ("textgocollector", "home", "");
|
---|
| 360 | }
|
---|
[284] | 361 |
|
---|
[866] | 362 | else if (arg_p == "preferences") {
|
---|
[2105] | 363 | if (collectproto == NULL) {return;}
|
---|
[866] | 364 | // _collectionoption_
|
---|
| 365 |
|
---|
[1270] | 366 | if (args["ccs"] == "1" && collectproto != NULL && (cinfo->ccsCols.size() > 1)) {
|
---|
[866] | 367 | text_t collectionoption = "_textcollectionoption_";
|
---|
[1270] | 368 | text_tarray::const_iterator col_here = cinfo->ccsCols.begin();
|
---|
| 369 | text_tarray::const_iterator col_end = cinfo->ccsCols.end();
|
---|
[905] | 370 | int count = 0;
|
---|
[866] | 371 | while (col_here != col_end) {
|
---|
| 372 | text_t colname;
|
---|
| 373 | if (*col_here == arg_c) {
|
---|
[1270] | 374 | colname = cinfo->collectionmeta["collectionname"];
|
---|
[866] | 375 | } else {
|
---|
[1270] | 376 | ColInfoResponse_t *this_cinfo = recpt->get_collectinfo_ptr (collectproto, *col_here, logout);
|
---|
| 377 | if (this_cinfo == NULL) {col_here ++; continue;}
|
---|
| 378 | colname = this_cinfo->collectionmeta["collectionname"];
|
---|
[866] | 379 | }
|
---|
| 380 |
|
---|
[905] | 381 | count ++;
|
---|
[866] | 382 | collectionoption += "<input type=checkbox name=\"cc\" value=\"" +
|
---|
| 383 | *col_here + "\" onClick=\"updatecc(\'" + *col_here + "\');\"> " +
|
---|
| 384 | colname + "<br>\n";
|
---|
| 385 | col_here ++;
|
---|
| 386 | }
|
---|
[905] | 387 |
|
---|
| 388 | if (count > 1)
|
---|
| 389 | disp.setmacro ("collectionoption", "preferences", collectionoption);
|
---|
[866] | 390 | }
|
---|
| 391 |
|
---|
| 392 | // _htmloptions_
|
---|
| 393 |
|
---|
[1270] | 394 | text_tmap::const_iterator it = cinfo->format.find ("DocumentUseHTML");
|
---|
| 395 | if ((it != cinfo->format.end()) && ((*it).second == "true")) {
|
---|
[866] | 396 | disp.setmacro ("htmloptions", "preferences", "_htmloptionson_");
|
---|
| 397 |
|
---|
[867] | 398 |
|
---|
| 399 | // _PreferenceDocsFromWeb_
|
---|
| 400 |
|
---|
[1270] | 401 | it = cinfo->format.find ("PreferenceDocsFromWeb");
|
---|
| 402 | if ((it == cinfo->format.end()) || ((*it).second == "true"))
|
---|
[867] | 403 | disp.setmacro ("PreferenceDocsFromWeb", "preferences", "1");
|
---|
| 404 | }
|
---|
| 405 |
|
---|
| 406 | // _languageoption_
|
---|
[1856] | 407 | // Create the "interface language" selection box for the preferences page.
|
---|
| 408 | // You can use something like "format PreferenceLanguages en|fr|zn" from within
|
---|
| 409 | // a collect.cfg file to use only a subset of the available languages for
|
---|
| 410 | // any given collection. This facility is kind of ugly though and should be
|
---|
| 411 | // replaced by something better when the configuration files are tidied up (as
|
---|
| 412 | // should all the other "format Preference..." options).
|
---|
[866] | 413 |
|
---|
[1856] | 414 | text_t &arg_l = args["l"];
|
---|
| 415 | const recptconf &configinfo = recpt->get_configinfo();
|
---|
| 416 | // put languages in another map to sort them by longname
|
---|
| 417 | text_tmap languages;
|
---|
| 418 | languageinfo_tmap::const_iterator thislang = configinfo.languages.begin();
|
---|
| 419 | languageinfo_tmap::const_iterator endlang = configinfo.languages.end();
|
---|
| 420 | while (thislang != endlang) {
|
---|
| 421 | languages[(*thislang).second.longname] = (*thislang).first;
|
---|
| 422 | thislang++;
|
---|
| 423 | }
|
---|
| 424 | text_tmap::iterator tlang = languages.begin();
|
---|
| 425 | text_tmap::iterator elang = languages.end();
|
---|
[867] | 426 |
|
---|
[1856] | 427 | text_t languageoption;
|
---|
[1270] | 428 | it = cinfo->format.find ("PreferenceLanguages");
|
---|
| 429 | if ((it != cinfo->format.end()) && (!(*it).second.empty())) {
|
---|
[867] | 430 | text_tset pref_langs;
|
---|
| 431 | splitchar ((*it).second.begin(), (*it).second.end(), '|', pref_langs);
|
---|
| 432 | if (pref_langs.size() > 1) {
|
---|
[1856] | 433 | while (tlang != elang) {
|
---|
| 434 | if (pref_langs.find((*tlang).second) != pref_langs.end()) {
|
---|
| 435 | languageoption += "<option value=\"" + (*tlang).second + "\"";
|
---|
| 436 | if ((*tlang).second == arg_l) languageoption += " selected";
|
---|
| 437 | languageoption += ">" + (*tlang).first + "\n";
|
---|
| 438 | }
|
---|
| 439 | tlang ++;
|
---|
[867] | 440 | }
|
---|
| 441 | }
|
---|
| 442 |
|
---|
| 443 | } else {
|
---|
[1856] | 444 | while (tlang != elang) {
|
---|
| 445 | languageoption += "<option value=\"" + (*tlang).second + "\"";
|
---|
| 446 | if ((*tlang).second == arg_l) languageoption += " selected";
|
---|
| 447 | languageoption += ">" + (*tlang).first + "\n";
|
---|
| 448 | tlang ++;
|
---|
[867] | 449 | }
|
---|
[1856] | 450 | }
|
---|
| 451 | if (!languageoption.empty()) {
|
---|
| 452 | languageoption = "<select name=\"l\" onChange=\"updatel();\">\n" + languageoption;
|
---|
[867] | 453 | languageoption += "</select>\n";
|
---|
| 454 | disp.setmacro ("languageoption", "preferences", languageoption);
|
---|
| 455 | }
|
---|
[1856] | 456 |
|
---|
| 457 | // _encodingoption_
|
---|
| 458 | // create the "encoding" selection box for the preferences page
|
---|
[1902] | 459 | if (configinfo.encodings.size() > 1) {
|
---|
| 460 | text_t &arg_w = args["w"];
|
---|
| 461 | text_t encodingoption;
|
---|
| 462 | text_tmap::const_iterator thisenc = configinfo.encodings.begin();
|
---|
| 463 | text_tmap::const_iterator endenc = configinfo.encodings.end();
|
---|
| 464 | while (thisenc != endenc) {
|
---|
| 465 | encodingoption += "<option value=\"" + (*thisenc).second + "\"";
|
---|
| 466 | if ((*thisenc).second == arg_w) encodingoption += " selected";
|
---|
| 467 | encodingoption += ">" + (*thisenc).first + "\n";
|
---|
| 468 | thisenc ++;
|
---|
| 469 | }
|
---|
[1856] | 470 |
|
---|
| 471 | encodingoption = "<select name=\"w\" onChange=\"updatew();\">\n" + encodingoption;
|
---|
| 472 | encodingoption += "</select>\n";
|
---|
| 473 | disp.setmacro ("encodingoption", "preferences", encodingoption);
|
---|
| 474 | }
|
---|
[867] | 475 |
|
---|
[866] | 476 | } else if (arg_p == "about" || arg_p == "help") {
|
---|
[761] | 477 | if (collectproto == NULL) return;
|
---|
| 478 |
|
---|
[471] | 479 | // _textbrowseoptions_ and _numbrowseoptions_
|
---|
[761] | 480 |
|
---|
[471] | 481 | FilterResponse_t response;
|
---|
[649] | 482 | text_tset metadata;
|
---|
| 483 | metadata.insert ("Title");
|
---|
[471] | 484 | bool getParents = false;
|
---|
| 485 | get_children ("", args["c"], metadata, getParents, collectproto, response, logout);
|
---|
| 486 |
|
---|
| 487 | disp.setmacro ("numbrowseoptions", "help", response.docInfo.size()+1);
|
---|
| 488 |
|
---|
[649] | 489 | ResultDocInfo_tarray::iterator here = response.docInfo.begin();
|
---|
| 490 | ResultDocInfo_tarray::iterator end = response.docInfo.end();
|
---|
[471] | 491 |
|
---|
| 492 | // we're assuming that we've always got a search button
|
---|
| 493 | text_t shorttext = "<ul><li>_textSearchshort_\n";
|
---|
| 494 | text_t longtext = "_textSearchlong_";
|
---|
| 495 |
|
---|
| 496 | while (here != end) {
|
---|
[649] | 497 | text_t title = (*here).metadata["Title"].values[0];
|
---|
[604] | 498 |
|
---|
[649] | 499 | text_t stext, ltext;
|
---|
[729] | 500 | disp.expandstring ("help", "_text" + title + "short_", stext);
|
---|
[649] | 501 | if (stext == ("_text" + title + "short_")) {
|
---|
[729] | 502 | shorttext += "<li>_help:textdefaultshorttext_";
|
---|
| 503 | longtext += "_help:textdefaultlongtext_";
|
---|
[649] | 504 | } else {
|
---|
[1667] | 505 | shorttext += "<li>_help:text" + title + "short_";
|
---|
[729] | 506 | longtext += "_help:text" + title + "long_";
|
---|
[649] | 507 | }
|
---|
[729] | 508 |
|
---|
[471] | 509 | here ++;
|
---|
| 510 | }
|
---|
| 511 | shorttext += "</ul>\n";
|
---|
[867] | 512 | if (response.docInfo.size() > 1) disp.setmacro ("textbrowseoptions", "help", shorttext + longtext);
|
---|
| 513 | else disp.setmacro ("textbrowseoptions", "help", longtext);
|
---|
[866] | 514 |
|
---|
[875] | 515 | if (arg_p == "help") {
|
---|
| 516 |
|
---|
| 517 | // _topicreadingdocs_ _textreadingdocs_ _texthelpreadingdocs_
|
---|
| 518 |
|
---|
| 519 | // if HTML collection there's no how to read document text
|
---|
[1270] | 520 | text_tmap::const_iterator it = cinfo->format.find ("HelpNoDocs");
|
---|
| 521 | if ((it != cinfo->format.end()) && ((*it).second == "true")) {
|
---|
[875] | 522 | disp.setmacro ("topicreadingdocs", "help", "");
|
---|
| 523 | disp.setmacro ("texthelpreadingdocs", "help", "");
|
---|
| 524 | }
|
---|
[1270] | 525 | it = cinfo->format.find ("HelpBibDocs");
|
---|
| 526 | if ((it != cinfo->format.end()) && ((*it).second == "true")) {
|
---|
[875] | 527 | disp.setmacro ("texthelpreadingdocs", "help", "_bibtexthelpreadingdocs_");
|
---|
| 528 | disp.setmacro ("textreadingdocs", "help", "_bibtextreadingdocs_");
|
---|
| 529 | }
|
---|
[1270] | 530 | it = cinfo->format.find ("HelpBookDocs");
|
---|
| 531 | if ((it != cinfo->format.end()) && ((*it).second == "true")) {
|
---|
[875] | 532 | disp.setmacro ("texthelpreadingdocs", "help", "_booktexthelpreadingdocs_");
|
---|
| 533 | disp.setmacro ("textreadingdocs", "help", "_booktextreadingdocs_");
|
---|
| 534 | }
|
---|
| 535 |
|
---|
| 536 | }
|
---|
[866] | 537 | if (arg_p == "about") {
|
---|
| 538 |
|
---|
| 539 | // _textsubcollections_
|
---|
[1270] | 540 | if (args["ccs"] == "1" && (cinfo->ccsCols.size() > 1)) {
|
---|
| 541 | text_t textsubcollections = "_textsubcols1_(" + text_t(cinfo->ccsCols.size()) + ")";
|
---|
| 542 | text_tarray::const_iterator here = cinfo->ccsCols.begin();
|
---|
| 543 | text_tarray::const_iterator end = cinfo->ccsCols.end();
|
---|
[867] | 544 | bool first = true;
|
---|
[905] | 545 | int count = 0;
|
---|
[866] | 546 | while (here != end) {
|
---|
| 547 | if (*here == arg_c) {
|
---|
[867] | 548 | if (!first) textsubcollections += "<br>";
|
---|
[1270] | 549 | textsubcollections += "\n" + cinfo->collectionmeta["collectionname"] + "\n";
|
---|
[866] | 550 | } else {
|
---|
[1270] | 551 | ColInfoResponse_t *this_cinfo = recpt->get_collectinfo_ptr (collectproto, *here, logout);
|
---|
| 552 | if (this_cinfo == NULL) {here ++; continue;}
|
---|
[905] | 553 | if (!first) textsubcollections += "<br>";
|
---|
[1270] | 554 | textsubcollections += "\n" + this_cinfo->collectionmeta["collectionname"] + "\n";
|
---|
[866] | 555 | }
|
---|
[905] | 556 | count ++;
|
---|
[867] | 557 | first = false;
|
---|
[866] | 558 | here ++;
|
---|
| 559 | }
|
---|
| 560 | textsubcollections += "_textsubcols2_";
|
---|
[905] | 561 | if (count > 1)
|
---|
| 562 | disp.setmacro ("textsubcollections", "about", textsubcollections);
|
---|
[866] | 563 | }
|
---|
| 564 | }
|
---|
[2329] | 565 |
|
---|
| 566 | } else if (arg_p == "homehelp") {
|
---|
| 567 |
|
---|
| 568 | set_collectionlist_macro (disp, protos, logout);
|
---|
| 569 |
|
---|
[471] | 570 | }
|
---|
[284] | 571 | }
|
---|
| 572 |
|
---|
[761] | 573 | bool pageaction::do_action (cgiargsclass &args, recptprotolistclass * /*protos*/,
|
---|
| 574 | browsermapclass * /*browsers*/, displayclass &disp,
|
---|
[421] | 575 | outconvertclass &outconvert, ostream &textout,
|
---|
| 576 | ostream &/*logout*/) {
|
---|
[173] | 577 |
|
---|
[172] | 578 | text_t &arg_p = args["p"];
|
---|
[160] | 579 |
|
---|
[172] | 580 | textout << outconvert << disp << ("_" + arg_p + ":header_\n")
|
---|
[266] | 581 | << ("_" + arg_p + ":content_\n")
|
---|
[172] | 582 | << ("_" + arg_p + ":footer_\n");
|
---|
| 583 |
|
---|
[160] | 584 | return true;
|
---|
| 585 | }
|
---|
[1759] | 586 |
|
---|
| 587 | void pageaction::configure (const text_t &key, const text_tarray &cfgline) {
|
---|
| 588 | if ((key == "status") && (cfgline.size() == 1) &&
|
---|
| 589 | (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
|
---|
| 590 | status_disabled = false;
|
---|
| 591 | } else if ((key == "collector") && (cfgline.size() == 1) &&
|
---|
| 592 | (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
|
---|
| 593 | collector_disabled = false;
|
---|
| 594 | } else {
|
---|
| 595 | // call the parent class to deal with the things which
|
---|
| 596 | // are not dealt with here
|
---|
| 597 | action::configure (key, cfgline);
|
---|
| 598 | }
|
---|
| 599 | }
|
---|