‘organization_level_instance’
);
$oli_xml = $api->request($url, $request_fields);

//echo $api->get_api_url($url, $request_fields);

$name = $oli_xml->InventoryItem->Name;
$collection_id = (int)$oli_xml->InventoryItem->CollectionID;
$date = false;

foreach($oli_xml->InventoryItem->AttributeValue as $av) {
$avname = $av->AttributeName;
$val = $av->Value;
switch ($avname) {
case ‘Date’:
if(!empty($val->Date)) $date = $api->format_date($val->Date);
if ($val->Date->attributes()->circa == ‘true’) {
$date = “circa ” . $date;
}
break;
}
}

//grab the items
$url = $api::baseURL . “/index.php/InventoryItems”;
$request_fields = array(
‘CollectionID’ => $collection_id,
‘OrganizationLevelInstanceID’ => $id,
‘Thumbnails[]’ => array(‘Standard’,’File’),
‘List’ => 1,
‘Start’ => $startnum,
‘Count’ => $slicecount
);
$item_list_xml = $api->request($url, $request_fields);

//echo ““;

$first_item_id = $item_list_xml->InventoryItem[0]->ID;

//grab the first item
$url = $api::baseURL . “/index.php/InventoryItems/” . $first_item_id;
$request_fields = array(
‘Type’ => ‘document’
);
$item_xml = $api->request($url, $request_fields);

//$search_query = “id=” . $id;

} else { //collection container

$slicecount = 10;
$startnum = $iter * $slicecount;

//grab the items
$url = $api::baseURL . “/index.php/InventoryItems”;
$request_fields = array(
‘CollectionID’ => $id,
‘Start’ => $startnum,
‘Count’ => $slicecount
);
$item_xml = $api->request($url, $request_fields);

$search_query = “id=” . $id . “&t=collection”;

//get the name from the first item’s ancestors…
$name = ”;
foreach($item_xml->InventoryItem[0]->Ancestor as $ancestor) {
if($ancestor->Type == ‘Collection’) {
$name = $ancestor->Name;
}
}
}

//echo ““;

$resultcnt = $item_xml->attributes()->total_count;

drupal_set_title($name);
?>
InventoryItem[0];
$item_id = $item->ID;
$document_type_id = $item->DocumentTypeID;
$item_name = $item->Name;
$subjects = $item->Category;
$people = array();
$title = false;
$is_zoomify = false;
$image_number = array();
$date = false;
$date_produced = false;
$date_published = false;
$date_range = false;
$language = false;
$description = false;
$historical_context = false;
$barcode = false;
$from_atlas = false;
$atlas_reference = false;
$title_translation = false;
$alternative_title = false;
$cartouche_elements = array();
$authors = array();
$creators = array();
$colorists = array();
$dedicatees = array();
$editors = array();
$printmakers = array();
$publishers = array();
$purveyors = array();
$surveyors = array();
$translators = array();
$publishing_location = array();
$region_depicted = array();
$see_also = array();
$parent_map = array();
$parent_map_barcode = false;
$source_referenced = false;
$map_type = array();
$dimensions = false;
$printing_process = array();
$printing_technique = array();
$material_type = array();
$notes = false;
$brief_description = false;
$physical_description = false;
$contains_inset = false;
$insets = array();
$theme = array();
$lc_call_number = false;
$accession_number = false;
$associated_cartouche = array();
$associated_map_imagery = array();
$donor = array();
$collection = false;

foreach($item->Ancestor as $ancestor) {
if($ancestor->Type == ‘Collection’) {
$collection = $ancestor->Name;
}
}

foreach($item->AttributeValue as $av) {
$avname = $av->AttributeName;
$val = $av->Value;
switch ($avname) {
case ‘Title’:
$title = (string)$val->Text;
break;
case ‘Barcode’:
$barcode = (string)$val->Text;
break;
case ‘Image Number’:
$image_number = explode(“,”, (string)$val->Text);
$is_zoomify = true;
break;
/*case ‘From Atlas’:
$from_atlas = (string)$val->Text;
break;*/
/*case ‘Atlas Reference’:
$atlas_reference = (string)$val->ReferenceName;
break;*/
case ‘Title Translation’:
$title_translation = (string)$val->Text;
break;
case ‘Alternative Title’:
$alternative_title = (string)$val->Text;
break;
case ‘Author’:
foreach($val as $v) {
$authors[(int)$v->ReferenceID] = flip_name((string)$v->ReferenceName);
}
break;
case ‘Creator’:
foreach($val as $v) {
$creators[(int)$v->ReferenceID] = flip_name((string)$v->ReferenceName);
}
break;
case ‘Colorist’:
foreach($val as $v) {
$colorist[(int)$v->ReferenceID] = flip_name((string)$v->ReferenceName);
}
break;
case ‘Dedicatee’:
foreach($val as $v) {
$dedicatees[(int)$v->ReferenceID] = flip_name((string)$v->ReferenceName);
}
break;
case ‘Editor’:
foreach($val as $v) {
$editors[(int)$v->ReferenceID] = flip_name((string)$v->ReferenceName);
}
break;
case ‘Printmaker’:
foreach($val as $v) {
$printmakers[(int)$v->ReferenceID] = flip_name((string)$v->ReferenceName);
}
break;
case ‘Publisher’:
foreach($val as $v) {
$publishers[(int)$v->ReferenceID] = flip_name((string)$v->ReferenceName);
}
break;
case ‘Purveyor’:
foreach($val as $v) {
$purveyors[(int)$v->ReferenceID] = flip_name((string)$v->ReferenceName);
}
break;
case ‘Surveyor’:
foreach($val as $v) {
$surveyors[(int)$v->ReferenceID] = flip_name((string)$v->ReferenceName);
}
break;
case ‘Translator’:
foreach($val as $v) {
$translators[(int)$v->ReferenceID] = flip_name((string)$v->ReferenceName);
}
break;
case ‘Publishing Location’:
foreach($val as $v) {
$publishing_location[(int)$v->ReferenceID] = (string)$v->ReferenceName;
}
break;
case ‘Region Depicted’:
foreach($val as $v) {
$region_depicted[(int)$v->ReferenceID] = (string)$v->ReferenceName;
}
break;
case ‘Date’:
if(!empty($val->Date)) $date = $api->format_date($val->Date);
if ($val->Date->attributes()->circa == ‘true’) {
$date = “circa ” . $date;
}
break;
case ‘Date Range’:
if(!empty($val->Date)) {
$start_date = (!empty($val->Date[0])) ? $api->format_date($val->Date[0]) : ”;
if ($val->Date[0]->attributes()->circa == ‘true’) {
$start_date = “circa ” . $start_date;
}
$end_date = (!empty($val->Date[1])) ? $api->format_date($val->Date[1]) : ”;
if ($val->Date[1]->attributes()->circa == ‘true’) {
$end_date = “circa ” . $end_date;
}
$date_range = $start_date . ” – ” . $end_date;
}
break;
case ‘Date Produced’:
if(!empty($val->Date)) $date_produced = $api->format_date($val->Date);
if ($val->Date->attributes()->circa == ‘true’) {
$date_produced = “circa ” . $date_produced;
}
break;
case ‘Date Published’:
if(!empty($val->Date)) $date_published = $api->format_date($val->Date);
if ($val->Date->attributes()->circa == ‘true’) {
$date_published = “circa ” . $date_published;
}
break;
case ‘Language’:
$language = (string)$val->ReferenceName;
break;
case ‘Description’:
$description = (string)$val->Text;
break;
case ‘Historical Context’:
$historical_context = (string)$val->Text;
break;
case ‘Cartouche Elements’:
foreach($val as $v) {
$cartouche_elements[(int)$v->ReferenceID] = (string)$v->ReferenceName;
}
break;
case ‘See Also’:
foreach($val as $v) {
$see_also[(int)$v->ReferenceID] = (string)$v->ReferenceName;
}
break;
case ‘Parent Map’:
foreach($val as $v) {
$parent_map[(int)$v->ReferenceID] = (string)$v->ReferenceName;
}
break;
/*case ‘Parent Map Barcode’:
$parent_map_barcode = (string)$val->Text;
break;*/
/*case ‘Source Referenced’:
$source_referenced = (string)$val->Text;
break;*/
case ‘Map Type’:
foreach($val as $v) {
$map_type[(int)$v->ReferenceID] = (string)$v->ReferenceName;
}
break;
case ‘Dimensions’:
$dimensions = (string)$val->Text;
break;
case ‘Printing Process’:
foreach($val as $v) {
$printing_process[(int)$v->ReferenceID] = (string)$v->ReferenceName;
}
break;
case ‘Printing Technique’:
foreach($val as $v) {
$printing_technique[(int)$v->ReferenceID] = (string)$v->ReferenceName;
}
break;
case ‘Material Type’:
foreach($val as $v) {
$material_type[(int)$v->ReferenceID] = (string)$v->ReferenceName;
}
break;
case ‘Notes’:
$notes = (string)$val->Text;
break;
case ‘Brief Description’:
$brief_description = (string)$val->Text;
break;
case ‘Physical Description’:
$physical_description = (string)$val->Text;
break;
/*case ‘Contains Inset’:
$contains_inset = (string)$val->Text;
break;*/
case ‘Insets’:
foreach($val as $v) {
$insets[(int)$v->ReferenceID] = (string)$v->ReferenceName;
}
break;
case ‘Theme’:
foreach($val as $v) {
$theme[(int)$v->ReferenceID] = (string)$v->ReferenceName;
}
break;
/*case ‘LC Call Number’:
$lc_call_number = (string)$val->Text;
break;*/
case ‘Accession Number’:
$accession_number = (string)$val->Text;
break;
case ‘Associated Cartouche’:
foreach($val as $v) {
$associated_cartouche[(int)$v->ReferenceID] = (string)$v->ReferenceName;
}
break;
case ‘Associated Map Imagery’:
foreach($val as $v) {
$associated_map_imagery[(int)$v->ReferenceID] = (string)$v->ReferenceName;
}
break;
case ‘Donor’:
foreach($val as $v) {
$donor[(int)$v->ReferenceID] = (string)$v->ReferenceName;
}
break;
}
}
?>

Page) && count($item->Page) > 0) {
//$i=1;
//can we assume that books and atlases will only have 1 image per item?
//foreach($item->Page as $page) {

if($is_zoomify) {
$zoomify_id = preg_replace(‘/\\.[^.\\s]{3,4}$/’, ”, $page->OriginalFileName);
$prefix = current(explode(‘.’, $zoomify_id));
$bucket = floor( $prefix / 500 ) * 500;

list($main_img_width, $main_img_height) = getimagesize($page->HugeThumbnail);
?>


attributes()->total_count;
$total_unloaded = max(0, ($total_items – $slicecount));

$i=1;
foreach($item_list_xml->InventoryItem as $item_thumb) {
if(!empty($item_thumb->Page)) {
$page = $item_thumb->Page[0];
$zoomify_id = preg_replace(‘/\\.[^.\\s]{3,4}$/’, ”, $page->OriginalFileName);
$prefix = current(explode(‘.’, $zoomify_id));
$bucket = floor( $prefix / 500 ) * 500;
?>

‘, ‘‘, , ID; ?>);” id=”zoom_link“>” class=”item”>

InventoryItem) > 1) {
?>

Collection: ” id=”item_link”>

0) { ?>

0) { ?>

0) { ?>





result

InventoryItem as $item) {
$item_id = $item->ID;
$item_name = $item->Name;

$thumbnail = false;
if(!empty($item->Page[0]->StandardThumbnail)) {
$thumbnail = $item->Page[0]->StandardThumbnail;
}

$link = “browse-maps?id=”.$item_id;

$subjects = $item->Category;
$people = array();
$barcode = false;
$date = false;
$date_produced = false;
$date_published = false;
$date_range = false;
$authors = array();
$creators = array();
$region_depicted = array();
$map_type = array();
$language = false;
$publishing_location = array();
$donor = array();

foreach($item->AttributeValue as $av) {
$avname = $av->AttributeName;
$val = $av->Value;
switch ($avname) {
case ‘Barcode’:
$barcode = (string)$val->Text;
break;
case ‘Author’:
foreach($val as $v) {
$authors[(int)$v->ReferenceID] = flip_name((string)$v->ReferenceName);
}
break;
case ‘Creator’:
foreach($val as $v) {
$creators[(int)$v->ReferenceID] = flip_name((string)$v->ReferenceName);
}
break;
case ‘Region Depicted’:
foreach($val as $v) {
$region_depicted[(int)$v->ReferenceID] = (string)$v->ReferenceName;
}
break;
case ‘Date’:
if(!empty($val->Date)) $date = $api->format_date($val->Date);
break;
case ‘Date Range’:
if(!empty($val->Date)) {
$start_date = (!empty($val->Date[0])) ? $api->format_date($val->Date[0]) : ”;
$end_date = (!empty($val->Date[1])) ? $api->format_date($val->Date[1]) : ”;
$date_range = $start_date . ” – ” . $end_date;
}
break;
case ‘Date Produced’:
if(!empty($val->Date)) $date_produced = $api->format_date($val->Date);
break;
case ‘Date Published’:
if(!empty($val->Date)) $date_published = $api->format_date($val->Date);
break;
case ‘Map Type’:
foreach($val as $v) {
$map_type[(int)$v->ReferenceID] = (string)$v->ReferenceName;
}
break;
case ‘Publishing Location’:
foreach($val as $v) {
$publishing_location[(int)$v->ReferenceID] = (string)$v->ReferenceName;
}
break;
case ‘Language’:
$language = (string)$val->ReferenceName;
break;
case ‘Donor’:
foreach($val as $v) {
$donor[(int)$v->ReferenceID] = (string)$v->ReferenceName;
}
break;
}
}
?>

$slicecount) {

$total_pages = ceil($resultcnt / $slicecount);

//calculate start and end for a manageable number.
$page_begin = max(0, min($page – 5, $total_pages – 10));
$page_end = min($total_pages, $page_begin + 10);

if($page_begin > 0) {
echo(‘
<< ‘);
echo(‘< ‘);
}
for ($i=$page_begin; $i<$page_end; $i++) { $page_number = $i + 1; if($page_number == $page) { echo($page_number . ' '); } else { echo('‘.$page_number.’ ‘);
}
}
if($page_end < $total_pages) { echo('> ‘);
echo(‘>>‘);
}
}

?>