Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 78641fd4b6
Fetching contributors…

Cannot retrieve contributors at this time

executable file 74 lines (62 sloc) 1.946 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
<?php

require_once '../../bootstrap.php';
require_once '../../Models/Item.php';

class Items {
function index($idsString="", $fields=null) {
if ($idsString==="") {
throw new RestException(501, "Working on it!");
}

$ids = explode(',', urldecode($idsString));
if (isset($fields)) {
$showAllFields = false;
$fieldList = explode(',', $fields);
} else {
$showAllFields = true;
}

$result = new stdClass();
#$result->items = new stdClass();
# $result->items->item = array(); To give nice xml

$result->items = array();

foreach ($ids as $id) {
$item = new stdClass();

$item->id = $id;

if ($showAllFields or in_array("biblio", $fieldList)) {
$itemsClass = new Models_Item();
$aliasResponse = $itemsClass->getAliases($id);
$biblioResponse = $itemsClass->getBiblio($id, $aliasResponse, false);
$item->biblio = $biblioResponse->$id;
}
if ($showAllFields or in_array("status", $fieldList)) {
$item->status = new Status();
}
if ($showAllFields or in_array("debug", $fieldList)) {
$item->debug = new stdClass();
}
if ($showAllFields or in_array("metrics", $fieldList)) {
$itemsClass = new Models_Item();
$aliasResponse = $itemsClass->getAliases($id);
$metricsResponse = $itemsClass->getMetrics($id, $aliasResponse);
$item->metrics = $metricsResponse->$id;
}
if ($showAllFields or in_array("aliases", $fieldList)) {
$itemsClass = new Models_Item();
$aliasResponse = $itemsClass->getAliases($id);
$item->aliases = $aliasResponse->$id;
}
$result->items[] = $item;
}
return $result;
}
}


class Status {
public $last_updated;
public $providers_queried;
public $synonyms_queried;
public $created_by;

    function __construct() {
        $this->created_by = "unknown";
        $this->synonyms_queried = "unknown";
        $this->synonyms_queried = "unknown";
        $this->last_updated = (string)time();
    }
}

Something went wrong with that request. Please try again.