if ($exportStylesheet == "DEFAULT") { $exportStylesheet = ""; } // TODO: finish 'opensearch2xhtml.xsl' $citeOrder = ""; // TODO/NOTE: '$citeOrder="creation-date"' would sort records such that newly added/edited records get listed top of the list, but then Atom links to alternate formats (such as HTML or SRW XML) would be mismatched! } // ------------------------------------------------------------------------------------------------------------------- // Handle the special index 'main_fields': if (!(preg_match("/^suggest\$/i", $operation) and preg_match("/^(html|json)\$/i", $recordSchema)) and preg_match("/^main_fields( +(all|any|exact|within) +| *(<>|<=|>=|<|>|=) *)/i", $cqlQuery)) { // if the 'main_fields' index is used in conjunction with a non-"suggest" operation $cqlQuery = preg_replace("/^main_fields(?= +(all|any|exact|within) +| *(<>|<=|>=|<|>|=) *)/i", "cql.serverChoice", $cqlQuery); } // replace 'main_fields' index (which, ATM, is only supported for search suggestions) with 'cql.serverChoice' // Parse CQL query: $searchArray = parseCQL("1.1", $cqlQuery, $operation); // function 'parseCQL()' is defined in 'webservice.inc.php' // Build SQL WHERE clause: $query = ""; // NOTE: although we don't supply a full SQL query here, the variable MUST be named '$query' to have function 'appendToWhereClause()' work correctly if (!empty($searchArray)) { appendToWhereClause($searchArray); } // function 'appendToWhereClause()' is defined in 'include.inc.php' // ------------------------------------------------------------------------------------------------------------------- // Check that mandatory parameters have been passed: // - if 'opensearch.php' was called with 'operation=explain', we'll return an appropriate OpenSearch description document: if (preg_match("/^explain\$/i", $operation)) { // Use an appropriate default stylesheet: if ($exportStylesheet == "DEFAULT") { $exportStylesheet = "";
} // if an unrecognized email address was given while querying a user-specific index: if (empty($userID) and $userSpecificIndex) { returnDiagnostic(3, "Couldn't map given authentication token to an existing user (expecting format: 'email=EMAIL_ADDRESS')"); // authentication error: couldn't map email address to user ID exit; } elseif (!empty($userID) and $privateIndex and (!isset($_SESSION['loginEmail']) or isset($_SESSION['loginEmail']) and $loginUserID != $userID)) { returnDiagnostic(68, "You have no permission to query or view any private data for the given email address"); // not authorised to request other user's private data exit; } } } // ------------------------------------------------------------------------------------------------------------------- // Parse CQL query: $searchArray = parseCQL($sruVersion, $sruQuery); // function 'parseCQL()' is defined in 'webservice.inc.php' // ------------------------------------------------------------------------------------------------------------------- // Check for operation and that mandatory parameters have been passed: if ($sruOperation == "explain" or !isset($_REQUEST['query']) and !isset($_REQUEST['version']) and !isset($_REQUEST['operation']) and !isset($_REQUEST['recordSchema']) and !isset($_REQUEST['recordPacking']) and !isset($_REQUEST['maximumRecords']) and !isset($_REQUEST['startRecord']) and !isset($_REQUEST['sortKeys']) and !isset($_REQUEST['recordXPath']) and !isset($_REQUEST['stylesheet']) and !isset($_REQUEST['x-info-2-auth1_0-authenticationToken'])) { // if 'sru.php' was called with 'operation=explain' -OR- without any recognized parameters, we'll return an appropriate 'explainResponse': // use an appropriate default stylesheet: if ($exportStylesheet == "DEFAULT") { $exportStylesheet = "srwExplainResponse2html.xsl"; } // 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 srwExplainResponse($exportStylesheet); // function 'srwExplainResponse()' is defined in 'srwxml.inc.php'