forked from omeka/plugin-ItemRelations
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathItemRelationsRelation.php
68 lines (62 loc) · 1.66 KB
/
ItemRelationsRelation.php
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
<?php
/**
* Item Relations
* @copyright Copyright 2010-2014 Roy Rosenzweig Center for History and New Media
* @license http://www.gnu.org/licenses/gpl-3.0.txt GNU GPLv3
*/
/**
* Item Relations Relation model.
*/
class ItemRelationsRelation extends Omeka_Record_AbstractRecord implements Zend_Acl_Resource_Interface
{
/**
* @var int
*/
public $id;
/**
* @var int
*/
public $subject_item_id;
/**
* @var int
*/
public $property_id;
/**
* @var int
*/
public $object_item_id;
protected function _validate()
{
//echo "Validating";
if (empty($this->subject_item_id)) {
$this->addError('subject_item_id', __('Relation requires subject item ID.'));
}
// An item must exist.
if (!$this->getTable('Item')->exists($this->subject_item_id)) {
$this->addError('subject_item_id', __('Relation requires a valid subject item ID.'));
}
}
/**
* Get a textual representation of the property for this relation.
*
* @uses ItemRelationsProperty::getText()
* @return string
*/
public function getPropertyText()
{
$property = new ItemRelationsProperty;
$property->local_part = $this->property_local_part;
$property->label = $this->property_label;
$property->vocabulary_namespace_prefix = $this->vocabulary_namespace_prefix;
return $property->getText();
}
/**
/* Identify ItemRelationsRelation records as relating to the ItemRelationsRelations ACL resource.
*
* @return string
*/
public function getResourceId()
{
return 'Relations';
}
}