/
Content.php
79 lines (60 loc) · 1.52 KB
/
Content.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
69
70
71
72
73
74
75
76
77
78
79
<?php
class Showcase_Content
{
protected $_id;
protected $_media;
protected $_article;
protected $_image;
protected $_status;
protected $_published;
protected $_updated;
protected $_created;
public function __get($v)
{
$var = "_" . $v;
if (property_exists($this, $var)){
return $this->$var;
}
return false;
}
public function __set($v, $val)
{
$var = "_" . $v;
if (property_exists($this, $var)){
$this->$var = $val;
}
return false;
}
protected function __construct (){
$this->_published = new Zend_Date(null, Zend_Registry::get('locale'));
$this->_created = new Zend_Date(null, Zend_Registry::get('locale'));
$this->_updated = new Zend_Date(null, Zend_Registry::get('locale'));
}
public static function factory(stdClass $result)
{
$self = new self();
$self->_id = $result->id;
$self->_media = $result->media;
$self->_article = $result->article;
$self->_image = $result->image;
$self->_status = $result->status;
$self->_published ->set($result->published);
$self->_updated ->set($result->updated);
$self->_created ->set($result->created);
return $self;
}
public function getMediaByIdentifier($identifier)
{
if ( (!$this->media) || (is_array($this->media) && 1 > count($this->media)) ) {
return false;
}
foreach($this->media as $media){
if ($media instanceof Showcase_Media) {
if (trim(strtolower($identifier)) === strtolower($media->identifier) ) {
return $media;
}
}
}
return false;
}
}