[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)) {
|
---|
[761] | 104 |
|
---|
[1276] | 105 | found_valid_col = true;
|
---|
[1860] | 106 | FilterResponse_t response;
|
---|
[761] | 107 | text_tset metadata;
|
---|
| 108 | metadata.insert ("collectionname");
|
---|
| 109 | metadata.insert ("iconcollection");
|
---|
| 110 | metadata.insert ("iconcollectionsmall");
|
---|
| 111 | text_t collectionname = *collist_here;
|
---|
| 112 | text_t alt = collectionname;
|
---|
[1860] | 113 |
|
---|
[761] | 114 | if (get_info ("collection", *collist_here, metadata, false,
|
---|
| 115 | (*rprotolist_here).p, response, logout)) {
|
---|
| 116 | if (!response.docInfo[0].metadata["collectionname"].values[0].empty())
|
---|
| 117 | alt = response.docInfo[0].metadata["collectionname"].values[0];
|
---|
| 118 |
|
---|
[1860] | 119 | text_t iconurl;
|
---|
| 120 | iconurl.clear();
|
---|
| 121 |
|
---|
[761] | 122 | if (!response.docInfo[0].metadata["iconcollectionsmall"].values[0].empty())
|
---|
[1759] | 123 | collectionname = "<img width=150 border=1 src=\""
|
---|
| 124 | + response.docInfo[0].metadata["iconcollectionsmall"].values[0]
|
---|
| 125 | + "\" alt=\"" + alt + "\">";
|
---|
[761] | 126 | else if (!response.docInfo[0].metadata["iconcollection"].values[0].empty())
|
---|
[1860] | 127 | {
|
---|
| 128 | iconurl = response.docInfo[0].metadata["iconcollection"].values[0];
|
---|
| 129 | }
|
---|
| 130 |
|
---|
| 131 | if (!iconurl.empty())
|
---|
| 132 | {
|
---|
| 133 | // check to see URL is local to colserver
|
---|
| 134 | text_t::iterator iconurl_head = iconurl.begin();
|
---|
| 135 | text_t iconhead = substr(iconurl_head,iconurl_head+16);
|
---|
| 136 | if (iconhead=="_httpcollection_")
|
---|
| 137 | {
|
---|
| 138 | // local and using _httpcollection_
|
---|
| 139 | text_t icontail = substr(iconurl_head+16,iconurl.end());
|
---|
| 140 | iconurl = "http://" + cinfo->httpdomain
|
---|
| 141 | + cinfo->httpprefix + "/collect/"
|
---|
| 142 | + *collist_here + "/" + icontail;
|
---|
| 143 | }
|
---|
| 144 | else if (iconurl[0]=='/')
|
---|
| 145 | {
|
---|
| 146 | // local but with full path
|
---|
| 147 | iconurl = "http://" + cinfo->httpdomain + iconurl;
|
---|
| 148 | }
|
---|
| 149 |
|
---|
| 150 | collectionname
|
---|
| 151 | = "<img width=150 border=1 src=\"" + iconurl + "\" alt=\"" + alt + "\">";
|
---|
| 152 | }
|
---|
| 153 | else
|
---|
| 154 | {
|
---|
| 155 | collectionname = alt;
|
---|
| 156 | }
|
---|
| 157 |
|
---|
[761] | 158 | }
|
---|
[1247] | 159 | if ((count%3 == 0) && (!first))
|
---|
| 160 | homeextra += "</tr><tr valign=top>\n";
|
---|
[970] | 161 |
|
---|
[1860] | 162 | text_t optsite = "";
|
---|
| 163 | text_t site_name = (*rprotolist_here).p->get_site_name ();
|
---|
| 164 | if (!site_name.empty()) { optsite = "site="+site_name+"&"; }
|
---|
| 165 |
|
---|
| 166 | text_t link = "<a href=\"_gwcgi_?"+optsite+"a=p&p=about&c=" + *collist_here + "\">";
|
---|
[761] | 167 | if (*collist_here == "chinese")
|
---|
[1860] | 168 | link = "<a href=\"_gwcgi_?"+optsite+"a=p&p=about&l=zh&nw=u&c=" + *collist_here + "\">";
|
---|
[866] | 169 | if (*collist_here == "arabic")
|
---|
[1860] | 170 | link = "<a href=\"_gwcgi_?"+optsite+"a=p&p=about&w=a&c=" + *collist_here + "\">";
|
---|
[761] | 171 |
|
---|
[1270] | 172 | if (!cinfo->receptionist.empty())
|
---|
| 173 | link = "<a href=\"" + cinfo->receptionist + "\">";
|
---|
[761] | 174 |
|
---|
[1247] | 175 | homeextra += "<td>" + link + collectionname + "</a></td>\n";
|
---|
[761] | 176 |
|
---|
| 177 | count ++;
|
---|
[1247] | 178 | first = false;
|
---|
[761] | 179 | }
|
---|
| 180 | }
|
---|
| 181 | collist_here ++;
|
---|
| 182 | }
|
---|
[1347] | 183 |
|
---|
| 184 | // disp.setmacro ("homeextra", "home", homeextra);
|
---|
[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 |
|
---|
| 199 | void pageaction::define_internal_macros (displayclass &disp, cgiargsclass &args,
|
---|
| 200 | recptprotolistclass *protos, ostream &logout) {
|
---|
| 201 |
|
---|
[284] | 202 | // define_internal_macros sets the following macros:
|
---|
| 203 |
|
---|
[866] | 204 | // _numdocs_ the number of documents in the collection
|
---|
| 205 |
|
---|
| 206 | // _builddate_ the date last built
|
---|
| 207 |
|
---|
| 208 |
|
---|
[471] | 209 | // if page is "home"
|
---|
| 210 | // _homeextra_ this is the list of available collections and collection info
|
---|
| 211 | // to be displayed on the home page
|
---|
[284] | 212 |
|
---|
[471] | 213 |
|
---|
[866] | 214 | // if page is "preferences"
|
---|
| 215 | // _collectionoption_ collections to search/browse (if cross-collection-searching is on)
|
---|
| 216 |
|
---|
| 217 | // _htmloptions_ set to _htmloptionson_ if DocumentUseHTML is set
|
---|
| 218 |
|
---|
[867] | 219 | // _PreferencesDocsFromWeb_ set to 1 if corresponding format option is set
|
---|
[866] | 220 |
|
---|
[867] | 221 | // _languageoption_ interface languages to select from (dependant on PreferenceLanguages)
|
---|
| 222 |
|
---|
[1856] | 223 | // _encodingoption_ encodings to select from
|
---|
[867] | 224 |
|
---|
[471] | 225 | // if page is "about"
|
---|
[866] | 226 | // _textsubcollections_ the text on which subcollections make up the collection (if
|
---|
| 227 | // cross-collection searching is being used
|
---|
[471] | 228 |
|
---|
| 229 | // _textbrowseoptions_ the 'how to find information' text in the about and help pages
|
---|
| 230 |
|
---|
| 231 | // _numbrowseoptions_ the number of browsing options
|
---|
| 232 |
|
---|
| 233 |
|
---|
| 234 | // if page is "help"
|
---|
| 235 | // _textbrowseoptions_ the 'how to find information' text in the about and help pages
|
---|
| 236 |
|
---|
| 237 | // _numbrowseoptions_ the number of browsing options
|
---|
| 238 |
|
---|
[875] | 239 | // _topicreadingdocs_ this section of the help text differs depending on what type of
|
---|
| 240 | // _textreadingdocs_ collection it is (e.g. html collection, bibliographic collection etc.)
|
---|
| 241 | // _texthelpreadingdocs_
|
---|
| 242 |
|
---|
[1759] | 243 | // _textgocollector_ set to "" if collector is disabled in main.cfg
|
---|
| 244 | // _textgoadmin_ set to "" if status is disabled in main.cfg
|
---|
| 245 |
|
---|
[471] | 246 |
|
---|
[1270] | 247 | if (recpt == NULL) {
|
---|
| 248 | logout << "ERROR (pageaction::define_internal_macros): This action does not contain\n"
|
---|
| 249 | << " information about any receptionists. The method set_receptionist was\n"
|
---|
| 250 | << " probably not called from the module which instantiated this action.\n";
|
---|
| 251 | return;
|
---|
| 252 | }
|
---|
| 253 |
|
---|
[471] | 254 | text_t &arg_p = args["p"];
|
---|
[866] | 255 | text_t &arg_c = args["c"];
|
---|
[1270] | 256 | ColInfoResponse_t *cinfo = NULL;
|
---|
[471] | 257 |
|
---|
[866] | 258 | recptproto* collectproto = protos->getrecptproto (arg_c, logout);
|
---|
[793] | 259 | if (collectproto != NULL) {
|
---|
[1270] | 260 | cinfo = recpt->get_collectinfo_ptr (collectproto, arg_c, logout);
|
---|
[866] | 261 |
|
---|
[1270] | 262 | disp.setmacro ("numdocs", "Global", cinfo->numDocs);
|
---|
[793] | 263 | unsigned long current_time = time(NULL);
|
---|
[1270] | 264 | unsigned long builddate = (current_time - cinfo->buildDate) / 86400;
|
---|
[793] | 265 | disp.setmacro ("builddate", "Global", builddate);
|
---|
| 266 | }
|
---|
| 267 |
|
---|
[1759] | 268 | if (arg_p == "home") {
|
---|
| 269 | set_homeextra_macro (disp, protos, logout);
|
---|
| 270 | if (status_disabled) disp.setmacro ("textgoadmin", "home", "");
|
---|
| 271 | if (collector_disabled) disp.setmacro ("textgocollector", "home", "");
|
---|
| 272 | }
|
---|
[284] | 273 |
|
---|
[866] | 274 | else if (arg_p == "preferences") {
|
---|
| 275 |
|
---|
| 276 | // _collectionoption_
|
---|
| 277 |
|
---|
[1270] | 278 | if (args["ccs"] == "1" && collectproto != NULL && (cinfo->ccsCols.size() > 1)) {
|
---|
[866] | 279 | text_t collectionoption = "_textcollectionoption_";
|
---|
[1270] | 280 | text_tarray::const_iterator col_here = cinfo->ccsCols.begin();
|
---|
| 281 | text_tarray::const_iterator col_end = cinfo->ccsCols.end();
|
---|
[905] | 282 | int count = 0;
|
---|
[866] | 283 | while (col_here != col_end) {
|
---|
| 284 | text_t colname;
|
---|
| 285 | if (*col_here == arg_c) {
|
---|
[1270] | 286 | colname = cinfo->collectionmeta["collectionname"];
|
---|
[866] | 287 | } else {
|
---|
[1270] | 288 | ColInfoResponse_t *this_cinfo = recpt->get_collectinfo_ptr (collectproto, *col_here, logout);
|
---|
| 289 | if (this_cinfo == NULL) {col_here ++; continue;}
|
---|
| 290 | colname = this_cinfo->collectionmeta["collectionname"];
|
---|
[866] | 291 | }
|
---|
| 292 |
|
---|
[905] | 293 | count ++;
|
---|
[866] | 294 | collectionoption += "<input type=checkbox name=\"cc\" value=\"" +
|
---|
| 295 | *col_here + "\" onClick=\"updatecc(\'" + *col_here + "\');\"> " +
|
---|
| 296 | colname + "<br>\n";
|
---|
| 297 | col_here ++;
|
---|
| 298 | }
|
---|
[905] | 299 |
|
---|
| 300 | if (count > 1)
|
---|
| 301 | disp.setmacro ("collectionoption", "preferences", collectionoption);
|
---|
[866] | 302 | }
|
---|
| 303 |
|
---|
| 304 | // _htmloptions_
|
---|
| 305 |
|
---|
[1270] | 306 | text_tmap::const_iterator it = cinfo->format.find ("DocumentUseHTML");
|
---|
| 307 | if ((it != cinfo->format.end()) && ((*it).second == "true")) {
|
---|
[866] | 308 | disp.setmacro ("htmloptions", "preferences", "_htmloptionson_");
|
---|
| 309 |
|
---|
[867] | 310 |
|
---|
| 311 | // _PreferenceDocsFromWeb_
|
---|
| 312 |
|
---|
[1270] | 313 | it = cinfo->format.find ("PreferenceDocsFromWeb");
|
---|
| 314 | if ((it == cinfo->format.end()) || ((*it).second == "true"))
|
---|
[867] | 315 | disp.setmacro ("PreferenceDocsFromWeb", "preferences", "1");
|
---|
| 316 | }
|
---|
| 317 |
|
---|
| 318 | // _languageoption_
|
---|
[1856] | 319 | // Create the "interface language" selection box for the preferences page.
|
---|
| 320 | // You can use something like "format PreferenceLanguages en|fr|zn" from within
|
---|
| 321 | // a collect.cfg file to use only a subset of the available languages for
|
---|
| 322 | // any given collection. This facility is kind of ugly though and should be
|
---|
| 323 | // replaced by something better when the configuration files are tidied up (as
|
---|
| 324 | // should all the other "format Preference..." options).
|
---|
[866] | 325 |
|
---|
[1856] | 326 | text_t &arg_l = args["l"];
|
---|
| 327 | const recptconf &configinfo = recpt->get_configinfo();
|
---|
| 328 | // put languages in another map to sort them by longname
|
---|
| 329 | text_tmap languages;
|
---|
| 330 | languageinfo_tmap::const_iterator thislang = configinfo.languages.begin();
|
---|
| 331 | languageinfo_tmap::const_iterator endlang = configinfo.languages.end();
|
---|
| 332 | while (thislang != endlang) {
|
---|
| 333 | languages[(*thislang).second.longname] = (*thislang).first;
|
---|
| 334 | thislang++;
|
---|
| 335 | }
|
---|
| 336 | text_tmap::iterator tlang = languages.begin();
|
---|
| 337 | text_tmap::iterator elang = languages.end();
|
---|
[867] | 338 |
|
---|
[1856] | 339 | text_t languageoption;
|
---|
[1270] | 340 | it = cinfo->format.find ("PreferenceLanguages");
|
---|
| 341 | if ((it != cinfo->format.end()) && (!(*it).second.empty())) {
|
---|
[867] | 342 | text_tset pref_langs;
|
---|
| 343 | splitchar ((*it).second.begin(), (*it).second.end(), '|', pref_langs);
|
---|
| 344 | if (pref_langs.size() > 1) {
|
---|
[1856] | 345 | while (tlang != elang) {
|
---|
| 346 | if (pref_langs.find((*tlang).second) != pref_langs.end()) {
|
---|
| 347 | languageoption += "<option value=\"" + (*tlang).second + "\"";
|
---|
| 348 | if ((*tlang).second == arg_l) languageoption += " selected";
|
---|
| 349 | languageoption += ">" + (*tlang).first + "\n";
|
---|
| 350 | }
|
---|
| 351 | tlang ++;
|
---|
[867] | 352 | }
|
---|
| 353 | }
|
---|
| 354 |
|
---|
[1860] | 355 | if (pref_langs.find("zh") == pref_langs.end())
|
---|
| 356 | disp.setmacro ("encodingoption", "preferences", "");
|
---|
| 357 |
|
---|
[867] | 358 | } else {
|
---|
[1856] | 359 | while (tlang != elang) {
|
---|
| 360 | languageoption += "<option value=\"" + (*tlang).second + "\"";
|
---|
| 361 | if ((*tlang).second == arg_l) languageoption += " selected";
|
---|
| 362 | languageoption += ">" + (*tlang).first + "\n";
|
---|
| 363 | tlang ++;
|
---|
[867] | 364 | }
|
---|
[1856] | 365 | }
|
---|
| 366 | if (!languageoption.empty()) {
|
---|
| 367 | languageoption = "<select name=\"l\" onChange=\"updatel();\">\n" + languageoption;
|
---|
[867] | 368 | languageoption += "</select>\n";
|
---|
| 369 | disp.setmacro ("languageoption", "preferences", languageoption);
|
---|
| 370 | }
|
---|
[1856] | 371 |
|
---|
| 372 | // _encodingoption_
|
---|
| 373 | // create the "encoding" selection box for the preferences page
|
---|
| 374 | text_t &arg_w = args["w"];
|
---|
| 375 | // put encodings in another map to sort them by longname
|
---|
| 376 | text_tmap encodings;
|
---|
| 377 | encodinginfo_tmap::const_iterator thisenc = configinfo.encodings.begin();
|
---|
| 378 | encodinginfo_tmap::const_iterator endenc = configinfo.encodings.end();
|
---|
| 379 | while (thisenc != endenc) {
|
---|
| 380 | encodings[(*thisenc).second.longname] = (*thisenc).first;
|
---|
| 381 | thisenc++;
|
---|
| 382 | }
|
---|
| 383 | text_tmap::iterator tenc = encodings.begin();
|
---|
| 384 | text_tmap::iterator eenc = encodings.end();
|
---|
| 385 |
|
---|
| 386 | text_t encodingoption;
|
---|
| 387 | while (tenc != eenc) {
|
---|
| 388 | encodingoption += "<option value=\"" + (*tenc).second + "\"";
|
---|
| 389 | if ((*tenc).second == arg_w) encodingoption += " selected";
|
---|
| 390 | encodingoption += ">" + (*tenc).first + "\n";
|
---|
| 391 | tenc ++;
|
---|
| 392 | }
|
---|
| 393 |
|
---|
| 394 | if (!encodingoption.empty()) {
|
---|
| 395 | encodingoption = "<select name=\"w\" onChange=\"updatew();\">\n" + encodingoption;
|
---|
| 396 | encodingoption += "</select>\n";
|
---|
| 397 | disp.setmacro ("encodingoption", "preferences", encodingoption);
|
---|
| 398 | }
|
---|
[867] | 399 |
|
---|
[866] | 400 | } else if (arg_p == "about" || arg_p == "help") {
|
---|
[761] | 401 | if (collectproto == NULL) return;
|
---|
| 402 |
|
---|
[471] | 403 | // _textbrowseoptions_ and _numbrowseoptions_
|
---|
[761] | 404 |
|
---|
[471] | 405 | FilterResponse_t response;
|
---|
[649] | 406 | text_tset metadata;
|
---|
| 407 | metadata.insert ("Title");
|
---|
[471] | 408 | bool getParents = false;
|
---|
| 409 | get_children ("", args["c"], metadata, getParents, collectproto, response, logout);
|
---|
| 410 |
|
---|
| 411 | disp.setmacro ("numbrowseoptions", "help", response.docInfo.size()+1);
|
---|
| 412 |
|
---|
[649] | 413 | ResultDocInfo_tarray::iterator here = response.docInfo.begin();
|
---|
| 414 | ResultDocInfo_tarray::iterator end = response.docInfo.end();
|
---|
[471] | 415 |
|
---|
| 416 | // we're assuming that we've always got a search button
|
---|
| 417 | text_t shorttext = "<ul><li>_textSearchshort_\n";
|
---|
| 418 | text_t longtext = "_textSearchlong_";
|
---|
| 419 |
|
---|
| 420 | while (here != end) {
|
---|
[649] | 421 | text_t title = (*here).metadata["Title"].values[0];
|
---|
[604] | 422 |
|
---|
[649] | 423 | text_t stext, ltext;
|
---|
[729] | 424 | disp.expandstring ("help", "_text" + title + "short_", stext);
|
---|
[649] | 425 | if (stext == ("_text" + title + "short_")) {
|
---|
[729] | 426 | shorttext += "<li>_help:textdefaultshorttext_";
|
---|
| 427 | longtext += "_help:textdefaultlongtext_";
|
---|
[649] | 428 | } else {
|
---|
[1667] | 429 | shorttext += "<li>_help:text" + title + "short_";
|
---|
[729] | 430 | longtext += "_help:text" + title + "long_";
|
---|
[649] | 431 | }
|
---|
[729] | 432 |
|
---|
[471] | 433 | here ++;
|
---|
| 434 | }
|
---|
| 435 | shorttext += "</ul>\n";
|
---|
[867] | 436 | if (response.docInfo.size() > 1) disp.setmacro ("textbrowseoptions", "help", shorttext + longtext);
|
---|
| 437 | else disp.setmacro ("textbrowseoptions", "help", longtext);
|
---|
[866] | 438 |
|
---|
[875] | 439 | if (arg_p == "help") {
|
---|
| 440 |
|
---|
| 441 | // _topicreadingdocs_ _textreadingdocs_ _texthelpreadingdocs_
|
---|
| 442 |
|
---|
| 443 | // if HTML collection there's no how to read document text
|
---|
[1270] | 444 | text_tmap::const_iterator it = cinfo->format.find ("HelpNoDocs");
|
---|
| 445 | if ((it != cinfo->format.end()) && ((*it).second == "true")) {
|
---|
[875] | 446 | disp.setmacro ("topicreadingdocs", "help", "");
|
---|
| 447 | disp.setmacro ("texthelpreadingdocs", "help", "");
|
---|
| 448 | }
|
---|
[1270] | 449 | it = cinfo->format.find ("HelpBibDocs");
|
---|
| 450 | if ((it != cinfo->format.end()) && ((*it).second == "true")) {
|
---|
[875] | 451 | disp.setmacro ("texthelpreadingdocs", "help", "_bibtexthelpreadingdocs_");
|
---|
| 452 | disp.setmacro ("textreadingdocs", "help", "_bibtextreadingdocs_");
|
---|
| 453 | }
|
---|
[1270] | 454 | it = cinfo->format.find ("HelpBookDocs");
|
---|
| 455 | if ((it != cinfo->format.end()) && ((*it).second == "true")) {
|
---|
[875] | 456 | disp.setmacro ("texthelpreadingdocs", "help", "_booktexthelpreadingdocs_");
|
---|
| 457 | disp.setmacro ("textreadingdocs", "help", "_booktextreadingdocs_");
|
---|
| 458 | }
|
---|
| 459 |
|
---|
| 460 | }
|
---|
[866] | 461 | if (arg_p == "about") {
|
---|
| 462 |
|
---|
| 463 | // _textsubcollections_
|
---|
[1270] | 464 | if (args["ccs"] == "1" && (cinfo->ccsCols.size() > 1)) {
|
---|
| 465 | text_t textsubcollections = "_textsubcols1_(" + text_t(cinfo->ccsCols.size()) + ")";
|
---|
| 466 | text_tarray::const_iterator here = cinfo->ccsCols.begin();
|
---|
| 467 | text_tarray::const_iterator end = cinfo->ccsCols.end();
|
---|
[867] | 468 | bool first = true;
|
---|
[905] | 469 | int count = 0;
|
---|
[866] | 470 | while (here != end) {
|
---|
| 471 | if (*here == arg_c) {
|
---|
[867] | 472 | if (!first) textsubcollections += "<br>";
|
---|
[1270] | 473 | textsubcollections += "\n" + cinfo->collectionmeta["collectionname"] + "\n";
|
---|
[866] | 474 | } else {
|
---|
[1270] | 475 | ColInfoResponse_t *this_cinfo = recpt->get_collectinfo_ptr (collectproto, *here, logout);
|
---|
| 476 | if (this_cinfo == NULL) {here ++; continue;}
|
---|
[905] | 477 | if (!first) textsubcollections += "<br>";
|
---|
[1270] | 478 | textsubcollections += "\n" + this_cinfo->collectionmeta["collectionname"] + "\n";
|
---|
[866] | 479 | }
|
---|
[905] | 480 | count ++;
|
---|
[867] | 481 | first = false;
|
---|
[866] | 482 | here ++;
|
---|
| 483 | }
|
---|
| 484 | textsubcollections += "_textsubcols2_";
|
---|
[905] | 485 | if (count > 1)
|
---|
| 486 | disp.setmacro ("textsubcollections", "about", textsubcollections);
|
---|
[866] | 487 | }
|
---|
| 488 | }
|
---|
[471] | 489 | }
|
---|
[284] | 490 | }
|
---|
| 491 |
|
---|
[761] | 492 | bool pageaction::do_action (cgiargsclass &args, recptprotolistclass * /*protos*/,
|
---|
| 493 | browsermapclass * /*browsers*/, displayclass &disp,
|
---|
[421] | 494 | outconvertclass &outconvert, ostream &textout,
|
---|
| 495 | ostream &/*logout*/) {
|
---|
[173] | 496 |
|
---|
[172] | 497 | text_t &arg_p = args["p"];
|
---|
[160] | 498 |
|
---|
[172] | 499 | textout << outconvert << disp << ("_" + arg_p + ":header_\n")
|
---|
[266] | 500 | << ("_" + arg_p + ":content_\n")
|
---|
[172] | 501 | << ("_" + arg_p + ":footer_\n");
|
---|
| 502 |
|
---|
[160] | 503 | return true;
|
---|
| 504 | }
|
---|
[1759] | 505 |
|
---|
| 506 | void pageaction::configure (const text_t &key, const text_tarray &cfgline) {
|
---|
| 507 | if ((key == "status") && (cfgline.size() == 1) &&
|
---|
| 508 | (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
|
---|
| 509 | status_disabled = false;
|
---|
| 510 | } else if ((key == "collector") && (cfgline.size() == 1) &&
|
---|
| 511 | (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {
|
---|
| 512 | collector_disabled = false;
|
---|
| 513 | } else {
|
---|
| 514 | // call the parent class to deal with the things which
|
---|
| 515 | // are not dealt with here
|
---|
| 516 | action::configure (key, cfgline);
|
---|
| 517 | }
|
---|
| 518 | }
|
---|