Changeset 6645 for trunk/gsdl/src


Ignore:
Timestamp:
2004-01-28T15:10:55+13:00 (20 years ago)
Author:
kjdon
Message:

modified the datelist display so that it can use other metadata eg dc.Date not just Date. The classifier itself had been modified a while ago to take a datemeta argument, and then build the classifier on that metadata rather than assuming Date. It now adds a mdtype value into the top level classifier node, which contains the name of the date metadata. The documentaction when making the nav bar macros looks for mdtype if it comes across a datelist, and sets the dm arg for that classifier button. datelist browser now looks for the dm arg and uses that metadata to create the special years and months bit down the side. Formattools is also modified. It used to modify the Date metadata to display it as xx month YYYY - now it does that for any metadata that ends in .Date - ignores namespaces

Location:
trunk/gsdl/src/recpt
Files:
4 edited

Legend:

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

    r5124 r6645  
    8282  ResultDocInfo_tarray::iterator thissection = sections.docInfo.begin();
    8383  ResultDocInfo_tarray::iterator endsection = sections.docInfo.end();
    84 
     84 
     85  // use the dm arg as date metadata or else Date
     86  text_t date_meta = args["dm"];
     87  if (date_meta == "") {
     88    date_meta = "Date";
     89  }
    8590  while (thissection != endsection) {
    8691
    8792    text_t &doctype = (*thissection).metadata["doctype"].values[0];
    88     text_t &date = (*thissection).metadata["Date"].values[0];
     93    text_t &date = (*thissection).metadata[date_meta].values[0];
    8994
    9095    // bail on this document if it has no date
  • trunk/gsdl/src/recpt/documentaction.cpp

    r6584 r6645  
    167167  arg_ainfo.defaultstatus = cgiarginfo::weak;
    168168  arg_ainfo.argdefault = "0";
     169  arg_ainfo.savedarginfo = cgiarginfo::must;
     170  argsinfo.addarginfo (NULL, arg_ainfo);
     171
     172  //dm is the metadata that has been used for the datelist
     173  arg_ainfo.shortname = "dm";
     174  arg_ainfo.longname = "date metadata";
     175  arg_ainfo.multiplechar = true;
     176  arg_ainfo.defaultstatus = cgiarginfo::weak;
     177  arg_ainfo.argdefault = "";
    169178  arg_ainfo.savedarginfo = cgiarginfo::must;
    170179  argsinfo.addarginfo (NULL, arg_ainfo);
     
    362371   text_t navigationbar = "<!-- Navigation Bar -->\n";
    363372
     373   text_t date_extra = "";
    364374   get_top (args["cl"], topparent);
    365375   int numc = response.docInfo.size();
     
    381391      bool first = true;
    382392      while (dochere != docend) {
    383      
     393    date_extra = "";
    384394     if (!first) navigationbar += "_imagespacer_";
    385395     
    386396     text_t title = (*dochere).metadata["Title"].values[0];
    387      
     397     if (title == "Date") { // a date list
     398       text_t date_meta = (*dochere).metadata["mdtype"].values[0];
     399       if (date_meta == "") {
     400         date_meta = "Date";
     401       }
     402       date_extra = "&dm="+date_meta;
     403     }
    388404     bool unknown = false;
    389405     
     
    403419        // set the _httpbrowseXXX_ macro for this classification
    404420        if (unknown) navigationbar += " <a href=\"_httpdocument_&cl=" +
    405                 (*dochere).OID + "\">" + title + "</a> ";
     421                (*dochere).OID + date_extra+"\">" + title + "</a> ";
    406422        else {
    407423           navigationbar += "_image" + title + "_";
    408            disp.setmacro ("httpbrowse" + title, "Global", "_httpdocument_&cl=" + (*dochere).OID);
     424           disp.setmacro ("httpbrowse" + title, "Global", "_httpdocument_&cl=" + (*dochere).OID+date_extra);
    409425        }
    410426     }
     
    438454      while (dochere != docend) {
    439455     text_t title = dochere->metadata["Title"].values[0];   
    440      navigationbar += "<option value=\"_httpdocument_&cl=" + dochere->OID + "\"";
     456     if (title == "Date") { // a date list
     457       text_t date_meta = (*dochere).metadata["mdtype"].values[0];
     458       if (date_meta == "") {
     459         date_meta = "Date";
     460       }
     461       date_extra = "&dm="+date_meta;
     462     }
     463
     464     navigationbar += "<option value=\"_httpdocument_&cl=" + dochere->OID +date_extra+ "\"";
    441465     if (topparent == dochere->OID) {
    442466        navigationbar += " selected";
     
    545569   
    546570    metadata.insert ("Title");
     571    metadata.insert ("mdtype"); // in case there is a datelist
    547572    bool getParents = false;
    548573    get_children ("", collection, metadata, getParents, collectproto, response, logout);
  • trunk/gsdl/src/recpt/formattools.cpp

    r6020 r6645  
    154154
    155155
     156text_t remove_namespace(const text_t &meta_name) {
     157  text_t::const_iterator end = meta_name.end();
     158  text_t::const_iterator it = findchar(meta_name.begin(), end, '.');
     159  if (it != end) {
     160    return substr(it+1, end);
     161  }
     162  return meta_name;
     163
     164}
    156165// returns a date of form 31 _textmonthnn_ 1999
    157166// input is date of type 19991231
     
    858867
    859868  MetadataInfo_t *parent = docinfo.metadata[meta.metaname].parent;
    860 
     869  text_t no_ns_metaname = remove_namespace(meta.metaname);
    861870  switch (meta.parentcommand) {
    862871  case pNone:
     
    873882    for (int i=start_i; i<=end_i; i++) {
    874883      if (!first) tmp += meta.functionoptions;
    875       if (meta.metaname == "Date") tmp += format_date (metaname_rec.values[i]);
    876       else if (meta.metaname == "Language") tmp += iso639(metaname_rec.values[i]);
     884     
     885      if (no_ns_metaname == "Date") tmp += format_date (metaname_rec.values[i]);
     886      else if (no_ns_metaname == "Language") tmp += iso639(metaname_rec.values[i]);
    877887      else tmp += metaname_rec.values[i];
    878888      first = false;
     
    890900    text_t metadata_item = docinfo.metadata[meta.metaname].values[metaname_index];
    891901   
    892     if (meta.metaname == "Date")
     902    if (no_ns_metaname == "Date")
    893903      return format_date (metadata_item);
    894     else if (meta.metaname == "Language")
     904    else if (no_ns_metaname == "Language")
    895905      return iso639(metadata_item);
    896906    if (meta.metacommand & mCgiSafe)
     
    902912  case pImmediate:
    903913    if (parent != NULL) {
    904       if (meta.metaname == "Date")
     914      if (no_ns_metaname == "Date")
    905915    return format_date (parent->values[0]);
    906916      if (meta.metacommand & mCgiSafe)
     
    914924      while (parent->parent != NULL) parent = parent->parent;
    915925
    916       if (meta.metaname == "Date")
     926      if (no_ns_metaname == "Date")
    917927    return format_date (parent->values[0]);
    918928      if (meta.metacommand & mCgiSafe)
     
    936946      while (here != end) {
    937947    if (!first) tmp += meta.functionoptions;
    938     if (meta.metaname == "Date") tmp += format_date (*here);
     948    if (no_ns_metaname == "Date") tmp += format_date (*here);
    939949    else tmp += *here;
    940950    first = false;
  • trunk/gsdl/src/recpt/formattools.h

    r6020 r6645  
    110110text_t format_date (const text_t &date);
    111111
     112text_t remove_namespace(const text_t &meta_name);
     113
    112114text_t iso639 (const text_t &langcode);
    113115
Note: See TracChangeset for help on using the changeset viewer.