예제 #1
0
function matcher($fp, $client)
{
    $parts = explode('/', $fp);
    $name = array_pop($parts);
    $sernum = DaseClient::makeSerialNumber($name);
    $item = $client->getBySerialNumber($sernum);
    $a = 'edit-media';
    if ($item) {
        return $client->getDaseUrl() . $item->links->{$a} . "\n";
    } else {
        $name = preg_replace('/-SAI seminar series/', '', $name, 1);
        $sernum = DaseClient::makeSerialNumber($name);
        $item = $client->getBySerialNumber($sernum);
        if ($item) {
            return $client->getDaseUrl() . $item->links->{$a} . "\n";
        } else {
            return false;
        }
    }
}
예제 #2
0
<?php

include 'DaseClient.php';
$user = '******';
$pass = DaseClient::promptForPassword($user);
$REPO = '/mnt/dar2/diia/wallercreek';
$c = new DaseClient('waller');
$c->setAuth($user, $pass);
foreach ($c->getFilePaths($REPO) as $fp) {
    $parts = explode('/', $fp);
    $last = array_pop($parts);
    $name = str_replace('.JPG', '', $last);
    $path = str_replace($REPO, '', $fp);
    $parts2 = explode('/', trim($path, '/'));
    $year = array_shift($parts2);
    $date = array_shift($parts2);
    print $name . "\n";
    $meta = array('description' => $name, 'title' => $path, 'year' => $year, 'date' => $date);
    $res = $c->postFileToCollection($fp, $meta);
    print $res[1];
}
예제 #3
0
<?php

//PHP ERROR REPORTING -- turn off for production
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
include 'DaseClient.php';
$client = new DaseClient('vrc');
$user = '******';
$pass = '******';
$REPO = '/mnt/dar2/favrc/for-dase';
function getFilePaths($directory)
{
    $dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory));
    $files = array();
    foreach ($dir as $file) {
        $file_path = $file->getPathname();
        if ($file->isFile() && '.' != substr($file->getFilename(), 0, 1)) {
            $files[$file->getMTime() . $file->getFilename()]['path'] = $file_path;
            $files[$file->getMTime() . $file->getFilename()]['name'] = $file->getFilename();
        }
    }
    krsort($files);
    return $files;
}
$max = 40;
foreach (getFilePaths($REPO) as $file) {
    $max--;
    if ($max > 0) {
        $mtime = filemtime($file['path']);
        if (time() - $mtime < 48 * 3600) {
예제 #4
0
 public static function createCollection($host, $collection_name, $user, $pass)
 {
     $ascii = self::dirify($collection_name);
     $entry = DaseClient::makeAtom($ascii, $collection_name, array());
     $entry = DaseClient::addCategory($entry, 'collection', 'http://daseproject.org/category/entrytype');
     //could have been retrieved from base AtomPub service doc:
     $url = $host . '/collections';
     $resp = DaseClient::post($url, $entry, $user, $pass, 'application/atom+xml');
     return $resp;
 }
예제 #5
0
<?php

include 'DaseClient.php';
$client = new DaseClient('keanepj');
$res = $client->search('hotel');
$app_root = $res->app_root;
$total = $res->total;
$html = "<html><head><title>DaseClient Sample</title></head><body>";
$html .= "<h1>DaseClient Sample</h1>";
$html .= "<h3>{$total} items found</h3>";
$html .= "<ul>";
foreach ($res->items as $item) {
    if (isset($item->metadata->keyword)) {
        $html .= '<li><img src="' . $app_root . '/' . $item->media->small . '">' . $item->metadata->keyword[0] . "</li>\n";
    }
}
$html .= "</ul>";
$html .= "</body></html>";
echo $html;
예제 #6
0
<?php

include 'DaseClient.php';
$client = new DaseClient('keanepj', false);
$q = trim(strip_tags($_GET['q']));
$res = $client->search($q);
header('Content-type: application/json');
echo $res;
예제 #7
0
<?php

include 'DaseClient.php';
$user = '******';
$c = new DaseClient('test');
$pass = DaseClient::promptForPassword($user);
$c->setAuth($user, $pass);
print $c->getUserCollections();
예제 #8
0
<?php

include 'DaseClient.php';
$user = '******';
$pass = DaseClient::promptForPassword($user);
$dase_host = 'https://daseupload.laits.utexas.edu';
$colls = array('Scratch One', 'Scratch Two');
foreach ($colls as $coll) {
    $res = DaseClient::createCollection($dase_host, $coll, $user, $pass);
    print_r($res);
}
예제 #9
0
<?php

//shows results in PHP and JSON
include 'DaseClient.php';
$client = new DaseClient('keanepj');
$res = $client->search('favorite');
$app_root = $res->app_root;
$total = $res->total;
print_r($res);
$client = new DaseClient('keanepj', false);
$res = $client->search('favorite');
print $res;
예제 #10
0
<?php

setlocale(LC_ALL, 'en_US.UTF-8');
include '../dase-client/DaseClient.php';
$client = new DaseClient('japanese_grammar');
$user = '******';
$pass = DaseClient::promptForPassword($user);
$filename = 'joshu_md2.csv';
$handle = fopen($filename, "r");
$meta = array();
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
    $filename = $data[0];
    $meta[$filename]['filename'] = $data[0];
    $meta[$filename]['grammar_tags'] = explode('|', $data[1]);
    $meta[$filename]['english_title'] = $data[2];
    $meta[$filename]['japanese_title'] = $data[3];
}
fclose($handle);
foreach ($meta as $filename => $m) {
    $title = $filename . '.mov';
    $res = $client->search('@title:' . $title);
    $url = $res->app_root . $res->items[0]->links->metadata;
    if ($url) {
        $pairs = array();
        foreach ($m as $k => $v) {
            if (is_array($v)) {
                $vset = array();
                foreach ($v as $str) {
                    $vset[] = '"' . $str . '"';
                }
                $pairs[] = '"' . $k . '":[' . join(',', $vset) . ']';
예제 #11
0
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>My Favorites</title>

		<link rel="stylesheet" type="text/css" href="www/css/style.css">
<script type="text/javascript" src="www/scripts/jquery.js"></script>
</head>

<?php 
include 'DaseClient.php';
$client = new DaseClient('keanepj');
$res = $client->search('keyword:favorite item_type:room');
$app_root = $res->app_root;
$total = $res->total;
?>

<body>

<h1>My Favorites (<?php 
echo $total;
?>
 items found)</h1>

<ul>

<?php 
foreach ($res->items as $item) {
    ?>
예제 #12
0
<?php

include 'DaseClient.php';
$user = '******';
$pass = DaseClient::getPassword($user);
$old_waller = new DaseClient('waller_creek');
$new_waller = new DaseClient('waller');
$new_waller->setAuth($user, $pass);
$atts = $old_waller->getCollectionAttributesAtom();
foreach (DaseClient::getLinksByRel($atts, 'edit') as $url) {
    $res = DaseClient::get($url);
    if ('200' == $res[0]) {
        $att_atom = $res[1];
        print $new_waller->postAttributeToCollection($att_atom);
        print "\n";
    }
}
예제 #13
0
<?php

include 'DaseClient.php';
ini_set('memory_limit', '700M');
$user = '******';
$pass = DaseClient::promptForPassword($user);
$client = new DaseClient('waller');
$uris = $client->getCollectionItemUris();
foreach (explode("\n", $uris) as $uri) {
    $res = DaseClient::get($uri . '.atom', $user, $pass);
    if ('200' == $res[0]['http_code']) {
        $atom_entry = $res[1];
        if ('image/jpeg' == $client->getAdminMetadata($atom_entry, 'admin_mime_type')) {
            $item_type_link = $client->getLinkByRel($atom_entry, 'http://daseproject.org/relation/edit-item_type') . "\n";
            $post_res = DaseClient::post($item_type_link, 'photo', $user, $pass, 'text/plain');
            //print HTTP code and response message
            print $post_res[0]['http_code'] . ' ' . $post_res[1] . "\n";
        }
    } else {
        print $res[0]['http_code'] . ' ' . $res[1] . "\n";
    }
}
예제 #14
0
<?php

include 'DaseClient.php';
$user = '******';
$c = new DaseClient('test', 'json', 'http://dase.laits.utexas.edu');
print $c->searchCollections('red', array('gov310', 'efossils'));