/
Group.php
133 lines (119 loc) · 2.67 KB
/
Group.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
/**
* @category Fishpig
* @package Fishpig_AttributeSplash
* @license http://fishpig.co.uk/license.txt
* @author Ben Tideswell <help@fishpig.co.uk>
*/
class Fishpig_AttributeSplash_Model_Group extends Fishpig_AttributeSplash_Model_Abstract
{
/**
* Setup the model's resource
*
* @return void
*/
public function _construct()
{
$this->_init('attributeSplash/group');
}
/**
* Retrieve the name of the splash page
* If display name isn't set, option value label will be returned
*
* @return string
*/
public function getName()
{
return $this->getDisplayName() ? $this->getDisplayName() : $this->getFrontendLabel();
}
/**
* Determine whether the model is active
*
* @return bool
*/
public function isActive()
{
return (($group = Mage::registry('splash_group')) !== null)
&& $group->getId() === $this->getId();
}
/**
* Retrieve the URL for the splash group
* If cannot find rewrite, return system URL
*
* @return string
*/
public function getUrl()
{
if (!$this->hasUrl()) {
$this->setUrl(
$this->_getUrl($this->getUrlKey() . $this->getUrlSuffix())
);
}
return $this->_getData('url');
}
/**
* Retrieve the attribute model for the page
*
* @return Mage_Eav_Model_Entity_Attribute
*/
public function getAttributeModel()
{
if (!$this->hasAttributeModel()) {
$this->setAttributeModel($this->getResource()->getAttributeModel($this));
}
return $this->getData('attribute_model');
}
/**
* Retrieve a collection of products associated with the splash page
*
* @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
*/
public function getSplashPages()
{
return $this->getResource()->getSplashPages($this);
}
/**
* Determine whether this group has any splash pages
*
* @return bool
*/
public function hasSplashPages()
{
return count($this->getSplashPages()) > 0;
}
/**
* Retrieve the date/time the item was updated
*
* @param bool $includeTime = true
* @return string
*/
public function getUpdatedAt($includeTime = true)
{
if ($str = $this->_getData('updated_at')) {
return $includeTime ? $str : trim(substr($str, 0, strpos($str, ' ')));
}
return '';
}
/**
* Retrieve the date/time the item was created
*
* @param bool $includeTime = true
* @return string
*/
public function getCreatedAt($includeTime = true)
{
if ($str = $this->_getData('created_at')) {
return $includeTime ? $str : trim(substr($str, 0, strpos($str, ' ')));
}
return '';
}
/**
* Determine whether it's possible to delete the group
*
* @return bool
*/
public function canDelete()
{
return $this->getResource()->canDelete($this);
}
}