Ignore:
Timestamp:
1999-06-24T17:12:25+12:00 (25 years ago)
Author:
sjboddie
Message:

lots of small changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/pageaction.cpp

    r266 r284  
    1212/*
    1313   $Log$
     14   Revision 1.7  1999/06/24 05:12:24  sjboddie
     15   lots of small changes
     16
    1417   Revision 1.6  1999/06/10 00:39:16  sjboddie
    1518   navigation bar is no longer written out for every page (it should
     
    4245#include "pageaction.h"
    4346#include "receptionist.h"
    44 
     47#include <time.h>
    4548
    4649pageaction::pageaction () {
     50
     51  recpt = NULL;
     52
    4753  // this action uses cgi variables "a" and "p"
    4854  cgiarginfo arg_ainfo;
     
    7985}
    8086
     87
     88void pageaction::define_internal_macros (displayclass &disp, cgiargsclass &args,
     89                     recptproto */*collectproto*/, ostream &logout) {
     90
     91  // define_internal_macros sets the following macros:
     92
     93  // _homeextra_   this is the list of available collections and collection info
     94  //               to be displayed on the home page
     95
     96  if (args["p"] == "home") {
     97    // make sure we know about a receptionist
     98    if (recpt == NULL) {
     99      logout << "The page action does not contain information\n"
     100         << "about any receptionists. The method set_receptionist\n"
     101         << "was probably not called from the module which instantiated\n"
     102         << "this page action.\n";
     103      return;
     104    }
     105
     106    unsigned long current_time = time(NULL);
     107    text_t homeextra;
     108
     109    recptprotolistclass *rprotolist = recpt->get_recptprotolist_ptr ();
     110    if (rprotolist == NULL) return;
     111
     112    recptprotolistclass::iterator rprotolist_here = rprotolist->begin();
     113    recptprotolistclass::iterator rprotolist_end = rprotolist->end();
     114    while (rprotolist_here != rprotolist_end) {
     115      if ((*rprotolist_here).p != NULL) {
     116    text_tarray collist;
     117    comerror_t err;
     118    (*rprotolist_here).p->get_collection_list (collist, err, logout);
     119    if (err == noError) {
     120      text_tarray::iterator collist_here = collist.begin();
     121      text_tarray::iterator collist_end = collist.end();
     122
     123      homeextra += "<dl>\n";
     124
     125      while (collist_here != collist_end) {
     126        ColInfoResponse_t collectinfo;
     127        (*rprotolist_here).p->get_collectinfo (*collist_here, collectinfo, err, logout);
     128        if (err == noError) {
     129
     130          homeextra += "<dt><a href=\"_httppagex_(about)&c=" + *collist_here + "\">"
     131        + *collist_here + "</a></dt>\n";
     132          homeextra += "<dd>";
     133          if (collectinfo.numDocs != 0) homeextra += text_t(collectinfo.numDocs) + "_documents_";
     134          if (collectinfo.numWords != 0) homeextra += text_t(collectinfo.numWords) + "_words_";
     135          unsigned long last_update = (current_time - collectinfo.buildDate) / 86400;
     136          homeextra += "_lastupdate_ " + text_t(last_update) + " _ago_</dd>\n";
     137        }
     138        collist_here ++;
     139      }
     140      homeextra += "</dl>\n";
     141      disp.setmacro ("homeextra", "home", homeextra);
     142    }
     143      }
     144      rprotolist_here ++;
     145    }
     146  }
     147}
     148
    81149bool pageaction::do_action (cgiargsclass &args, recptproto */*collectproto*/,
    82150                displayclass &disp, outconvertclass &outconvert,
Note: See TracChangeset for help on using the changeset viewer.