function generateCitations($result, $rowsFound, $query, $queryURL, $showQuery, $showLinks, $rowOffset, $showRows, $previousOffset, $nextOffset, $wrapResults, $nothingChecked, $citeStyle, $citeOrder, $citeType, $orderBy, $headerMsg, $userID, $viewType) { global $contentTypeCharset; // these variables are defined in 'ini.inc.php' global $defaultCiteStyle; global $client; global $userOptionsArray; // get all user options for the current user: // (note that '$userOptionsArray' is made globally available) $userOptionsArray = getUserOptions($userID); // function 'getUserOptions()' is defined in 'include.inc.php' // if the query has results ... if ($rowsFound > 0) { // Save the current Citation view query to a session variable: // saveSessionVariable("lastCitationViewQuery", $query); // fetch the name of the citation style file that's associated with the style given in '$citeStyle': $citeStyleFile = getStyleFile($citeStyle); // function 'getStyleFile()' is defined in 'include.inc.php' if (empty($citeStyleFile)) { $citeStyle = $defaultCiteStyle; // if the given cite style could not be found, we'll use the default cite style which is defined by the '$defaultCiteStyle' variable in 'ini.inc.php' $citeStyleFile = getStyleFile($citeStyle); } // include the found citation style file *once*: include_once "cite/" . $citeStyleFile; // fetch the name of the citation format file that's associated with the format given in '$citeType': $citeFormatFile = getFormatFile($citeType, "cite"); // function 'getFormatFile()' is defined in 'include.inc.php()' if (empty($citeFormatFile)) { if (preg_match("/^cli/i", $client)) { // if the query originated from a command line client such as the refbase CLI clients ("cli-refbase-1.1", "cli-refbase_import-1.0") $citeType = "ASCII"; } else { $citeType = "html"; } $citeFormatFile = getFormatFile($citeType, "cite"); } // include the found citation format file *once*: include_once "cite/" . $citeFormatFile; $citationData = citeRecords($result, $rowsFound, $query, $queryURL, $showQuery, $showLinks, $rowOffset, $showRows, $previousOffset, $nextOffset, $wrapResults, $citeStyle, $citeOrder, $citeType, $orderBy, $headerMsg, $userID, $viewType); if (preg_match("/^RTF\$/i", $citeType)) { $citeContentType = "application/rtf"; $citeFileName = "citations.rtf"; } elseif (preg_match("/^PDF\$/i", $citeType)) { $citeContentType = "application/pdf"; $citeFileName = "citations.pdf"; } elseif (preg_match("/^LaTeX\$/i", $citeType)) { $citeContentType = "application/x-latex"; $citeFileName = "citations.tex"; } elseif (preg_match("/^LaTeX \\.bbl\$/i", $citeType)) { $citeContentType = "application/x-latex"; $citeFileName = "citations.bbl"; } elseif (preg_match("/^Markdown\$/i", $citeType)) { $citeContentType = "text/plain"; $citeFileName = "citations.txt"; } elseif (preg_match("/^ASCII\$/i", $citeType)) { $citeContentType = "text/plain"; $citeFileName = "citations.txt"; } else { $citeContentType = "text/html"; $citeFileName = "citations.html"; } if (!preg_match("/^html\$/i", $citeType)) { // set the appropriate mimetype & set the character encoding to the one given in '$contentTypeCharset' (which is defined in 'ini.inc.php'): setHeaderContentType($citeContentType, $contentTypeCharset); } // function 'setHeaderContentType()' is defined in 'include.inc.php' if (preg_match("/^application/i", $citeContentType)) { // instruct the browser to download the resulting output as file: header('Content-Disposition: attachment; filename="' . $citeFileName . '"'); } // Note that this doesn't seem to work with all browsers (notably not with Safari & OmniWeb on MacOSX Panther, but it does work with Mozilla & Camino as well as Safari on Tiger) echo $citationData; } else { $nothingFoundFeedback = nothingFound($nothingChecked); echo $nothingFoundFeedback; } }
list($errors, $sourceText) = fetchDataFromCrossRef($idArray, $sourceFormat); // function 'fetchDataFromCrossRef()' is defined in 'import.inc.php' // In case of a latin1-based database, attempt to convert UTF-8 data to refbase markup & latin1: if ($contentTypeCharset == "ISO-8859-1" and detectCharacterEncoding($sourceText) == "UTF-8") { $sourceText = convertToCharacterEncoding("ISO-8859-1", "TRANSLIT", $sourceText, "UTF-8"); } } else { $sourceFormat = "Pubmed Medline"; } } } // -------------------------------------------------------------------- // PARSE SOURCE TEXT: if (!empty($sourceText) and !empty($sourceFormat)) { // fetch the path/name of the import format file that's associated with the import format given in '$sourceFormat': $importFormatFile = getFormatFile($sourceFormat, "import"); // function 'getFormatFile()' is defined in 'include.inc.php()' if (!empty($importFormatFile)) { // Get all cite keys specified by the current user and build an array of uniquified cite keys ('$citeKeysArray') // which is used to ensure uniqueness of generated cite keys among all imported records as well as the user's existing records: $userCiteKeysArray = getUserCiteKeys($loginUserID); // '$loginUserID' is provided as session variable on login; function 'getUserCiteKeys()' is defined in 'include.inc.php' // Get all user options for the current user (which is required by function 'generateCiteKey()' // that, in turn, is called below & from within the 'addRecords()' function): $userOptionsArray = getUserOptions($loginUserID); // function 'getUserOptions()' is defined in 'include.inc.php' // Include the found import format file *once*: include_once "import/" . $importFormatFile; // Parse records from the specified import format: // function 'importRecords()' is defined in the import format file given in '$importFormatFile' (which, in turn, must reside in the 'import' directory of the refbase root directory) // NOTE: see note above below the 'fetchDataFromArXiv()' function