Changeset 869
- Timestamp:
- 2000-01-26T11:37:57+13:00 (24 years ago)
- Location:
- trunk/gsdl/src/recpt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/extlinkaction.cpp
r827 r869 27 27 #include <string.h> 28 28 #include "extlinkaction.h" 29 #include "OIDtools.h" 29 30 #include "cgiutils.h" 30 31 … … 80 81 81 82 82 83 void extlinkaction::get_cgihead_info (cgiargsclass &args, recptprotolistclass * /*protos*/, 83 void extlinkaction::get_cgihead_info (cgiargsclass &args, recptprotolistclass *protos, 84 84 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") { 89 97 response = location; 90 response_data = args["href"]; 98 response_data = link; 99 return; 91 100 } 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 } 100 106 101 107 void extlinkaction::define_internal_macros (displayclass &disp, cgiargsclass &args, … … 108 114 // _prevdoc_ link to previous document 109 115 110 disp.setmacro("nexturl", "extlink", cgi_safe(args["href"]));116 disp.setmacro("nexturl", "extlink", args["href"]); 111 117 disp.setmacro("prevdoc", "extlink", args["d"]); 112 118 } 113 119 114 120 115 bool extlinkaction::do_action (cgiargsclass &args, recptprotolistclass * /*protos*/, 121 // if link is found returns true and url in link, otherwise returns 122 // false 123 bool 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 182 bool extlinkaction::do_action (cgiargsclass &args, recptprotolistclass *protos, 116 183 browsermapclass * /*browsers*/, displayclass &disp, 117 184 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 } 127 232 } 128 else 129 { 130 textout << outconvert << disp << ("_extlink:header_\n") 131 << ("_extlink:notfoundcontent_\n") 132 << ("_extlink:footer_\n"); 133 } 233 col_here ++; 234 } 134 235 } 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 } 135 247 136 248 return true; … … 138 250 139 251 140 -
trunk/gsdl/src/recpt/extlinkaction.h
r756 r869 51 51 ostream &logout); 52 52 53 54 protected: 55 bool get_link (cgiargsclass &args, recptprotolistclass *protos, 56 text_t &link, ostream &logout); 57 53 58 }; 54 59
Note:
See TracChangeset
for help on using the changeset viewer.