Ejemplo n.º 1
0
require_once 'config.inc.php';
require_once 'functions.inc.php';
require_once 'Mendeley.php';
$mendeley = new Mendeley(API_KEY);
if (isset($_GET['gid']) && $_GET['gid'] != "") {
    $gid = $_GET['gid'];
    is_mendeley_group_id($gid) or die('invalid gid');
    if (isset($_GET['format']) && $_GET['format'] == "raw") {
        $json = $mendeley->fetch_docs_in_group($gid);
        format_json($json);
    } else {
        $uuids = $mendeley->get_uuids_in_group($gid);
        if (count($uuids) == 0) {
            echo 'No documents found';
            link_home();
        } else {
            html_header();
            link_home();
            echo '<h3>Documents in group ' . $gid . '</h3>';
            foreach ($uuids as $uuid) {
                $paper = $mendeley->get_document($uuid);
                echo '<P>';
                $paper->format_html();
                echo '</P>';
            }
            html_footer();
        }
    }
} else {
    echo 'No GID given.';
}
Ejemplo n.º 2
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();
     }
 }