Exemplo n.º 1
0
//       permissions for the *anonymous* user (userID = 0) here
$anonymousUserPermissionsArray = getPermissions(0, "user", false);
// function 'getPermissions()' is defined in 'include.inc.php'
if (isset($_SESSION['user_permissions']) and $anonymousUserPermissionsArray["allow_cite"] == "yes") {
    // NOTE: - as an alternative to the below code block, we could also fetch citations via an AJAX event and let the JavaScript functions in file 'javascript/show.js' ' write the results into the '<div id="includerefs">' section;
    //         to do so:
    //           1. pass the JavaScript file 'javascript/show.js' as the 6th parameter to the 'displayHTMLhead' function (see above)
    //           2. call JavaScript function 'showRefs()' via an 'onload' event in the body tag of function 'displayHTMLhead()' in 'includes/header.inc.php':  onload="showRefs('records=all&amp;showRows=5&amp;citeOrder=creation-date')"
    //              TODO: function 'displayHTMLhead()' should get modified so that it only calls the 'onload' event if necessary/requested
    //
    //       - the above alternative works within the user's current session, i.e. the links section will contain any edit or file links (if the user has appropriate permissions);
    //         however, the below method (which uses function 'fetchDataFromURL()') does NOT maintain the user's current session (and adding the user's current PHPSESSID doesn't seem to work ?:-/)
    // Prepare a query that will fetch a HTML table with the most recently added publications (as formatted citations):
    $recentAdditionsQueryURL = $databaseBaseURL . "show.php?records=all&submit=Cite&showRows=5&citeOrder=creation-date&client=inc-refbase-1.0&wrapResults=0";
    // variable '$databaseBaseURL' is defined in 'ini.inc.php'
    $recentAdditionsResultTable = fetchDataFromURL($recentAdditionsQueryURL);
    // function 'fetchDataFromURL()' is defined in 'include.inc.php'
}
if (!empty($recentAdditionsResultTable)) {
    echo $recentAdditionsResultTable;
} else {
    ?>

				<a href="show.php?records=all&amp;citeOrder=creation-date"><?php 
    echo $loc["ShowAll"];
    ?>
</a><?php 
}
?>

			</div>
Exemplo n.º 2
0
function fetchDataFromCrossRef($itemArray, $sourceFormat = "CrossRef XML")
{
    global $errors;
    global $crossRefReqDat;
    $sourceText = "";
    if (!empty($itemArray)) {
        // Remove any duplicate IDs:
        $itemArray = array_unique($itemArray);
        // Define response format:
        //			if (preg_match("/^CrossRef XML$/i", $sourceFormat))
        //				$fetchType = "unixref";
        //			else // by default, we'll use the "unixref XML" format
        $fetchType = "unixref";
        foreach ($itemArray as $item) {
            // Build query URL:
            $sourceURL = "http://www.crossref.org/openurl/" . "?noredirect=true" . "&format=" . $fetchType;
            if (!empty($crossRefReqDat)) {
                $sourceURL .= "&pid=" . rawurlencode($crossRefReqDat);
            }
            if (preg_match("#^10\\.\\d{4}/\\S+\$#", $item)) {
                // '$item' is a DOI
                $sourceURL .= "&id=" . rawurlencode("doi:" . $item);
            } else {
                // otherwise we assume a full OpenURL context object // TODO: verify OpenURL!?
                $sourceURL .= "&" . $item;
            }
            // Perform query:
            $sourceText .= fetchDataFromURL($sourceURL);
            // function 'fetchDataFromURL()' is defined in 'include.inc.php'
        }
    }
    return array($errors, $sourceText);
}