Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 40 additions & 39 deletions models/Api/Exhibit.php
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
<?php

class Api_Exhibit extends Omeka_Record_Api_AbstractRecordAdapter
{
public function getRepresentation(Omeka_Record_AbstractRecord $record)
{
$representation = array();
$representation['id'] = $record->id;
$representation['title'] = $record->title;
$representation['url'] = self::getResourceUrl("/exhibits/{$record->id}");
$representation['slug'] = $record->slug;
$representation['description'] = $record->description;
$representation['credits'] = $record->credits;
$representation['featured'] = (bool) $record->featured;
$representation['public'] = (bool) $record->public;
$representation['added'] = self::getDate($record->added);
$representation['modified'] = self::getDate($record->modified);
$representation['owner'] = array(
'id' => $record->owner_id,
'resource' => 'users',
'url' => self::getResourceUrl("/users/{$record->owner_id}")
);
$pageCount = get_db()->getTable('ExhibitPage')->count(array('exhibit'=>$record->id));
$representation['pages'] = array(
'count' => $pageCount,
'resource' => 'exhibit_pages',
'url' => self::getResourceUrl("/exhibit_pages?exhibit={$record->id}")
);
return $representation;
}

public function getResourceId()
{
return "ExhibitBuilder_Exhibits";
}

<?php

class Api_Exhibit extends Omeka_Record_Api_AbstractRecordAdapter
{
public function getRepresentation(Omeka_Record_AbstractRecord $record)
{
$representation = array();
$representation['id'] = $record->id;
$representation['title'] = $record->title;
$representation['url'] = self::getResourceUrl("/exhibits/{$record->id}");
$representation['slug'] = $record->slug;
$representation['description'] = $record->description;
$representation['credits'] = $record->credits;
$representation['featured'] = (bool) $record->featured;
$representation['public'] = (bool) $record->public;
$representation['cover_image_file_id'] = $record->cover_image_file_id;
$representation['added'] = self::getDate($record->added);
$representation['modified'] = self::getDate($record->modified);
$representation['owner'] = array(
'id' => $record->owner_id,
'resource' => 'users',
'url' => self::getResourceUrl("/users/{$record->owner_id}")
);
$pageCount = get_db()->getTable('ExhibitPage')->count(array('exhibit'=>$record->id));
$representation['pages'] = array(
'count' => $pageCount,
'resource' => 'exhibit_pages',
'url' => self::getResourceUrl("/exhibit_pages?exhibit={$record->id}")
);
return $representation;
}

public function getResourceId()
{
return "ExhibitBuilder_Exhibits";
}

// Set data to a record during a POST request.
public function setPostData(Omeka_Record_AbstractRecord $record, $data)
{
Expand All @@ -44,6 +45,6 @@ public function setPostData(Omeka_Record_AbstractRecord $record, $data)
public function setPutData(Omeka_Record_AbstractRecord $record, $data)
{
// Set properties directly to an existing record.
}

}
}
}