Пример #1
0
 /**
  * Find for all papers in the local database the related papers and add them to the database.
  * Warning: This function does a lot of API calls.
  */
 function expand()
 {
     $mendeley = new Mendeley(API_KEY);
     $docs_in_db = $this->get_all_papers();
     foreach ($docs_in_db as $doc) {
         $uuid1 = $doc->uuid;
         $uuids = $mendeley->get_related_uuids($uuid1);
         foreach ($uuids as $uuid2) {
             if (!$this->in_db($uuid2)) {
                 $paper2 = $mendeley->get_document($uuid2);
                 $this->to_db($paper2);
             }
             if (!$this->sim_in_db($uuid1, $uuid2)) {
                 $this->sim_to_db($uuid1, $uuid2);
                 //echo '.';
                 //flush();
             }
         }
         //echo '<br>';
         //flush();
     }
 }
Пример #2
0
# HS 2011-06-15
##########################################################
require_once 'config.inc.php';
require_once 'functions.inc.php';
require_once 'Mendeley.php';
require_once 'LitDb.php';
$mendeley = new Mendeley(API_KEY);
if (isset($_GET['uuid']) && $_GET['uuid'] != "") {
    $uuid = $_GET['uuid'];
    is_uuid($uuid) or die('invalid uuid');
    if (isset($_GET['format']) && $_GET['format'] == "raw") {
        $json = $mendeley->fetch_related($uuid);
        format_json($json);
    } else {
        html_header();
        $uuids = $mendeley->get_related_uuids($uuid);
        if (count($uuids) == 0) {
            echo 'No documents found';
            link_home();
        } else {
            $paper = $mendeley->get_document($uuid);
            $db = new LitDb(DB_PATH);
            if (!$db->in_db($uuid)) {
                $db->to_db($paper);
            }
            link_home();
            echo '<h3>Related documents for ' . $uuid . '</h3>';
            foreach ($uuids as $uuid2) {
                $paper2 = $mendeley->get_document($uuid2);
                if (!$db->in_db($uuid2)) {
                    $db->to_db($paper2);