Changeset 869


Ignore:
Timestamp:
2000-01-26T11:37:57+13:00 (24 years ago)
Author:
sjboddie
Message:

lots of stuff

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

Legend:

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

    r827 r869  
    2727#include <string.h>
    2828#include "extlinkaction.h"
     29#include "OIDtools.h"
    2930#include "cgiutils.h"
    3031
     
    8081
    8182
    82 
    83 void extlinkaction::get_cgihead_info (cgiargsclass &args, recptprotolistclass * /*protos*/,
     83void extlinkaction::get_cgihead_info (cgiargsclass &args, recptprotolistclass *protos,
    8484                      response_t &response, text_t &response_data,
    85                       ostream &/*logout*/)
    86 {
    87   if (args["el"] == "direct")
    88     {
     85                      ostream &logout) {
     86
     87  text_t link;
     88  if (get_link (args, protos, link, logout)) {
     89    response = location;
     90    response_data = link;
     91    return;
     92  }
     93
     94  // external link
     95  if (!link.empty()) {
     96    if (args["el"] == "direct") {
    8997      response = location;
    90       response_data =  args["href"];
     98      response_data = link;
     99      return;
    91100    }
    92   else
    93     {
    94       response = content;
    95       response_data = "text/html";
    96     }
    97 }
    98 
    99 
     101  }
     102
     103  response = content;
     104  response_data = "text/html";
     105}
    100106
    101107void extlinkaction::define_internal_macros (displayclass &disp, cgiargsclass &args,
     
    108114  // _prevdoc_             link to previous document
    109115 
    110   disp.setmacro("nexturl", "extlink", cgi_safe(args["href"]));
     116  disp.setmacro("nexturl", "extlink", args["href"]);
    111117  disp.setmacro("prevdoc", "extlink", args["d"]);
    112118}
    113119
    114120
    115 bool extlinkaction::do_action (cgiargsclass &args, recptprotolistclass * /*protos*/,
     121// if link is found returns true and url in link, otherwise returns
     122// false
     123bool extlinkaction::get_link (cgiargsclass &args, recptprotolistclass *protos,
     124                  text_t &link, ostream &logout) {
     125
     126    text_t &arg_href = args["href"];
     127    text_t &thiscollection = args["c"];
     128    if (arg_href.empty()) return false;
     129
     130    if (args["rl"] == "1") {
     131
     132      FilterResponse_t response;
     133      text_tset metadata;
     134      metadata.insert ("section");
     135     
     136      recptproto *collectproto = protos->getrecptproto (thiscollection, logout);
     137
     138      if (get_info (arg_href, thiscollection, metadata, false, collectproto, response, logout)) {
     139    if (!response.docInfo[0].metadata["section"].values[0].empty()) {
     140      link = "_httpdoc_&d=" + response.docInfo[0].metadata["section"].values[0];
     141      return true;
     142    }
     143      }
     144
     145      // need to see if link exists in any other collection
     146      // if cross-collection searching/browsing is turned on
     147      if (args["ccs"] == "1" && !args["cc"].empty()) {
     148    text_tarray collections;
     149    splitchar (args["cc"].begin(), args["cc"].end(), ',', collections);
     150
     151    text_tarray::const_iterator col_here = collections.begin();
     152    text_tarray::const_iterator col_end = collections.end();
     153
     154    while (col_here != col_end) {
     155     
     156      // don't need to check current collection again
     157      if (*col_here == thiscollection) {col_here ++; continue;}
     158     
     159      recptproto *collectproto = protos->getrecptproto (*col_here, logout);
     160      if (collectproto == NULL) {col_here ++; continue;}
     161
     162      if (get_info (arg_href, *col_here, metadata, false, collectproto, response, logout)) {
     163        if (!response.docInfo[0].metadata["section"].values[0].empty()) {
     164          link = "_httpdoc_&c=" + *col_here + "&d=" +
     165        response.docInfo[0].metadata["section"].values[0];
     166          return true;
     167        }
     168      }
     169      col_here ++;
     170    }
     171      }
     172      return false;
     173     
     174    } else {
     175      // link is external
     176      link = arg_href;
     177      return false;
     178    }
     179}
     180
     181
     182bool extlinkaction::do_action (cgiargsclass &args, recptprotolistclass *protos,
    116183                   browsermapclass * /*browsers*/, displayclass &disp,
    117184                   outconvertclass &outconvert, ostream &textout,
    118                    ostream &/*logout*/) {
    119 
    120   if (args["el"] != "direct")
    121     {
    122       if (args["href"] != "")
    123     {
    124       textout << outconvert << disp << ("_extlink:header_\n")
    125           << ("_extlink:foundcontent_\n")
    126           << ("_extlink:footer_\n");
     185                   ostream &logout) {
     186
     187  if (args["href"].empty()) {
     188    // oops, this shouldn't happen
     189    textout << outconvert << disp << ("_extlink:header_\n")
     190        << ("_extlink:notfoundcontent_\n")
     191        << ("_extlink:footer_\n");
     192    return true;
     193  }
     194
     195  if (args["rl"] == "1") {
     196    // need to see if link exists in any other collection
     197    // if cross-collection searching/browsing is turned on
     198    if (args["ccs"] == "1" && !args["cc"].empty()) {
     199     
     200      FilterResponse_t response;
     201      text_tset metadata;
     202      metadata.insert ("section");
     203      text_tarray collections;
     204      splitchar (args["cc"].begin(), args["cc"].end(), ',', collections);
     205     
     206      text_tarray::const_iterator col_here = collections.begin();
     207      text_tarray::const_iterator col_end = collections.end();
     208     
     209      while (col_here != col_end) {
     210   
     211    // don't need to check current collection
     212    if (*col_here == args["c"]) {col_here ++; continue;}
     213   
     214    recptproto *collectproto = protos->getrecptproto (*col_here, logout);
     215   
     216    if (get_info (args["href"], *col_here, metadata, false, collectproto, response, logout)) {
     217      if (!response.docInfo[0].metadata["section"].values[0].empty()) {
     218        text_t collectionname = *col_here;
     219        metadata.erase (metadata.begin(), metadata.end());
     220        metadata.insert ("collectionname");
     221        FilterResponse_t nresponse;
     222        if (get_info ("collection", *col_here, metadata, false, collectproto, nresponse, logout)) {
     223          if (!nresponse.docInfo[0].metadata["collectionname"].values[0].empty())
     224        collectionname = nresponse.docInfo[0].metadata["collectionname"].values[0];
     225        }
     226        textout << outconvert << disp << ("_extlink:header_\n")
     227            << ("_extlink:foundintcontent_(" + *col_here + ", " + collectionname +
     228            ", " + response.docInfo[0].metadata["section"].values[0] + "\n")
     229            << ("_extlink:footer_\n");
     230        return true;
     231      }
    127232    }
    128       else
    129     {
    130       textout << outconvert << disp << ("_extlink:header_\n")
    131           << ("_extlink:notfoundcontent_\n")
    132           << ("_extlink:footer_\n");
    133     }
     233    col_here ++;
     234      }
    134235    }
     236    textout << outconvert << disp << ("_extlink:header_\n")
     237        << ("_extlink:notfoundcontent_\n")
     238        << ("_extlink:footer_\n");
     239   
     240   
     241  } else {
     242    // link is external
     243    textout << outconvert << disp << ("_extlink:header_\n")
     244        << ("_extlink:foundcontent_\n")
     245        << ("_extlink:footer_\n");
     246  }
    135247
    136248  return true;
     
    138250
    139251
    140 
  • trunk/gsdl/src/recpt/extlinkaction.h

    r756 r869  
    5151          ostream &logout);
    5252
     53
     54protected:
     55  bool get_link (cgiargsclass &args, recptprotolistclass *protos,
     56         text_t &link, ostream &logout);
     57
    5358};
    5459
Note: See TracChangeset for help on using the changeset viewer.