Ignore:
Timestamp:
2000-04-03T19:28:25+12:00 (24 years ago)
Author:
sjboddie
Message:

replaced old DocumentIcon and DocumentContents format options
with DocumentColumn stuff

File:
1 edited

Legend:

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

    r1048 r1059  
    2929/*
    3030   $Log$
     31   Revision 1.41  2000/04/03 07:25:02  sjboddie
     32   replaced old DocumentIcon and DocumentContents format options
     33   with DocumentColumn stuff
     34
    3135   Revision 1.40  2000/03/31 03:04:30  nzdl
    3236   tidied up some of the browsing code - replaced DocumentImages,
     
    182186
    183187
    184 // output_controls displays the detach, expand/contract contents,
    185 // expand/contract text and highlighting/no highlighting buttons
    186 
    187 void output_controls (cgiargsclass &args, const text_tarray &ibuttons,
    188               recptproto * /*collectproto*/, displayclass &disp,
    189               outconvertclass &outconvert, ostream &textout,
    190               ostream &/*logout*/) {
    191 
    192   if (args["u"] != "1") {
    193    
    194     FilterResponse_t response;
    195     text_tarray metadata;
    196     text_tarray buttons;
    197    
    198     text_tarray::const_iterator here = ibuttons.begin();
    199     text_tarray::const_iterator end = ibuttons.end();
    200    
    201     while (here != end) {
    202      
    203       if (*here == "Detach")
    204     buttons.push_back ("_document:imagedetach_");
    205       else if (*here == "Highlight") {
    206     if (args["hl"] == "1")
    207       buttons.push_back ("_document:imagenohighlight_");
    208     else
    209       buttons.push_back ("_document:imagehighlight_");
    210       } else if (*here == "Expand Contents") {
    211     if (args["gc"] == "1")
    212       buttons.push_back ("_document:imagecontracttoc_");
    213     else
    214       buttons.push_back ("_document:imageexpandtoc_");
    215       } else if (*here == "Expand Text") {
    216     if (args.getintarg("gt"))
    217       buttons.push_back ("_document:imagecontracttext_");
    218     else
    219       buttons.push_back ("_document:imageexpandtext_");
    220       }
    221       here ++;
    222     }
    223    
    224     here = buttons.begin();
    225     end = buttons.end();
    226     int count = 0;
    227     while (here != end) {
    228       if ((count != 0) && ((count % 2) == 0)) textout << "<br>\n";
    229       textout << outconvert << disp << *here;
    230       count ++;
    231       here ++;
    232     }
    233   }
    234 }
    235 
    236 
    237 // at the moment this just writes out the html to display
    238 // the cover image (assuming it's called cover.jpg)
    239 // this whole thing should be done with a call to the collection
    240 // server which would send a link to the cover image if there
    241 // was one otherwise send title, author and stuff
    242 void output_cover_image (cgiargsclass &args, recptproto * /*collectproto*/,
    243              displayclass &disp, outconvertclass &outconvert,
    244              ostream &textout, ostream &/*logout*/) {
    245  
    246   if (args["d"].empty()) return;
    247  
    248   textout << outconvert << disp <<
    249     "<img src=\"_httpcollimg_/_thisOID_/cover.jpg\"><br>\n";
    250 }
    251 
    252 void output_titles (cgiargsclass &args, recptproto *collectproto,
    253             formatinfo_t &formatinfo, displayclass &disp,
    254             outconvertclass &outconvert, ostream &textout,
    255             ostream &logout) {
    256 
    257   if (args["d"].empty()) return;
    258  
    259   text_tset metadata;
    260   bool getParents;
    261   FilterResponse_t response;
    262 
    263   format_t *formatlistptr = new format_t();
    264   parse_formatstring (formatinfo.DocumentIcon, formatlistptr, metadata, getParents);
    265 
    266   if (!get_info (args["d"], args["c"], metadata, getParents, collectproto, response, logout))
    267     return;
    268 
    269   textout << outconvert << disp << get_formatted_string (response.docInfo[0], formatlistptr);
    270 }
    271 
    272 
    273188static void recurse_contents (ResultDocInfo_t &section, cgiargsclass &args, bool fulltoc,
    274189                  browserclass *bptr, text_tset &metadata, bool &getParents,
    275190                  format_t *formatlistptr, format_tmap &formatlistmap,
    276                   formatinfo_t &formatinfo, browsermapclass *browsermap,
     191                  text_tmap &formatstrings, browsermapclass *browsermap,
    277192                  int tabcount, recptproto *collectproto, displayclass &disp,
    278193                  outconvertclass &outconvert, ostream &textout, ostream &logout) {
     
    308223
    309224    // get the formatstring if there is one
    310     if (!get_formatstring (classification, classifytype,
    311                formatinfo.formatstrings, formatstring))
     225    if (!get_formatstring (classification, classifytype, formatstrings, formatstring))
    312226      formatstring = bptr->get_default_formatstring();
    313227
     
    328242    while (thisdoc != lastdoc) {
    329243      recurse_contents (*thisdoc, args, fulltoc, bptr, metadata, getParents,
    330             formatlistptr, formatlistmap, formatinfo, browsermap,
     244            formatlistptr, formatlistmap, formatstrings, browsermap,
    331245            tabcount, collectproto, disp, outconvert, textout, logout);
    332246      thisdoc ++;
     
    343257// the current one
    344258
    345 void expanded_contents (cgiargsclass &args, int tabcount, bool fulltoc,
    346             browsermapclass *browsermap, formatinfo_t &formatinfo,
    347             recptproto *collectproto, displayclass &disp,
    348             outconvertclass &outconvert, ostream &textout,
    349             ostream &logout) {
     259static void expanded_contents (cgiargsclass &args, int tabcount, bool fulltoc,
     260                   browsermapclass *browsermap, text_tmap &formatstrings,
     261                   recptproto *collectproto, displayclass &disp,
     262                   outconvertclass &outconvert, ostream &textout,
     263                   ostream &logout) {
    350264 
    351265  if (args["d"].empty() && args["cl"].empty()) return;
     
    419333
    420334  // get the formatstring if there is one or use the browsers default
    421   if (!get_formatstring (classification, classifytype,
    422              formatinfo.formatstrings, formatstring))
     335  if (!get_formatstring (classification, classifytype, formatstrings, formatstring))
    423336    formatstring = bptr->get_default_formatstring();
    424337
     
    434347
    435348  recurse_contents (response.docInfo[0], args, fulltoc, bptr, metadata,
    436             getParents, formatlistptr, formatlistmap, formatinfo, browsermap,
     349            getParents, formatlistptr, formatlistmap, formatstrings, browsermap,
    437350            tabcount, collectproto, disp, outconvert, textout, logout);
    438351
     
    449362static void load_formatstring (const text_t &classifytype, text_tset &metadata,
    450363                   bool &getParents, const text_t &classification,
    451                    browsermapclass *browsermap, formatinfo_t &formatinfo,
     364                   browsermapclass *browsermap, text_tmap &formatstrings,
    452365                   format_tmap &formatlistmap) {
    453366  text_t formatstring;
     
    458371
    459372  // get the formatstring if there is one or use the browsers default
    460   if (!get_formatstring (classification, classifytype,
    461              formatinfo.formatstrings, formatstring))
     373  if (!get_formatstring (classification, classifytype, formatstrings, formatstring))
    462374    formatstring = bptr->get_default_formatstring();
    463375
     
    473385static void load_formatstrings (FilterResponse_t &response, text_tset &metadata,
    474386                bool &getParents, const text_t &classification,
    475                 browsermapclass *browsermap, formatinfo_t &formatinfo,
     387                browsermapclass *browsermap, text_tmap &formatstrings,
    476388                format_tmap &formatlistmap) {
    477389
     
    485397    if (is_top ((*thisdoc).OID))
    486398      load_formatstring ((*thisdoc).metadata["thistype"].values[0], metadata,
    487              getParents, classification, browsermap, formatinfo,
     399             getParents, classification, browsermap, formatstrings,
    488400             formatlistmap);
    489401
     
    492404    if (it == cache.end()) {
    493405      load_formatstring (childtype, metadata, getParents, classification,
    494              browsermap, formatinfo, formatlistmap);
     406             browsermap, formatstrings, formatlistmap);
    495407      cache.insert (childtype);
    496408    }
     
    500412
    501413static void output_parents (FilterResponse_t &response, cgiargsclass &args,
    502                 browsermapclass *browsermap, formatinfo_t &formatinfo,
     414                browsermapclass *browsermap, text_tmap &formatstrings,
    503415                format_tmap &formatlistmap, const text_t &classification,
    504416                int &tabcount, text_tset &metadata, bool &getParents,
     
    527439
    528440    // get the formatstring if there is one or use the browsers default
    529     if (!get_formatstring (classification, classifytype,
    530                formatinfo.formatstrings, formatstring))
     441    if (!get_formatstring (classification, classifytype, formatstrings, formatstring))
    531442      formatstring = bptr->get_default_formatstring();
    532443   
     
    548459}
    549460
    550 void contracted_contents (cgiargsclass &args, int tabcount, bool fulltoc,
    551               browsermapclass *browsermap, formatinfo_t &formatinfo,
    552               recptproto *collectproto, displayclass &disp,
    553               outconvertclass &outconvert, ostream &textout,
    554               ostream &logout) {
     461static void contracted_contents (cgiargsclass &args, int tabcount, bool fulltoc,
     462                 browsermapclass *browsermap, text_tmap &formatstrings,
     463                recptproto *collectproto, displayclass &disp,
     464                outconvertclass &outconvert, ostream &textout,
     465                ostream &logout) {
    555466
    556467  FilterResponse_t response;
     
    585496    format_tmap formatlistmap; 
    586497    load_formatstrings (response, metadata, getParents, classification,
    587             browsermap, formatinfo, formatlistmap);
     498            browsermap, formatstrings, formatlistmap);
    588499
    589500    if (!get_info (parents, args["c"], metadata, getParents, collectproto, response, logout))
     
    591502   
    592503    // display each parent
    593     output_parents (response, args, browsermap, formatinfo, formatlistmap,
     504    output_parents (response, args, browsermap, formatstrings, formatlistmap,
    594505            classification, tabcount, metadata, getParents,
    595506            collectproto, disp, outconvert, textout, logout);
     
    622533
    623534  // get the formatstring if there is one or use the browsers default
    624   if (!get_formatstring (classification, classifytype,
    625              formatinfo.formatstrings, formatstring))
     535  if (!get_formatstring (classification, classifytype, formatstrings, formatstring))
    626536    formatstring = bptr->get_default_formatstring();
    627537
     
    650560
    651561void output_toc (cgiargsclass &args, browsermapclass *browsermap,
    652                  formatinfo_t &formatinfo, recptproto *collectproto,
     562                 text_tmap &formatstrings, recptproto *collectproto,
    653563                 displayclass &disp, outconvertclass &outconvert,
    654564                 ostream &textout, ostream &logout) {
    655565
    656566  int tabcount = 0;
    657   bool havecontrols = false;
    658567  bool fulltoc = false;
    659568
     
    662571    text_t cl_top, full_toc;
    663572    get_top (args["cl"], cl_top);
    664     if (get_formatstring (cl_top, "FullTOC", formatinfo.formatstrings, full_toc))
     573    if (get_formatstring (cl_top, "FullTOC", formatstrings, full_toc))
    665574      if (full_toc == "true") fulltoc = true;
    666575  }
    667  
    668   // get the cover image (if there is one) and the control buttons
    669   // if we're inside a book
    670   if ((!fulltoc) && (!args["d"].empty())) {
    671     textout << outconvert << disp
    672         << "<p><center><table width=_pagewidth_><tr>\n"
    673         << "<td valign=top";
    674     if (formatinfo.DocumentContents) textout << " width=200>\n";
    675     else textout << " width=100%>\n";
    676     if (formatinfo.DocumentIcon == "true")
    677       output_cover_image (args, collectproto, disp, outconvert, textout, logout);
    678     else if (formatinfo.DocumentIcon != "false")
    679       output_titles (args, collectproto, formatinfo, disp, outconvert, textout, logout);
    680     output_controls (args, formatinfo.DocumentButtons, collectproto, disp,
    681              outconvert, textout, logout);
    682     textout << "</td><td valign=top>\n";
    683     havecontrols = true;
    684   }
    685 
    686   if (formatinfo.DocumentContents || args["d"].empty()) {
    687     if (args.getintarg("gc") == 1) {
     576
     577  if (args["gc"] == 1) {
    688578     
    689       // expanded table of contents
    690       expanded_contents (args, tabcount, fulltoc, browsermap, formatinfo,
     579    // expanded table of contents
     580    expanded_contents (args, tabcount, fulltoc, browsermap, formatstrings,
     581               collectproto, disp, outconvert, textout, logout);
     582  } else {
     583     
     584    // contracted table of contents
     585    contracted_contents (args, tabcount, fulltoc, browsermap, formatstrings,
    691586             collectproto, disp, outconvert, textout, logout);
    692     } else {
    693      
    694       // contracted table of contents
    695       contracted_contents (args, tabcount, fulltoc, browsermap, formatinfo,
    696                collectproto, disp, outconvert, textout, logout);
    697     }
    698   }
    699 
    700   if (havecontrols) textout << "</td></tr></table></center>\n";
    701 }
    702 
    703 
    704 
     587  }
     588}
Note: See TracChangeset for help on using the changeset viewer.