예제 #1
0
/**
 * Metainformation catalogue
 * --------------------------------------------------
 *
 * HARVEST for MicKa
 *
 * @link       http://www.bnhelp.cz
 * @package    Micka admin
 * @category   Metadata
 * @version    20140522
 */
function adminHarvest($harvestAction)
{
    $params = array();
    while (list($key, $val) = each($_REQUEST)) {
        $params[$key] = htmlspecialchars($val);
    }
    $harvest = new Harvest(null, null);
    $rs = array();
    $rs['types'] = array_flip($harvest->types);
    $rs['error'] = '';
    //my_print_r($params); my_print_r($harvestAction); //exit;
    switch ($harvestAction) {
        case 'save':
            $overwrite = isset($params['new']) && $params['new'] == 1 ? false : true;
            if ($params['handlers']) {
                $handlers = "email:" . $params['handlers'];
            }
            if ($params['period'] <= 0) {
                $params['period'] = "0";
            }
            if ($params['ok']) {
                if (!canAction('*')) {
                    $params['active'] = 0;
                }
                $result = $harvest->setParameters($params['id'], $params['source'], $params['type'], $handlers, "P" . $params['period'] . "D", $params['filter'], $params['active'], $overwrite);
                if ($result['status'] == 'fail') {
                    $rs['error'] = $result['error'];
                }
            }
            break;
        case 'edit':
            if ($params['id'] && $result['status'] != 'fail') {
                $par = $harvest->getParameters($params['id']);
                $params = $par[0];
                $days = $par[0]['h_interval'] / 24;
                $params['period'] = $days;
                $email = explode(":", $params['handlers']);
                $params['handlers'] = $email[1];
            } else {
                $rs['new'] = '1';
            }
            $rs['values'] = $params;
            $rs['isadmin'] = canAction('*');
            return $rs;
        case 'delete':
            $harvest->delete($params['id']);
            break;
        default:
            break;
    }
    $rs['list'] = $harvest->getParameters();
    //my_print_r($rs); exit;
    return $rs;
}
예제 #2
0
파일: Csw.php 프로젝트: riskatlas/micka
 function harvest($io = true)
 {
     //var_dump($this->params);
     include PHPPRG_DIR . '/Harvest.php';
     include PHPPRG_DIR . '/CswClient.php';
     $cswFrom = new CSWClient();
     $harvestor = new Harvest($this, $cswFrom);
     // jen vrati hodnoty - nad ramec standardu
     if ($io == false) {
         $result = $harvestor->getParameters($this->params['ID']);
         header("Content-type: application/json");
         echo json_encode($result);
         exit;
     }
     // implicitni hodnota
     if (!$this->params['RESOURCETYPE']) {
         $this->params['RESOURCETYPE'] = "csw/2.0.2";
     }
     //--- save to database ---
     if ($this->params['HANDLERS']) {
         if (!$this->params['ID']) {
             $this->params['ID'] = $this->params['SOURCE'];
         }
         if ($this->params['HARVESTINTERVAL'] != '') {
             $result = $harvestor->setParameters($this->params['ID'], $this->params['SOURCE'], $this->params['RESOURCETYPE'], $this->params['HANDLERS'], $this->params['HARVESTINTERVAL'], "");
         } else {
             //TODO poslat hned uzivateli
             $result = $harvestor->runResource(array('source' => $this->params['SOURCE'], 'name' => 'instant', 'type' => $this->params['RESOURCETYPE']));
             $result = $this->updateResponse($result, "Update");
             $h = explode("|", $this->params['HANDLERS']);
             file_put_contents($h[0], $result);
             //FIXME - toto je docasne
         }
         $this->logText .= "HARVEST";
         // XML verze
         if (count($_GET) == 0) {
             // quick and dirty
             $this->xsl->load(PHPPRG_DIR . "/../xsl/HarvestResponse.xsl");
             $this->xp->importStyleSheet($this->xsl);
             $this->xp->setParameter('', 'timestamp', gmdate("Y-m-d\\TH:i:s"));
             // svetovy cas
             $processed = $this->xp->transformToXML($this->xml);
         } else {
             header("Content-type: application/json");
             echo json_encode($result);
             exit;
         }
         return $processed;
     } else {
         $result = $harvestor->runResource(array('source' => $this->params['SOURCE'], 'name' => 'blee', 'type' => $this->params['RESOURCETYPE']));
         return $this->updateResponse($result, "Update");
     }
 }
예제 #3
0
 public static function relateReverseEntity($entityguid, $entitytype, $userid, $relations)
 {
     $rels = self::filterByEntityType($entitytype, self::filterRelations($relations, $entityguid, true));
     $relatedids = array();
     foreach ($rels as $r) {
         if (is_numeric($r["subjectguid"])) {
             $imp = Harvest::importRecord($r["subjectguid"], $userid);
             if (is_string($imp) === true || $imp === false) {
                 throw new Exception($imp);
             }
             $r["subjectguid"] = $imp->guid;
         }
         $r = EntityRelations::relate($r["id"], $entityguid, $r["subjectguid"], $userid, $r["parentid"], true);
         if (is_string($r) || $r == false || $r == null) {
             throw new Exception($r);
         }
         $relatedids[] = $r->id;
     }
     return $relatedids;
 }
예제 #4
0
define('HARVEST_RSS_URL', 'http://geoportal.gov.cz/php/wmc/reports');
define('HARVEST_RSS_DIR', '/var/www/html/php/wmc/reports');
chdir(dirname(__FILE__));
include '../application/Csw.php';
require PHPPRG_DIR . "/CswClient.php";
require PHPPRG_DIR . "/Harvest.php";
require_once PHPPRG_DIR . "/MdRecord.php";
//require(PHPPRG_DIR . "/micka_lib_auth.php");
for ($i = 0; $i < $argc; $i++) {
    $pom = explode("=", $argv[$i]);
    $params[$pom[0]] = $pom[1];
}
// --- misto prihlaseni bude rovnou  struktura - dost derave
$_SESSION['u'] = "harvest";
$_SESSION['maplist']['micka']['users']['harvest'] = "rwp*";
$_SESSION['ms_groups'] = "harvest";
// ------------------------------------------------
$cswFrom = new CSWClient();
$cswTo = new Csw(CSW_LOG);
$harvestor = new Harvest($cswTo, $cswFrom, $params['to'], $params['log'], $params['delete']);
$results = $harvestor->runAll();
$harvestor->writeRSS($results);
$report = "";
foreach ($results as $rec) {
    $report .= $rec['uuid'] . ":" . $rec['title'] . "\n";
    if ($rec['report']) {
        $report .= str_replace(array("['", "']"), array("/", ""), $rec['report']);
    }
}
echo $report;
//echo $cswTo->updateResponse($results,'update');