1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2"http://www.w3.org/TR/html4/loose.dtd">
3<html>
4<head>
5<title>OSBib-Format</title>
6<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
7<style type="text/css">
8<!--
9.style3 {color: #00CC00}
10.style7 {color: #CC00FF}
11.style8 {color: #FF0000}
12.style9 {color: #996600}
13-->
14</style>
15</head>
16
17<body>
18<h1>OSBib</h1>
19<p> A collection of PHP classes to manage bibliographic formatting for OS bibliography software
20  using the OSBib standard. Taken from and originally developed in WIKINDX (<a href="http://wikindx.sourceforge.net">http://wikindx.sourceforge.net</a>). </p>
21<p>Released through <a href="http://bibliophile.sourceforge.net">http://bibliophile.sourceforge.net</a> under the GPL licence.</p>
22<p>If you make improvements, please consider contacting the administrators at <a href="http://bibliophile.sourceforge.net">bibliophile.sourceforge.net</a> so that your improvements can be added to the release package.</p>
23<p><em>May 2005<br>
24</em>Mark Grimshaw (<a href="http://wikindx.sourceforge.net">WIKINDX</a>)<br>
25Andrea Rossato (<a href="http://uniwakka.sourceforge.net/HomePage">Uniwakka</a>)<br>
26Guillaume Gardey (<a href="http://biborb.glymn.net/doku.php">BibOrb</a>)<br>
27Christian Boulanger (<a href="http://bibliograph.panya.de/">Bibliograph</a>)</p>
28<hr>
29<p><a href="#introduction">INTRODUCTION</a><br>
30<a href="#bibstyle">BIBSTYLE</a><br>
31  <a href="#parsexml">PARSEXML</a><br>
32  <a href="#loadstyle">LOADSTYLE</a><br>
33<a href="#parsestyle">PARSESTYLE</a><br>
34<a href="#stylemap">STYLEMAP</a><br>
35<a href="#utf8">UTF8</a><br>
36<a href="#bibformat">BIBFORMAT</a><br>
37<a href="#usage">USAGE</a>
38</p>
39<hr>
40<h3><a name="introduction"></a>INTRODUCTION</h3>
41<p>OSBib is an Open Source bibliographic formatting engine written in PHP that use XML style files to store formatting data for in-text citations/footnotes and bibliographic lists. Released through <a href="http://bibliophile.sourceforge.net">Bibliophile</a>, OSBib is designed to work with bibliographic data stored in any format via mapping arrays as defined in the class <code><a href="#stylemap">STYLEMAP</a></code>. For those bibliographic systems whose data are stored in or that can be accessed as bibtex-type arrays, <code>STYLEMAPBIBTEX</code> is a set of pre-defined mapping arrays designed to get you up and running within a matter of minutes. Data stored in other formats require that <code><a href="#stylemap">STYLEMAP</a></code> be edited.</p>
42<p>OSBib provides support for printing the formatted output to web browsers or for exporting to Rich Text Format (for insertion into OpenOffice and similar word processors), exporting to OpenOffice's native <em>sxw</em> format or to plain text with no font formatting. </p>
43<p>Style files are stored in XML format and are available for download from the Bibliophile site at:<br>
44  <a href="http://bibliophile.sourceforge.net">http://bibliophile.sourceforge.net</a><br>
45The naming of the style files to be downloaded is (for example):<br>
46<code>OSBib-americanPsychologicalAssociation_1.0_1.1</code><br>
47where the first number (in this case '1.0') is the version number of the OSBib classes the style is at <em>least</em> compatible with and the second number is the version number of the style file itself. For an explanation of the structure of the XML file, see <a href="bibliography_xml.html">bibliography_xml</a> and <a href="citation_xml.html">citation_xml</a>. </p>
48<p>Please note. Although in-text/footnotes citation formatting is defined in the XML style files, this version of OSBib-Format does not yet have the citation engine and will only handle bibliographic lists. Citation formatting will come...</p>
49<p>The OSBib package has two sections which share some common PHP files. Files in the directory<em> format/</em> will format the bibliography output as described above. Files in the directory <em>create/</em> will create or edit the XML style files. As supplied in the OSBib package, the create interface is stand-alone and runs via <code>index.php</code>. Users wishing to integrate the creation/editing interface within their bibliographic management system will need to modify or extract various portions of <code>index.php</code> for use in their own PHP code. </p>
50<hr>
51<h3><a name="bibstyle"></a>BIBSTYLE</h3>
52<p> This is not part of the distribution package but is here as an example of how WIKINDX uses OSBib-Format. <code>BIBSTYLE::process()</code> is the loop that parses each bibliographic entry one by one. You are likely to need a similar process loop.</p>
53<hr width="50%">
54<h3><a name="parsexml"></a>PARSEXML</h3>
55<p> Parse the XML style file into usable arrays. Used within<code> <a href="#bibformatLoadstyle">BIBFORMAT::loadStyle()</a></code>.</p>
56<hr width="50%">
57<h3><a name="loadstyle"></a>LOADSTYLE</h3>
58<p> <span class="style3"><code>include_once($pathToOsbibClasses . &quot;LOADSTYLE.php&quot;);<br>
59  ARRAY LOADSTYLE::loadDir($pathToStyleFileDirectory);</code></span></p>
60<p>This scans the style file directory and returns an alphabetically sorted (on the key) array of available bibliographic styles e.g.<span class="style3"><br>
61  <code>$styles = LOADSTYLE::loadDir(&quot;styles/bibliography&quot;);<br>
62  print_r($styles);</code></span></p>
63<p>An example output from this would be :<br>
64  <span class="style7"><code>Array ( [APA] =&gt; American Psychological Association (APA) [BRITISHMEDICALJOURNAL] =&gt; British Medical Journal (BMJ) [CHICAGO] =&gt; Chicago [HARVARD] =&gt; Harvard [IEEE] =&gt; Institute of Electrical and Electronics Engineers (IEEE) [MLA] =&gt; Modern Language Association (MLA) [TEST] =&gt; test [TURABIAN] =&gt; Turabian [WIKINDX] =&gt; WIKINDX -- Show All )</code></span></p>
65<p>Use this to provide your users with a HTML FORM selectbox to choose their preferred style where the key from the array above is used in <a href="#bibformatLoadstyle"><code>BIBFORMAT::loadStyle()</code></a>.</p>
66<hr width="50%">
67<h3><a name="parsestyle"></a>PARSESTYLE</h3>
68<p> This is used internally in <code><a href="#bibformat">BIBFORMAT</a></code> and currently just parses a single style definition string for a particular resource type (book, web article etc.) from a style XML file into an array to be used by OSBib.</p>
69<hr width="50%">
70<h3><a name="stylemap"></a>STYLEMAP</h3>
71<p><em> (If your database stores or access its records in a BibTeX style format, you should use <code>STYLEMAPBIBTEX</code> instead as this has been specially devised to offer an out-of-the-box solution for such systems and is a version of <code>STYLEMAP</code> that should not require editing. See also <a href="#usage">USAGE</a> below.)</em></p>
72<p> This contains all the mapping between your particular database/bibliographic management system and OSBib. There are plenty of comments in that file so read them carefully.<br>
73  1/ You should edit <code>$this-&gt;types</code> array.<br>
74  2/ You should edit each resource type's array changing <strong>only</strong> the key of each element. However, do <strong>not</strong> edit any key (or its value) that is 'creator1', 'creator2', 'creator3', 'creator4' or 'creator5'. For resource types in <code>$this-&gt;types</code> that you set to FALSE, you do not need to do anything to the specific resource array as these arrays will then be ignored.</p>
75<p>A SQL query in WIKINDX to display each resource in a format suitable for OSBib processing may return the following associative array for one resource:<br>
76  <span class="style7"><code>Array ( [resourceId] =&gt; 1 [type] =&gt; journal_article [title] =&gt; {X} Window System, Version 11 [subtitle] =&gt; [noSort] =&gt; The [url] =&gt; [isbn] =&gt; [field1] =&gt; 20 [field2] =&gt; S2 [field3] =&gt; [field4] =&gt; [field5] =&gt; [field6] =&gt; [field7] =&gt; [field8] =&gt; [field9] =&gt; [file] =&gt; [collection] =&gt; 1 [publisher] =&gt; [miscField1] =&gt; [miscField2] =&gt; [miscField3] =&gt; [miscField4] =&gt; [tag] =&gt; [addUserIdResource] =&gt; 1 [editUserIdResource] =&gt; [year1] =&gt; 1990 [year2] =&gt; [year3] =&gt; [pageStart] =&gt; [pageEnd] =&gt; [creator1] =&gt; 1,2,3 [creator2] =&gt; [creator3] =&gt; [creator4] =&gt; [creator5] =&gt; [quotes] =&gt; [paraphrases] =&gt; [musings] =&gt; [publisherName] =&gt; [publisherLocation] =&gt; [publisherType] =&gt; [collectionTitle] =&gt; Software Practice and Experience [collectionTitleShort] =&gt; [collectionType] =&gt; journal [timestamp] =&gt; 2005-04-24 10:48:15 )</code></span></p>
77<p>What is important here is that the key names of the above array match the key names of the resource type arrays in <code>STYLEMAP</code>. This is how the data from <em>your</em> particular database is mapped to a format that OSBib understands and this is why you <strong>must</strong> edit the key names of the resource type array in <code>STYLEMAP</code>. The <strong>one</strong> exception to this is the handling of creator elements (author, editor, composer, inventor etc.) which OSBib expects to be listed as 'creator1', 'creator2', 'creator3', 'creator4' and 'creator5' where 'creator1' is always the <strong>primary</strong> creator (usually the author). Do <strong>not</strong> edit these key names.</p>
78<hr width="50%">
79<h3><a name="utf8" id="utf8"></a>UTF8</h3>
80<p><span class="style3"><code>include_once($pathToOsbibClasses . &quot;BIBFORMAT.php&quot;);</code></span>
81  <code><br>
82  <span class="style3">$utf8 = new UTF8();</span></code></p>
83<p><em><code>BIBFORMAT</code> expects its data to be in UTF-8 format and will return its formatted data in UTF-8 format. If you need to encode or decode your data prior to or after using OSBib, do <strong>not</strong> use PHP's utf8_encode() and utf8_decode() functions. Use the OSBib functions <a href="#utf8EncodeUtf8">UTF8::encodeUtf8()</a> and <a href="#utf8DecodeUtf8">UTF8::decodeUtf8()</a> instead. Additionally, if you need to manipulate UTF-8-encoded strings with functions such as strtolower(), strlen() etc., you should strongly consider using the appropriate methods in the OSBib <a href="#utf8">UTF8</a> class.</em></p>
84<p class="style8">METHODS</p>
85<table width="100%"  border="0" cellpadding="10" bgcolor="#CCCCCC">
86  <tr>
87    <td><p class="style3"><code><a name="utf8EncodeUtf8" id="utf8EncodeUtf8"></a><span class="style9">UTF8::encodeUtf8()</span><br>
88        $utf8String = $utf8-&gt;encodeUtf8(STRING: $string);</code></p>
89        <p>Properly encode a string into multi-byte UTF-8. </p>
90    </td>
91  </tr>
92</table>
93<br>
94<table width="100%"  border="0" cellpadding="10" bgcolor="#CCCCCC">
95  <tr>
96    <td><p class="style3"><code><a name="utf8DecodeUtf8" id="utf8DecodeUtf8"></a><span class="style9">UTF8::decodeUtf8()</span><br>
97        $string = $utf8-&gt;decodeUtf8(STRING: $utf8String);</code></p>
98        <p>Properly decode a multi-byte UTF-8 string. </p></td>
99  </tr>
100</table>
101<br>
102<table width="100%"  border="0" cellpadding="10" bgcolor="#CCCCCC">
103  <tr>
104    <td><p class="style3"><code><span class="style9">UTF8::utf8_strtolower()</span><br>
105        $utf8String = $utf8-&gt;utf8_strtolower(STRING: $utf8String);</code></p>
106        <p>Convert a UTF-8 string to lowercase. Where PHP has been compiled with mb_string, mb_strtolower() will be used. </p></td>
107  </tr>
108</table>
109<br>
110<table width="100%"  border="0" cellpadding="10" bgcolor="#CCCCCC">
111  <tr>
112    <td><p class="style3"><code><span class="style9">UTF8::utf8_strtoupper()</span><br>
113        $utf8String = $utf8-&gt;utf8_strtoupper(STRING: $utf8String);</code></p>
114        <p>Convert a UTF-8 string to uppercase. Where PHP has been compiled with mb_string, mb_strtoupper() will be used. </p></td>
115  </tr>
116</table>
117<br>
118<table width="100%"  border="0" cellpadding="10" bgcolor="#CCCCCC">
119  <tr>
120    <td><p class="style3"><code><span class="style9">UTF8::utf8_substr()</span><br>
121        $utf8String = $utf8-&gt;utf8_strtolower(STRING: $utf8String, INT $start [, INT: $length=NULL]);</code></p>
122        <p>Return a portion of  a UTF-8 string. Where PHP has been compiled with mb_string, mb_substr() will be used. </p></td>
123  </tr>
124</table>
125<br>
126<table width="100%"  border="0" cellpadding="10" bgcolor="#CCCCCC">
127  <tr>
128    <td><p class="style3"><code><span class="style9">UTF8::utf8_ucfirst()</span><br>
129        $utf8String = $utf8-&gt;utf8_ucfirst(STRING: $utf8String);</code></p>
130        <p>Ensure that the first letter of a UTF-8 string is uppercase. </p></td>
131  </tr>
132</table>
133<br>
134<table width="100%"  border="0" cellpadding="10" bgcolor="#CCCCCC">
135  <tr>
136    <td><p class="style3"><code><span class="style9">UTF8::utf8_strlen()</span><br>
137        $length = $utf8-&gt;utf8_strlen(STRING: $utf8String);</code></p>
138        <p>Return the length of  a UTF-8 string. Where PHP has been compiled with mb_string, mb_strlen() will be used. </p></td>
139  </tr>
140</table>
141<br>
142<hr width="50%">
143<h3><a name="bibformat"></a>BIBFORMAT</h3>
144<p> This is the main OSBib engine.<br>
145  <span class="style3"><code>include_once($pathToOsbibClasses . &quot;BIBFORMAT.php&quot;);<br>
146  $bibformat = new BIBFORMAT(STRING: $pathToOsbibClasses = FALSE [, BOOLEAN: $useBibtex = FALSE]);</code></span></p>
147<p>By default, <code>$pathToOsbibClasses</code> will be the same directory as<code> BIBFORMAT</code> is in.</p>
148<p><em>NB - <code>BIBFORMAT</code> expects its data to be in UTF-8 format and will return its formatted data in UTF-8 format. If you need to encode or decode your data prior to or after using OSBib, do <strong>not</strong> use PHP's utf8_encode() and utf8_decode() functions. Use the OSBib functions UTF8::encodeUtf8() and UTF8::decodeUtf8() instead. Additionally, if you need to manipulate UTF-8-encoded strings with functions such as strtolower(), strlen() etc., you should strongly consider using the appropriate methods in the OSBib <a href="#utf8">UTF8</a> class. </em></p>
149<p><span class="style8">PROPERTIES </span>(to be set after instantiating the <code>BIBFORMAT</code> class)<br>
150  <span class="style3"><code>$bibformat-&gt;output</code></span> -- By default this property is 'html' but you can change it to 'rtf' for exporting to RTF files, 'sxw' for OpenOffice or 'plain' for plain text. It is used to format bold, underline, italics etc. for the appropriate output medium.<br>
151  <span class="style3"><code>$bibformat-&gt;patterns</code></span> -- A preg pattern (e.g. <code>&quot;/matchThis|matchThat/i&quot;</code>) that, in conjunction with <code>$bibformat-&gt;patternHighlight,</code> is used to highlight words or phrases when displaying the results to a browser. This is useful when the bibliography to be displayed is the result of a SQL search. Default is FALSE and its value will be ignored if <code>$bibformat-&gt;output</code> is anything other than 'html'.<br>
152  <span class="style3"><code>$bibformat-&gt;patternHighlight</code></span> -- A CSS class defining the highlighting for above. Default is FALSE.<br>
153  <span class="style3"><code>$bibformat-&gt;bibtexParsePath</code></span> -- If you wish to use <code>STYLEMAPBIBTEX</code> because your database stores or accesses its data in a form similar to BibTeX, you should set the constructor parameter <code>$useBibtex</code> to TRUE and set this property to the path where <code>PARSECREATORS</code>, <code>PARSEMONTH</code> and <code>PARSEPAGE</code> can be found. These classes are not part of OSBib but are part of the bibtexParse package that can be downloaded from <a href="http://bibliophile.sourceforge.net">http://bibliophile.sourceforge.net</a>. By default, this path will be to a <code>bibtexParse/</code> directory in the same directory as <code>BIBFORMAT</code> is in.</p>
154<hr width="25%">
155<p class="style8">METHODS</p>
156<table width="100%"  border="0" cellpadding="10" bgcolor="#CCCCCC">
157  <tr>
158    <td><p class="style3"><code><a name="bibformatLoadstyle" id="bibformatLoadstyle"></a><span class="style9">BIBFORMAT::loadStyle()</span><br>
159  list($info, $citation, $styleCommon, $styleTypes) = $bibformat-&gt;loadStyle(STRING: $pathToStyleFiles, STRING: $styleFile);</code></p>
160      <p>Parses the XML style file into raw arrays (to be further processed in <a href="#bibformatGetstyle"><code>BIBFORMAT::getStyle()</code></a>. The four associative arrays returned are:<br>
161          <span class="style3"><code>$info</code></span> -- general information about the resource including description, language, version etc.<br>
162          <span class="style3"><code>$citation</code></span> -- in-text citation styling (not currently used).<br>
163          <span class="style3"><code>$styleCommon</code></span> -- common styling for bibliographic output such as formatting of names, title capitalisation etc.<br>
164          <span class="style3"><code>$styleTypes</code></span> -- bibliographic styling for each resource type supported by that particular style.</p>
165    <p>These last two are used in <a href="#bibformatGetstyle"><code>BIBFORMAT::getStyle()</code></a>.</p></td>
166  </tr>
167</table>
168<br>
169<table width="100%"  border="0" cellpadding="10" bgcolor="#CCCCCC">
170  <tr>
171    <td><p class="style3"><code><span class="style9"><a name="bibformatGetstyle"></a>BIBFORMAT::getStyle()</span><br>
172  $bibformat-&gt;getStyle(ASSOC_ARRAY: $styleCommon, ASSOC_ARRAY: $styleTypes);</code></p>
173      <p>Transform the raw XML arrays from <a href="#bibformatLoadstyle"><code>BIBFORMAT::loadStyle()</code></a> into OSBib-usable arrays and perform some pre-processing.</p>
174      <p><code>loadStyle()</code> and <code>getStyle()</code> need be called only once so can be outside your process loop. </p>
175    <p>The following should be called for each database row you wish to process.</p></td>
176  </tr>
177</table>
178<br>
179<table width="100%"  border="0" cellpadding="10" bgcolor="#CCCCCC">
180  <tr>
181    <td><p class="style3"><code><span class="style9">BIBFORMAT::preProcess()</span><br>
182  $row = $bibformat-&gt;preProcess(STRING: $type, ASSOC_ARRAY: $row);</code></p>
183      <p><span class="style3"><code>$row</code></span> -- an associative array returned from your SQL query as described in the <a href="#stylemap"><code>STYLEMAP</code></a> section above.<br>
184          <span class="style3"><code>$type</code></span> -- the resource type which must be one of the ones listed in <code>$this-&gt;types</code> in <a href="#stylemap"><code>STYLEMAP</code></a>.</p>
185    <p>Among other things, <code>preProcess()</code> supplies one of the three generic style definitions if the requested bibliographic style does not provide a definition for a specific resource type. It also handles editor/author switching for books which have only editors.</p></td>
186  </tr>
187</table>
188<p>Internally within <code>BIBFORMAT</code>, data from the SQL query <code>$row</code> is formatted and stored in a <code>$item</code> associative array. The following methods accomplish this:</p>
189<table width="100%"  border="0" cellpadding="10" bgcolor="#CCCCCC">
190  <tr>
191    <td><p><span class="style9"><code>BIBFORMAT::formatNames()</code></span><br>
192          <span class="style3"><code>$bibformat-&gt;formatNames(ASSOC_ARRAY: $creators, STRING: $nameType);</code></span></p>
193      <p> This method should be called for each type of creator the resource has. (See <a href="#bibstyle"><code>BIBSTYLE</code></a> for an example of how this is used in WIKINDX.)</p>
194      <p><span class="style3"><code>$creators</code></span> -- Multi-associative array of creator names. e.g. this array might be of the primary authors (in 'creator1'):<br>
195          <span class="style7"><code>array(<br>
196  [0] =&gt; array(['surname'] =&gt; 'Grimshaw', ['firstname'] =&gt; Mark, ['initials'] =&gt; 'N', ['prefix'] =&gt; ),<br>
197  [1] =&gt; array(['surname'] =&gt; 'Witt', ['firstname'] =&gt; Jan, ['initials'] =&gt; , ['prefix'] =&gt; 'de')<br>
198  );</code></span><br>
199  <code>$nameType</code> -- One of 'creator1', 'creator2', 'creator3', 'creator4' or 'creator5'. This is mapped against the resource type array in <a href="#stylemap"><code>STYLEMAP</code></a> to determine what type of creator we're looking at. 'creator1' is always assumed to be the primary creator whether that is an author, composer, inventor etc.</p></td>
200  </tr>
201</table>
202<br>
203<table width="100%"  border="0" cellpadding="10" bgcolor="#CCCCCC">
204  <tr>
205    <td><p class="style3"><code><span class="style9"><a name="bibformatFormattitle"></a>BIBFORMAT::formatTitle()</span><br>
206  $bibformat-&gt;formatTitle(STRING: $title[, STRING: $delimitLeft, STRING: $delimitRight]);</code></p>
207      <p> Format the title of the resource.</p>
208      <p><span class="style3"><code>$title</code></span> -- The title of the resource.<br>
209          <span class="style3"><code>$delimitLeft <br>
210  $delimitRight</code></span> -- Some bibliographic styles require all except the first letter of the title to be lowercased. If your bibliographic system allows users to specify groups of letters in the title that should not be lowercased (for example, proper names), then you enter the delimiters here. WIKINDX uses '{' and '}' as delimiters to protect character case.</p></td>
211  </tr>
212</table>
213<br>
214<table width="100%"  border="0" cellpadding="10" bgcolor="#CCCCCC">
215  <tr>
216    <td><p class="style3"><code><span class="style9">BIBFORMAT::formatEdition()</span><br>
217  $bibformat-&gt;formatEdition($edition);</code></p>
218    <p> Bibliographic styles may require the book edition number to be a cardinal or an ordinal number. If your edition number is stored in the database as a cardinal number, then it will be formatted as an ordinal number <em>if</em> required by the bibliographic style. If your edition number is stored as anything other than a cardinal number it will be used unchanged. The conversion is English - i.e. '3' =&gt; '3rd'. This works all the way up to infinity-1 ;-)</p></td>
219  </tr>
220</table>
221<br>
222<table width="100%"  border="0" cellpadding="10" bgcolor="#CCCCCC">
223  <tr>
224    <td><span class="style3"><code><span class="style9">BIBFORMAT::formatPages()</span><br>
225$bibformat-&gt;formatPages(STRING: $pageStart [, STRING: $pageEnd])</code></span></td>
226  </tr>
227</table>
228<br>
229<table width="100%"  border="0" cellpadding="10" bgcolor="#CCCCCC">
230  <tr>
231    <td><span class="style3"><code><span class="style9">BIBFORMAT::formatDate()</span><br>
232$bibformat-&gt;formatDate(INT: $day, INT: $month);</code></span></td>
233  </tr>
234</table>
235<br>
236<table width="100%"  border="0" cellpadding="10" bgcolor="#CCCCCC">
237  <tr>
238    <td><p><span class="style3"><code><span class="style9">BIBFORMAT::formatRunningTime()</span><br>
239  $bibformat-&gt;formatRunningTime(INT: $minutes, INT: $hours);</code></span></p>
240    <p> Running time for films, broadcasts etc.</p></td>
241  </tr>
242</table>
243<br>
244<table width="100%"  border="0" cellpadding="10" bgcolor="#CCCCCC">
245  <tr>
246    <td><p class="style3"><code><span class="style9">BIBFORMAT::addItem()</span><br>
247  $bibformat-&gt;addItem(STRING: $item, STRING: $fieldName);</code></p>
248    <p> Add an item to the internal <code>$item</code> array in <code>BIBFORMAT</code>. Use this to add elements of your resource to the <code>$item</code> array that do not require special formatting with the methods above. <em>If it's not added, it won't be displayed.</em> You'll notice a use of this in the example <a href="#bibstyle"><code>BIBSTYLE</code></a>. for the URL of a resource. If you don't need to do your own special formatting, it's far easier to use<code>addAllOtherItems()</code> below.</p></td>
249  </tr>
250</table>
251<br>
252<table width="100%"  border="0" cellpadding="10" bgcolor="#CCCCCC">
253  <tr>
254    <td><p class="style3"><code><span class="style9">BIBFORMAT::addAllOtherItems()</span><br>
255  $bibformat-&gt;addItem(ASSOC_ARRAY: $row);</code></p>
256    <p> Add all remaining items to the internal <code>$item</code> array in <code>BIBFORMAT</code>. Use this to add elements of your resource to the <code>$item</code> array that do not require special formatting with the methods above. <em>If it's not added, it won't be displayed.</em></p></td>
257  </tr>
258</table>
259<br>
260<table width="100%"  border="0" cellpadding="10" bgcolor="#CCCCCC">
261  <tr>
262    <td><span class="style3"><code><span class="style9">BIBFORMAT::map()</span><br>
263STRING $bibformat-&gt;map();</code></span><br>
264After you have added resource elements to the <code>$item</code> array using the methods above, calling <code>map()</code> will produce a formatted string suitable for printing to the output medium.</td>
265  </tr>
266</table>
267<p>&nbsp;</p>
268<hr width="50%">
269<h3><a name="usage"></a>USAGE:</h3>
270<p>The formatting in <code>BIBFORMAT</code> works on one resource at a time so you will want to call it via a loop as you cycle through your data.</p>
271<table width="100%"  border="0" cellpadding="10" bgcolor="#CCCCCC">
272  <tr>
273    <td><p>If you do <em>not</em> intend to use <code>STYLEMAPBIBTEX</code>, the following is a rough order of events within the loop described above. It's a general outline of what happens in <a href="#bibstyle"><code>BIBSTYLE</code></a> as used by WIKINDX:</p>
274      <p>// Instantiate the <code>BIBFORMAT</code> class and initialize various parameters<br>
275          <span class="style3"><code>include_once(&quot;core/styles/BIBFORMAT.php&quot;);<br>
276  $bibformat = new BIBFORMAT();<br>
277  list($info, $citation, $styleCommon, $styleTypes) = $bibformat-&gt;loadStyle(&quot;styles/bibliography/&quot;, &quot;APA&quot;);<br>
278  $bibformat-&gt;getStyle($styleCommon, $styleTypes);</code></span></p>
279      <p>// process loop starts here:<br>
280  // Get the resource type ('book', 'journal_article', 'artwork' etc.)<br>
281  <span class="style3"><code>$resourceType = $row['type'];<br>
282  $row = $bibformat-&gt;preProcess($resourceType, $databaseRow);</code></span><br>
283  // PreProcessing may change the value of <code>$resourceType</code> so get it back!<br>
284  <span class="style3"><code>$resourceType = $bibformat-&gt;type;</code></span><br>
285  // Add various resource elements to <code>the BIBFORMAT::item</code> array that require special processing and formatting<br>
286  1. Creator names<br>
287  2. Resource title<br>
288  3. Resource edition<br>
289  4. Resource pages<br>
290  5. Resource date<br>
291  6. Resource running time<br>
292  7. Add the URL creating a hyperlink for web browser display<br>
293  // Add all the other elements of the resource to <code>BIBFORMAT::item</code> array<br>
294  <span class="style3"><code>$bibformat-&gt;addAllOtherItems($row);</code></span><br>
295  // Finally, get the formatted resource string ready for printing to the web browser or exporting to RTF, OpenOffice or plain text<br>
296  <span class="style3"><code>$string = $bibformat-&gt;map();<br>
297</code></span>// process loop ends here</p></td>
298  </tr>
299</table>
300<br>
301<table width="100%"  border="0" cellpadding="10" bgcolor="#CCCCCC">
302  <tr>
303    <td><p>If you <em>are</em> using <code>STYLEMAPBIBTEX</code> for reasons described in the sections above, then the following is a rough order of events within the loop described above (with an example bibtex array supplied). <em>You will need <code>PARSECREATORS</code>, <code>PARSEMONTH</code> and <code>PARSEPAGE</code>. These classes are not part of OSBib but are part of the bibtexParse package that can be downloaded from <a href="http://bibliophile.sourceforge.net">http://bibliophile.sourceforge.net</a>.</em></p>
304      <p>// Instantiate the <code>BIBFORMAT</code> class and initialize various parameters<br>
305          <span class="style3"><code>include_once(&quot;core/styles/BIBFORMAT.php&quot;);<br>
306  $bibformat = new BIBFORMAT(FALSE, TRUE);<br>
307  list($info, $citation, $styleCommon, $styleTypes) = $bibformat-&gt;loadStyle(&quot;styles/bibliography/&quot;, &quot;APA&quot;);<br>
308  $bibformat-&gt;getStyle($styleCommon, $styleTypes);</code></span></p>
309      <p>// process loop starts here:<br>
310          <code>// $resourceArray</code> must be an array of all the elements in the resource where the key names are valid, lowercase BibTeX field names. e.g.:<br>
311          <span class="style3"><code>$resourceArray = array(<br>
312  'author' =&gt; 'Grimshaw, Mark and Boulanger, Christian',<br>
313  'title' =&gt; 'How Bibliographies Ruined our Lives',<br>
314  'year' =&gt; '2005',<br>
315  'volume' =&gt; '20',<br>
316  'number' =&gt; '4',<br>
317  'journal' =&gt; 'Journal of Mundane Trivia',<br>
318  'pages' =&gt; '42--111',<br>
319  'howpublished' =&gt; &quot;\url{http://bibliophile.sourceforge.net}&quot;,<br>
320  );<br>
321          </code></span>// Get the resource type ('book', 'article', 'inbook' etc.)<br>
322          <span class="style3"><code>$resourceType = 'misc';</code></span><br>
323  // In this case, <code>BIBFORMAT::preProcess()</code> adds all the resource elements automatically to the <code>BIBFORMAT::item</code> array...<br>
324  <span class="style3"><code>$bibformat-&gt;preProcess($resourceType, $resourceArray);</code></span><br>
325  // Finally, get the formatted resource string ready for printing to the web browser or exporting to RTF, OpenOffice or plain text<br>
326  <code><span class="style3">$string = $bibformat-&gt;map();<code><br>
327</code></span></code>// process loop ends here</p></td>
328  </tr>
329</table>
330<p>&nbsp;</p>
331</body>
332</html>
333