Esempio n. 1
0
$dwcaManager = new DwcArchiverOccurrence();
$includeDets = 1;
$includeImgs = 1;
$redactLocalities = 1;
if ($action) {
    if (!array_key_exists('dets', $_POST)) {
        $includeDets = 0;
        $dwcaManager->setIncludeDets(0);
    }
    if (!array_key_exists('imgs', $_POST)) {
        $includeImgs = 0;
        $dwcaManager->setIncludeImgs(0);
    }
    if (!array_key_exists('redact', $_POST)) {
        $redactLocalities = 0;
        $dwcaManager->setRedactLocalities(0);
    }
    $dwcaManager->setTargetPath($serverRoot . (substr($serverRoot, -1) == '/' ? '' : '/') . 'collections/datasets/dwc/');
}
$isEditor = 0;
if ($isAdmin || array_key_exists("CollAdmin", $userRights) && in_array($collId, $userRights["CollAdmin"])) {
    $isEditor = 1;
}
$collArr = array();
if ($collId) {
    $dwcaManager->setCollArr($collId);
    $collArr = $dwcaManager->getCollArr();
}
if ($isEditor) {
    if (array_key_exists('colliddel', $_POST)) {
        $dwcaManager->deleteArchive($_POST['colliddel']);
Esempio n. 2
0
 public function exportDataset($dsid)
 {
     //Get occurrence records
     $zip = array_key_exists('zip', $_POST) ? $_POST['zip'] : 0;
     $format = $_POST['format'];
     $extended = array_key_exists('extended', $_POST) ? $_POST['extended'] : 0;
     $redactLocalities = 1;
     $rareReaderArr = array();
     if ($IS_ADMIN || array_key_exists("CollAdmin", $userRights)) {
         $redactLocalities = 0;
     } elseif (array_key_exists("RareSppAdmin", $userRights) || array_key_exists("RareSppReadAll", $userRights)) {
         $redactLocalities = 0;
     } else {
         if (array_key_exists('CollEditor', $userRights)) {
             $rareReaderArr = $userRights['CollEditor'];
         }
         if (array_key_exists('RareSppReader', $userRights)) {
             $rareReaderArr = array_unique(array_merge($rareReaderArr, $userRights['RareSppReader']));
         }
     }
     $dwcaHandler = new DwcArchiverOccurrence();
     $dwcaHandler->setCharSetOut($cSet);
     $dwcaHandler->setSchemaType($schema);
     $dwcaHandler->setExtended($extended);
     $dwcaHandler->setDelimiter($format);
     $dwcaHandler->setVerbose(0);
     $dwcaHandler->setRedactLocalities($redactLocalities);
     if ($rareReaderArr) {
         $dwcaHandler->setRareReaderArr($rareReaderArr);
     }
     $occurManager = new OccurrenceManager();
     $dwcaHandler->setCustomWhereSql($occurManager->getSqlWhere());
     $outputFile = null;
     if ($zip) {
         //Ouput file is a zip file
         $includeIdent = array_key_exists('identifications', $_POST) ? 1 : 0;
         $dwcaHandler->setIncludeDets($includeIdent);
         $images = array_key_exists('images', $_POST) ? 1 : 0;
         $dwcaHandler->setIncludeImgs($images);
         $outputFile = $dwcaHandler->createDwcArchive('webreq');
     } else {
         //Output file is a flat occurrence file (not a zip file)
         $outputFile = $dwcaHandler->getOccurrenceFile();
     }
     //ob_start();
     $contentDesc = '';
     if ($schema == 'dwc') {
         $contentDesc = 'Darwin Core ';
     } else {
         $contentDesc = 'Symbiota ';
     }
     $contentDesc .= 'Occurrence ';
     if ($zip) {
         $contentDesc .= 'Archive ';
     }
     $contentDesc .= 'File';
     header('Content-Description: ' . $contentDesc);
     if ($zip) {
         header('Content-Type: application/zip');
     } elseif ($format == 'csv') {
         header('Content-Type: text/csv; charset=' . $charset);
     } else {
         header('Content-Type: text/html; charset=' . $charset);
     }
     header('Content-Disposition: attachment; filename=' . basename($outputFile));
     header('Content-Transfer-Encoding: binary');
     header('Expires: 0');
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Pragma: public');
     header('Content-Length: ' . filesize($outputFile));
     ob_clean();
     flush();
     //od_end_clean();
     readfile($outputFile);
     unlink($outputFile);
 }
     $dlManager->setSchemaType($schema);
     $dlManager->setCharSetOut($cSet);
     $dlManager->setDelimiter($format);
     $dlManager->setZipFile($zip);
     $taxonFilterCode = array_key_exists("taxonFilterCode", $_POST) ? $_POST["taxonFilterCode"] : 0;
     $dlManager->setTaxonFilter($taxonFilterCode);
     $dlManager->downloadData();
 } else {
     //Is an occurrence download
     $dwcaHandler = new DwcArchiverOccurrence();
     $dwcaHandler->setCharSetOut($cSet);
     $dwcaHandler->setSchemaType($schema);
     $dwcaHandler->setExtended($extended);
     $dwcaHandler->setDelimiter($format);
     $dwcaHandler->setVerbose(0);
     $dwcaHandler->setRedactLocalities($redactLocalities);
     if ($rareReaderArr) {
         $dwcaHandler->setRareReaderArr($rareReaderArr);
     }
     if (array_key_exists("publicsearch", $_POST) && $_POST["publicsearch"]) {
         $occurManager = new OccurrenceManager();
         $dwcaHandler->setCustomWhereSql($occurManager->getSqlWhere());
     } else {
         //Request is coming from exporter.php for collection manager tools
         $dwcaHandler->setCollArr($_POST['targetcollid']);
         if (array_key_exists('processingstatus', $_POST) && $_POST['processingstatus']) {
             $dwcaHandler->addCondition('processingstatus', 'EQUALS', $_POST['processingstatus']);
         }
         if (array_key_exists('customfield1', $_POST) && $_POST['customfield1']) {
             $dwcaHandler->addCondition($_POST['customfield1'], $_POST['customtype1'], $_POST['customvalue1']);
         }
Esempio n. 4
0
 $isEditor = false;
 if ($IS_ADMIN || array_key_exists("CollAdmin", $USER_RIGHTS) && in_array($collid, $USER_RIGHTS["CollAdmin"])) {
     $isEditor = true;
 }
 if ($isEditor) {
     $processingStatus = array_key_exists('ps', $_REQUEST) ? $_REQUEST['ps'] : '';
     $customField1 = array_key_exists('cf1', $_POST) ? $_POST['cf1'] : '';
     $customField2 = array_key_exists('cf2', $_POST) ? $_POST['cf2'] : '';
     $dwcaHandler = new DwcArchiverOccurrence();
     $dwcaHandler->setCollArr($collid);
     $dwcaHandler->setCharSetOut('UTF-8');
     $dwcaHandler->setSchemaType('coge');
     $dwcaHandler->setExtended(false);
     $dwcaHandler->setDelimiter('csv');
     $dwcaHandler->setVerbose(0);
     $dwcaHandler->setRedactLocalities(0);
     $dwcaHandler->setIncludeDets(0);
     $dwcaHandler->setIncludeImgs(0);
     $dwcaHandler->addCondition('decimallatitude', 'NULL');
     $dwcaHandler->addCondition('decimallongitude', 'NULL');
     $dwcaHandler->addCondition('catalognumber', 'NOTNULL');
     $dwcaHandler->addCondition('locality', 'NOTNULL');
     if ($processingStatus) {
         $dwcaHandler->addCondition('processingstatus', 'EQUALS', $processingStatus);
     }
     if ($customField1) {
         $dwcaHandler->addCondition($customField1, $_POST['ct1'], $_POST['cv1']);
     }
     if ($customField2) {
         $dwcaHandler->addCondition($customField2, $_POST['ct2'], $_POST['cv2']);
     }
Esempio n. 5
0
<?php

include_once '../../config/symbini.php';
include_once $serverRoot . '/classes/DwcArchiverOccurrence.php';
$collStr = $argv[1];
$serverDomain = $argv[2];
$includeDets = 1;
$includeImgs = 1;
$redactLocalities = 1;
if ($argc > 3 && is_numeric($argv[3])) {
    $includeDets = $argv[3];
    if ($argc > 4 && is_numeric($argv[4])) {
        $includeImgs = $argv[4];
        if ($argc > 5 && is_numeric($argv[5])) {
            $redactLocalities = $argv[5];
        }
    }
}
if ($collStr) {
    $dwcaManager = new DwcArchiverOccurrence();
    $dwcaManager->setIncludeDets($includeDets);
    $dwcaManager->setIncludeImgs($includeImgs);
    $dwcaManager->setRedactLocalities($redactLocalities);
    $dwcaManager->setServerDomain($serverDomain);
    $dwcaManager->setTargetPath($serverRoot . (substr($serverRoot, -1) == '/' ? '' : '/') . 'collections/datasets/dwc/');
    $dwcaManager->setVerbose(0);
    $collArr = explode(',', $collStr);
    $dwcaManager->batchCreateDwca($collArr);
}