1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * browseaction.cpp --
|
---|
4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
5 | *
|
---|
6 | * PUT COPYRIGHT NOTICE HERE
|
---|
7 | *
|
---|
8 | * $Id: browseaction.cpp 213 1999-03-29 02:14:31Z sjboddie $
|
---|
9 | *
|
---|
10 | *********************************************************************/
|
---|
11 |
|
---|
12 | /*
|
---|
13 | $Log$
|
---|
14 | Revision 1.2 1999/03/29 02:14:27 sjboddie
|
---|
15 |
|
---|
16 | More changes to browseaction
|
---|
17 |
|
---|
18 | Revision 1.1 1999/03/25 03:09:40 sjboddie
|
---|
19 |
|
---|
20 | subjectbrowseaction became browseaction
|
---|
21 |
|
---|
22 |
|
---|
23 | */
|
---|
24 |
|
---|
25 |
|
---|
26 | #include "browseaction.h"
|
---|
27 | #include "browsetools.h"
|
---|
28 |
|
---|
29 | browseaction::browseaction () {
|
---|
30 | // this action uses cgi variables "a", "d", "cl",
|
---|
31 | // "x", "gc", and "gt"
|
---|
32 | cgiarginfo arg_ainfo;
|
---|
33 | arg_ainfo.shortname = "a";
|
---|
34 | arg_ainfo.longname = "action";
|
---|
35 | arg_ainfo.multiplechar = true;
|
---|
36 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
37 | arg_ainfo.argdefault = "p";
|
---|
38 | arg_ainfo.savedarginfo = cgiarginfo::must;
|
---|
39 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
40 |
|
---|
41 | arg_ainfo.shortname = "d";
|
---|
42 | arg_ainfo.longname = "document OID";
|
---|
43 | arg_ainfo.multiplechar = true;
|
---|
44 | arg_ainfo.defaultstatus = cgiarginfo::none;
|
---|
45 | arg_ainfo.argdefault = "";
|
---|
46 | arg_ainfo.savedarginfo = cgiarginfo::can;
|
---|
47 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
48 |
|
---|
49 | arg_ainfo.shortname = "cl";
|
---|
50 | arg_ainfo.longname = "classification OID";
|
---|
51 | arg_ainfo.multiplechar = true;
|
---|
52 | arg_ainfo.defaultstatus = cgiarginfo::none;
|
---|
53 | arg_ainfo.argdefault = "";
|
---|
54 | arg_ainfo.savedarginfo = cgiarginfo::can;
|
---|
55 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
56 |
|
---|
57 | // in this action "gc" controls the expand/contract
|
---|
58 | // contents function
|
---|
59 | arg_ainfo.shortname = "gc";
|
---|
60 | arg_ainfo.longname = "expand contents";
|
---|
61 | arg_ainfo.multiplechar = false;
|
---|
62 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
63 | arg_ainfo.argdefault = "0";
|
---|
64 | arg_ainfo.savedarginfo = cgiarginfo::can;
|
---|
65 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
66 |
|
---|
67 | // in this action "gt" controls the expand/contract
|
---|
68 | // text function
|
---|
69 | arg_ainfo.shortname = "gt";
|
---|
70 | arg_ainfo.longname = "expand text";
|
---|
71 | arg_ainfo.multiplechar = false;
|
---|
72 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
73 | arg_ainfo.argdefault = "0";
|
---|
74 | arg_ainfo.savedarginfo = cgiarginfo::can;
|
---|
75 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
76 |
|
---|
77 | // "x" is 0 normally or 1 if page
|
---|
78 | // has been "detached"
|
---|
79 | arg_ainfo.shortname = "x";
|
---|
80 | arg_ainfo.longname = "detached page";
|
---|
81 | arg_ainfo.multiplechar = false;
|
---|
82 | arg_ainfo.defaultstatus = cgiarginfo::weak;
|
---|
83 | arg_ainfo.argdefault = "0";
|
---|
84 | arg_ainfo.savedarginfo = cgiarginfo::can;
|
---|
85 | argsinfo.addarginfo (NULL, arg_ainfo);
|
---|
86 | }
|
---|
87 |
|
---|
88 | browseaction::~browseaction () {
|
---|
89 | }
|
---|
90 |
|
---|
91 | bool browseaction::check_cgiargs (cgiargsclass &/*args*/, ostream &/*logout*/) {
|
---|
92 | // don't want to check anything yet.
|
---|
93 | return true;
|
---|
94 | }
|
---|
95 |
|
---|
96 | void browseaction::get_cgihead_info (cgiargsclass &/*args*/, response_t &response,
|
---|
97 | text_t &response_data, ostream &/*logout*/) {
|
---|
98 | response = content;
|
---|
99 | response_data = "text/html";
|
---|
100 | }
|
---|
101 |
|
---|
102 |
|
---|
103 | // define all the macros which are related to pages generated
|
---|
104 | // by this action
|
---|
105 | void browseaction::define_internal_macros (displayclass &disp, cgiargsclass &args,
|
---|
106 | recptproto *collectproto, ostream &logout) {
|
---|
107 |
|
---|
108 | text_t ctype, cname, toc, navbar;
|
---|
109 |
|
---|
110 | collectproto->get_classification_info (args["cl"], ctype, cname);
|
---|
111 |
|
---|
112 | // set the _toc_ macro
|
---|
113 | if (ctype == "hierarchy") get_hierarchy_toc (args, collectproto, toc, logout);
|
---|
114 | else if (ctype == "book") get_book_toc (args, collectproto, toc, logout);
|
---|
115 | else if (ctype == "datelist") {
|
---|
116 | get_datelist_toc (args, collectproto, toc, logout);
|
---|
117 | set_arrow_links (disp, args, collectproto, cname, logout);
|
---|
118 | set_classification_links (disp, args, collectproto, cname, logout);
|
---|
119 | } else {
|
---|
120 | get_list_toc (args, collectproto, toc, logout); // list is the default
|
---|
121 | set_arrow_links (disp, args, collectproto, cname, logout);
|
---|
122 | set_classification_links (disp, args, collectproto, cname, logout);
|
---|
123 | }
|
---|
124 | disp.setmacro ("toc", cname, toc);
|
---|
125 |
|
---|
126 | // set the _navigationbar_ macro
|
---|
127 | set_navigation_bar (disp, args, collectproto, cname, logout);
|
---|
128 | }
|
---|
129 |
|
---|
130 |
|
---|
131 | bool browseaction::do_action (cgiargsclass &args, recptproto *collectproto,
|
---|
132 | displayclass &disp, outconvertclass &outconvert,
|
---|
133 | ostream &textout, ostream &/*logout*/) {
|
---|
134 |
|
---|
135 | if (collectproto == NULL) return false;
|
---|
136 |
|
---|
137 | text_t ctype, cname;
|
---|
138 | collectproto->get_classification_info (args["cl"], ctype, cname);
|
---|
139 |
|
---|
140 | textout << outconvert << disp << ("_" + cname + ":header_\n")
|
---|
141 | << ("_" + cname + ":content_\n") << ("_" + cname + ":footer_\n");
|
---|
142 |
|
---|
143 | return true;
|
---|
144 | }
|
---|
145 |
|
---|