source: main/trunk/greenstone2/runtime-src/src/recpt/formattools.h@ 21752

Last change on this file since 21752 was 21752, checked in by mdewsnip, 12 years ago

Added new "htmlsafe:", "xmlsafe:", and "truncate(X):" (truncate metadata value to X characters) format statement modifiers. By Michael Dewsnip at DL Consulting Ltd.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 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 "recptproto.h"
32#include "display.h"
33
34enum command_t {comIf, comOr, comMeta, comText, comLink, comEndLink, comNum, comIcon,
35 comDoc, comHighlight, comEndHighlight,
36 comMetadataSpanWrap, comEndMetadataSpanWrap,
37 comRel, comHref, comSummary,
38 comTOC, comImage, comDocumentButtonDetach, comDocumentButtonHighlight,
39 comDocumentButtonExpandContents, comDocumentButtonExpandText, comOID, comTopOID, comRank,
40 comCollection, comDocTermsFreqTotal};
41
42enum mcommand_t {mNone=0, mCgiSafe=1, mParent=2, mSibling=4, mChild=8, mSpecial=16, mTruncate=32, mXMLSafe=64, mHTMLSafe=128};
43
44enum pcommand_t {pNone, pImmediate, pTop, pAll};
45enum scommand_t {sNone, sAll, sNum};
46enum ccommand_t {cNone, cAll, cNum};
47enum dcommand_t {dMeta, dText};
48
49struct metadata_t {
50 void clear();
51 metadata_t () {clear();}
52
53 text_t metaname;
54 int metacommand; // used to hold flags from mcommand_t
55 struct {
56 pcommand_t parent;
57 scommand_t sibling;
58 ccommand_t child;
59 } mqualifier;
60
61 text_t pre_tree_traverse;
62 text_t parentoptions;
63 text_t siblingoptions;
64 text_t childoptions;
65};
66
67
68// The decision component of an {If}{decision,true-text,false-text}
69// formatstring. The decision can be based on metadata or on text;
70// normally that text would be a macro like _cgiargmode_. --gordon
71struct decision_t {
72 void clear();
73 decision_t () {clear();}
74
75 dcommand_t command;
76 metadata_t meta;
77 text_t text;
78};
79
80struct format_t {
81 void clear();
82 format_t () {clear();}
83
84 command_t command;
85 decision_t decision;
86 text_t text;
87 metadata_t meta;
88 format_t *nextptr;
89 format_t *ifptr;
90 format_t *elseptr;
91 format_t *orptr;
92};
93
94// the format structure used by this receptionist
95struct formatinfo_t {
96 void clear();
97 formatinfo_t () {clear();}
98
99 bool DocumentImages;
100 bool DocumentTitles;
101 text_t DocumentHeading;
102 bool DocumentContents;
103 bool DocumentArrowsBottom;
104 bool DocumentArrowsTop;
105 bool DocumentSearchResultLinks;
106 text_tarray DocumentButtons;
107 text_t DocumentText;
108 //-----------------
109 text_t RelatedDocuments;
110 //----------------
111 text_tmap formatstrings;
112 bool DocumentUseHTML;
113 bool AllowExtendedOptions;
114};
115
116bool is_table_content (const text_t &formatstring);
117bool is_table_content (const format_t *formatlistptr);
118
119bool get_formatstring (const text_t &key, const text_tmap &formatstringmap,
120 text_t &formatstring);
121bool get_formatstring (const text_t &key1, const text_t &key2,
122 const text_tmap &formatstringmap,
123 text_t &formatstring);
124
125text_t format_date (const text_t &date);
126
127text_t remove_namespace(const text_t &meta_name);
128
129text_t iso639 (const text_t &langcode);
130
131text_t get_href (const text_t &link);
132
133text_t get_related_docs(const text_t& collection, recptproto* collectproto,
134 ResultDocInfo_t &docinfo, ostream& logout);
135
136
137bool parse_formatstring (const text_t &formatstring, format_t *formatlistptr,
138 text_tset &metadata, bool &getParents);
139
140
141
142text_t get_formatted_string (const text_t& collection, recptproto* collectproto,
143 ResultDocInfo_t &docinfo, displayclass &disp,
144 format_t *formatlistptr, text_tmap &options,
145 ostream& logout);
146
147#endif
148
149
Note: See TracBrowser for help on using the repository browser.