Repository navigation
Expand file tree
/
Copy pathcontainer.php
More file actions
94 lines (81 loc) · 2.24 KB
/
Copy pathcontainer.php
File metadata and controls
94 lines (81 loc) · 2.24 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/**
* @package midgardmvc_ui_create
* @author The Midgard Project, http://www.midgard-project.org
* @copyright The Midgard Project, http://www.midgard-project.org
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
*/
/**
* Helper for handling object containers.
*
* @package midgardmvc_ui_create
*/
class midgardmvc_ui_create_container extends SplObjectStorage
{
private $placeholder = null;
private $urlpattern = '';
private $typeof = 'http://purl.org/dc/dcmitype/Collection';
public function __get($key)
{
if ($key == 'urlpattern')
{
return $this->urlpattern;
}
if ($key == 'typeof')
{
return $this->typeof;
}
}
public function attach(midgard_object $object, $data = null)
{
// We're attaching real objects to container, forget about placeholder
if ($object == $this->placeholder)
{
$identifier = 'mgd:containerPlaceholder';
}
else
{
$identifier = null;
if ($this->placeholder)
{
$this->detach($this->placeholder);
$this->placeholder = null;
}
}
// Add RDFmapper to the object
$object->rdfmapper = new midgardmvc_ui_create_rdfmapper($object, $identifier);
parent::attach($object, $data);
}
/**
* Add a placeholder object to be used in empty listings
*/
public function set_placeholder(midgard_object $object)
{
if (count($this) > 0)
{
// We already have items, skip
return;
}
if (!midgardmvc_ui_create_injector::can_use())
{
// Placeholders only matter to Create users
return;
}
$object->guid = 'placeholder';
$this->placeholder = $object;
$this->attach($object);
}
public function set_urlpattern($urlpattern)
{
if (!midgardmvc_ui_create_injector::can_use())
{
// URL Patterns only matter to Create users
return;
}
$this->urlpattern = $urlpattern;
}
public function set_typeof($typeof)
{
$this->typeof = $typeof;
}
}