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