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

Last change on this file since 21758 was 21758, checked in by kjdon, 14 years ago

now we dynamically generate srclink (and /srclink, and new srchref which is the link without the a tag), using srclink_file metadata. This is to get gs2 receptionist stuff out of metadata and into the source code where it belongs

  • 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,
[21758]40 comCollection, comDocTermsFreqTotal,
41 comAssocLink, comEndAssocLink};
[9401]42
[21752]43enum mcommand_t {mNone=0, mCgiSafe=1, mParent=2, mSibling=4, mChild=8, mSpecial=16, mTruncate=32, mXMLSafe=64, mHTMLSafe=128};
[9401]44
[649]45enum pcommand_t {pNone, pImmediate, pTop, pAll};
[10415]46enum scommand_t {sNone, sAll, sNum};
[9401]47enum ccommand_t {cNone, cAll, cNum};
[1610]48enum dcommand_t {dMeta, dText};
[347]49
50struct metadata_t {
51 void clear();
52 metadata_t () {clear();}
53
[410]54 text_t metaname;
[5787]55 int metacommand; // used to hold flags from mcommand_t
[9401]56 struct {
57 pcommand_t parent;
58 scommand_t sibling;
59 ccommand_t child;
60 } mqualifier;
61
[19046]62 text_t pre_tree_traverse;
[10415]63 text_t parentoptions;
64 text_t siblingoptions;
65 text_t childoptions;
[347]66};
67
[1610]68
69// The decision component of an {If}{decision,true-text,false-text}
[7389]70// formatstring. The decision can be based on metadata or on text;
[1610]71// normally that text would be a macro like _cgiargmode_. --gordon
[347]72struct decision_t {
73 void clear();
74 decision_t () {clear();}
75
76 dcommand_t command;
77 metadata_t meta;
[1610]78 text_t text;
[347]79};
80
81struct format_t {
82 void clear();
83 format_t () {clear();}
84
85 command_t command;
86 decision_t decision;
87 text_t text;
88 metadata_t meta;
89 format_t *nextptr;
90 format_t *ifptr;
91 format_t *elseptr;
92 format_t *orptr;
93};
94
[442]95// the format structure used by this receptionist
96struct formatinfo_t {
97 void clear();
98 formatinfo_t () {clear();}
[347]99
[1079]100 bool DocumentImages;
101 bool DocumentTitles;
102 text_t DocumentHeading;
103 bool DocumentContents;
[442]104 bool DocumentArrowsBottom;
[4868]105 bool DocumentArrowsTop;
[13365]106 bool DocumentSearchResultLinks;
[442]107 text_tarray DocumentButtons;
108 text_t DocumentText;
[1941]109 //-----------------
110 text_t RelatedDocuments;
111 //----------------
[649]112 text_tmap formatstrings;
[868]113 bool DocumentUseHTML;
[4972]114 bool AllowExtendedOptions;
[442]115};
116
[749]117bool is_table_content (const text_t &formatstring);
118bool is_table_content (const format_t *formatlistptr);
119
[649]120bool get_formatstring (const text_t &key, const text_tmap &formatstringmap,
121 text_t &formatstring);
122bool get_formatstring (const text_t &key1, const text_t &key2,
123 const text_tmap &formatstringmap,
124 text_t &formatstring);
[442]125
[422]126text_t format_date (const text_t &date);
[347]127
[6645]128text_t remove_namespace(const text_t &meta_name);
129
[2001]130text_t iso639 (const text_t &langcode);
[1941]131
[2706]132text_t get_href (const text_t &link);
133
[1941]134text_t get_related_docs(const text_t& collection, recptproto* collectproto,
135 ResultDocInfo_t &docinfo, ostream& logout);
136
137
[347]138bool parse_formatstring (const text_t &formatstring, format_t *formatlistptr,
[649]139 text_tset &metadata, bool &getParents);
[347]140
[407]141
[347]142
[1443]143text_t get_formatted_string (const text_t& collection, recptproto* collectproto,
[1610]144 ResultDocInfo_t &docinfo, displayclass &disp,
[4906]145 format_t *formatlistptr, text_tmap &options,
[1443]146 ostream& logout);
[347]147
148#endif
[1443]149
150
Note: See TracBrowser for help on using the repository browser.