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

Last change on this file since 21752 was 21752, checked in by mdewsnip, 14 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
RevLine 
[347]1/**********************************************************************
2 *
3 * formattools.h --
4 * Copyright (C) 1999 The New Zealand Digital Library Project
5 *
[533]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.
[347]9 *
[533]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 *
[347]24 *********************************************************************/
25
26
27#ifndef FORMATTOOLS_H
28#define FORMATTOOLS_H
29
30#include "text_t.h"
[1443]31#include "recptproto.h"
[1610]32#include "display.h"
[347]33
[670]34enum command_t {comIf, comOr, comMeta, comText, comLink, comEndLink, comNum, comIcon,
[19302]35 comDoc, comHighlight, comEndHighlight,
36 comMetadataSpanWrap, comEndMetadataSpanWrap,
37 comRel, comHref, comSummary,
[4936]38 comTOC, comImage, comDocumentButtonDetach, comDocumentButtonHighlight,
[16915]39 comDocumentButtonExpandContents, comDocumentButtonExpandText, comOID, comTopOID, comRank,
40 comCollection, comDocTermsFreqTotal};
[9401]41
[21752]42enum mcommand_t {mNone=0, mCgiSafe=1, mParent=2, mSibling=4, mChild=8, mSpecial=16, mTruncate=32, mXMLSafe=64, mHTMLSafe=128};
[9401]43
[649]44enum pcommand_t {pNone, pImmediate, pTop, pAll};
[10415]45enum scommand_t {sNone, sAll, sNum};
[9401]46enum ccommand_t {cNone, cAll, cNum};
[1610]47enum dcommand_t {dMeta, dText};
[347]48
49struct metadata_t {
50 void clear();
51 metadata_t () {clear();}
52
[410]53 text_t metaname;
[5787]54 int metacommand; // used to hold flags from mcommand_t
[9401]55 struct {
56 pcommand_t parent;
57 scommand_t sibling;
58 ccommand_t child;
59 } mqualifier;
60
[19046]61 text_t pre_tree_traverse;
[10415]62 text_t parentoptions;
63 text_t siblingoptions;
64 text_t childoptions;
[347]65};
66
[1610]67
68// The decision component of an {If}{decision,true-text,false-text}
[7389]69// formatstring. The decision can be based on metadata or on text;
[1610]70// normally that text would be a macro like _cgiargmode_. --gordon
[347]71struct decision_t {
72 void clear();
73 decision_t () {clear();}
74
75 dcommand_t command;
76 metadata_t meta;
[1610]77 text_t text;
[347]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
[442]94// the format structure used by this receptionist
95struct formatinfo_t {
96 void clear();
97 formatinfo_t () {clear();}
[347]98
[1079]99 bool DocumentImages;
100 bool DocumentTitles;
101 text_t DocumentHeading;
102 bool DocumentContents;
[442]103 bool DocumentArrowsBottom;
[4868]104 bool DocumentArrowsTop;
[13365]105 bool DocumentSearchResultLinks;
[442]106 text_tarray DocumentButtons;
107 text_t DocumentText;
[1941]108 //-----------------
109 text_t RelatedDocuments;
110 //----------------
[649]111 text_tmap formatstrings;
[868]112 bool DocumentUseHTML;
[4972]113 bool AllowExtendedOptions;
[442]114};
115
[749]116bool is_table_content (const text_t &formatstring);
117bool is_table_content (const format_t *formatlistptr);
118
[649]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);
[442]124
[422]125text_t format_date (const text_t &date);
[347]126
[6645]127text_t remove_namespace(const text_t &meta_name);
128
[2001]129text_t iso639 (const text_t &langcode);
[1941]130
[2706]131text_t get_href (const text_t &link);
132
[1941]133text_t get_related_docs(const text_t& collection, recptproto* collectproto,
134 ResultDocInfo_t &docinfo, ostream& logout);
135
136
[347]137bool parse_formatstring (const text_t &formatstring, format_t *formatlistptr,
[649]138 text_tset &metadata, bool &getParents);
[347]139
[407]140
[347]141
[1443]142text_t get_formatted_string (const text_t& collection, recptproto* collectproto,
[1610]143 ResultDocInfo_t &docinfo, displayclass &disp,
[4906]144 format_t *formatlistptr, text_tmap &options,
[1443]145 ostream& logout);
[347]146
147#endif
[1443]148
149
Note: See TracBrowser for help on using the repository browser.