Beispiel #1
0
foreach ($ids as $reference_id) {
    echo $reference_id . "\n";
    $specimens = specimens_from_db($reference_id);
    if (count($specimens) == 0) {
        $specimens = specimens_from_reference($reference_id);
    }
    echo "Specimens:\n";
    print_r($specimens);
    $nm = bhl_names_in_reference_by_page($reference_id);
    $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);
    $expanded = expand_path($majority_rule);
    print_r($expanded);
    // OK, now match...
    foreach ($specimens as $specimen) {
        //$go = false;
        $go = true;
        $code = $specimen->code;
        if (preg_match('/^AMNH /', $code)) {
            if (in_array('Amphibia', $expanded)) {
                $code = str_replace('AMNH ', 'AMNH A-', $code);
            }
            if (in_array('Reptilia', $expanded)) {
                $code = str_replace('AMNH ', 'AMNH R-', $code);
            }
Beispiel #2
0
function get_paths($path)
{
    global $server, $size, $max_size;
    $list = $server->parse_raw_list($path);
    if (!$list) {
        return array();
    }
    $items = array();
    foreach ($list as $v) {
        if ($v['type'] != 'file') {
            if ($v['name'] == '.' or $v['name'] == '..') {
                continue;
            }
            $size += $v['size'];
            if ($size > $max_size) {
                return false;
            }
            $arr = get_paths($path . $v['name'] . '/');
            $items = array_merge($items, $arr);
        } else {
            $items[] = $path . $v['name'];
        }
    }
    return $items;
}
Beispiel #3
0
 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 ')';
     }
 }
Beispiel #4
0
        $parts2 = explode("/", $current);
    }
    $real_path = "";
    for ($i = 0; $i < count($parts2) - $dirNumber - 1; $i++) {
        if (isset($_SESSION["Windows"])) {
            $real_path .= $parts2[$i] . '\\';
        } else {
            $real_path .= $parts2[$i] . '/';
        }
    }
    if (isset($_SESSION["Windows"])) {
        $directories = glob($real_path . "\\*", GLOB_ONLYDIR);
    } else {
        $directories = glob($real_path . "/*", GLOB_ONLYDIR);
    }
    $paths = get_paths($real_path);
    $write_read_dir = "";
    foreach ($paths as $path) {
        if (is_writable("{$real_path}{$path}") && is_readable("{$real_path}{$path}")) {
            $write_read_dir = "{$real_path}{$path}";
            break;
        }
    }
    if (isset($_SESSION["Windows"])) {
        $write_read_dir .= "\\";
    } else {
        $write_read_dir .= "/";
    }
} else {
    $write_read_dir = $_SESSION['directory'];
}
Beispiel #5
0
Datei: yf.php Projekt: yfix/yf
            } elseif (strpos($file, $prefix_project) === 0) {
                $name = substr($file, strlen($prefix_project), -strlen($ext));
                $inside_project = true;
            }
            if ($name && !isset($cmds[$name])) {
                require_once $path;
                $class_name = ($is_project ? $prefix_project : $prefix_framework) . $name;
                if (class_exists($class_name)) {
                    $cmds[$name] = new $class_name();
                }
            }
        }
    }
    return $cmds;
}
$yf_paths = get_paths();
if (!defined('YF_PATH')) {
    define('YF_PATH', $yf_paths['yf_path']);
}
if (!defined('APP_PATH')) {
    define('APP_PATH', $yf_paths['app_path']);
}
if (!defined('CONFIG_PATH')) {
    define('CONFIG_PATH', $yf_paths['config_path']);
}
if (!defined('PROJECT_PATH')) {
    define('PROJECT_PATH', $yf_paths['project_path']);
}
if (!defined('SITE_PATH')) {
    define('SITE_PATH', $yf_paths['project_path']);
}