1<?php
2/********************************
3OSBib:
4A collection of PHP classes to create and manage bibliographic formatting for OS bibliography software
5using the OSBib standard.
6
7Released through http://bibliophile.sourceforge.net under the GPL licence.
8Do whatever you like with this -- some credit to the author(s) would be appreciated.
9
10If you make improvements, please consider contacting the administrators at bibliophile.sourceforge.net
11so that your improvements can be added to the release package.
12
13Adapted from WIKINDX: http://wikindx.sourceforge.net
14
15Mark Grimshaw 2005
16http://bibliophile.sourceforge.net
17********************************/
18/*****
19*	ADMINSTYLE class.
20*
21*	Administration of citation bibliographic styles
22*
23*	$Header: /cvsroot/bibliophile/OSBib/create/ADMINSTYLE.php,v 1.3 2005/06/27 22:18:54 sirfragalot Exp $
24*****/
25class ADMINSTYLE
26{
27// Constructor
28	function ADMINSTYLE($vars)
29	{
30		$this->vars = $vars;
31/**
32* THE OSBIB Version number
33*/
34		$this->osbibVersion = "2.0";
35		include_once("SESSION.php");
36		$this->session = new SESSION();
37		include_once("MESSAGES.php");
38		$this->messages = new MESSAGES();
39		include_once("SUCCESS.php");
40		$this->success = new SUCCESS();
41		include_once("ERRORS.php");
42		$this->errors = new ERRORS();
43		include_once("MISC.php");
44		include_once("FORM.php");
45		include_once("../LOADSTYLE.php");
46		$this->style = new LOADSTYLE();
47		$this->styles = $this->style->loadDir(OSBIB_STYLE_DIR);
48	}
49// check we really are admin
50	function gateKeep($method)
51	{
52// else, run $method
53		return $this->$method();
54	}
55// display options for styles
56	function display($message = FALSE)
57	{
58// Clear previous style in session
59		$this->session->clearArray("cite");
60		$this->session->clearArray("style");
61		$pString = MISC::h($this->messages->text("heading", "styles"), FALSE, 3);
62		if($message)
63			$pString .= MISC::p($message);
64		$pString .= MISC::p(MISC::a("link", $this->messages->text("style", "addLabel"),
65			"index.php?action=adminStyleAddInit"));
66		if(sizeof($this->styles))
67		{
68			$pString .= MISC::p(MISC::a("link", $this->messages->text("style", "copyLabel"),
69				"index.php?action=adminStyleCopyInit"));
70			$pString .= MISC::p(MISC::a("link", $this->messages->text("style", "editLabel"),
71				"index.php?action=adminStyleEditInit"));
72		}
73		return $pString;
74	}
75// Add a style - display options.
76	function addInit($error = FALSE)
77	{
78		$pString = MISC::h($this->messages->text("heading", "styles",
79			" (" . $this->messages->text("style", "addLabel") . ")"), FALSE, 3);
80		if($error)
81			$pString .= MISC::p($error, "error", "center");
82		$pString .= $this->displayStyleForm('add');
83		return $pString;
84	}
85// Write style to text file
86	function add()
87	{
88		if($error = $this->validateInput('add'))
89			$this->badInput($error, 'addInit');
90		$this->writeFile();
91		$pString = $this->success->text("style", " " . $this->messages->text("misc", "added") . " ");
92		$this->styles = $this->style->loadDir(OSBIB_STYLE_DIR);
93		return $this->display($pString);
94	}
95// display styles for editing
96	function editInit($error = FALSE)
97	{
98		$pString = MISC::h($this->messages->text("heading", "styles",
99			" (" . $this->messages->text("style", "editLabel") . ")"), FALSE, 3);
100		$pString .= FORM::formHeader("adminStyleEditDisplay");
101		$styleFile = $this->session->getVar('editStyleFile');
102		if($styleFile)
103			$pString .= FORM::selectedBoxValue(FALSE, "editStyleFile", $this->styles, $styleFile, 20);
104		else
105			$pString .= FORM::selectFBoxValue(FALSE, "editStyleFile", $this->styles, 20);
106		$pString .= MISC::br() . FORM::formSubmit('Edit');
107		$pString .= FORM::formEnd();
108		return $pString;
109	}
110// Display a style for editing.
111	function editDisplay($error = FALSE)
112	{
113		if(!$error)
114			$this->loadEditSession();
115		$pString = MISC::h($this->messages->text("heading", "styles",
116			" (" . $this->messages->text("style", "editLabel") . ")"), FALSE, 3);
117		if($error)
118			$pString .= MISC::p($error, "error", "center");
119		$pString .= $this->displayStyleForm('edit');
120		return $pString;
121	}
122// Read data from style file and load it into the session
123	function loadEditSession($copy = FALSE)
124	{
125// Clear previous style in session
126		$this->session->clearArray("style");
127		include_once("../PARSEXML.php");
128		$parseXML = new PARSEXML();
129		include_once("../STYLEMAP.php");
130		$styleMap = new STYLEMAP();
131		$resourceTypes = array_keys($styleMap->types);
132		$this->session->setVar('editStyleFile', $this->vars['editStyleFile']);
133		$dir = strtolower($this->vars['editStyleFile']);
134		$fileName = $this->vars['editStyleFile'] . ".xml";
135		if($fh = fopen(OSBIB_STYLE_DIR . "/" . $dir . "/" . $fileName, "r"))
136		{
137			list($info, $citation, $common, $types) = $parseXML->extractEntries($fh);
138			if(!$copy)
139			{
140				$this->session->setVar("style_shortName", $this->vars['editStyleFile']);
141				$this->session->setVar("style_longName", base64_encode($info['description']));
142			}
143			foreach($citation as $array)
144			{
145				if(array_key_exists('_NAME', $array) && array_key_exists('_DATA', $array))
146					$this->session->setVar("cite_" . $array['_NAME'],
147					base64_encode($array['_DATA']));
148			}
149			foreach($common as $array)
150			{
151				if(array_key_exists('_NAME', $array) && array_key_exists('_DATA', $array))
152					$this->session->setVar("style_" . $array['_NAME'],
153					base64_encode($array['_DATA']));
154			}
155			$this->arrayToTemplate($types);
156//print_r($types);
157//			$this->session->setVar("style_generic", base64_encode($this->generic));
158			foreach($resourceTypes as $type)
159			{
160				$sessionKey = 'style_' . $type;
161				if(!empty($this->$type))
162					$this->session->setVar($sessionKey, base64_encode($this->$type));
163				if(array_key_exists($type, $this->fallback))
164				{
165					$sessionKey .= "_generic";
166					$this->session->setVar($sessionKey, base64_encode($this->fallback[$type]));
167				}
168			}
169		}
170		else
171			$this->badInput($this->errors->text("file", "read"));
172	}
173// Transform XML nodal array to resource type template strings
174	function arrayToTemplate($types)
175	{
176		$this->fallback = array();
177		foreach($types as $resourceArray)
178		{
179//print_r($resourceArray); print "<P>";
180			$temp = $tempArray = $newArray = $independent = array();
181			$empty = FALSE;
182/**
183* The resource type which will be our array name
184*/
185			$type = $resourceArray['_ATTRIBUTES']['name'];
186			$styleDefinition = $resourceArray['_ELEMENTS'];
187			foreach($styleDefinition as $array)
188			{
189				if(array_key_exists('_NAME', $array) && array_key_exists('_DATA', $array)
190					 && array_key_exists('_ELEMENTS', $array))
191				{
192					if($array['_NAME'] == 'ultimate')
193					{
194						$temp['ultimate'] = $array['_DATA'];
195						continue;
196					}
197					if(empty($array['_ELEMENTS']))
198					{
199						$this->fallback[$type] = $array['_DATA'];
200						$empty = TRUE;
201					}
202					foreach($array['_ELEMENTS'] as $elements)
203					{
204						if($array['_NAME'] == 'independent')
205						{
206							$split = split("_", $elements['_NAME']);
207							$temp[$array['_NAME']][$split[1]]
208							= $elements['_DATA'];
209						}
210						else
211							$temp[$array['_NAME']][$elements['_NAME']]
212							= $elements['_DATA'];
213					}
214				}
215			}
216			if($empty)
217			{
218				$this->$type = array();
219				continue;
220			}
221/**
222* Now parse the temp array into template strings
223*/
224			foreach($temp as $key => $value)
225			{
226				if(!is_array($value))
227				{
228					if($key == 'ultimate')
229						$ultimate = $value;
230					continue;
231				}
232				if(($key == 'independent'))
233				{
234					$independent = $value;
235					continue;
236				}
237				$pre = $post = $dependentPre = $dependentPost = $dependentPreAlternative =
238					$dependentPostAlternative = $singular = $plural = $string = FALSE;
239				if(array_key_exists('pre', $value))
240					$string .= $value['pre'];
241				$string .= $key;
242				if(array_key_exists('post', $value))
243					$string .= $value['post'];
244				if(array_key_exists('dependentPre', $value))
245				{
246					$replace = "%" . $value['dependentPre'] . "%";
247					if(array_key_exists('dependentPreAlternative', $value))
248						$replace .= $value['dependentPreAlternative'] . "%";
249					$string = str_replace("__DEPENDENT_ON_PREVIOUS_FIELD__", $replace, $string);
250				}
251				if(array_key_exists('dependentPost', $value))
252				{
253					$replace = "%" . $value['dependentPost'] . "%";
254					if(array_key_exists('dependentPostAlternative', $value))
255						$replace .= $value['dependentPostAlternative'] . "%";
256					$string = str_replace("__DEPENDENT_ON_NEXT_FIELD__", $replace, $string);
257				}
258				if(array_key_exists('singular', $value) && array_key_exists('plural', $value))
259				{
260					$replace = "^" . $value['singular'] . "^" . $value['plural'] . "^";
261					$string = str_replace("__SINGULAR_PLURAL__", $replace, $string);
262				}
263				$tempArray[] = $string;
264			}
265			if(!empty($independent))
266			{
267				$firstOfPair = FALSE;
268				foreach($tempArray as $index => $value)
269				{
270					if(!$firstOfPair)
271					{
272						if(array_key_exists($index, $independent))
273						{
274							$newArray[] = $independent[$index] . '|' . $value;
275							$firstOfPair = TRUE;
276							continue;
277						}
278					}
279					else
280					{
281						if(array_key_exists($index, $independent))
282						{
283							$newArray[] = $value . '|' . $independent[$index];
284							$firstOfPair = FALSE;
285							continue;
286						}
287					}
288					$newArray[] = $value;
289				}
290			}
291			else
292				$newArray = $tempArray;
293			$tempString = join('|', $newArray);
294			if(isset($ultimate) && (substr($tempString, -1, 1) != $ultimate))
295				$tempString .= '|' . $ultimate;
296			$this->$type = $tempString;
297		}
298	}
299// Edit groups
300	function edit()
301	{
302		if($error = $this->validateInput('edit'))
303			$this->badInput($error, 'editDisplay');
304		$dirName = OSBIB_STYLE_DIR . "/" . strtolower(trim($this->vars['styleShortName']));
305		$fileName = $dirName . "/" . strtoupper(trim($this->vars['styleShortName'])) . ".xml";
306		$this->writeFile($fileName);
307		$pString = $this->success->text("style", " " . $this->messages->text("misc", "edited") . " ");
308		return $this->display($pString);
309	}
310// display groups for copying and making a new style
311	function copyInit($error = FALSE)
312	{
313		$pString = MISC::h($this->messages->text("heading", "styles",
314			" (" . $this->messages->text("style", "copyLabel") . ")"), FALSE, 3);
315		$pString .= FORM::formHeader("adminStyleCopyDisplay");
316		$pString .= FORM::selectFBoxValue(FALSE, "editStyleFile", $this->styles, 20);
317		$pString .= MISC::br() . FORM::formSubmit('Edit');
318		$pString .= FORM::formEnd();
319		return $pString;
320	}
321// Display a style for copying.
322	function copyDisplay($error = FALSE)
323	{
324		if(!$error)
325			$this->loadEditSession(TRUE);
326		$pString = MISC::h($this->messages->text("heading", "styles",
327			" (" . $this->messages->text("style", "copyLabel") . ")"), FALSE, 3);
328		if($error)
329			$pString .= MISC::p($error, "error", "center");
330		$pString .= $this->displayStyleForm('copy');
331		return $pString;
332	}
333// display the citation templating form
334	function displayCiteForm($type)
335	{
336		include_once("TABLE.php");
337		include_once("../STYLEMAP.php");
338		$this->map = new STYLEMAP();
339		$pString = MISC::h($this->messages->text("cite", "citationFormat") . " (" .
340			$this->messages->text("cite", "citationFormatInText") . ")");
341// 1st., creator style
342		$pString .= TABLE::tableStart("styleTable", 1, FALSE, 5);
343		$pString .= TABLE::trStart();
344		$exampleName = array("Joe Bloggs", "Bloggs, Joe", "Bloggs Joe",
345			$this->messages->text("cite", "lastName"));
346		$exampleInitials = array("T. U. ", "T.U.", "T U ", "TU");
347		$example = array($this->messages->text("style", "creatorFirstNameFull"),
348			$this->messages->text("style", "creatorFirstNameInitials"));
349		$firstStyle = base64_decode($this->session->getVar("cite_creatorStyle"));
350		$otherStyle = base64_decode($this->session->getVar("cite_creatorOtherStyle"));
351		$initials = base64_decode($this->session->getVar("cite_creatorInitials"));
352		$firstName = base64_decode($this->session->getVar("cite_creatorFirstName"));
353		$useInitials = base64_decode($this->session->getVar("cite_useInitials"));
354		$td = MISC::b($this->messages->text("cite", "creatorStyle")) . MISC::br() .
355			FORM::selectedBoxValue($this->messages->text("style", "creatorFirstStyle"),
356			"cite_creatorStyle", $exampleName, $firstStyle, 4);
357		$td .= MISC::br() . "&nbsp;" . MISC::br();
358		$td .= FORM::selectedBoxValue($this->messages->text("style", "creatorOthers"),
359			"cite_creatorOtherStyle", $exampleName, $otherStyle, 4);
360		$td .= MISC::br() . "&nbsp;" . MISC::br();
361		$td .= $this->messages->text("cite", "useInitials") . ' ' . FORM::checkbox(FALSE,
362			"cite_useInitials", $useInitials);
363		$td .= MISC::br() . "&nbsp;" . MISC::br();
364		$td .= FORM::selectedBoxValue($this->messages->text("style", "creatorInitials"),
365			"cite_creatorInitials", $exampleInitials, $initials, 4);
366		$td .= MISC::br() . "&nbsp;" . MISC::br();
367		$td .= FORM::selectedBoxValue($this->messages->text("style", "creatorFirstName"),
368			"cite_creatorFirstName", $example, $firstName, 2);
369		$uppercase = base64_decode($this->session->getVar("cite_creatorUppercase")) ?
370			TRUE : FALSE;
371		$td .= MISC::P(FORM::checkbox($this->messages->text("style", "uppercaseCreator"),
372			"cite_creatorUppercase", $uppercase));
373		$pString .= TABLE::td($td);
374// Delimiters
375		$twoCreatorsSep = base64_decode($this->session->getVar("cite_twoCreatorsSep"));
376		$betweenFirst = base64_decode($this->session->getVar("cite_creatorSepFirstBetween"));
377		$betweenNext = base64_decode($this->session->getVar("cite_creatorSepNextBetween"));
378		$last = base64_decode($this->session->getVar("cite_creatorSepNextLast"));
379		$td = MISC::b($this->messages->text("cite", "creatorSep")) .
380			MISC::p($this->messages->text("style", "ifOnlyTwoCreators") . "&nbsp;" .
381			FORM::textInput(FALSE, "cite_twoCreatorsSep", $twoCreatorsSep, 7, 255)) .
382			$this->messages->text("style", "sepCreatorsFirst") . "&nbsp;" .
383			FORM::textInput(FALSE, "cite_creatorSepFirstBetween",
384				$betweenFirst, 7, 255) . MISC::br() .
385			MISC::p($this->messages->text("style", "sepCreatorsNext") . MISC::br() .
386			$this->messages->text("style", "creatorSepBetween") . "&nbsp;" .
387			FORM::textInput(FALSE, "cite_creatorSepNextBetween", $betweenNext, 7, 255) .
388			$this->messages->text("style", "creatorSepLast") . "&nbsp;" .
389			FORM::textInput(FALSE, "cite_creatorSepNextLast", $last, 7, 255));
390		$td .= MISC::br() . "&nbsp;" . MISC::br();
391// List abbreviation
392		$example = array($this->messages->text("style", "creatorListFull"),
393			$this->messages->text("style", "creatorListLimit"));
394		$list = base64_decode($this->session->getVar("cite_creatorList"));
395		$listMore = base64_decode($this->session->getVar("cite_creatorListMore"));
396		$listLimit = base64_decode($this->session->getVar("cite_creatorListLimit"));
397		$listAbbreviation = base64_decode($this->session->getVar("cite_creatorListAbbreviation"));
398		$italic = base64_decode($this->session->getVar("cite_creatorListAbbreviationItalic")) ?
399			TRUE : FALSE;
400		$td .= MISC::b($this->messages->text("cite", "creatorList")) .
401			MISC::p(FORM::selectedBoxValue(FALSE,
402			"cite_creatorList", $example, $list, 2) . MISC::br() .
403			$this->messages->text("style", "creatorListIf") . ' ' .
404			FORM::textInput(FALSE, "cite_creatorListMore", $listMore, 3) .
405			$this->messages->text("style", "creatorListOrMore") . ' ' .
406			FORM::textInput(FALSE, "cite_creatorListLimit", $listLimit, 3) . MISC::br() .
407			$this->messages->text("style", "creatorListAbbreviation") . ' ' .
408			FORM::textInput(FALSE, "cite_creatorListAbbreviation", $listAbbreviation, 15) . ' ' .
409			FORM::checkbox(FALSE, "cite_creatorListAbbreviationItalic", $italic) . ' ' .
410			$this->messages->text("style", "italics"));
411		$list = base64_decode($this->session->getVar("cite_creatorListSubsequent"));
412		$listMore = base64_decode($this->session->getVar("cite_creatorListSubsequentMore"));
413		$listLimit = base64_decode($this->session->getVar("cite_creatorListSubsequentLimit"));
414		$listAbbreviation = base64_decode($this->session->getVar("cite_creatorListSubsequentAbbreviation"));
415		$italic = base64_decode($this->session->getVar("cite_creatorListSubsequentAbbreviationItalic")) ?
416			TRUE : FALSE;
417		$td .= MISC::br() . "&nbsp;" . MISC::br();
418		$td .= MISC::b($this->messages->text("cite", "creatorListSubsequent")) .
419			MISC::p(FORM::selectedBoxValue(FALSE,
420			"cite_creatorListSubsequent", $example, $list, 2) . MISC::br() .
421			$this->messages->text("style", "creatorListIf") . ' ' .
422			FORM::textInput(FALSE, "cite_creatorListSubsequentMore", $listMore, 3) .
423			$this->messages->text("style", "creatorListOrMore") . ' ' .
424			FORM::textInput(FALSE, "cite_creatorListSubsequentLimit", $listLimit, 3) . MISC::br() .
425			$this->messages->text("style", "creatorListAbbreviation") . ' ' .
426			FORM::textInput(FALSE, "cite_creatorListSubsequentAbbreviation", $listAbbreviation, 15) . ' ' .
427			FORM::checkbox(FALSE, "cite_creatorListSubsequentAbbreviationItalic", $italic) . ' ' .
428			$this->messages->text("style", "italics"));
429		$pString .= TABLE::td($td, FALSE, FALSE, "top");
430		$pString .= TABLE::trEnd();
431		$pString .= TABLE::tableEnd();
432		$pString .= TABLE::tdEnd() . TABLE::trEnd() . TABLE::trStart() . TABLE::tdStart();
433		$pString .= MISC::br() . "&nbsp;" . MISC::br();
434// Miscellaneous citation formatting
435		$pString .= TABLE::tableStart("styleTable", 1, FALSE, 5);
436		$pString .= TABLE::trStart();
437// Consecutive citations by same author(s)
438		$example = array($this->messages->text("cite", "printCreator"),
439			$this->messages->text("cite", "omitCreator"));
440		$consecutive = base64_decode($this->session->getVar("cite_consecutiveCreator"));
441		$consecutiveSep = base64_decode($this->session->getVar("cite_consecutiveCreatorSep"));
442		$td = FORM::selectedBoxValue($this->messages->text("cite", "consecutiveCreator"),
443			"cite_consecutiveCreator", $example, $consecutive, 2);
444		$td .= MISC::br() . "&nbsp;" . MISC::br();
445		$td .= $this->messages->text("cite", "consecutiveCreatorSep") . ' ' .
446			FORM::textInput(FALSE, "cite_consecutiveCreatorSep", $consecutiveSep, 7);
447		$pString .= TABLE::td($td, FALSE, FALSE, "top");
448		$template = base64_decode($this->session->getVar("cite_template"));
449		$availableFields = join(', ', $this->map->citation);
450		$consecutiveSep = base64_decode($this->session->getVar("cite_consecutiveCitationSep"));
451		$year = base64_decode($this->session->getVar("cite_yearFormat"));
452		$superscript = base64_decode($this->session->getVar("cite_templateSuperscript"));
453		$td = $this->messages->text("cite", "template") . ' ' .
454			FORM::textInput(FALSE, "cite_template", $template, 30, 255) .
455			" " . MISC::span('*', 'required') . MISC::br() .
456			$this->messages->text("cite", "superscript") . ' ' .
457			FORM::checkbox(FALSE, "cite_templateSuperscript", $superscript) .
458			MISC::p(MISC::i($this->messages->text("style", "availableFields")) .
459			MISC::br() . $availableFields, "small");
460		$td .= MISC::br() . "&nbsp;" . MISC::br();
461		$td .= $this->messages->text("cite", "consecutiveCitationSep") . ' ' .
462			FORM::textInput(FALSE, "cite_consecutiveCitationSep", $consecutiveSep, 7);
463		$td .= MISC::br() . "&nbsp;" . MISC::br();
464		$pString .= TABLE::td($td, FALSE, FALSE, "top");
465		$example = array("132-9", "132-39", "132-139");
466		$input = base64_decode($this->session->getVar("cite_pageFormat"));
467		$td = FORM::selectedBoxValue($this->messages->text("style", "pageFormat"),
468			"cite_pageFormat", $example, $input, 3);
469		$td .= MISC::br() . "&nbsp;" . MISC::br();
470		$example = array("1998", "'98", "98");
471		$td .= FORM::selectedBoxValue($this->messages->text("cite", "yearFormat"),
472			"cite_yearFormat", $example, $year, 3);
473		$pString .= TABLE::td($td, FALSE, FALSE, "top");
474		$pString .= TABLE::trEnd();
475		$pString .= TABLE::tableEnd();
476		$pString .= MISC::br() . "&nbsp;" . MISC::br();
477		$pString .= TABLE::tdEnd() . TABLE::trEnd() . TABLE::trStart() . TABLE::tdStart();
478// Ambiguous citations
479		$pString .= TABLE::tableStart("styleTable", 1, FALSE, 5);
480		$pString .= TABLE::trStart();
481		$ambiguousName = base64_decode($this->session->getVar("cite_ambiguousName")) ? TRUE : FALSE;
482		$ambiguousMore = base64_decode($this->session->getVar("cite_ambiguousMore")) ? TRUE : FALSE;
483		$ambiguousTitle = base64_decode($this->session->getVar("cite_ambiguousTitle")) ? TRUE : FALSE;
484		$ambiguousYear = base64_decode($this->session->getVar("cite_ambiguousYear")) ? TRUE : FALSE;
485		$nameFormat = base64_decode($this->session->getVar("cite_ambiguousNameFormat"));
486		$yearFormat = base64_decode($this->session->getVar("cite_ambiguousYearFormat"));
487		$td = MISC::p(MISC::b($this->messages->text("cite", "ambiguous")));
488		$td .= MISC::P(FORM::checkbox(FALSE,
489			"cite_ambiguousName", $ambiguousName) . ' ' . $this->messages->text("cite", "ambiguousFull"));
490		$td .= MISC::P(FORM::checkbox(FALSE,
491			"cite_ambiguousMore", $ambiguousMore) . ' ' . $this->messages->text("cite", "ambiguousMore"));
492		$td .= MISC::P(FORM::checkbox(FALSE,
493			"cite_ambiguousTitle", $ambiguousTitle) . ' ' . $this->messages->text("cite", "ambiguousTitle"));
494		$td .= MISC::P(FORM::checkbox(FALSE,
495			"cite_ambiguousYear", $ambiguousYear) . ' ' . $this->messages->text("cite", "ambiguousYear"));
496		$pString .= TABLE::td($td, FALSE, FALSE, "top");
497		$example = array($this->messages->text("style", "creatorFirstNameFull"),
498			"T. U. ", "T.U.", "T U ", "TU");
499		$td = FORM::selectedBoxValue($this->messages->text("cite", "ambiguousNameFormat"),
500			"cite_ambiguousNameFormat", $example, $nameFormat, 5);
501		$pString .= TABLE::td($td);
502		$example = array("1999a, b", "1999a, 1999b");
503		$td = FORM::selectedBoxValue($this->messages->text("cite", "ambiguousYearFormat"),
504			"cite_ambiguousYearFormat", $example, $yearFormat, 2);
505		$pString .= TABLE::td($td);
506		$pString .= TABLE::trEnd();
507		$pString .= TABLE::tableEnd();
508		$pString .= MISC::br() . "&nbsp;" . MISC::br();
509		$pString .= TABLE::tdEnd() . TABLE::trEnd() . TABLE::trStart() . TABLE::tdStart();
510// Footnote style citations
511		$pString .= MISC::h($this->messages->text("cite", "citationFormat") . " (" .
512			$this->messages->text("cite", "citationFormatFootnote") . ")");
513		$pString .= TABLE::tableStart("styleTable", 1, FALSE, 5);
514		$pString .= TABLE::trStart();
515		$style = base64_decode($this->session->getVar("cite_footnoteStyle"));
516		$example = array($this->messages->text("cite", "footnoteStyleBib"),
517				$this->messages->text("cite", "footnoteStyleInText"));
518		$td = FORM::selectedBoxValue(FALSE, "cite_footnoteStyle", $example, $style, 2);
519		$td .= MISC::br() . "&nbsp;" . MISC::br();
520		$ibid = base64_decode($this->session->getVar("cite_ibid"));
521		$ibidPage = base64_decode($this->session->getVar("cite_ibidPage"));
522		$td .= FORM::textInput($this->messages->text("cite", "ibid"), "cite_ibid", $ibid, 30, 255);
523		$td .= MISC::br();
524		$td .= FORM::checkbox(FALSE,
525			"cite_ibidPage", $ibidPage) . ' ' . $this->messages->text("cite", "ibidPage");
526		$td .= MISC::br() . "&nbsp;" . MISC::br();
527		$idem = base64_decode($this->session->getVar("cite_idem"));
528		$td .= FORM::textInput($this->messages->text("cite", "idem"), "cite_idem", $idem, 30, 255);
529		$td .= MISC::br() . "&nbsp;" . MISC::br();
530		$opCit = base64_decode($this->session->getVar("cite_opCit"));
531		$td .= FORM::textInput($this->messages->text("cite", "opCit"), "cite_opCit", $opCit, 30, 255);
532		$pString .= TABLE::td($td);
533
534		$example = array($this->messages->text("cite", "footnoteCitationPageFormatNever"),
535				$this->messages->text("cite", "footnoteCitationPageFormatBib"),
536				$this->messages->text("cite", "footnoteCitationPageFormatTemplate"));
537		$pageFormat = base64_decode($this->session->getVar("cite_footnoteCitationPageFormat"));
538		$td = FORM::selectedBoxValue($this->messages->text("cite", "footnoteCitationPageFormat"),
539			"cite_footnoteCitationPageFormat", $example, $pageFormat, 3);
540		$td .= MISC::br() . "&nbsp;" . MISC::br();
541		$template = base64_decode($this->session->getVar("cite_footnotePageTemplate"));
542		$td .= $this->messages->text("cite", "template") . ' ' .
543			FORM::textInput(FALSE, "cite_footnotePageTemplate", $template, 30, 255) .
544			MISC::p(MISC::i($this->messages->text("style", "availableFields")) .
545			MISC::br() . 'pages', "small");
546		$td .= MISC::br() . "&nbsp;" . MISC::br();
547		$example = array($this->messages->text("cite", "footnotePageAfter"),
548			$this->messages->text("cite", "footnotePageBefore"));
549		$pagePosition = base64_decode($this->session->getVar("cite_footnotePagePosition"));
550		$td .= FORM::selectedBoxValue($this->messages->text("cite", "footnotePagePosition"),
551			"cite_footnotePagePosition", $example, $pagePosition, 2);
552
553		$pString .= TABLE::td($td);
554		$pString .= TABLE::trEnd();
555		$pString .= TABLE::tableEnd();
556		$pString .= MISC::br() . "&nbsp;" . MISC::br();
557		$pString .= TABLE::tdEnd() . TABLE::trEnd() . TABLE::trStart() . TABLE::tdStart();
558		return $pString;
559	}
560// display the style form for both adding and editing
561	function displayStyleForm($type)
562	{
563		include_once("TABLE.php");
564		include_once("../STYLEMAP.php");
565		$this->map = new STYLEMAP();
566		$types = array_keys($this->map->types);
567		if($type == 'add')
568			$pString = FORM::formHeader("adminStyleAdd");
569		else if($type == 'edit')
570			$pString = FORM::formHeader("adminStyleEdit");
571		else // copy
572			$pString = FORM::formHeader("adminStyleAdd");
573		$pString .= TABLE::tableStart();
574		$pString .= TABLE::trStart();
575		$input = $this->session->getVar("style_shortName");
576		if($type == 'add')
577			$pString .= TABLE::td(FORM::textInput($this->messages->text("style", "shortName"),
578				"styleShortName", $input, 20, 255) . " " . MISC::span('*', 'required') .
579				MISC::br() . $this->messages->text("hint", "styleShortName"));
580		else if($type == 'edit')
581			$pString .= FORM::hidden("editStyleFile", $this->vars['editStyleFile']) .
582				FORM::hidden("styleShortName", $input) .
583				TABLE::td(MISC::b($this->vars['editStyleFile'] . ":&nbsp;&nbsp;"),
584				FALSE, FALSE, "top");
585		else // copy
586			$pString .= TABLE::td(FORM::textInput($this->messages->text("style", "shortName"),
587				"styleShortName", $input, 20, 255) . " " . MISC::span('*', 'required') .
588				MISC::br() . $this->messages->text("hint", "styleShortName"));
589		$input = base64_decode($this->session->getVar("style_longName"));
590		$pString .= TABLE::td(FORM::textInput($this->messages->text("style", "longName"),
591			"styleLongName", $input, 50, 255) . " " . MISC::span('*', 'required'));
592		$pString .= TABLE::trEnd();
593		$pString .= TABLE::tableEnd();
594		$pString .= TABLE::tdEnd() . TABLE::trEnd() . TABLE::trStart() . TABLE::tdStart();
595		$pString .= MISC::p(MISC::hr());
596		$pString .= $this->displayCiteForm('copy');
597		$pString .= MISC::p(MISC::hr() . MISC::hr());
598		$pString .= MISC::h($this->messages->text("style", "bibFormat"));
599// Display general options for creator limits, formats etc.
600// 1st., creator style
601		$pString .= TABLE::tableStart("styleTable", 1, FALSE, 5);
602		$pString .= TABLE::trStart();
603		$exampleName = array("Joe Bloggs", "Bloggs, Joe", "Bloggs Joe",
604			$this->messages->text("cite", "lastName"));
605		$exampleInitials = array("T. U. ", "T.U.", "T U ", "TU");
606		$example = array($this->messages->text("style", "creatorFirstNameFull"),
607			$this->messages->text("style", "creatorFirstNameInitials"));
608		$firstStyle = base64_decode($this->session->getVar("style_primaryCreatorFirstStyle"));
609		$otherStyle = base64_decode($this->session->getVar("style_primaryCreatorOtherStyle"));
610		$initials = base64_decode($this->session->getVar("style_primaryCreatorInitials"));
611		$firstName = base64_decode($this->session->getVar("style_primaryCreatorFirstName"));
612		$td = MISC::b($this->messages->text("style", "primaryCreatorStyle")) . MISC::br() .
613			FORM::selectedBoxValue($this->messages->text("style", "creatorFirstStyle"),
614			"style_primaryCreatorFirstStyle", $exampleName, $firstStyle, 4);
615		$td .= MISC::br() . "&nbsp;" . MISC::br();
616		$td .= FORM::selectedBoxValue($this->messages->text("style", "creatorOthers"),
617			"style_primaryCreatorOtherStyle", $exampleName, $otherStyle, 4);
618		$td .= MISC::br() . "&nbsp;" . MISC::br();
619		$td .= FORM::selectedBoxValue($this->messages->text("style", "creatorInitials"),
620			"style_primaryCreatorInitials", $exampleInitials, $initials, 4);
621		$td .= MISC::br() . "&nbsp;" . MISC::br();
622		$td .= FORM::selectedBoxValue($this->messages->text("style", "creatorFirstName"),
623			"style_primaryCreatorFirstName", $example, $firstName, 2);
624		$uppercase = base64_decode($this->session->getVar("style_primaryCreatorUppercase")) ?
625			TRUE : FALSE;
626		$td .= MISC::P(FORM::checkbox($this->messages->text("style", "uppercaseCreator"),
627			"style_primaryCreatorUppercase", $uppercase));
628		$repeat = base64_decode($this->session->getVar("style_primaryCreatorRepeat"));
629		$exampleRepeat = array($this->messages->text("style", "repeatCreators1"),
630			$this->messages->text("style", "repeatCreators2"),
631			$this->messages->text("style", "repeatCreators3"));
632		$td .= FORM::selectedBoxValue($this->messages->text("style", "repeatCreators"),
633			"style_primaryCreatorRepeat", $exampleRepeat, $repeat, 3) . MISC::br();
634		$repeatString = base64_decode($this->session->getVar("style_primaryCreatorRepeatString"));
635		$td .= FORM::textInput(FALSE, "style_primaryCreatorRepeatString", $repeatString, 15, 255);
636		$pString .= TABLE::td($td);
637		$firstStyle = base64_decode($this->session->getVar("style_otherCreatorFirstStyle"));
638		$otherStyle = base64_decode($this->session->getVar("style_otherCreatorOtherStyle"));
639		$initials = base64_decode($this->session->getVar("style_otherCreatorInitials"));
640		$firstName = base64_decode($this->session->getVar("style_otherCreatorFirstName"));
641		$td = MISC::b($this->messages->text("style", "otherCreatorStyle")) . MISC::br() .
642			FORM::selectedBoxValue($this->messages->text("style", "creatorFirstStyle"),
643			"style_otherCreatorFirstStyle", $exampleName, $firstStyle, 4);
644		$td .= MISC::br() . "&nbsp;" . MISC::br();
645		$td .= FORM::selectedBoxValue($this->messages->text("style", "creatorOthers"),
646			"style_otherCreatorOtherStyle", $exampleName, $otherStyle, 4);
647		$td .= MISC::br() . "&nbsp;" . MISC::br();
648		$td .= FORM::selectedBoxValue($this->messages->text("style", "creatorInitials"),
649			"style_otherCreatorInitials", $exampleInitials, $initials, 4);
650		$td .= MISC::br() . "&nbsp;" . MISC::br();
651		$td .= FORM::selectedBoxValue($this->messages->text("style", "creatorFirstName"),
652			"style_otherCreatorFirstName", $example, $firstName, 2);
653		$uppercase = base64_decode($this->session->getVar("style_otherCreatorUppercase")) ?
654			TRUE : FALSE;
655		$td .= MISC::P(FORM::checkbox($this->messages->text("style", "uppercaseCreator"),
656			"style_otherCreatorUppercase", $uppercase));
657		$pString .= TABLE::td($td);
658		$pString .= TABLE::trEnd();
659		$pString .= TABLE::tableEnd();
660		$pString .= MISC::br() . "&nbsp;" . MISC::br();
661		$pString .= TABLE::tdEnd() . TABLE::trEnd() . TABLE::trStart() . TABLE::tdStart();
662// 2nd., creator delimiters
663		$pString .= TABLE::tableStart("styleTable", 1, FALSE, 5);
664//		$pString .= TABLE::trStart();
665//		$pString .= TABLE::tdStart();
666//		$pString .= TABLE::tableStart();
667		$pString .= TABLE::trStart();
668		$twoCreatorsSep = base64_decode($this->session->getVar("style_primaryTwoCreatorsSep"));
669		$betweenFirst = base64_decode($this->session->getVar("style_primaryCreatorSepFirstBetween"));
670		$betweenNext = base64_decode($this->session->getVar("style_primaryCreatorSepNextBetween"));
671		$last = base64_decode($this->session->getVar("style_primaryCreatorSepNextLast"));
672		$pString .= TABLE::td(MISC::b($this->messages->text("style", "primaryCreatorSep")) .
673			MISC::p($this->messages->text("style", "ifOnlyTwoCreators") . "&nbsp;" .
674			FORM::textInput(FALSE, "style_primaryTwoCreatorsSep", $twoCreatorsSep, 7, 255)) .
675			$this->messages->text("style", "sepCreatorsFirst") . "&nbsp;" .
676			FORM::textInput(FALSE, "style_primaryCreatorSepFirstBetween", $betweenFirst, 7, 255) . MISC::br() .
677			MISC::p($this->messages->text("style", "sepCreatorsNext") . MISC::br() .
678			$this->messages->text("style", "creatorSepBetween") . "&nbsp;" .
679			FORM::textInput(FALSE, "style_primaryCreatorSepNextBetween", $betweenNext, 7, 255) .
680			$this->messages->text("style", "creatorSepLast") . "&nbsp;" .
681			FORM::textInput(FALSE, "style_primaryCreatorSepNextLast", $last, 7, 255)),
682			FALSE, FALSE, "bottom");
683//		$pString .= TABLE::trEnd();
684//		$pString .= TABLE::tableEnd();
685//		$pString .= TABLE::tdEnd() . TABLE::trEnd() . TABLE::trStart() . TABLE::tdStart();
686//		$pString .= TABLE::tdEnd();
687//		$pString .= TABLE::tdStart();
688//		$pString .= TABLE::tableStart();
689//		$pString .= TABLE::trStart();
690		$twoCreatorsSep = base64_decode($this->session->getVar("style_otherTwoCreatorsSep"));
691		$betweenFirst = base64_decode($this->session->getVar("style_otherCreatorSepFirstBetween"));
692		$betweenNext = base64_decode($this->session->getVar("style_otherCreatorSepNextBetween"));
693		$last = base64_decode($this->session->getVar("style_otherCreatorSepNextLast"));
694		$pString .= TABLE::td(MISC::b($this->messages->text("style", "otherCreatorSep")) .
695			MISC::p($this->messages->text("style", "ifOnlyTwoCreators") . "&nbsp;" .
696			FORM::textInput(FALSE, "style_otherTwoCreatorsSep", $twoCreatorsSep, 7, 255)) .
697			$this->messages->text("style", "sepCreatorsFirst") . "&nbsp;" .
698			FORM::textInput(FALSE, "style_otherCreatorSepFirstBetween", $betweenFirst, 7, 255) .
699			MISC::p($this->messages->text("style", "sepCreatorsNext") . MISC::br() .
700			$this->messages->text("style", "creatorSepBetween") . "&nbsp;" .
701			FORM::textInput(FALSE, "style_otherCreatorSepNextBetween", $betweenNext, 7, 255) .
702			$this->messages->text("style", "creatorSepLast") . "&nbsp;" .
703			FORM::textInput(FALSE, "style_otherCreatorSepNextLast", $last, 7, 255)),
704			FALSE, FALSE, "bottom");
705		$pString .= TABLE::trEnd();
706		$pString .= TABLE::tableEnd();
707		$pString .= TABLE::tdEnd() . TABLE::trEnd() . TABLE::trStart() . TABLE::tdStart();
708//		$pString .= TABLE::tdEnd();
709// Editor replacements
710//		$pString .= TABLE::trEnd();
711//		$pString .= TABLE::tableEnd();
712//		$pString .= TABLE::tdEnd() . TABLE::trEnd() . TABLE::trStart() . TABLE::tdStart();
713		$pString .= MISC::br() . "&nbsp;" . MISC::br();
714		$pString .= TABLE::tableStart("styleTable", 1, FALSE, 5);
715		$pString .= TABLE::trStart();
716		$switch = base64_decode($this->session->getVar("style_editorSwitch"));
717		$editorSwitchIfYes = stripslashes(base64_decode($this->session->getVar("style_editorSwitchIfYes")));
718		$example = array($this->messages->text("style", "no"), $this->messages->text("style", "yes"));
719		$pString .= TABLE::td(MISC::b($this->messages->text("style", "editorSwitchHead")) . MISC::br() .
720			FORM::selectedBoxValue($this->messages->text("style", "editorSwitch"),
721			"style_editorSwitch", $example, $switch, 2));
722		$pString .= TABLE::td(
723			FORM::textInput($this->messages->text("style", "editorSwitchIfYes"),
724			"style_editorSwitchIfYes", $editorSwitchIfYes, 30, 255), FALSE, FALSE, "bottom");
725		$pString .= TABLE::trEnd();
726		$pString .= TABLE::tableEnd();
727		$pString .= TABLE::tdEnd() . TABLE::trEnd() . TABLE::trStart() . TABLE::tdStart();
728		$pString .= MISC::br() . "&nbsp;" . MISC::br();
729// 3rd., creator list limits
730		$pString .= TABLE::tableStart("styleTable", 1, FALSE, 5);
731		$pString .= TABLE::trStart();
732		$example = array($this->messages->text("style", "creatorListFull"),
733			$this->messages->text("style", "creatorListLimit"));
734		$list = base64_decode($this->session->getVar("style_primaryCreatorList"));
735		$listMore = base64_decode($this->session->getVar("style_primaryCreatorListMore"));
736		$listLimit = base64_decode($this->session->getVar("style_primaryCreatorListLimit"));
737		$listAbbreviation = base64_decode($this->session->getVar("style_primaryCreatorListAbbreviation"));
738		$italic = base64_decode($this->session->getVar("style_primaryCreatorListAbbreviationItalic")) ?
739			TRUE : FALSE;
740		$pString .= TABLE::td(MISC::b($this->messages->text("style", "primaryCreatorList")) . MISC::br() .
741			FORM::selectedBoxValue(FALSE,
742			"style_primaryCreatorList", $example, $list, 2) . MISC::br() .
743			$this->messages->text("style", "creatorListIf") . ' ' .
744			FORM::textInput(FALSE, "style_primaryCreatorListMore", $listMore, 3) .
745			$this->messages->text("style", "creatorListOrMore") . ' ' .
746			FORM::textInput(FALSE, "style_primaryCreatorListLimit", $listLimit, 3) . MISC::br() .
747			$this->messages->text("style", "creatorListAbbreviation") . ' ' .
748			FORM::textInput(FALSE, "style_primaryCreatorListAbbreviation", $listAbbreviation, 15) . ' ' .
749			FORM::checkbox(FALSE, "style_primaryCreatorListAbbreviationItalic", $italic) . ' ' .
750			$this->messages->text("style", "italics"));
751		$list = base64_decode($this->session->getVar("style_otherCreatorList"));
752		$listMore = base64_decode($this->session->getVar("style_otherCreatorListMore"));
753		$listLimit = base64_decode($this->session->getVar("style_otherCreatorListLimit"));
754		$listAbbreviation = base64_decode($this->session->getVar("style_otherCreatorListAbbreviation"));
755		$italic = base64_decode($this->session->getVar("style_otherCreatorListAbbreviationItalic")) ?
756			TRUE : FALSE;
757		$pString .= TABLE::td(MISC::b($this->messages->text("style", "otherCreatorList")) . MISC::br() .
758			FORM::selectedBoxValue(FALSE,
759			"style_otherCreatorList", $example, $list, 2) . MISC::br() .
760			$this->messages->text("style", "creatorListIf") . ' ' .
761			FORM::textInput(FALSE, "style_otherCreatorListMore", $listMore, 3) .
762			$this->messages->text("style", "creatorListOrMore") . ' ' .
763			FORM::textInput(FALSE, "style_otherCreatorListLimit", $listLimit, 3) . MISC::br() .
764			$this->messages->text("style", "creatorListAbbreviation") . ' ' .
765			FORM::textInput(FALSE, "style_otherCreatorListAbbreviation", $listAbbreviation, 15) . ' ' .
766			FORM::checkbox(FALSE, "style_otherCreatorListAbbreviationItalic", $italic) . ' ' .
767			$this->messages->text("style", "italics"));
768		$pString .= TABLE::trEnd();
769		$pString .= TABLE::tableEnd();
770		$pString .= TABLE::tdEnd() . TABLE::trEnd() . TABLE::trStart() . TABLE::tdStart();
771		$pString .= MISC::br() . "&nbsp;" . MISC::br();
772// Title capitalization, edition, day and month, runningTime and page formats
773		$pString .= TABLE::tableStart("styleTable", 1, FALSE, 5);
774		$pString .= TABLE::trStart();
775		$example = array($this->messages->text("style", "titleAsEntered"),
776			"Wikindx bibliographic management system");
777		$input = base64_decode($this->session->getVar("style_titleCapitalization"));
778		$pString .= TABLE::td(MISC::b($this->messages->text("style", "titleCapitalization")) . MISC::br() .
779			FORM::selectedBoxValue(FALSE, "style_titleCapitalization", $example, $input, 2));
780		$example = array("3", "3rd");
781		$input = base64_decode($this->session->getVar("style_editionFormat"));
782		$pString .= TABLE::td(MISC::b($this->messages->text("style", "editionFormat")) . MISC::br() .
783			FORM::selectedBoxValue(FALSE, "style_editionFormat", $example, $input, 2));
784		$example = array("132-9", "132-39", "132-139");
785		$input = base64_decode($this->session->getVar("style_pageFormat"));
786		$pString .= TABLE::td(MISC::b($this->messages->text("style", "pageFormat")) . MISC::br() .
787			FORM::selectedBoxValue(FALSE, "style_pageFormat", $example, $input, 3));
788		$pString .= TABLE::trEnd();
789		$pString .= TABLE::tableEnd();
790		$pString .= TABLE::tdEnd() . TABLE::trEnd() . TABLE::trStart() . TABLE::tdStart();
791		$pString .= MISC::br() . "&nbsp;" . MISC::br();
792		$pString .= TABLE::tableStart("styleTable", 1, FALSE, 5);
793		$pString .= TABLE::trStart();
794		$example = array("10", "10th");
795		$input = base64_decode($this->session->getVar("style_dayFormat"));
796		$pString .= TABLE::td(MISC::b($this->messages->text("style", "dayFormat")) . MISC::br() .
797			FORM::selectedBoxValue(FALSE, "style_dayFormat", $example, $input, 2));
798		$example = array("Feb", "February", $this->messages->text("style", "userMonthSelect"));
799		$input = base64_decode($this->session->getVar("style_monthFormat"));
800		$pString .= TABLE::td(MISC::b($this->messages->text("style", "monthFormat")) . MISC::br() .
801			FORM::selectedBoxValue(FALSE, "style_monthFormat", $example, $input, 3));
802		$example = array("Day Month", "Month Day");
803		$input = base64_decode($this->session->getVar("style_dateFormat"));
804		$pString .= TABLE::td(MISC::b($this->messages->text("style", "dateFormat")) . MISC::br() .
805			FORM::selectedBoxValue(FALSE, "style_dateFormat", $example, $input, 2));
806		$example = array("3'45\"", "3:45", "3,45", "3 hours, 45 minutes", "3 hours and 45 minutes");
807		$input = base64_decode($this->session->getVar("style_runningTimeFormat"));
808		$pString .= TABLE::td(MISC::b($this->messages->text("style", "runningTimeFormat")) . MISC::br() .
809			FORM::selectedBoxValue(FALSE, "style_runningTimeFormat", $example, $input, 5));
810		$pString .= TABLE::trEnd();
811		$pString .= TABLE::trStart();
812		$monthString = '';
813		for($i = 1; $i <= 12; $i++)
814		{
815			$input = base64_decode($this->session->getVar("style_userMonth_$i"));
816			if($i == 7)
817				$monthString .= MISC::br() . "$i:&nbsp;&nbsp;" .
818				FORM::textInput(FALSE, "style_userMonth_$i", $input, 15, 255);
819			else
820				$monthString .= "$i:&nbsp;&nbsp;" .
821				FORM::textInput(FALSE, "style_userMonth_$i", $input, 15, 255);
822		}
823		$pString .= TABLE::td($this->messages->text("style", "userMonths") . MISC::br() .
824			$monthString, FALSE, FALSE, FALSE, 5);
825		$pString .= TABLE::trEnd();
826		$pString .= TABLE::tableEnd();
827		$pString .= TABLE::tdEnd() . TABLE::trEnd() . TABLE::trStart() . TABLE::tdStart();
828		$pString .= MISC::br() . "&nbsp;" . MISC::br();
829// Date range formatting
830		$pString .= TABLE::tableStart("styleTable", 1, FALSE, 5);
831		$pString .= TABLE::trStart();
832
833		$td = MISC::p(MISC::b($this->messages->text("style", "dateRange")));
834		$input = base64_decode($this->session->getVar("style_dateRangeDelimit1"));
835		$td .= MISC::p(FORM::textInput($this->messages->text("style", "dateRangeDelimit1"),
836			"style_dateRangeDelimit1", $input, 6, 255));
837		$input = base64_decode($this->session->getVar("style_dateRangeDelimit2"));
838		$td .= MISC::p(FORM::textInput($this->messages->text("style", "dateRangeDelimit2"),
839			"style_dateRangeDelimit2", $input, 6, 255));
840		$input = base64_decode($this->session->getVar("style_dateRangeSameMonth"));
841		$example = array($this->messages->text("style", "dateRangeSameMonth1"),
842			$this->messages->text("style", "dateRangeSameMonth2"));
843		$td .= MISC::p(FORM::selectedBoxValue($this->messages->text("style", "dateRangeSameMonth"),
844			"style_dateRangeSameMonth", $example, $input, 2));
845
846		$pString .= TABLE::td($td);
847
848		$pString .= TABLE::trEnd();
849		$pString .= TABLE::tableEnd();
850		$pString .= TABLE::tdEnd() . TABLE::trEnd() . TABLE::trStart() . TABLE::tdStart();
851		$pString .= MISC::br() . MISC::hr() . MISC::br();
852		$generic = array("genericBook" => $this->messages->text("resourceType", "genericBook"),
853			"genericArticle" => $this->messages->text("resourceType", "genericArticle"),
854			"genericMisc" => $this->messages->text("resourceType", "genericMisc"));
855// Resource types
856		foreach($types as $key)
857		{
858			if(($key == 'genericBook') || ($key == 'genericArticle') || ($key == 'genericMisc'))
859			{
860				$required = " " . MISC::span('*', 'required');
861				$fallback = FALSE;
862			}
863			else
864			{
865				$required = FALSE;
866				$formElementName = "style_" . $key . "_generic";
867				$input = $this->session->issetVar($formElementName) ?
868					base64_decode($this->session->getVar($formElementName)) : "genericMisc";
869				$fallback = FORM::selectedBoxValue($this->messages->text("style", "fallback"),
870					$formElementName, $generic, $input, 3);
871			}
872			$pString .= MISC::br() . MISC::hr() . MISC::br();
873			$pString .= TABLE::tableStart();
874			$pString .= TABLE::trStart();
875			$keyName = 'style_' . $key;
876			$input = stripslashes(base64_decode($this->session->getVar($keyName)));
877			$pString .= TABLE::td(FORM::textareaInput($this->messages->text("resourceType", $key),
878				$keyName, $input, 80, 3) . $required . MISC::br() .
879			$this->messages->text("hint", "caseSensitive"));
880// List available fields for this type
881			$availableFields = join(', ', array_values($this->map->$key));
882			$pString .= TABLE::td(MISC::p(MISC::i($this->messages->text("style", "availableFields")) .
883				MISC::br() . $availableFields, "small") . MISC::p($fallback) .
884				MISC::p(MISC::a("link linkHidden", "preview",
885				"javascript:openPopUpStylePreview('index.php?action=previewStyle',
886				'100', '750', '$keyName')")));
887            $pString .= TABLE::trEnd();
888            // iframe preview
889/*
890            $pString .= TABLE::trStart();
891
892            $pString .= "<td><textarea name='$keyName' id='$key' ".
893                        "onchange=\"document.getElementById('previewIframe').src=".
894                        "'index.php?action=previewStyle&template='+this.value.replace(/&/, '!!amp!!').replace(/=/,'!!eq!!');\">".
895                        "$input</textarea><iframe id='previewIframe'/></td>";
896            $pString .= TABLE::trEnd();
897*/
898			// end iframe preview
899			$pString .= TABLE::tableEnd();
900			$pString .= TABLE::tdEnd() . TABLE::trEnd() . TABLE::trStart() . TABLE::tdStart();
901		}
902		if(($type == 'add') || ($type == 'copy'))
903			$pString .= MISC::p(FORM::formSubmit('Add'));
904		else
905			$pString .= MISC::p(FORM::formSubmit('Edit'));
906		$pString .= FORM::formEnd();
907		return $pString;
908	}
909// parse input into array
910	function parseStringToArray($type, $subject, $map = FALSE, $preview = FALSE)
911	{
912		if(!$subject)
913			return array();
914		if($map)
915			$this->map = $map;
916		$search = join('|', $this->map->$type);
917		$subjectArray = split("\|", $subject);
918// Loop each field string
919		$index = 0;
920		$independentFound = FALSE;
921		foreach($subjectArray as $subject)
922		{
923			$dependentPre = $dependentPost = $dependentPreAlternative =
924				$dependentPostAlternative = $singular = $plural = FALSE;
925// First grab fieldNames from the input string.
926			preg_match("/(.*)(?<!`|[a-zA-Z])($search)(?!`|[a-zA-Z])(.*)/", $subject, $array);
927			if(empty($array))
928			{
929				if($independentFound)
930				{
931					$independent['independent_' . ($index - 1)] = $subject;
932					$independentFound = FALSE;
933				}
934				else
935				{
936					$independent['independent_' . $index] = $subject;
937					$independentFound = TRUE;
938				}
939				continue;
940			}
941// At this stage, [2] is the fieldName, [1] is what comes before and [3] is what comes after.
942			$pre = $array[1];
943			$fieldName = $array[2];
944			$post = $array[3];
945// Anything in $pre enclosed in '%' characters is only to be printed if the resource has something in the
946// previous field -- replace with unique string for later preg_replace().
947			if(preg_match("/%(.*)%(.*)%|%(.*)%/U", $pre, $dependent))
948			{
949// if sizeof == 4, we have simply %*% with the significant character in [3].
950// if sizeof == 3, we have %*%*% with dependent in [1] and alternative in [2].
951				$pre = str_replace($dependent[0], "__DEPENDENT_ON_PREVIOUS_FIELD__", $pre);
952				if(sizeof($dependent) == 4)
953				{
954					$dependentPre = $dependent[3];
955					$dependentPreAlternative = '';
956				}
957				else
958				{
959					$dependentPre = $dependent[1];
960					$dependentPreAlternative = $dependent[2];
961				}
962			}
963// Anything in $post enclosed in '%' characters is only to be printed if the resource has something in the
964// next field -- replace with unique string for later preg_replace().
965			if(preg_match("/%(.*)%(.*)%|%(.*)%/U", $post, $dependent))
966			{
967				$post = str_replace($dependent[0], "__DEPENDENT_ON_NEXT_FIELD__", $post);
968				if(sizeof($dependent) == 4)
969				{
970					$dependentPost = $dependent[3];
971					$dependentPostAlternative = '';
972				}
973				else
974				{
975					$dependentPost = $dependent[1];
976					$dependentPostAlternative = $dependent[2];
977				}
978			}
979// find singular/plural alternatives in $pre and $post and replace with unique string for later preg_replace().
980			if(preg_match("/\^(.*)\^(.*)\^/U", $pre, $matchCarat))
981			{
982				$pre = str_replace($matchCarat[0], "__SINGULAR_PLURAL__", $pre);
983				$singular = $matchCarat[1];
984				$plural = $matchCarat[2];
985			}
986			else if(preg_match("/\^(.*)\^(.*)\^/U", $post, $matchCarat))
987			{
988				$post = str_replace($matchCarat[0], "__SINGULAR_PLURAL__", $post);
989				$singular = $matchCarat[1];
990				$plural = $matchCarat[2];
991			}
992// Now dump into $final[$fieldName] stripping any backticks
993			if($dependentPre)
994//				$final[$fieldName]['dependentPre'] = str_replace('`', '', $dependentPre);
995$final[$fieldName]['dependentPre'] = $dependentPre;
996			else
997				$final[$fieldName]['dependentPre'] = '';
998			if($dependentPost)
999//				$final[$fieldName]['dependentPost'] = str_replace('`', '', $dependentPost);
1000$final[$fieldName]['dependentPost'] = $dependentPost;
1001			if($dependentPreAlternative)
1002//				$final[$fieldName]['dependentPreAlternative'] =
1003//				str_replace('`', '', $dependentPreAlternative);
1004$final[$fieldName]['dependentPreAlternative'] = $dependentPreAlternative;
1005			else
1006				$final[$fieldName]['dependentPreAlternative'] = '';
1007			if($dependentPostAlternative)
1008//				$final[$fieldName]['dependentPostAlternative'] =
1009//				str_replace('`', '', $dependentPostAlternative);
1010$final[$fieldName]['dependentPostAlternative'] = $dependentPostAlternative;
1011			else
1012				$final[$fieldName]['dependentPostAlternative'] = '';
1013			if($singular)
1014//				$final[$fieldName]['singular'] = str_replace('`', '', $singular);
1015$final[$fieldName]['singular'] = $singular;
1016			else
1017				$final[$fieldName]['singular'] = '';
1018			if($plural)
1019//				$final[$fieldName]['plural'] = str_replace('`', '', $plural);
1020$final[$fieldName]['plural'] = $plural;
1021			else
1022				$final[$fieldName]['plural'] = '';
1023			$final[$fieldName]['pre'] = str_replace('`', '', $pre);
1024			$final[$fieldName]['post'] = str_replace('`', '', $post);
1025			$index++;
1026			$final[$fieldName]['pre'] = $pre;
1027			$final[$fieldName]['post'] = $post;
1028		}
1029		if(!isset($final)) // presumably no field names...
1030		{
1031			if($preview)
1032				return FALSE;
1033			$this->badInput($this->errors->text("inputError", "invalid"), $this->errorDisplay);
1034		}
1035// last element of odd number is actually ultimate punctuation
1036		if(isset($independent) && sizeof($independent) % 2)
1037			$final['ultimate'] = array_pop($independent);
1038		if(isset($independent) && !empty($independent))
1039			$final['independent'] = $independent;
1040		return $final;
1041	}
1042// write the styles to file.
1043// If !$fileName, this is called from add() and we create folder/filename immediately before writing to file.
1044// If $fileName, this comes from edit()
1045	function writeFile($fileName = FALSE)
1046	{
1047		if($fileName)
1048			$this->errorDisplay = 'editInit';
1049		else
1050			$this->errorDisplay = 'addInit';
1051		include_once("TABLE.php");
1052		include_once("../STYLEMAP.php");
1053		$this->map = new STYLEMAP();
1054		include_once("../UTF8.php");
1055		$this->utf8 = new UTF8();
1056		$types = array_keys($this->map->types);
1057// Start XML
1058		$fileString = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
1059		$fileString .= "<style xml:lang=\"en\">";
1060// Main style information
1061		$fileString .= "<info>";
1062		$fileString .= "<name>" . trim(stripslashes($this->vars['styleShortName'])) . "</name>";
1063		$fileString .= "<description>" . htmlspecialchars(trim(stripslashes($this->vars['styleLongName'])))
1064			 . "</description>";
1065// Temporary place holder
1066		$fileString .= "<language>English</language>";
1067		$fileString .= "<osbibVersion>$this->osbibVersion</osbibVersion>";
1068		$fileString .= "</info>";
1069// Start citation definition
1070		$fileString .= "<citation>";
1071		$inputArray = array(
1072			"cite_creatorStyle", "cite_creatorOtherStyle", "cite_creatorInitials",
1073			"cite_creatorFirstName", "cite_twoCreatorsSep", "cite_creatorSepFirstBetween",
1074			"cite_creatorListSubsequentAbbreviation", "cite_creatorSepNextBetween",
1075			"cite_creatorSepNextLast", "cite_creatorList", "cite_creatorListMore",
1076			"cite_creatorListLimit", "cite_creatorListAbbreviation", "cite_creatorUppercase",
1077			"cite_creatorListSubsequentAbbreviationItalic", "cite_creatorListAbbreviationItalic",
1078			"cite_creatorListSubsequent", "cite_creatorListSubsequentMore",
1079			"cite_creatorListSubsequentLimit", "cite_consecutiveCreator", "cite_consecutiveCreatorSep",
1080			"cite_template", "cite_useInitials", "cite_consecutiveCitationSep", "cite_yearFormat",
1081			"cite_pageFormat", "cite_templateSuperscript", "cite_ambiguousName", "cite_ambiguousMore",
1082			"cite_ambiguousTitle", "cite_ambiguousYear", "cite_ibid", "cite_idem", "cite_opCit",
1083			"cite_ambiguousNameFormat", "cite_ambiguousYearFormat", "cite_footnotePagePosition",
1084			"cite_footnotePageTemplate", "cite_ibidPage",  "cite_footnoteStyle",
1085		);
1086		foreach($inputArray as $input)
1087		{
1088			if(isset($this->vars[$input]))
1089			{
1090				$split = split("_", $input, 2);
1091				$elementName = $split[1];
1092				$fileString .= "<$elementName>" .
1093					htmlspecialchars(stripslashes($this->vars[$input])) . "</$elementName>";
1094			}
1095		}
1096		$fileString .= "</citation>";
1097// Start bibliography
1098		$fileString .= "<bibliography>";
1099// Common section defining how authors, titles etc. are formatted
1100		$fileString .= "<common>";
1101		$inputArray = array(
1102// style
1103			"style_titleCapitalization", "style_primaryCreatorFirstStyle",
1104			"style_primaryCreatorOtherStyle", "style_primaryCreatorInitials",
1105			"style_primaryCreatorFirstName", "style_otherCreatorFirstStyle",
1106			"style_otherCreatorOtherStyle", "style_otherCreatorInitials", "style_dayFormat",
1107			"style_otherCreatorFirstName", "style_primaryCreatorList", "style_otherCreatorList",
1108			"style_primaryCreatorListAbbreviationItalic", "style_otherCreatorListAbbreviationItalic",
1109			"style_monthFormat", "style_editionFormat", "style_primaryCreatorListMore",
1110			"style_primaryCreatorListLimit", "style_dateFormat",
1111			"style_primaryCreatorListAbbreviation", "style_otherCreatorListMore",
1112			"style_runningTimeFormat", "style_primaryCreatorRepeatString", "style_primaryCreatorRepeat",
1113			"style_otherCreatorListLimit", "style_otherCreatorListAbbreviation", "style_pageFormat",
1114			"style_editorSwitch", "style_editorSwitchIfYes", "style_primaryCreatorUppercase",
1115			"style_otherCreatorUppercase", "style_primaryCreatorSepFirstBetween",
1116			"style_primaryCreatorSepNextBetween", "style_primaryCreatorSepNextLast",
1117			"style_otherCreatorSepFirstBetween", "style_otherCreatorSepNextBetween",
1118			"style_otherCreatorSepNextLast", "style_primaryTwoCreatorsSep", "style_otherTwoCreatorsSep",
1119			"style_userMonth_1", "style_userMonth_2", "style_userMonth_3", "style_userMonth_4",
1120			"style_userMonth_5", "style_userMonth_6", "style_userMonth_7", "style_userMonth_8",
1121			"style_userMonth_9", "style_userMonth_10", "style_userMonth_11", "style_userMonth_12",
1122			"style_dateRangeDelimit1", "style_dateRangeDelimit2", "style_dateRangeSameMonth",
1123		);
1124		foreach($inputArray as $input)
1125		{
1126			if(isset($this->vars[$input]))
1127			{
1128				$split = split("_", $input, 2);
1129				$elementName = $split[1];
1130				$fileString .= "<$elementName>" .
1131					htmlspecialchars(stripslashes($this->vars[$input])) . "</$elementName>";
1132			}
1133		}
1134		$fileString .= "</common>";
1135// Resource types
1136		foreach($types as $key)
1137		{
1138			$type = 'style_' . $key;
1139			$input = trim(stripslashes($this->vars[$type]));
1140// remove newlines etc.
1141			$input = preg_replace("/\r|\n|\015|\012/", "", $input);
1142			$fileString .= "<resource name=\"$key\">";
1143			$fileString .= $this->arrayToXML($this->parseStringToArray($key, $input), $type);
1144			$fileString .= "</resource>";
1145		}
1146		$fileString .= "</bibliography>";
1147		$fileString .= "</style>";
1148		if(!$fileName) // called from add()
1149		{
1150// Create folder with lowercase styleShortName
1151			$dirName = OSBIB_STYLE_DIR . "/" . strtolower(trim($this->vars['styleShortName']));
1152			if(!mkdir($dirName))
1153				$this->badInput($error = $this->errors->text("file", "folder"), $this->errorDisplay);
1154			$fileName = $dirName . "/" . strtoupper(trim($this->vars['styleShortName'])) . ".xml";
1155		}
1156		if(!$fp = fopen("$fileName", "w"))
1157			$this->badInput($this->errors->text("file", "write", ": $fileName"), $this->errorDisplay);
1158		if(!fputs($fp, $this->utf8->encodeUtf8($fileString)))
1159			$this->badInput($this->errors->text("file", "write", ": $fileName"), $this->errorDisplay);
1160		fclose($fp);
1161	}
1162// Parse array to XML
1163	function arrayToXML($array, $type)
1164	{
1165		$fileString = '';
1166		if(empty($array)) // no style definition for this type so set fallback
1167		{
1168			$name = $type . "_generic";
1169			if(!isset($this->vars[$name]))
1170				$name = "genericMisc";
1171			else
1172				$name = $this->vars[$name];
1173			return "<fallbackstyle>$name</fallbackstyle>";
1174		}
1175		foreach($array as $key => $value)
1176		{
1177			$fileString .= "<$key>";
1178			if(is_array($value))
1179				$fileString .= $this->arrayToXML($value, $type);
1180			else
1181				$fileString .= htmlspecialchars($value);
1182			$fileString .= "</$key>";
1183		}
1184		return $fileString;
1185	}
1186// validate input
1187	function validateInput($type)
1188	{
1189		$error = FALSE;
1190		if(($type == 'add') || ($type == 'edit'))
1191		{
1192			$array = array("style_titleCapitalization", "style_primaryCreatorFirstStyle",
1193				"style_primaryCreatorOtherStyle", "style_primaryCreatorInitials",
1194				"style_primaryCreatorFirstName", "style_otherCreatorFirstStyle", "style_dateFormat",
1195				"style_otherCreatorOtherStyle", "style_otherCreatorInitials", "style_pageFormat",
1196				"style_otherCreatorFirstName", "style_primaryCreatorList", "style_dayFormat",
1197				"style_otherCreatorList", "style_monthFormat", "style_editionFormat",
1198				"style_runningTimeFormat", "style_editorSwitch", "style_primaryCreatorRepeat",
1199				"style_dateRangeSameMonth",
1200		"cite_creatorStyle", "cite_creatorOtherStyle", "cite_creatorInitials", "cite_creatorFirstName",
1201		"cite_twoCreatorsSep", "cite_creatorSepFirstBetween", "cite_creatorListSubsequentAbbreviation",
1202		"cite_creatorSepNextBetween", "cite_creatorSepNextLast",
1203		"cite_creatorList", "cite_creatorListMore", "cite_creatorListLimit", "cite_creatorListAbbreviation",
1204		"cite_creatorListSubsequent", "cite_creatorListSubsequentMore", "cite_creatorListSubsequentLimit",
1205		"cite_consecutiveCreator", "cite_consecutiveCreatorSep", "cite_template",
1206		"cite_consecutiveCitationSep", "cite_yearFormat", "cite_pageFormat", "cite_footnoteStyle",
1207		);
1208
1209			$this->writeSession($array);
1210			if(!trim($this->vars['styleShortName']))
1211				$error = $this->errors->text("inputError", "missing");
1212			else
1213				$this->session->setVar("style_shortName", trim($this->vars['styleShortName']));
1214			if(preg_match("/\s/", trim($this->vars['styleShortName'])))
1215				$error = $this->errors->text("inputError", "invalid");
1216			else if(!trim($this->vars['styleLongName']))
1217				$error = $this->errors->text("inputError", "missing");
1218			else if(!trim($this->vars['cite_template']))
1219				$error = $this->errors->text("inputError", "missing");
1220			else if(!trim($this->vars['style_genericBook']))
1221				$error = $this->errors->text("inputError", "missing");
1222			else if(!trim($this->vars['style_genericArticle']))
1223				$error = $this->errors->text("inputError", "missing");
1224			else if(!trim($this->vars['style_genericMisc']))
1225				$error = $this->errors->text("inputError", "missing");
1226			foreach($array as $input)
1227			{
1228				if(!isset($this->vars[$input]))
1229					return $this->errors->text("inputError", "missing");
1230			}
1231// If xxx_creatorList set to 1 (limit), we must have style_xxxCreatorListMore and xxx_CreatorListLimit. The
1232// latter two must be numeric.
1233			if(($this->vars['style_primaryCreatorList'] == 1) &&
1234				(!trim($this->vars['style_primaryCreatorListLimit']) ||
1235				(!$this->vars['style_primaryCreatorListMore'])))
1236					$error = $this->errors->text("inputError", "missing");
1237			else if(($this->vars['style_primaryCreatorList'] == 1) &&
1238				(!is_numeric($this->vars['style_primaryCreatorListLimit']) ||
1239				!is_numeric($this->vars['style_primaryCreatorListMore'])))
1240					$error = $this->errors->text("inputError", "nan");
1241			else if(($this->vars['style_otherCreatorList'] == 1) &&
1242				(!trim($this->vars['style_otherCreatorListLimit']) ||
1243				(!$this->vars['style_otherCreatorListMore'])))
1244					$error = $this->errors->text("inputError", "missing");
1245			else if(($this->vars['style_otherCreatorList'] == 1) &&
1246				(!is_numeric($this->vars['style_otherCreatorListLimit']) ||
1247				!is_numeric($this->vars['style_otherCreatorListMore'])))
1248					$error = $this->errors->text("inputError", "nan");
1249			else if(($this->vars['cite_creatorList'] == 1) &&
1250				(!trim($this->vars['cite_creatorListLimit']) ||
1251				(!$this->vars['cite_creatorListMore'])))
1252					$error = $this->errors->text("inputError", "missing");
1253			else if(($this->vars['cite_creatorList'] == 1) &&
1254				(!is_numeric($this->vars['cite_creatorListLimit']) ||
1255				!is_numeric($this->vars['cite_creatorListMore'])))
1256					$error = $this->errors->text("inputError", "nan");
1257			else if(($this->vars['cite_creatorListSubsequent'] == 1) &&
1258				(!trim($this->vars['cite_creatorListSubsequentLimit']) ||
1259				(!$this->vars['cite_creatorListSubsequentMore'])))
1260					$error = $this->errors->text("inputError", "missing");
1261			else if(($this->vars['cite_creatorListSubsequent'] == 1) &&
1262				(!is_numeric($this->vars['cite_creatorListSubsequentLimit']) ||
1263				!is_numeric($this->vars['cite_creatorListSubsequentMore'])))
1264					$error = $this->errors->text("inputError", "nan");
1265			else if(($this->vars['style_editorSwitch'] == 1) &&
1266				!trim($this->vars['style_editorSwitchIfYes']))
1267					$error = $this->errors->text("inputError", "missing");
1268			else if(($this->vars['style_primaryCreatorRepeat'] == 2) &&
1269				!trim($this->vars['style_primaryCreatorRepeatString']))
1270					$error = $this->errors->text("inputError", "missing");
1271			else if($this->vars['style_monthFormat'] == 2)
1272			{
1273				for($i = 1; $i <= 12; $i++)
1274				{
1275					if(!trim($this->vars["style_userMonth_$i"]))
1276						$error = $this->errors->text("inputError", "missing");
1277				}
1278			}
1279		}
1280		if($type == 'add')
1281		{
1282			if(preg_match("/\s/", trim($this->vars['styleShortName'])))
1283				$error = $this->errors->text("inputError", "invalid");
1284			else if(array_key_exists(strtoupper(trim($this->vars['styleShortName'])), $this->styles))
1285				$error = $this->errors->text("inputError", "styleExists");
1286		}
1287		else if($type == 'editDisplay')
1288		{
1289			if(!array_key_exists('editStyleFile', $this->vars))
1290				$error = $this->errors->text("inputError", "missing");
1291		}
1292		if($error)
1293			return $error;
1294// FALSE means validated input
1295		return FALSE;
1296	}
1297// Write session
1298	function writeSession($array)
1299	{
1300		include_once("TABLE.php");
1301		include_once("../STYLEMAP.php");
1302		$this->map = new STYLEMAP();
1303		$types = array_keys($this->map->types);
1304		if(trim($this->vars['styleLongName']))
1305			$this->session->setVar("style_longName", base64_encode(trim($this->vars['styleLongName'])));
1306// other resource types
1307		foreach($types as $key)
1308		{
1309			$type = 'style_' . $key;
1310			if(trim($this->vars[$type]))
1311				$this->session->setVar($type, base64_encode(trim($this->vars[$type])));
1312// Fallback styles
1313			if(($key != 'genericBook') && ($key != 'genericArticle') && ($key != 'genericMisc'))
1314			{
1315				$name = $type . "_generic";
1316				$this->session->setVar($name, base64_encode(trim($this->vars[$name])));
1317			}
1318		}
1319// Other values. $array parameter is required, other optional input is added to the array
1320		$array[] = "style_primaryCreatorSepBetween";
1321		$array[] = "style_primaryCreatorSepLast";
1322		$array[] = "style_otherCreatorSepBetween";
1323		$array[] = "style_otherCreatorSepLast";
1324		$array[] = "style_primaryCreatorListMore";
1325		$array[] = "style_primaryCreatorListLimit";
1326		$array[] = "style_primaryCreatorListAbbreviation";
1327		$array[] = "style_otherCreatorListMore";
1328		$array[] = "style_otherCreatorListLimit";
1329		$array[] = "style_otherCreatorListAbbreviation";
1330		$array[] = "style_editorSwitchIfYes";
1331		$array[] = "style_primaryCreatorUppercase";
1332		$array[] = "style_otherCreatorUppercase";
1333		$array[] = "style_primaryTwoCreatorsSep";
1334		$array[] = "style_primaryCreatorSepFirstBetween";
1335		$array[] = "style_primaryCreatorSepNextBetween";
1336		$array[] = "style_primaryCreatorSepNextLast";
1337		$array[] = "style_otherTwoCreatorsSep";
1338		$array[] = "style_otherCreatorSepFirstBetween";
1339		$array[] = "style_otherCreatorSepNextBetween";
1340		$array[] = "style_otherCreatorSepNextLast";
1341		$array[] = "style_primaryCreatorRepeatString";
1342		$array[] = "style_primaryCreatorListAbbreviationItalic";
1343		$array[] = "style_otherCreatorListAbbreviationItalic";
1344		$array[] = "style_userMonth_1";
1345		$array[] = "style_userMonth_2";
1346		$array[] = "style_userMonth_3";
1347		$array[] = "style_userMonth_4";
1348		$array[] = "style_userMonth_5";
1349		$array[] = "style_userMonth_6";
1350		$array[] = "style_userMonth_7";
1351		$array[] = "style_userMonth_8";
1352		$array[] = "style_userMonth_9";
1353		$array[] = "style_userMonth_10";
1354		$array[] = "style_userMonth_11";
1355		$array[] = "style_userMonth_12";
1356		$array[] = "style_dateRangeDelimit1";
1357		$array[] = "style_dateRangeDelimit2";
1358		$array[] = "cite_useInitials";
1359		$array[] = "cite_creatorUppercase";
1360		$array[] = "cite_creatorListAbbreviationItalic";
1361		$array[] = "cite_creatorListSubsequentAbbreviationItalic";
1362		$array[] = "cite_templateSuperscript";
1363		$array[] = "cite_ambiguousName";
1364		$array[] = "cite_ambiguousMore";
1365		$array[] = "cite_ambiguousTitle";
1366		$array[] = "cite_ambiguousYear";
1367		$array[] = "cite_ambiguousNameFormat";
1368		$array[] = "cite_ambiguousYearFormat";
1369		$array[] = "cite_ibid";
1370		$array[] = "cite_idem";
1371		$array[] = "cite_opCit";
1372		$array[] = "cite_footnotePagePosition";
1373		$array[] = "cite_footnotePageTemplate";
1374		$array[] = "cite_ibidPage";
1375		foreach($array as $input)
1376		{
1377			if(isset($this->vars[$input]))
1378				$this->session->setVar($input, base64_encode($this->vars[$input]));
1379			else
1380				$this->session->delVar($input);
1381		}
1382	}
1383// bad Input function
1384	function badInput($error, $method)
1385	{
1386		include_once("CLOSE.php");
1387		new CLOSE($this->$method($error));
1388	}
1389}
1390?>
1391
1392