/
key_list.php
214 lines (184 loc) · 5.11 KB
/
key_list.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<?php
namespace Concrete\Controller\Element\Attribute;
use Concrete\Core\Attribute\AttributeKeyInterface;
use Concrete\Core\Attribute\Category\CategoryInterface;
use Concrete\Core\Entity\Attribute\Type;
use Concrete\Core\Controller\ElementController;
class KeyList extends ElementController
{
protected $dashboard_page_path;
protected $dashboard_page_add_action = 'select_type';
protected $dashboard_page_edit_action = 'edit';
protected $dashboard_page_sort_action = 'sort_attribute_set';
protected $dashboard_page_parameters = array();
protected $enable_sorting = true;
protected $attribute_sets = array();
protected $unassigned_attribute_keys = array();
protected $category;
protected $types = array();
/**
* @return bool
*/
public function enableSorting()
{
return $this->enable_sorting;
}
/**
* @param bool $enable_sorting
*/
public function setEnableSorting($enable_sorting)
{
$this->enable_sorting = $enable_sorting;
}
/**
* @return array
*/
public function getAttributeSets()
{
return $this->attribute_sets;
}
/**
* @param array $attribute_sets
*/
public function setAttributeSets($attribute_sets)
{
$this->attribute_sets = $attribute_sets;
}
/**
* @return array
*/
public function getUnassignedAttributeKeys()
{
return $this->unassigned_attribute_keys;
}
/**
* @param array $unassigned_attribute_keys
*/
public function setUnassignedAttributeKeys($unassigned_attribute_keys)
{
$this->unassigned_attribute_keys = $unassigned_attribute_keys;
}
/**
* @return mixed
*/
public function getCategory()
{
return $this->category;
}
/**
* @param mixed $category
*/
public function setCategory(CategoryInterface $category)
{
$this->category = $category;
}
public function getElement()
{
return 'attribute/key/list';
}
/**
* @return array
*/
public function getAttributeTypes()
{
return $this->types;
}
/**
* @param array $types
*/
public function setAttributeTypes($types)
{
$this->types = $types;
}
public function getSortAttributeCategoryURL()
{
$args = array($this->getDashboardPagePath(), $this->getDashboardPageSortAction());
return call_user_func_array(array('\URL', 'to'), $args);
}
public function getAddAttributeTypeURL(Type $type)
{
$args = array($this->getDashboardPagePath(), $this->getDashboardPageAddAction());
$args = array_merge($args, $this->getDashboardPageParameters(), array($type->getAttributeTypeID()));
return call_user_func_array(array('\URL', 'to'), $args);
}
public function getEditAttributeKeyURL(AttributeKeyInterface $key)
{
$args = array($this->getDashboardPagePath(), $this->getDashboardPageEditAction());
$args = array_merge($args, $this->getDashboardPageParameters(), array($key->getAttributeKeyID()));
return call_user_func_array(array('\URL', 'to'), $args);
}
public function view()
{
$types = array();
foreach ($this->getAttributeTypes() as $type) {
$types[$type->getAttributeTypeID()] = $type;
}
$this->set('types', $types);
$this->set('enableSorting', $this->enableSorting());
$this->set('sortable_sets', $this->getAttributeSets());
$this->set('unassigned', $this->getUnassignedAttributeKeys());
}
/**
* @return mixed
*/
public function getDashboardPagePath()
{
return $this->dashboard_page_path;
}
/**
* @param mixed $dashboard_page_path
*/
public function setDashboardPagePath($dashboard_page_path)
{
$this->dashboard_page_path = $dashboard_page_path;
}
/**
* @return string
*/
public function getDashboardPageSortAction()
{
return $this->dashboard_page_sort_action;
}
/**
* @return string
*/
public function getDashboardPageAddAction()
{
return $this->dashboard_page_add_action;
}
/**
* @param string $dashboard_page_add_action
*/
public function setDashboardPageAddAction($dashboard_page_add_action)
{
$this->dashboard_page_add_action = $dashboard_page_add_action;
}
/**
* @return array
*/
public function getDashboardPageParameters()
{
return $this->dashboard_page_parameters;
}
/**
* @param array $dashboard_page_parameters
*/
public function setDashboardPageParameters($dashboard_page_parameters)
{
$this->dashboard_page_parameters = $dashboard_page_parameters;
}
/**
* @return string
*/
public function getDashboardPageEditAction()
{
return $this->dashboard_page_edit_action;
}
/**
* @param string $dashboard_page_edit_action
*/
public function setDashboardPageEditAction($dashboard_page_edit_action)
{
$this->dashboard_page_edit_action = $dashboard_page_edit_action;
}
}