コード例 #1
0
ファイル: reference.php プロジェクト: rdmpage/bioguid
function reference_to_solr($reference)
{
    $obj = reference_to_mendeley($reference);
    $item = array();
    $item['id'] = 'reference/' . $reference->reference_id;
    $item['title'] = $obj->title;
    $item['publication_outlet'] = $obj->publication_outlet;
    $item['year'] = $obj->year;
    $authors = array();
    foreach ($obj->authors as $a) {
        $authors[] = $a->forename . ' ' . $a->surname;
    }
    $item['authors'] = $authors;
    $item['citation'] = reference_authors_to_text_string($reference) . ' ' . $reference->year . ' ' . $reference->title . ' ' . reference_to_citation_text_string($reference);
    return $item;
}
コード例 #2
0
ファイル: display_reference.php プロジェクト: rdmpage/bioguid
 function DisplayJson()
 {
     $j = reference_to_mendeley($this->object);
     // Array of BHL pages
     $j->bhl_pages = array();
     $j->thumbnails = array();
     $count = 0;
     $pages = bhl_retrieve_reference_pages($this->id);
     foreach ($pages as $page) {
         $j->bhl_pages[] = (int) $page->PageID;
         // Store thumbnails of pages (just page 1 for now)
         if ($count == 0) {
             $image = bhl_fetch_page_image($page->PageID);
             $file = @fopen($image->thumbnail->file_name, "r") or die("could't open file --\"{$image->thumbnail}->file_name\"");
             $img = fread($file, filesize($image->thumbnail->file_name));
             fclose($file);
             // to do: test for MIME type, don't assume it
             $base64 = chunk_split(base64_encode($img));
             $thumbnail = 'data:image/gif;base64,' . $base64;
             $j->thumbnails[] = $thumbnail;
         }
         $count++;
     }
     // don't do names..
     if (1) {
         // Names
         $nm = bhl_names_in_reference_by_page($this->id);
         $j->names = $nm->names;
         // Get majority rule taxon (what paper is about)
         $tags = array();
         foreach ($nm->names as $name) {
             $tags[] = $name->namestring;
         }
         $paths = get_paths($tags);
         $majority_rule = majority_rule_path($paths);
         $j->expanded = expand_path($majority_rule);
         /*
         			// Nomenclatural acts
         			$acts = acts_in_publication($this->id);
         			if (count($acts) > 0)
         			{
         				$count = count($nm->names);
         				foreach ($acts as $tn)
         				{
         					$name = $tn->nameComplete;
         					
         					// Zoobank crap
         					$name = preg_replace('/ subsp\. /', ' ', $name);
         					$name = preg_replace('/ var\. /', ' ', $name);
         					
         					// BHL might have missed this name
         					if (!isset($nm->found[$name]))
         					{
         						$n = new stdclass;
         						$n->namestring = $name;
         						$n->identifiers = new stdclass;
         						$n->pages = array();
         						$j->names[] = $n;
         						$nm->found[$name] = $count++;					
         					}
         	
         					$index = $nm->found[$name];
         					
         					// ION
         					if (preg_match('/urn:lsid:organismnames.com:name:(?<id>\d+)/', $tn->global_id, $m))
         					{
         						$j->names[$index]->identifiers->ion = (Integer)$m['id'];
         					}
         					// Zoobank
         					if (preg_match('/urn:lsid:zoobank.org:act:(?<id>.*)/', $tn->global_id, $m))
         					{
         						$j->names[$index]->identifiers->zoobank = $m['id'];
         					}
         					// IPNI
         					if (preg_match('/urn:lsid:ipni.org:names:(?<id>.*)/', $tn->global_id, $m))
         					{
         						$j->names[$index]->identifiers->ipni = $m['id'];
         					}
         					// Index Fungorum
         					if (preg_match('/urn:lsid:indexfungorum.org:names(?<id>.*)/', $tn->global_id, $m))
         					{
         						$j->names[$index]->identifiers->indexfungorum = (Integer)$m['id'];
         					}
         				
         				}
         				
         				//ksort($j->names);
         			} */
     }
     // Output localities in text as array of features in GeoJSON format
     /*		$j->featurecollection = new stdclass;
     		$j->featurecollection->type = "FeatureCollection";
     		$j->featurecollection->features = array();
     		foreach ($this->localities as $loc)
     		{
     			$feature = new stdclass;
     			$feature->type = "Feature";
     			$feature->geometry = new stdclass;
     			$feature->geometry->type = "Point";
     			$feature->geometry->coordinates = array();
     			$feature->geometry->coordinates[] = (Double)$loc->longitude;
     			$feature->geometry->coordinates[] = (Double)$loc->latitude;
     			
     			$j->featurecollection->features[] = $feature;
     		}
     */
     if (count($this->localities) > 0) {
         $j->geometry = new stdclass();
         $j->geometry->type = "MultiPoint";
         $j->geometry->coordinates = array();
         foreach ($this->localities as $loc) {
             $j->geometry->coordinates[] = array((double) $loc->longitude, (double) $loc->latitude);
         }
     }
     // ?
     header("Content-type: text/plain; charset=utf-8\n\n");
     if ($this->callback != '') {
         echo $this->callback . '(';
     }
     echo json_format(json_encode($j));
     if ($this->callback != '') {
         echo ')';
     }
 }