- Timestamp:
- 1998-11-25T15:45:00+13:00 (26 years ago)
- Location:
- trunk/gsdl
- Files:
-
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/library/browse.cpp
r4 r32 1 1 #include "browse.h" 2 3 4 ////////////////////////////////////////////////////////////////////////////////////////////// 5 // get_browse_bar returns (in return_text) the html for the browse bar at the top of 6 // each page with the button for the current classification hierarchy deactivated 7 8 void browseclass::get_browse_bar(const text_t &targetdoc, text_t &return_text) { 9 if (targetdoc[0] == 'B') return_text = "_imagestandardbar_"; 10 else { 11 return_text = "_browse:imagebrowse"; 12 return_text.push_back(targetdoc[0]); 13 return_text += "bar_"; 14 } 15 } 16 17 18 ////////////////////////////////////////////////////////////////////////////////////////////// 19 ////////////////////////////////////////////////////////////////////////////////////////////// 20 // toc functions 21 22 23 ////////////////////////////////////////////////////////////////////////////////////////////// 24 // get_list_toc returns all the titles of the sections in secarray as a list of links 25 // (i.e. as used by howto classifications in hdl collection) 26 void browseclass::get_list_toc (vector<text_t> &secarray, text_t &collection, 27 gdbmclass &gdbm, text_t &return_text) { 28 gdbm_info info; 29 text_t section, child; 30 31 text_t doclink = "<a href=\"_httptext_&d="; 32 return_text += "<p>\n"; 33 34 vector<text_t>::const_iterator thissection = secarray.begin(); 35 vector<text_t>::const_iterator end = secarray.end(); 36 37 while (thissection != end) { 38 39 section.clear(); 40 child.clear(); 41 // get info on this section from gdbm 42 if (is_book(*thissection)) get_book(*thissection, section); 43 else section = *thissection; 44 45 gdbm.getinfo(section, collection, info); 46 get_first_section(info.c, child); 47 48 // return_text += "<br>" + doclink + *thissection + "." + child + "\">" + info.t + "</a>\n"; 49 return_text += "<br>" + doclink + *thissection + "." + child + ".1\">" + info.t + "</a>\n"; 50 thissection ++; 51 } 52 } 53 54 55 ////////////////////////////////////////////////////////////////////////////////////////////// 56 // get_page_toc returns links to previous and next pages and text box for going to 57 // a selected page (as used by gberg collection). It is intended for use with collections 58 // whose documents are simply numbered as pages (should be single level TOCs). 59 // There may be introductory text sections before numbered pages. 60 void browseclass::get_page_toc (cgiargsclass &args, const text_t &booksection, 61 const text_t &classification, const text_t &class_string, 62 gdbmclass &gdbm, text_t &return_text) { 63 gdbm_info info, topinfo; 64 text_t previous, next; 65 vector<text_t> contents; 66 67 // don't want arrows and page number if text expanded 68 if (args["g"][1] != '1') { 69 70 // get links to previous and next sections. 71 get_prev_next_links(booksection, args["c"], previous, next); 72 73 return_text += "<p>\n<table cellpadding=\"0\" cellspacing=\"0\">\n"; 74 return_text += "<tr valign=\"absmiddle\">\n"; 75 76 // get previous arrow 77 if (gdbm.exists(previous, args["c"])) { 78 return_text += "<td><a href=\"_httptext_&d=" + classification + "." + previous; 79 return_text += "\">_iconless_</a></td>\n"; 80 } 81 82 // get page ? of ? text 83 return_text += "<td align=\"center\">\n"; 84 gdbm.getinfo(booksection, args["c"], info); 85 if (is_number(info.t)) { 86 splitstring(class_string, contents); 87 gdbm.getinfo(contents.back(), args["c"], topinfo); 88 if (is_number(topinfo.t)) 89 return_text += " page " + info.t + " of " + topinfo.t + " "; 90 else 91 return_text += " " + info.t + " "; 92 } else { 93 return_text += " " + info.t + " "; 94 } 95 return_text += "</td>\n"; 96 97 // get next arrow 98 if (gdbm.exists(next, args["c"])) { 99 return_text += "<td><a href=\"_httptext_&d=" + classification + "." + next; 100 return_text += "\">_iconmore_</a></td>\n"; 101 } 102 return_text += "</tr></table>\n"; 103 } 104 // goto line 105 return_text += "_gotoform_"; 106 } 107 108 ////////////////////////////////////////////////////////////////////////////////////////////// 109 // get_standard_toc is the standard (unexpanded) toc used by hdl, unu, unesco etc. 110 111 void browseclass::get_standard_toc(cgiargsclass &args, text_t &booksection, 112 const text_t &classification, gdbmclass &gdbm, 113 text_t &return_text) { 114 115 // text_t doclink, tab, pagetype, section, icon, pointer, fulldoc; 116 int colnum, tabcount = 0; 117 text_t fulldoc; 118 // gdbm_info info; 119 // vector<text_t> contents, parents, siblings; 120 vector<text_t> parents, siblings; 121 122 if (!booksection.empty()) fulldoc = classification + "." + booksection; 123 else fulldoc = classification; 124 125 get_parents (fulldoc, parents); 126 get_siblings (classification, booksection, gdbm, args["c"], siblings); 127 128 // remove everything above top level of book from parents 129 // list if inside of book 130 if (!booksection.empty() && !is_top_level(booksection)) { 131 vector<text_t> temp; 132 for (unsigned int i = 0; i < parents.size(); i++) { 133 if (is_book(parents[i])) temp.push_back(parents[i]); 134 } 135 parents = temp; 136 } 137 138 // remove top level of title and author hierarchies 139 if (((classification[0] == 'T') || (classification[0] == 'A')) && 140 (booksection.empty() || is_top_level(booksection))) { 141 if (!parents.empty()) 142 parents.erase(parents.begin(), parents.begin()+1); 143 } 144 colnum = parents.size() + 1; 145 146 // sort out toc of sections parents 147 if (parents.size() > 0) 148 get_parents_toc(args, parents, gdbm, tabcount, colnum, return_text); 149 150 // sort out toc of sections siblings 151 if (siblings.size() > 0) 152 get_siblings_toc (args, siblings, gdbm, booksection, classification, 153 tabcount, colnum, return_text); 154 155 return_text += "</table>\n"; 156 return_text += "</td></tr></table>\n"; 157 } 158 159 160 ////////////////////////////////////////////////////////////////////////////////////////////// 161 // get_expanded_toc is the expanded toc used by hdl, unu, unesco etc. 162 163 void browseclass::get_expanded_toc(cgiargsclass &args, text_t &booksection, 164 const text_t &classification, gdbmclass &gdbm, 165 text_t &return_text) { 166 167 text_t doclink, icon, pointer, tab, pagetype; 168 int totalcols, tabcols, tabsleft; 169 vector<text_t> contents; 170 gdbm_info info; 171 172 // get array of all contents to be included (all contents of entire book) 173 text_t book_top; 174 get_book_top (booksection, book_top); 175 get_contents (book_top, gdbm, args["c"], contents, totalcols); 176 177 vector<text_t>::const_iterator section = contents.begin(); 178 vector<text_t>::const_iterator end = contents.end(); 179 180 int count = 1; 181 while (section != end) { 182 tab.clear(); 183 gdbm.getinfo(*section, args["c"], info); 184 text_t icontabs; 185 186 // set up icon 187 icon = "_iconsmalltext_"; 188 if (is_top_level(*section)) icon = "_iconopenbook_"; 189 else if (!info.c.empty()) icon = "_iconopenfolder_"; 190 191 // set up pointer 192 if (*section == booksection) pointer = "_iconpointer_"; 193 else pointer = "_icontab_"; 194 195 // set up tabbing 196 tabcols = count_dots(*section); 197 for (int i = 0; i < (tabcols - 1); i++) { 198 icontabs += "_icontab_"; 199 } 200 //char *tabcolsstr; 201 //itoa(tabcols, tabcolsstr, 10); 202 tab = "<td valign=top colspan=" + text_t(tabcols); 203 tab += ">" + icontabs + pointer + "</td>"; 204 tabsleft = totalcols - tabcols; 205 206 // set up url 207 if (is_book(*section) && !is_top_level(*section)) 208 doclink = "<a href=\"_httptext_"; 209 else doclink = "<a href=\"_httpbrowse_"; 210 if (args["x"] == "1") doclink += "&x=1"; 211 212 return_text += "<tr>" + tab + "<td valign=top>"; 213 if (is_top_level(*section) && args["x"] == "1") { 214 return_text += "<a href=\"\" onClick = \"close_detach()"; 215 } else { 216 if (args["g"][1] == '0' || is_top_level(*section) || 217 !are_same_chapter(booksection, *section) || 218 !info.c.empty()) { 219 return_text += doclink + "d=" + classification; 220 return_text += "." + *section + "&a=" + pagetype; 221 } else { 222 return_text += "<a href=\"#"; 223 return_text += count; 224 count ++; 225 } 226 } 227 return_text += "\">" + icon + "</a></td>"; 228 return_text += "<td colspan=" + text_t(tabsleft); 229 return_text += "><_font_>" + info.t + "</font>"; 230 return_text += "</td></tr>\n"; 231 232 section ++; 233 } 234 return_text += "</table>\n"; 235 return_text += "</td></tr></table>\n"; 236 } 237 238 239 void browseclass::get_parents_toc (cgiargsclass &args, const vector<text_t> &parents, 240 gdbmclass &gdbm, int &tabcount, int &colnum, 241 text_t &return_text) { 242 243 text_t section, tab, icon, doclink; 244 gdbm_info info; 245 246 vector<text_t>::const_iterator thisparent = parents.begin(); 247 vector<text_t>::const_iterator end = parents.end(); 248 249 while (thisparent != end) { 250 text_t icontabs; 251 section.clear(); 252 tab.clear(); 253 254 // get info on this parent from gdbm 255 if (is_book(*thisparent)) get_book(*thisparent, section); 256 else section = *thisparent; 257 gdbm.getinfo(section, args["c"], info); 258 259 // set up icon for this parent 260 icon = "_iconopenfolder_"; 261 if (!is_book(*thisparent)) icon = "_iconopenbookshelf_"; 262 else if (is_top_level(*thisparent)) icon = "_iconopenbook_"; 263 264 for (int j = 0; j < tabcount; j++) { 265 icontabs += "_icontab_"; 266 } 267 268 if (!icontabs.empty()) { 269 tab = "<td valign=top"; 270 if (tabcount > 1) tab += " colspan=" + text_t(tabcount); 271 tab += ">" + icontabs + "</td>"; 272 } 273 tabcount ++; 274 275 // set up url 276 if (is_book(*thisparent) && !is_top_level(*thisparent)) 277 doclink = "<a href=\"_httptext_"; 278 else doclink = "<a href=\"_httpbrowse_"; 279 if (args["x"] == "1") doclink += "&x=1"; 280 281 if (is_top_level(*thisparent) && args["x"] == "1") { 282 return_text += "<tr>" + tab + "<td valign=top><a href=\"\" "; 283 return_text += "onClick = \"close_detach()\">" + icon + "</a></td>"; 284 } else { 285 return_text += "<tr>" + tab + "<td valign=top>" + doclink + "&d=" + *thisparent; 286 return_text += "\">" + icon + "</a></td>"; 287 } 288 return_text += "<td"; 289 if (colnum > 1) return_text += " colspan=" + text_t(colnum); 290 return_text += "><_font_>" + info.t; 291 if (!info.a.empty()) return_text += " by " + info.a; 292 return_text += "</font>"; 293 return_text += "</td></tr>\n"; 294 colnum --; 295 thisparent ++; 296 } 297 } 298 299 void browseclass::get_siblings_toc (cgiargsclass &args, const vector<text_t> &siblings, 300 gdbmclass &gdbm, const text_t &booksection, 301 const text_t &classification, int &tabcount, 302 int &colnum, text_t &return_text) { 303 304 text_t tab, section, icon, pointer, child, doclink; 305 int count = 1; 306 gdbm_info info; 307 308 vector<text_t>::const_iterator thissibling = siblings.begin(); 309 vector<text_t>::const_iterator sibend = siblings.end(); 310 311 while (thissibling != sibend) { 312 section.clear(); 313 314 // get info on this sibling from gdbm 315 if (is_book(*thissibling)) get_book(*thissibling, section); 316 else section = *thissibling; 317 gdbm.getinfo(section, args["c"], info); 318 319 // set up icon for this sibling 320 icon = "_iconclosedfolder_"; 321 if (!is_book(*thissibling)) icon = "_iconclosedbookshelf_"; 322 else if (is_top_level(*thissibling)) icon = "_iconclosedbook_"; 323 324 // fit pointer into tabbing if current section 325 pointer = "_icontab_"; 326 if (is_book(section)) { 327 if (section == booksection) pointer = "_iconpointer_"; 328 } else if (section == classification) pointer = "_iconpointer_"; 329 330 text_t thesetabs; 331 for (int j = 0; j < (tabcount - 1); j++) { 332 thesetabs += "_icontab_"; 333 } 334 335 tab = "<td valign=top"; 336 if (tabcount > 1) tab += " colspan=" + text_t(tabcount); 337 tab += ">" + thesetabs + pointer + "</td>"; 338 339 if (info.c.empty()) { 340 // sibling is text document 341 icon = "_iconsmalltext_"; 342 343 // set up url 344 if (is_book(*thissibling) && !is_top_level(*thissibling)) 345 doclink = "<a href=\"_httptext_"; 346 else doclink = "<a href=\"_httpbrowse_"; 347 if (args["x"] == "1") doclink += "&x=1"; 348 349 return_text += "<tr>" + tab + "<td valign=top>"; 350 if (args["g"][1] == '0') { 351 return_text += doclink + "&d=" + *thissibling; 352 } else { 353 return_text += "<a href=\"#"; 354 return_text += count; 355 count ++; 356 } 357 return_text += "\">" + icon + "</a></td><td"; 358 if (colnum > 1) return_text += " colspan=" + text_t(colnum); 359 return_text += "><_font_>" + info.t; 360 if (!info.a.empty()) return_text += " by " + info.a; 361 return_text += "</font></td></tr>\n"; 362 } else { 363 // sibling is closed book or folder so clicking 364 // it should open contents 365 get_first_section(info.c, child); 366 367 // get classification of child if it's a book 368 if (is_book(child)) { 369 text_t classif = classification; 370 // remove last part (i.e. '.n') from classification if current section is 371 // a classification and sibling is a book 372 if (booksection.empty() && is_book(*thissibling)) { 373 get_parent_section(classif); 374 } 375 // if sibling is a classification it is the classification of its child 376 if (!is_book(*thissibling)) classif = *thissibling; 377 378 child = classif + "." + child; 379 } 380 381 // set up url 382 if (is_book(child) && !is_top_level(child)) 383 doclink = "<a href=\"_httptext_"; 384 else doclink = "<a href=\"_httpbrowse_"; 385 if (args["x"] == "1") doclink += "&x=1"; 386 387 return_text += "<tr>" + tab + "<td valign=top>" + doclink + "&d=" + child; 388 return_text += "\">" + icon + "</a></td><td"; 389 if (colnum > 1) return_text += " colspan=" + text_t(colnum); 390 return_text += "><_font_>" + info.t; 391 if (!info.a.empty()) return_text += " by " + info.a; 392 return_text += "</font></td></tr>\n"; 393 } 394 thissibling ++; 395 } 396 } 397 398 399 400 // get_alphabet_links adds the html for the letter selection links to return_text 401 void browseclass::get_alphabet_links (const text_t &classification, 402 const text_t &booksection, gdbmclass &gdbm, 403 const text_t &collection, text_t &return_text) { 404 405 gdbm_info info; 406 407 text_t link = "<a href=\"_httpbrowse_&d="; 408 vector<text_t> classcontents; 409 text_t classt, firstcontent; 410 classt.push_back(classification[0]); 411 412 return_text += "\n<p>\n"; 413 return_text += "<table width=\"100%\" cellpadding=0 cellspacing=0 border=0>\n"; 414 return_text += "<tr><td valign=top><center>\n"; 415 return_text += "<_font_>\n"; 416 417 // get list of contents for this classification 418 gdbm.getinfo(classt, collection, info); 419 if (!info.c.empty()) { 420 splitstring(info.c, classcontents); 421 vector<text_t>::const_iterator here = classcontents.begin(); 422 vector<text_t>::const_iterator end = classcontents.end(); 423 424 while (here != end) { 425 gdbm.getinfo(*here, collection, info); 426 427 if (*here == classification) { 428 return_text += "<b>" + info.t + "</b> "; 429 } else { 430 if (!info.c.empty()) { 431 get_first_section(info.c, firstcontent); 432 return_text += link + *here + "." + firstcontent + "\">"; 433 return_text += info.t + "</a> "; 434 } 435 } 436 here ++; 437 } 438 } 439 return_text += "</font>\n"; 440 return_text += "</center></td>\n</tr><tr>\n"; 441 } 442 443 // get_arrows returns (in arrows) the html for the arrows to select 444 // next/previous section at same level. If there is no next/previous 445 // section at current level then there'll be no arrow. 446 void browseclass::get_arrows(text_t &docref, gdbmclass &gdbm, 447 const text_t &collection, text_t &arrows) { 448 text_t previous, next, firstcontent; 449 gdbm_info info; 450 451 arrows = "\n<table width=\"100%\" border=0 cellspacing=0 cellpadding=0>"; 452 arrows += "<tr><td align=left>\n"; 453 arrows += "<_font_>\n"; 454 455 // get links to previous and next sections. 456 get_prev_next_links(docref, collection, previous, next); 457 458 // get html for previous link if it exists 459 gdbm.getinfo(previous, collection, info); 460 if (!info.c.empty()) { 461 get_first_section(info.c, firstcontent); 462 arrows += "<a href=\"_httpbrowse_&d="; 463 arrows += previous + "." + firstcontent + "\">"; 464 arrows += "_iconalphless_</a>\n"; 465 } 466 467 arrows += "</font>\n"; 468 arrows += "</td><td align=right>\n"; 469 arrows += "<_font_>\n"; 470 471 // get html for next link if it exists 472 gdbm.getinfo(next, collection, info); 473 if (!info.c.empty()) { 474 get_first_section(info.c, firstcontent); 475 arrows += "<a href=\"_httpbrowse_&d="; 476 arrows += next + "." + firstcontent + "\">"; 477 arrows += "_iconalphmore_</a>\n"; 478 } 479 480 arrows += "</font>\n"; 481 arrows += "</td></tr></table>\n"; 482 } 483 484 // get_prev_next_links returns (in previous and next) the sections previous to 485 // and next after docref (on the same level). These sections may not be 486 // defined in the infodb so calling function should check. 487 488 void browseclass::get_prev_next_links (text_t docref, const text_t &collection, 489 text_t &previous, text_t &next) { 490 int prevnum, nextnum, thisnum; 491 text_t section; 492 493 get_parent_section(docref, section); 494 495 thisnum = section.getint(); 496 prevnum = thisnum - 1; 497 nextnum = thisnum + 1; 498 499 previous = docref + "." + text_t(prevnum); 500 next = docref + "." + text_t(nextnum); 501 } 502 503 // get contents returns a contents array of all contents below (and including) 504 // the classification in expandlevel. 505 // it also returns (in totalcols) the total number of columns needed for 506 // a table of contents using contents 507 void browseclass::get_contents (text_t expandlevel1, gdbmclass &gdbm, 508 const text_t &collection, vector<text_t> &contents, 509 int &totalcols) { 510 511 text_t expandlevel = expandlevel1; 512 513 contents.erase(contents.begin(), contents.end()); 514 totalcols = 0; 515 516 vector<text_t> sections; 517 text_t section, book_top; 518 int cols; 519 gdbm_info info; 520 521 if (!is_top_level(expandlevel)) get_parent_section(expandlevel); 522 523 sections.push_back(expandlevel); 524 525 while (!sections.empty()) { 526 section = sections.back(); 527 sections.pop_back(); 528 get_book (section, section); 529 530 contents.push_back(section); 531 532 // update number of columns needed for table 533 cols = count_dots(section) + 1; 534 if (cols > totalcols) totalcols = cols; 535 536 gdbm.getinfo(section, collection, info); 537 if (!info.c.empty()) { 538 vector<text_t> temp; 539 splitstring(info.c, temp); 540 while (!temp.empty()) { 541 sections.push_back(temp.back()); 542 temp.pop_back(); 543 } 544 } 545 } 546 // get top level of book and add to contents if not already there 547 get_book_top(expandlevel, book_top); 548 549 if (contents.front() != book_top) { 550 contents.insert(contents.begin(), book_top); 551 } 552 } 553 554 555 ////////////////////////////////////////////////////////////////////////////////////////////// 556 // get_links returns (in return_text) the html for the buttons to link to the next and 557 // previous sections 558 559 void browseclass::get_links(cgiargsclass &args, gdbmclass &gdbm, text_t &return_text) { 560 561 text_t doclink, classification, booksection; 562 text_t nextsibling, previoussibling, lastsibling; 563 vector<text_t> siblings; 564 gdbm_info info; 565 566 seperate_parts(args["d"], gdbm, args["c"], classification, booksection); 567 568 // don't want links at top levels 569 if (booksection.empty() || is_top_level(booksection)) return; 570 571 text_t current_classification = classification + "." + booksection; 572 573 return_text += "<table width=\"100%\" border=0 cellspacing=0 cellpadding=0>\n"; 574 return_text += "<tr><td align=left>\n"; 575 576 get_siblings (classification, booksection, gdbm, args["c"], siblings); 577 578 // get older and younger siblings if they exist 579 int found = 0; 580 vector<text_t>::const_iterator thissibling = siblings.begin(); 581 vector<text_t>::const_iterator end = siblings.end(); 582 while (thissibling != end) { 583 if (found) { 584 nextsibling = *thissibling; 585 break; 586 } 587 588 if (*thissibling == current_classification) { 589 previoussibling = lastsibling; 590 found = 1; 591 } 592 lastsibling = *thissibling; 593 thissibling ++; 594 } 595 596 // don't want 'next' arrow pointing to next sibling if current section 597 // has children 598 gdbm.getinfo(booksection, args["c"], info); 599 if (!info.c.empty()) nextsibling = current_classification; 600 601 // set up the 'previous' arrow 602 603 if (is_section_top(booksection)) { 604 // if this section is the top of any section in line with 605 // top of book there'll be no 'previous' arrow 606 // (i.e. B.n.1, B.n.1.1, B.n.1.1.1 etc.) 607 } else { 608 // get parents older sibling if no older sibling of own 609 text_t sec = booksection; 610 while (previoussibling.empty()) { 611 vector<text_t> parentsiblings; 612 gdbm.getinfo(sec, args["c"], info); // info on this section 613 text_t last, parent = info.p; 614 gdbm.getinfo(parent, args["c"], info); // info on parent 615 gdbm.getinfo(info.p, args["c"], info); // info on grandparent 616 splitstring(info.c, parentsiblings); // now have parents siblings 617 618 vector<text_t>::const_iterator thisuncle = parentsiblings.begin(); 619 vector<text_t>::const_iterator end = parentsiblings.end(); 620 621 while (thisuncle != end) { 622 if (*thisuncle == parent) { 623 previoussibling = last; 624 break; 625 } 626 last = *thisuncle; 627 thisuncle ++; 628 } 629 sec = parent; 630 } 631 632 // if previous section has contents then we need to link to the last 633 // of those contents 634 text_t prev; // use this in case previoussibling contains classification 635 get_book(previoussibling, prev); 636 gdbm.getinfo(prev, args["c"], info); 637 while (!info.c.empty()) { 638 vector<text_t> contents; 639 splitstring(info.c, contents); 640 previoussibling = contents.back(); 641 gdbm.getinfo(previoussibling, args["c"], info); 642 } 643 644 if (previoussibling[0] == 'B') previoussibling = classification + "." + previoussibling; 645 } 646 647 648 // set up the 'next' arrow 649 text_t sec = booksection; 650 // if no younger siblings get parents younger siblings 651 while (nextsibling.empty()) { 652 gdbm.getinfo(sec, args["c"], info); 653 text_t parent = info.p; 654 gdbm.getinfo(parent, args["c"], info); // parent info 655 if (!info.p.empty()) { 656 vector<text_t> parentsiblings; 657 gdbm.getinfo(info.p, args["c"], info); // grandparent info 658 splitstring(info.c, parentsiblings); // got parents siblings 659 660 vector<text_t>::iterator thissibling = parentsiblings.begin(); 661 vector<text_t>::iterator end = parentsiblings.end(); 662 int found = 0; 663 while(thissibling != end) { 664 if (found) { 665 nextsibling = *thissibling; 666 break; 667 } 668 if (*thissibling == parent) found = 1; 669 thissibling ++; 670 } 671 sec = parent; 672 } else { 673 // no more contents 674 break; 675 } 676 } 677 678 if (!nextsibling.empty()) { 679 // if nextsibling still isn't set there are no more sections in the 680 // book and so no 'next' arrow 681 682 // if next section has contents we want to link to the first 683 // of those contents 684 text_t next; 685 get_book(nextsibling, next); 686 gdbm.getinfo(next, args["c"], info); 687 while (!info.c.empty()) { 688 get_first_section(info.c, nextsibling); 689 gdbm.getinfo(nextsibling, args["c"], info); 690 } 691 if (nextsibling[0] == 'B') nextsibling = classification + "." + nextsibling; 692 } 693 694 // html for 'previous' arrow 695 if (!previoussibling.empty()) { 696 if (is_book(previoussibling) && !is_top_level(previoussibling)) 697 doclink = "<a href=\"_httptext_"; 698 else doclink = "<a href=\"_httpbrowse_"; 699 if (args["x"] == "1") doclink += "&x=1"; 700 701 return_text += doclink + "&d=" + previoussibling + "\">_iconless_</a>\n"; 702 } 703 704 return_text += "</td><td align=right>\n"; 705 706 // html for 'next' arrow 707 if (!nextsibling.empty()) { 708 if (is_book(nextsibling) && !is_top_level(nextsibling)) 709 doclink = "<a href=\"_httptext_"; 710 else doclink = "<a href=\"_httpbrowse_"; 711 if (args["x"] == "1") doclink += "&x=1"; 712 713 return_text += doclink + "&d=" + nextsibling + "\">_iconmore_</a>\n"; 714 } 715 716 return_text += "</td></tr></table>\n"; 717 } 718 719 // get_contents_arr returns an array containing the classifications of all the sections 720 // in the book mentioned in targetdoc 721 722 void browseclass::get_contents_arr(cgiargsclass &args, gdbmclass &gdbm, 723 vector<text_t> &contents_arr) { 724 text_t booksection; 725 int totalcols = 0; 726 get_book(args["d"], booksection); 727 get_contents (booksection, gdbm, args["c"], contents_arr, totalcols); 728 } 729 730 731 // sorts an array of sections alphabetically (i.e. by title, author depending 732 // on what classification is) 733 void browseclass::sort_array (vector<text_t> &array, gdbmclass &gdbm, 734 const text_t &collection, const text_t classification) { 735 736 gdbm_info info; 737 char **tmparray = NULL; 738 int len = 0, i; 739 text_t tmpstr; 740 741 vector<text_t>::const_iterator here = array.begin(); 742 vector<text_t>::const_iterator end = array.end(); 743 744 while (here != end) { 745 text_t key; 746 if (is_book(*here)) get_book(*here, key); 747 else key = *here; 748 749 gdbm.getinfo(key, collection, info); 750 if (classification[0] == 'T') { 751 752 alphabetize_string_english(info.t); 753 info.t += ":#:" + *here; 754 tmparray = string_add(tmparray, &len, info.t.getcstr()); 755 756 } else { 757 alphabetize_string_name(info.a); 758 info.a += ":#:" + *here; 759 tmparray = string_add(tmparray, &len, info.a.getcstr()); 760 } 761 here ++; 762 } 763 string_sort (tmparray, len); 764 765 array.clear(); 766 for (i = 0; i < len; i ++) { 767 tmpstr = get_section_str(tmparray[i]); 768 array.push_back(tmpstr); 769 } 770 string_free(tmparray, len); 771 } 772 -
trunk/gsdl/src/library/browse.h
r4 r32 14 14 virtual ~browseclass () {} 15 15 16 virtual void get_browse_bar(const text_t &targetdoc, text_t &return_text) {} 17 16 virtual void get_browse_bar(const text_t &targetdoc, text_t &return_text); 18 17 virtual void get_top_locator(cgiargsclass &args, gdbmclass &gdbm, int oversize, text_t &return_text) {} 19 virtual void get_links(cgiargsclass &args, gdbmclass &gdbm, text_t &return_text) {}20 virtual void get_contents_arr(cgiargsclass &args, gdbmclass &gdbm, vector<text_t> &contents_arr) {}18 virtual void get_links(cgiargsclass &args, gdbmclass &gdbm, text_t &return_text); 19 virtual void get_contents_arr(cgiargsclass &args, gdbmclass &gdbm, vector<text_t> &contents_arr); 21 20 22 21 protected: 23 22 23 virtual void get_list_toc (vector<text_t> &secarray, text_t &collection, 24 gdbmclass &gdbm, text_t &return_text); 25 virtual void get_page_toc (cgiargsclass &args, const text_t &booksection, 26 const text_t &classification, const text_t &class_string, 27 gdbmclass &gdbm, text_t &return_text); 28 virtual void get_standard_toc(cgiargsclass &args, text_t &booksection, 29 const text_t &classification, gdbmclass &gdbm, 30 text_t &return_text); 24 31 virtual void get_expanded_toc(cgiargsclass &args, text_t &booksection, 25 32 const text_t &classification, gdbmclass &gdbm, 26 text_t &return_text) {} 27 virtual void get_standard_toc(cgiargsclass &args, text_t &booksection, 28 const text_t &classification, gdbmclass &gdbm, 29 text_t &return_text) {} 30 virtual void get_alphabet_links (const text_t &booksection, gdbmclass &gdbm, 31 const text_t &collection, text_t &return_text) {} 32 virtual void get_title_arrows(text_t classification, gdbmclass &gdbm, 33 const text_t &collection, text_t &alphabet_arrows) {} 34 virtual void get_contents (text_t expandlevel, gdbmclass &gdbm, 33 text_t &return_text); 34 virtual void get_parents_toc (cgiargsclass &args, const vector<text_t> &parents, 35 gdbmclass &gdbm, int &tabcount, int &colnum, 36 text_t &return_text); 37 virtual void get_siblings_toc (cgiargsclass &args, const vector<text_t> &siblings, 38 gdbmclass &gdbm, const text_t &booksection, 39 const text_t &classification, int &tabcount, 40 int &colnum, text_t &return_text); 41 virtual void get_alphabet_links (const text_t &classification, 42 const text_t &booksection, gdbmclass &gdbm, 43 const text_t &collection, text_t &return_text); 44 virtual void get_arrows(text_t &docref, gdbmclass &gdbm, 45 const text_t &collection, text_t &arrows); 46 virtual void get_prev_next_links (text_t docref, const text_t &collection, 47 text_t &previous, text_t &next); 48 virtual void get_contents (text_t expandlevel1, gdbmclass &gdbm, 35 49 const text_t &collection, vector<text_t> &contents, 36 int &totalcols) {} 37 50 int &totalcols); 51 virtual void sort_array (vector<text_t> &array, gdbmclass &gdbm, 52 const text_t &collection, const text_t classification); 38 53 }; 39 54 -
trunk/gsdl/src/library/locateinfo.cpp
r4 r32 5 5 text_t &ttidxsuffix) 6 6 { 7 ttidxsuffix = "collect";8 7 9 #ifdef __WIN32__ 10 ttidxsuffix += "\\"; 11 #else 12 ttidxsuffix += "/"; 13 #endif 8 // new directory structure 9 // ttidxsuffix = "collect"; 14 10 15 ttidxsuffix += collection; 11 //#ifdef __WIN32__ 12 //ttidxsuffix += "\\"; 13 //#else 14 //ttidxsuffix += "/"; 15 //#endif 16 17 //ttidxsuffix += collection; 18 16 19 17 20 #ifdef __WIN32__ … … 34 37 text_t &tttxtsuffix) 35 38 { 36 tttxtsuffix = "collect"; 39 // new directory structure 40 // tttxtsuffix = "collect"; 37 41 38 #ifdef __WIN32__39 tttxtsuffix += "\\";40 #else41 tttxtsuffix += "/";42 #endif42 //#ifdef __WIN32__ 43 //tttxtsuffix += "\\"; 44 //#else 45 //tttxtsuffix += "/"; 46 //#endif 43 47 44 tttxtsuffix += collection;48 //tttxtsuffix += collection; 45 49 46 50 #ifdef __WIN32__
Note:
See TracChangeset
for help on using the changeset viewer.