Changeset 19298


Ignore:
Timestamp:
04/30/09 14:04:59 (12 years ago)
Author:
davidb
Message:

optional support for metadata wrapped in span tags added. *OFF* by default.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/runtime-src/src/recpt/formattools.cpp

    r19058 r19298  
    3131
    3232#include <assert.h>
     33
     34bool spanwrap = false;
    3335
    3436// a few function prototypes
     
    881883{
    882884  text_t no_ns_metaname = remove_namespace(meta.metaname);
    883   text_t tmp;
     885  text_t formatted_metatext;
    884886  bool first = true;
    885887 
     
    889891  if (position == -1) { // all
    890892    for (int i=start_i; i<=end_i; ++i) {
    891       if (!first) tmp += meta.siblingoptions;
     893      if (!first) formatted_metatext += meta.siblingoptions;
     894     
     895      text_t fresh_metatext;
     896
    892897      if (meta.metacommand & mSpecial) {
    893898    // special formatting
    894     if (no_ns_metaname == "Date") tmp += format_date (metainfo.values[i]);
    895     else if (no_ns_metaname == "Language") tmp += iso639(metainfo.values[i]);
    896     else tmp += "_format:"+meta.metaname+"_("+metainfo.values[i]+")";
     899    if (no_ns_metaname == "Date") fresh_metatext = format_date (metainfo.values[i]);
     900    else if (no_ns_metaname == "Language") fresh_metatext = iso639(metainfo.values[i]);
     901    else fresh_metatext = "_format:"+meta.metaname+"_("+metainfo.values[i]+")";
    897902      }
    898       else tmp += metainfo.values[i];
     903      else fresh_metatext = metainfo.values[i];
     904
     905      if (spanwrap) {
     906    fresh_metatext = "<span metaname=\"" + meta.metaname + "\" metapos=\"" + i + "\">" + fresh_metatext + "</span>";
     907      }
     908      formatted_metatext += fresh_metatext;
     909
    899910      first = false;
    900911     
     
    906917      return "";
    907918    }
     919
     920    text_t fresh_metatext;
    908921    if (meta.metacommand & mSpecial) {
     922
    909923      // special formatting
    910       if (no_ns_metaname == "Date") tmp += format_date (metainfo.values[position]);
    911       else if (no_ns_metaname == "Language") tmp += iso639(metainfo.values[position]);
    912       else tmp += "_format:"+meta.metaname+"_("+metainfo.values[position]+")";
     924      if (no_ns_metaname == "Date") fresh_metatext = format_date (metainfo.values[position]);
     925      else if (no_ns_metaname == "Language") fresh_metatext = iso639(metainfo.values[position]);
     926      else fresh_metatext = "_format:"+meta.metaname+"_("+metainfo.values[position]+")";
    913927    }
    914     else tmp += metainfo.values[position];
    915   }
    916   if (meta.metacommand & mCgiSafe && !no_cgisafe) return cgi_safe_unicode (tmp);
    917   else return tmp;
     928    else fresh_metatext = metainfo.values[position];
     929
     930    if (spanwrap) {
     931      fresh_metatext = "<span metaname=\"" + meta.metaname + "\" metapos=\"" + position + "\">" + fresh_metatext + "</span>";
     932    }
     933
     934    formatted_metatext += fresh_metatext;
     935  }
     936
     937  if (meta.metacommand & mCgiSafe && !no_cgisafe) return cgi_safe_unicode (formatted_metatext);
     938  else return formatted_metatext;
    918939}
    919940
     
    13651386  // to see whether we output the "then" or the "else" clause
    13661387  if (decision.command == dMeta) {
    1367     if (get_meta (collection,collectproto,docinfo,disp,decision.meta,options,
    1368           logout) != "") {
     1388
     1389    bool store_spanwrap = spanwrap;
     1390    spanwrap = 0;
     1391
     1392    // temporarily suspend spanwrap (if on) so can test if metadata item really exits or not
     1393    bool metadata_exists
     1394      = (get_meta (collection,collectproto,docinfo,disp,decision.meta,options,
     1395           logout) != "");
     1396
     1397    spanwrap = store_spanwrap;
     1398
     1399    if (metadata_exists) {
    13691400      if (ifptr != NULL)
    13701401    return get_formatted_string (collection,collectproto,docinfo, disp, ifptr,
Note: See TracChangeset for help on using the changeset viewer.