source: trunk/gsdl/src/recpt/formattools.h@ 10361

Last change on this file since 10361 was 9948, checked in by kjdon, 19 years ago

added [collection] and [collection:metaname] items to format statements. [collection] returns the coll name, and [collection:metaname] returns collection metadata, eg [collection:collectionname] or [colleciton:collectionextra]. this is really only useful for crosscollection searching, where you can't use the _collectionname_ etc macros.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
Line 
1/**********************************************************************
2 *
3 * formattools.h --
4 * Copyright (C) 1999 The New Zealand Digital Library Project
5 *
6 * A component of the Greenstone digital library software
7 * from the New Zealand Digital Library Project at the
8 * University of Waikato, New Zealand.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 *********************************************************************/
25
26
27#ifndef FORMATTOOLS_H
28#define FORMATTOOLS_H
29
30#include "text_t.h"
31#include "comtypes.h"
32#include "recptproto.h"
33#include "display.h"
34
35enum command_t {comIf, comOr, comMeta, comText, comLink, comEndLink, comNum, comIcon,
36 comDoc, comHighlight, comEndHighlight, comRel, comHref, comSummary,
37 comTOC, comImage, comDocumentButtonDetach, comDocumentButtonHighlight,
38 comDocumentButtonExpandContents, comDocumentButtonExpandText, comOID, comRank, comCollection};
39
40enum mcommand_t {mNone=0, mCgiSafe=1, mParent=2, mSibling=4, mChild=8};
41
42enum pcommand_t {pNone, pImmediate, pTop, pAll};
43enum scommand_t {sNone, sAll};
44enum ccommand_t {cNone, cAll, cNum};
45enum dcommand_t {dMeta, dText};
46
47struct metadata_t {
48 void clear();
49 metadata_t () {clear();}
50
51 text_t metaname;
52 int metacommand; // used to hold flags from mcommand_t
53 struct {
54 pcommand_t parent;
55 scommand_t sibling;
56 ccommand_t child;
57 } mqualifier;
58
59 text_t functionoptions;
60};
61
62
63// The decision component of an {If}{decision,true-text,false-text}
64// formatstring. The decision can be based on metadata or on text;
65// normally that text would be a macro like _cgiargmode_. --gordon
66struct decision_t {
67 void clear();
68 decision_t () {clear();}
69
70 dcommand_t command;
71 metadata_t meta;
72 text_t text;
73};
74
75struct format_t {
76 void clear();
77 format_t () {clear();}
78
79 command_t command;
80 decision_t decision;
81 text_t text;
82 metadata_t meta;
83 format_t *nextptr;
84 format_t *ifptr;
85 format_t *elseptr;
86 format_t *orptr;
87};
88
89// the format structure used by this receptionist
90struct formatinfo_t {
91 void clear();
92 formatinfo_t () {clear();}
93
94 bool DocumentImages;
95 bool DocumentTitles;
96 text_t DocumentHeading;
97 bool DocumentContents;
98 bool DocumentArrowsBottom;
99 bool DocumentArrowsTop;
100 text_tarray DocumentButtons;
101 text_t DocumentText;
102 //-----------------
103 text_t RelatedDocuments;
104 //----------------
105 text_tmap formatstrings;
106 bool DocumentUseHTML;
107 bool AllowExtendedOptions;
108};
109
110bool is_table_content (const text_t &formatstring);
111bool is_table_content (const format_t *formatlistptr);
112
113bool get_formatstring (const text_t &key, const text_tmap &formatstringmap,
114 text_t &formatstring);
115bool get_formatstring (const text_t &key1, const text_t &key2,
116 const text_tmap &formatstringmap,
117 text_t &formatstring);
118
119text_t format_date (const text_t &date);
120
121text_t remove_namespace(const text_t &meta_name);
122
123text_t iso639 (const text_t &langcode);
124
125text_t get_href (const text_t &link);
126
127text_t get_related_docs(const text_t& collection, recptproto* collectproto,
128 ResultDocInfo_t &docinfo, ostream& logout);
129
130
131bool parse_formatstring (const text_t &formatstring, format_t *formatlistptr,
132 text_tset &metadata, bool &getParents);
133
134
135
136text_t get_formatted_string (const text_t& collection, recptproto* collectproto,
137 ResultDocInfo_t &docinfo, displayclass &disp,
138 format_t *formatlistptr, text_tmap &options,
139 ostream& logout);
140
141#endif
142
143
Note: See TracBrowser for help on using the repository browser.