[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 | * $Id: pageaction.cpp 905 2000-02-03 01:49:35Z sjboddie $
|
---|
| 25 | *
|
---|
| 26 | *********************************************************************/
|
---|
| 27 |
|
---|
| 28 | /*
|
---|
| 29 | $Log$
|
---|
[905] | 30 | Revision 1.26 2000/02/03 01:49:35 sjboddie
|
---|
| 31 | fixed up some of the preferences stuff
|
---|
| 32 |
|
---|
[875] | 33 | Revision 1.25 2000/01/26 20:11:04 sjboddie
|
---|
| 34 | added some collection specific help text
|
---|
| 35 |
|
---|
[867] | 36 | Revision 1.24 2000/01/25 22:31:09 sjboddie
|
---|
| 37 | more hacky changes to get preferences to be a bit smarter
|
---|
| 38 |
|
---|
[866] | 39 | Revision 1.23 2000/01/24 22:59:57 sjboddie
|
---|
| 40 | changes to set macros differently for preferences page depending
|
---|
| 41 | on type of collection - pageaction is getting kind of hacky - should
|
---|
| 42 | tidy it up some day
|
---|
| 43 |
|
---|
[793] | 44 | Revision 1.22 1999/11/25 23:01:09 sjboddie
|
---|
| 45 | now need to be able to handle it if no collection is selected
|
---|
| 46 |
|
---|
[771] | 47 | Revision 1.21 1999/11/03 22:50:13 sjboddie
|
---|
| 48 | now defaults to home page
|
---|
| 49 |
|
---|
[761] | 50 | Revision 1.20 1999/11/01 21:58:02 sjboddie
|
---|
| 51 | changes to arguments of many functions, now pass list of protocols
|
---|
| 52 | instead of just that for this collection
|
---|
| 53 |
|
---|
[729] | 54 | Revision 1.19 1999/10/19 21:59:09 sjboddie
|
---|
| 55 | bug in generating "how to find information" text for about pages
|
---|
| 56 |
|
---|
[722] | 57 | Revision 1.18 1999/10/19 03:23:44 davidb
|
---|
| 58 | Collection building support through web pages
|
---|
| 59 | and internal and external link handling for collection documents
|
---|
| 60 |
|
---|
[673] | 61 | Revision 1.17 1999/10/14 23:04:44 sjboddie
|
---|
| 62 | some hacks to make nzdl home page look right
|
---|
| 63 |
|
---|
[649] | 64 | Revision 1.16 1999/10/10 08:14:09 sjboddie
|
---|
| 65 | - metadata now returns mp rather than array
|
---|
| 66 | - redesigned browsing support (although it's not finished so
|
---|
| 67 | won't currently work ;-)
|
---|
| 68 |
|
---|
[604] | 69 | Revision 1.15 1999/09/17 04:46:05 sjboddie
|
---|
| 70 | fixed a couple of problems with 'unknown' classifier
|
---|
| 71 |
|
---|
[542] | 72 | Revision 1.14 1999/09/07 23:08:09 rjmcnab
|
---|
| 73 | Removed some compiler warnings
|
---|
| 74 |
|
---|
[533] | 75 | Revision 1.13 1999/09/07 04:56:57 sjboddie
|
---|
| 76 | added GPL notice
|
---|
| 77 |
|
---|
[511] | 78 | Revision 1.12 1999/09/02 00:26:43 rjmcnab
|
---|
| 79 | made the p cgi argument always saved in the compressed arguments
|
---|
| 80 |
|
---|
[471] | 81 | Revision 1.11 1999/08/25 04:48:43 sjboddie
|
---|
| 82 | changes to the home and about pages
|
---|
| 83 |
|
---|
[452] | 84 | Revision 1.10 1999/08/11 23:29:43 sjboddie
|
---|
| 85 | added support for html classifier (i.e. the hp argument)
|
---|
| 86 |
|
---|
[430] | 87 | Revision 1.9 1999/08/03 03:29:47 sjboddie
|
---|
| 88 | added ability to set receptionist from collect.cfg
|
---|
| 89 |
|
---|
[421] | 90 | Revision 1.8 1999/07/30 02:24:44 sjboddie
|
---|
| 91 | added collectinfo argument to some functions
|
---|
| 92 |
|
---|
[284] | 93 | Revision 1.7 1999/06/24 05:12:24 sjboddie
|
---|
| 94 | lots of small changes
|
---|
| 95 |
|
---|
[266] | 96 | Revision 1.6 1999/06/10 00:39:16 sjboddie
|
---|
| 97 | navigation bar is no longer written out for every page (it should
|
---|
| 98 | be included in the _content_ macro of pages wanting to display it).
|
---|
| 99 |
|
---|
[261] | 100 | Revision 1.5 1999/06/08 04:29:35 sjboddie
|
---|
| 101 | added argsinfo to the call to check_cgiargs to make it easy to set
|
---|
| 102 | args to their default if they're found to be screwed up
|
---|
| 103 |
|
---|
[173] | 104 | Revision 1.4 1999/02/28 20:00:14 rjmcnab
|
---|
| 105 |
|
---|
| 106 |
|
---|
| 107 | Fixed a few things.
|
---|
| 108 |
|
---|
[172] | 109 | Revision 1.3 1999/02/25 21:58:58 rjmcnab
|
---|
| 110 |
|
---|
| 111 | Merged sources.
|
---|
| 112 |
|
---|
[165] | 113 | Revision 1.2 1999/02/21 22:33:54 rjmcnab
|
---|
| 114 |
|
---|
| 115 | Lots of stuff :-)
|
---|
| 116 |
|
---|
[160] | 117 | Revision 1.1 1999/02/12 02:40:17 sjboddie
|
---|
| 118 |
|
---|
| 119 | Added page action
|
---|
| 120 |
|
---|
| 121 | */
|
---|
| 122 |
|
---|
[471] | 123 | #include "OIDtools.h"
|
---|
[160] | 124 | #include "pageaction.h"
|
---|
[172] | 125 | #include "receptionist.h"
|
---|
[284] | 126 | #include <time.h>
|
---|
[160] | 127 |
|
---|
[284] | 128 | pageaction::pageaction () {
|
---|
[160] | 129 |
|
---|
[284] | 130 | recpt = NULL;
|
---|
| 131 |
|
---|
[452] | 132 | // this action uses cgi variables "a", "p", and "hp"
|
---|
[160] | 133 | cgiarginfo arg_ainfo;
|
---|
| 134 | arg_ainfo.shortname = "a";
|
---|
| 135 | arg_ainfo.longname = "action";
|
---|
| 136 | arg_ainfo.multiplechar = true;
|
---|
| 137 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
[165] | 138 | arg_ainfo.argdefault = "p";
|
---|
[160] | 139 | arg_ainfo.savedarginfo = cgiarginfo::must;
|
---|
| 140 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
| 141 |
|
---|
| 142 | arg_ainfo.shortname = "p";
|
---|
| 143 | arg_ainfo.longname = "page";
|
---|
| 144 | arg_ainfo.multiplechar = true;
|
---|
| 145 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
[771] | 146 | arg_ainfo.argdefault = "home";
|
---|
[511] | 147 | arg_ainfo.savedarginfo = cgiarginfo::must;
|
---|
[160] | 148 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
[452] | 149 |
|
---|
| 150 | arg_ainfo.shortname = "hp";
|
---|
| 151 | arg_ainfo.longname = "html page";
|
---|
| 152 | arg_ainfo.multiplechar = true;
|
---|
| 153 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
| 154 | arg_ainfo.argdefault = "";
|
---|
| 155 | arg_ainfo.savedarginfo = cgiarginfo::mustnot;
|
---|
| 156 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
[160] | 157 | }
|
---|
| 158 |
|
---|
| 159 | pageaction::~pageaction () {
|
---|
| 160 | }
|
---|
| 161 |
|
---|
[261] | 162 | bool pageaction::check_cgiargs (cgiargsinfoclass &/*argsinfo*/, cgiargsclass &/*args*/,
|
---|
| 163 | ostream &/*logout*/) {
|
---|
[160] | 164 | // don't want to check anything yet.
|
---|
| 165 | return true;
|
---|
| 166 | }
|
---|
| 167 |
|
---|
[761] | 168 | void pageaction::get_cgihead_info (cgiargsclass &/*args*/, recptprotolistclass * /*protos*/,
|
---|
| 169 | response_t &response,text_t &response_data,
|
---|
| 170 | ostream &/*logout*/) {
|
---|
[160] | 171 | response = content;
|
---|
| 172 | response_data = "text/html";
|
---|
| 173 | }
|
---|
| 174 |
|
---|
[761] | 175 | void pageaction::set_homeextra_macro (displayclass &disp, recptprotolistclass *protos,
|
---|
| 176 | ostream &logout) {
|
---|
[421] | 177 |
|
---|
[761] | 178 | text_t homeextra = "<center><table width=_pagewidth_><tr valign=top>\n";
|
---|
| 179 |
|
---|
| 180 | recptprotolistclass::iterator rprotolist_here = protos->begin();
|
---|
| 181 | recptprotolistclass::iterator rprotolist_end = protos->end();
|
---|
| 182 | while (rprotolist_here != rprotolist_end) {
|
---|
| 183 | if ((*rprotolist_here).p != NULL) {
|
---|
| 184 |
|
---|
| 185 | text_tarray collist;
|
---|
| 186 | comerror_t err;
|
---|
| 187 | (*rprotolist_here).p->get_collection_list (collist, err, logout);
|
---|
| 188 | if (err == noError) {
|
---|
| 189 | text_tarray::iterator collist_here = collist.begin();
|
---|
| 190 | text_tarray::iterator collist_end = collist.end();
|
---|
| 191 |
|
---|
[866] | 192 | int row1 = 7;
|
---|
| 193 | int row2 = 5;
|
---|
[761] | 194 | int count = 1;
|
---|
| 195 | while (collist_here != collist_end) {
|
---|
| 196 |
|
---|
| 197 | if (*collist_here == "niupepa")
|
---|
| 198 | homeextra += "<p><a href=\"_httpmusiclibrary_\">_iconmusiclibrary_</a>\n";
|
---|
| 199 |
|
---|
| 200 | ColInfoResponse_t cinfo;
|
---|
| 201 | (*rprotolist_here).p->get_collectinfo (*collist_here, cinfo, err, logout);
|
---|
| 202 |
|
---|
| 203 | if (err == noError) {
|
---|
| 204 | if (cinfo.isPublic && (cinfo.buildDate > 0)) {
|
---|
| 205 |
|
---|
| 206 | FilterResponse_t response;
|
---|
| 207 | text_tset metadata;
|
---|
| 208 | metadata.insert ("collectionname");
|
---|
| 209 | metadata.insert ("iconcollection");
|
---|
| 210 | metadata.insert ("iconcollectionsmall");
|
---|
| 211 | text_t collectionname = *collist_here;
|
---|
| 212 | text_t alt = collectionname;
|
---|
| 213 | if (get_info ("collection", *collist_here, metadata, false,
|
---|
| 214 | (*rprotolist_here).p, response, logout)) {
|
---|
| 215 | if (!response.docInfo[0].metadata["collectionname"].values[0].empty())
|
---|
| 216 | alt = response.docInfo[0].metadata["collectionname"].values[0];
|
---|
| 217 |
|
---|
| 218 | if (!response.docInfo[0].metadata["iconcollectionsmall"].values[0].empty())
|
---|
| 219 | collectionname = "<img width=150 border=1 src=\""
|
---|
| 220 | + response.docInfo[0].metadata["iconcollectionsmall"].values[0]
|
---|
| 221 | + "\" alt=\"" + alt + "\">";
|
---|
| 222 | else if (!response.docInfo[0].metadata["iconcollection"].values[0].empty())
|
---|
| 223 | collectionname = "<img width=150 border=1 src=\""
|
---|
| 224 | + response.docInfo[0].metadata["iconcollection"].values[0]
|
---|
| 225 | + "\" alt=\"" + alt + "\">";
|
---|
| 226 | else collectionname = alt;
|
---|
| 227 | }
|
---|
| 228 |
|
---|
| 229 | if ((count == 1) || (count == (row1+1)) || (count == ((row1+row2)+1)))
|
---|
| 230 | homeextra += "<td align=center>";
|
---|
| 231 | else homeextra += "<p>";
|
---|
| 232 | text_t link = "<a href=\"_gwcgi_?a=p&p=about&c=" + *collist_here + "\">";
|
---|
| 233 | if (*collist_here == "chinese")
|
---|
| 234 | link = "<a href=\"_gwcgi_?a=p&p=about&l=zh&nw=u&c=" + *collist_here + "\">";
|
---|
[866] | 235 | if (*collist_here == "arabic")
|
---|
| 236 | link = "<a href=\"_gwcgi_?a=p&p=about&w=a&c=" + *collist_here + "\">";
|
---|
[761] | 237 |
|
---|
| 238 | if (!cinfo.receptionist.empty())
|
---|
[866] | 239 | link = "<a href=\"" + cinfo.receptionist + "\">";
|
---|
[761] | 240 |
|
---|
| 241 | homeextra += link + collectionname + "</a>\n";
|
---|
| 242 |
|
---|
| 243 | if ((count == row1) || (count == (row1+row2)))
|
---|
| 244 | homeextra += "</td>";
|
---|
| 245 |
|
---|
| 246 | count ++;
|
---|
| 247 | }
|
---|
| 248 | }
|
---|
| 249 |
|
---|
| 250 | collist_here ++;
|
---|
| 251 | }
|
---|
| 252 | homeextra += "</tr></table></center>\n";
|
---|
| 253 | disp.setmacro ("homeextra", "home", homeextra);
|
---|
| 254 | }
|
---|
| 255 | }
|
---|
| 256 | rprotolist_here ++;
|
---|
| 257 | }
|
---|
| 258 | }
|
---|
| 259 |
|
---|
| 260 | void pageaction::define_internal_macros (displayclass &disp, cgiargsclass &args,
|
---|
| 261 | recptprotolistclass *protos, ostream &logout) {
|
---|
| 262 |
|
---|
[284] | 263 | // define_internal_macros sets the following macros:
|
---|
| 264 |
|
---|
[866] | 265 | // _numdocs_ the number of documents in the collection
|
---|
| 266 |
|
---|
| 267 | // _builddate_ the date last built
|
---|
| 268 |
|
---|
| 269 |
|
---|
[471] | 270 | // if page is "home"
|
---|
| 271 | // _homeextra_ this is the list of available collections and collection info
|
---|
| 272 | // to be displayed on the home page
|
---|
[284] | 273 |
|
---|
[471] | 274 |
|
---|
[866] | 275 | // if page is "preferences"
|
---|
| 276 | // _collectionoption_ collections to search/browse (if cross-collection-searching is on)
|
---|
| 277 |
|
---|
| 278 | // _htmloptions_ set to _htmloptionson_ if DocumentUseHTML is set
|
---|
| 279 |
|
---|
[867] | 280 | // _PreferencesDocsFromWeb_ set to 1 if corresponding format option is set
|
---|
[866] | 281 |
|
---|
[867] | 282 | // _languageoption_ interface languages to select from (dependant on PreferenceLanguages)
|
---|
| 283 |
|
---|
| 284 | // _encodingoption_ will be overridden to "" if chinese language interface isn't specified
|
---|
| 285 |
|
---|
[471] | 286 | // if page is "about"
|
---|
[866] | 287 | // _textsubcollections_ the text on which subcollections make up the collection (if
|
---|
| 288 | // cross-collection searching is being used
|
---|
[471] | 289 |
|
---|
| 290 | // _textbrowseoptions_ the 'how to find information' text in the about and help pages
|
---|
| 291 |
|
---|
| 292 | // _numbrowseoptions_ the number of browsing options
|
---|
| 293 |
|
---|
| 294 |
|
---|
| 295 | // if page is "help"
|
---|
| 296 | // _textbrowseoptions_ the 'how to find information' text in the about and help pages
|
---|
| 297 |
|
---|
| 298 | // _numbrowseoptions_ the number of browsing options
|
---|
| 299 |
|
---|
[875] | 300 | // _topicreadingdocs_ this section of the help text differs depending on what type of
|
---|
| 301 | // _textreadingdocs_ collection it is (e.g. html collection, bibliographic collection etc.)
|
---|
| 302 | // _texthelpreadingdocs_
|
---|
| 303 |
|
---|
[471] | 304 |
|
---|
| 305 | text_t &arg_p = args["p"];
|
---|
[866] | 306 | text_t &arg_c = args["c"];
|
---|
| 307 | ColInfoResponse_t cinfo;
|
---|
| 308 | comerror_t err;
|
---|
[471] | 309 |
|
---|
[866] | 310 | recptproto* collectproto = protos->getrecptproto (arg_c, logout);
|
---|
[793] | 311 | if (collectproto != NULL) {
|
---|
[866] | 312 | collectproto->get_collectinfo (arg_c, cinfo, err, logout);
|
---|
| 313 |
|
---|
[793] | 314 | disp.setmacro ("numdocs", "Global", cinfo.numDocs);
|
---|
| 315 | unsigned long current_time = time(NULL);
|
---|
| 316 | unsigned long builddate = (current_time - cinfo.buildDate) / 86400;
|
---|
| 317 | disp.setmacro ("builddate", "Global", builddate);
|
---|
| 318 | }
|
---|
| 319 |
|
---|
[761] | 320 | if (arg_p == "home") set_homeextra_macro (disp, protos, logout);
|
---|
[284] | 321 |
|
---|
[866] | 322 | else if (arg_p == "preferences") {
|
---|
| 323 |
|
---|
| 324 | // _collectionoption_
|
---|
| 325 |
|
---|
| 326 | if (args["ccs"] == "1" && collectproto != NULL && (cinfo.ccsCols.size() > 1)) {
|
---|
| 327 | text_t collectionoption = "_textcollectionoption_";
|
---|
| 328 | text_tarray::const_iterator col_here = cinfo.ccsCols.begin();
|
---|
| 329 | text_tarray::const_iterator col_end = cinfo.ccsCols.end();
|
---|
[905] | 330 | int count = 0;
|
---|
[866] | 331 | while (col_here != col_end) {
|
---|
| 332 | text_t colname;
|
---|
| 333 | if (*col_here == arg_c) {
|
---|
| 334 | colname = cinfo.collectionmeta["collectionname"];
|
---|
| 335 | } else {
|
---|
| 336 | ColInfoResponse_t this_cinfo;
|
---|
| 337 | collectproto->get_collectinfo (*col_here, this_cinfo, err, logout);
|
---|
[905] | 338 | if (err != noError) {col_here ++; continue;}
|
---|
[866] | 339 | colname = this_cinfo.collectionmeta["collectionname"];
|
---|
| 340 | }
|
---|
| 341 |
|
---|
[905] | 342 | count ++;
|
---|
[866] | 343 | collectionoption += "<input type=checkbox name=\"cc\" value=\"" +
|
---|
| 344 | *col_here + "\" onClick=\"updatecc(\'" + *col_here + "\');\"> " +
|
---|
| 345 | colname + "<br>\n";
|
---|
| 346 | col_here ++;
|
---|
| 347 | }
|
---|
[905] | 348 |
|
---|
| 349 | if (count > 1)
|
---|
| 350 | disp.setmacro ("collectionoption", "preferences", collectionoption);
|
---|
[866] | 351 | }
|
---|
| 352 |
|
---|
| 353 | // _htmloptions_
|
---|
| 354 |
|
---|
| 355 | text_tmap::const_iterator it = cinfo.format.find ("DocumentUseHTML");
|
---|
[867] | 356 | if ((it != cinfo.format.end()) && ((*it).second == "true")) {
|
---|
[866] | 357 | disp.setmacro ("htmloptions", "preferences", "_htmloptionson_");
|
---|
| 358 |
|
---|
[867] | 359 |
|
---|
| 360 | // _PreferenceDocsFromWeb_
|
---|
| 361 |
|
---|
| 362 | it = cinfo.format.find ("PreferenceDocsFromWeb");
|
---|
| 363 | if ((it == cinfo.format.end()) || ((*it).second == "true"))
|
---|
| 364 | disp.setmacro ("PreferenceDocsFromWeb", "preferences", "1");
|
---|
| 365 | }
|
---|
| 366 |
|
---|
| 367 | // _languageoption_
|
---|
| 368 | // this is kind of a hack (another one!!). note that there're potential
|
---|
| 369 | // problems here as no checking is done anywhere to make sure language
|
---|
| 370 | // is set to a valid value. this does allow us to set which languages
|
---|
| 371 | // should go in the preference selection box (from collect.cfg) however
|
---|
| 372 | // and that's sufficient for current requirements
|
---|
[866] | 373 |
|
---|
[867] | 374 | // currently supported languages (_languageoption_ will default to all
|
---|
| 375 | // these languages unless PreferenceLanguages is set
|
---|
| 376 | text_tarray languages;
|
---|
| 377 | languages.push_back ("en");
|
---|
| 378 | languages.push_back ("mi");
|
---|
| 379 | languages.push_back ("zh");
|
---|
| 380 | text_tarray::const_iterator this_lang = languages.begin();
|
---|
| 381 | text_tarray::const_iterator end_lang = languages.end();
|
---|
| 382 |
|
---|
| 383 | text_t languageoption = "_textlanguage_\n<select name=\"l\" onChange=\"updatel();\">\n";
|
---|
| 384 | it = cinfo.format.find ("PreferenceLanguages");
|
---|
| 385 | if ((it != cinfo.format.end()) && (!(*it).second.empty())) {
|
---|
| 386 | text_tset pref_langs;
|
---|
| 387 | splitchar ((*it).second.begin(), (*it).second.end(), '|', pref_langs);
|
---|
| 388 | if (pref_langs.size() > 1) {
|
---|
| 389 | while (this_lang != end_lang) {
|
---|
| 390 | if (pref_langs.find(*this_lang) != pref_langs.end())
|
---|
| 391 | languageoption += "_" + *this_lang + "languageoption_\n";
|
---|
| 392 | this_lang ++;
|
---|
| 393 | }
|
---|
| 394 | languageoption += "</select>\n";
|
---|
| 395 | disp.setmacro ("languageoption", "preferences", languageoption);
|
---|
| 396 | }
|
---|
| 397 |
|
---|
| 398 | // _encodingoption_
|
---|
| 399 |
|
---|
| 400 | if (pref_langs.find("zh") == pref_langs.end())
|
---|
| 401 | disp.setmacro ("encodingoption", "preferences", "");
|
---|
| 402 |
|
---|
| 403 | } else {
|
---|
| 404 | while (this_lang != end_lang) {
|
---|
| 405 | languageoption += "_" + *this_lang + "languageoption_\n";
|
---|
| 406 | this_lang ++;
|
---|
| 407 | }
|
---|
| 408 | languageoption += "</select>\n";
|
---|
| 409 | disp.setmacro ("languageoption", "preferences", languageoption);
|
---|
| 410 | }
|
---|
| 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 {
|
---|
| 441 | shorttext += "<li>" + stext;
|
---|
[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
|
---|
| 456 | text_tmap::const_iterator it = cinfo.format.find ("HelpNoDocs");
|
---|
| 457 | if ((it != cinfo.format.end()) && ((*it).second == "true")) {
|
---|
| 458 | disp.setmacro ("topicreadingdocs", "help", "");
|
---|
| 459 | disp.setmacro ("texthelpreadingdocs", "help", "");
|
---|
| 460 | }
|
---|
| 461 | it = cinfo.format.find ("HelpBibDocs");
|
---|
| 462 | if ((it != cinfo.format.end()) && ((*it).second == "true")) {
|
---|
| 463 | disp.setmacro ("texthelpreadingdocs", "help", "_bibtexthelpreadingdocs_");
|
---|
| 464 | disp.setmacro ("textreadingdocs", "help", "_bibtextreadingdocs_");
|
---|
| 465 | }
|
---|
| 466 | it = cinfo.format.find ("HelpBookDocs");
|
---|
| 467 | if ((it != cinfo.format.end()) && ((*it).second == "true")) {
|
---|
| 468 | disp.setmacro ("texthelpreadingdocs", "help", "_booktexthelpreadingdocs_");
|
---|
| 469 | disp.setmacro ("textreadingdocs", "help", "_booktextreadingdocs_");
|
---|
| 470 | }
|
---|
| 471 |
|
---|
| 472 | }
|
---|
[866] | 473 | if (arg_p == "about") {
|
---|
| 474 |
|
---|
| 475 | // _textsubcollections_
|
---|
| 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>";
|
---|
| 485 | textsubcollections += "\n" + cinfo.collectionmeta["collectionname"] + "\n";
|
---|
[866] | 486 | } else {
|
---|
| 487 | ColInfoResponse_t this_cinfo;
|
---|
| 488 | collectproto->get_collectinfo (*here, this_cinfo, err, logout);
|
---|
[905] | 489 | if (err != noError) {here ++; continue;}
|
---|
| 490 | if (!first) textsubcollections += "<br>";
|
---|
| 491 | textsubcollections += "\n" + this_cinfo.collectionmeta["collectionname"] + "\n";
|
---|
[866] | 492 | }
|
---|
[905] | 493 | count ++;
|
---|
[867] | 494 | first = false;
|
---|
[866] | 495 | here ++;
|
---|
| 496 | }
|
---|
| 497 | textsubcollections += "_textsubcols2_";
|
---|
[905] | 498 | if (count > 1)
|
---|
| 499 | disp.setmacro ("textsubcollections", "about", textsubcollections);
|
---|
[866] | 500 | }
|
---|
| 501 | }
|
---|
[471] | 502 | }
|
---|
[284] | 503 | }
|
---|
| 504 |
|
---|
[761] | 505 | bool pageaction::do_action (cgiargsclass &args, recptprotolistclass * /*protos*/,
|
---|
| 506 | browsermapclass * /*browsers*/, displayclass &disp,
|
---|
[421] | 507 | outconvertclass &outconvert, ostream &textout,
|
---|
| 508 | ostream &/*logout*/) {
|
---|
[173] | 509 |
|
---|
[172] | 510 | text_t &arg_p = args["p"];
|
---|
[160] | 511 |
|
---|
[172] | 512 | textout << outconvert << disp << ("_" + arg_p + ":header_\n")
|
---|
[266] | 513 | << ("_" + arg_p + ":content_\n")
|
---|
[172] | 514 | << ("_" + arg_p + ":footer_\n");
|
---|
| 515 |
|
---|
[160] | 516 | return true;
|
---|
| 517 | }
|
---|