function returnDiagnostic($diagCode, $diagDetails) { global $recordSchema; global $exportContentType; global $contentTypeCharset; // '$contentTypeCharset' is defined in 'ini.inc.php' global $exportStylesheet; // Set the appropriate mimetype & set the character encoding to the one given in '$contentTypeCharset': setHeaderContentType($exportContentType, $contentTypeCharset); // function 'setHeaderContentType()' is defined in 'include.inc.php' if (preg_match("/^srw([ _]?(mods|dc))?([ _]?xml)?\$/i", $recordSchema)) { // Return SRW diagnostics (i.e. SRW error information) wrapped into SRW XML ('searchRetrieveResponse'): echo srwDiagnostics($diagCode, $diagDetails, $exportStylesheet); } else { // Return OpenSearch diagnostics (i.e. OpenSearch error information) wrapped into OpenSearch Atom XML: echo openSearchDiagnostics($diagCode, $diagDetails, $exportStylesheet); } // function 'openSearchDiagnostics()' is defined in 'opensearch.inc.php' }
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; } }
$displayType = ""; // if the 'submit' parameter is empty, this will produce the default view $exportFormat = ""; // if no export format was given, 'show.php' will use the default export format which is defined by the '$defaultExportFormat' variable in 'ini.inc.php' $citeType = "html"; } // For the context of 'unapi.php' we set some parameters explicitly: $exportType = "file"; $citeOrder = "author"; $citeStyle = ""; // if no cite style was given, 'show.php' will use the default cite style which is defined by the '$defaultCiteStyle' variable in 'ini.inc.php' $exportContentType = "application/xml"; // this will be used for unAPI XML response output // ------------------------------------------------------------------------------------------------------------------- // Check if the correct parameters have been passed: if (empty($unapiID) or !empty($unapiID) and !isset($_REQUEST['format'])) { // if 'unapi.php' was called without the 'format' parameter, we'll return an appropriate unAPI XML response: // Set the appropriate mimetype & set the character encoding to the one given // in '$contentTypeCharset' (which is defined in 'ini.inc.php'): setHeaderContentType($exportContentType, $contentTypeCharset); // function 'setHeaderContentType()' is defined in 'include.inc.php' echo unapiExplainResponse($unapiID); // function 'unapiExplainResponse()' is defined in 'unapi.inc.php' } else { // Build the correct query URL: // (we skip unnecessary parameters here since 'show.php' will use it's default values for them) $queryURL = "&submit=" . $displayType . "&exportFormat=" . rawurlencode($exportFormat) . "&exportType=" . $exportType . "&citeOrder=" . $citeOrder . "&citeStyle=" . rawurlencode($citeStyle) . "&citeType=" . $citeType; // call 'show.php' with the correct query URL in order to output record details in the requested format: header("Location: {$unapiID}{$queryURL}"); } // -------------------------------------------------------------------------------------------------------------------
function returnDiagnostic($diagCode, $diagDetails) { global $exportContentType; global $contentTypeCharset; // '$contentTypeCharset' is defined in 'ini.inc.php' global $exportStylesheet; // use an appropriate default stylesheet: if ($exportStylesheet == "DEFAULT") { $exportStylesheet = ""; } // TODO: create a stylesheet ('diag2html.xsl') that's appropriate for SRW diagnostics // Set the appropriate mimetype & set the character encoding to the one given in '$contentTypeCharset': setHeaderContentType($exportContentType, $contentTypeCharset); // function 'setHeaderContentType()' is defined in 'include.inc.php' // Return SRW diagnostics (i.e. SRW error information) wrapped into SRW XML ('searchRetrieveResponse'): echo srwDiagnostics($diagCode, $diagDetails, $exportStylesheet); // function 'srwDiagnostics()' is defined in 'srwxml.inc.php' }
// redirect to main page ('index.php') which will display the error message stored within the 'HeaderString' session variable exit; // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> !EXIT! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< } // -------------------------------------------------------------------- // (1) OPEN CONNECTION, (2) SELECT DATABASE connectToMySQLDatabase(); // function 'connectToMySQLDatabase()' is defined in 'include.inc.php' // -------------------------------------------------------------------- // (3) RUN the query on the database through the connection: $result = queryMySQLDatabase($query); // function 'queryMySQLDatabase()' is defined in 'include.inc.php' // find out how many rows are available: $rowsFound = @mysql_num_rows($result); // construct a meaningful channel description based on the specified 'WHERE' clause: $rssChannelDescription = "Displays all newly added records where " . explainSQLQuery($sanitizedWhereClause) . "."; // function 'explainSQLQuery()' is defined in 'include.inc.php' // Generate RSS XML data from the result set (upto the limit given in '$showRows'): $rssFeed = generateRSS($result, $showRows, $rssChannelDescription); // function 'generateRSS()' is defined in 'include.inc.php' // -------------------------------------------------------------------- // (4) DISPLAY search results as RSS feed: // set mimetype to 'application/rss+xml' and character encoding to the one given in '$contentTypeCharset' (which is defined in 'ini.inc.php'): setHeaderContentType("application/rss+xml", $contentTypeCharset); // function 'setHeaderContentType()' is defined in 'include.inc.php' echo $rssFeed; // -------------------------------------------------------------------- // (5) CLOSE the database connection: disconnectFromMySQLDatabase(); // function 'disconnectFromMySQLDatabase()' is defined in 'include.inc.php' // --------------------------------------------------------------------