function loadEditSession($copy = FALSE) { // Clear previous style in session $this->session->clearArray("style"); $this->session->clearArray("cite"); $this->session->clearArray("footnote"); include_once "../PARSEXML.php"; $parseXML = new PARSEXML(); $styleMap = new STYLEMAP(); $resourceTypes = array_keys($styleMap->types); $this->session->setVar('editStyleFile', $this->vars['editStyleFile']); $dir = strtolower($this->vars['editStyleFile']); $fileName = $this->vars['editStyleFile'] . ".xml"; if ($fh = fopen(OSBIB_STYLE_DIR . "/" . $dir . "/" . $fileName, "r")) { list($info, $citation, $footnote, $common, $types) = $parseXML->extractEntries($fh); if (!$copy) { $this->session->setVar("style_shortName", $this->vars['editStyleFile']); $this->session->setVar("style_longName", base64_encode($info['description'])); } foreach ($citation as $array) { if (array_key_exists('_NAME', $array) && array_key_exists('_DATA', $array)) { $this->session->setVar("cite_" . $array['_NAME'], base64_encode(htmlspecialchars($array['_DATA']))); } } $this->arrayToTemplate($footnote, TRUE); foreach ($resourceTypes as $type) { $type = 'footnote_' . $type; $sessionKey = $type . 'Template'; if (!empty($this->{$type})) { $this->session->setVar($sessionKey, base64_encode(htmlspecialchars($this->{$type}))); } unset($this->{$type}); } foreach ($common as $array) { if (array_key_exists('_NAME', $array) && array_key_exists('_DATA', $array)) { $this->session->setVar("style_" . $array['_NAME'], base64_encode(htmlspecialchars($array['_DATA']))); } } $this->arrayToTemplate($types); foreach ($resourceTypes as $type) { $sessionKey = 'style_' . $type; if (!empty($this->{$type})) { $this->session->setVar($sessionKey, base64_encode(htmlspecialchars($this->{$type}))); } if (array_key_exists($type, $this->fallback)) { $sessionKey .= "_generic"; $this->session->setVar($sessionKey, base64_encode($this->fallback[$type])); } } } else { $this->badInput($this->errors->text("file", "read")); } }
/** * Read the chosen bibliographic style and create arrays. * * @author Mark Grimshaw * @version 1 * * @param $stylePath The path where the styles are. * @param $style The requested bibliographic output style. * @return BOOLEAN */ function loadStyle($stylePath, $style) { //05/05/2005 G.GARDEY: add a last "/" to $stylePath if not present. $stylePath = trim($stylePath); if ($stylePath[strlen($stylePath) - 1] != "/") { $stylePath .= "/"; } $uc = $stylePath . strtolower($style) . "/" . strtolower($style) . ".xml"; $lc = $stylePath . strtolower($style) . "/" . strtoupper($style) . ".xml"; $styleFile = file_exists($uc) ? $uc : $lc; if (!($fh = fopen($styleFile, "r"))) { return array(FALSE, FALSE, FALSE, FALSE); } include_once $this->dir . "PARSEXML.php"; $parseXML = new PARSEXML(); list($info, $citation, $common, $types) = $parseXML->extractEntries($fh); fclose($fh); return array($info, $citation, $common, $types); }