ServiceController.php
4.17 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
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
<?php
class ServiceController extends Controller
{
/** @var array General Section Params */
public $generalData;
public function init()
{
parent::init();
/** @var $sectionData StaticData */
$sectionData = StaticData::model()->with('i18n')->findByPk(array('section' => $this->id, 'key' => 'general'));
$this->generalData = $sectionData->getDataAttributes() + $sectionData->i18n->getDataAttributes();
$this->headerGalleryId = $this->generalData['gallery_id'];
}
public function actionIndex()
{
$data = $this->loadStaticPage($this->id, $this->action->id);
$this->setContacts($data['contacts']);
$this->setContacts($this->generalData['contacts']);
$this->render('index', array(
'content1' => $data['content1'],
'content2' => $data['content2'],
));
}
public function actionCategory($category)
{
/** @var $currentCategory ServiceCategory */
$currentCategory = ServiceCategory::model()->with('i18n')->findByAttributes(array(
'link' => $category,
));
if (empty($currentCategory))
throw new CHttpException(404);
$this->sectionGalleryId = $currentCategory->gallery_id;
$this->setContacts(explode(',', $currentCategory->contacts_data));
$this->setContacts($this->generalData['contacts']);
$this->pageName = $currentCategory->i18n->page_name;
$this->setSEOParams($currentCategory->i18n->title, $currentCategory->i18n->keywords, $currentCategory->i18n->description);
$this->render('category', array(
'currentCategory' => $currentCategory,
));
}
public function actionView($category, $link)
{
/** @var $currentCategory ServiceCategory */
$currentCategory = ServiceCategory::model()->with('i18n')->findByAttributes(array(
'link' => $category,
));
if (empty($currentCategory))
throw new CHttpException(404);
$this->sectionGalleryId = $currentCategory->gallery_id;
/** @var $currentService Service */
$currentService = Service::model()->with('i18n')->findByAttributes(array(
'link' => $link,
'service_category_id' => $currentCategory->id,
));
if (empty($currentService))
throw new CHttpException(404);
$this->setContacts(explode(',', $currentService->contacts_data));
$this->setContacts(explode(',', $currentCategory->contacts_data));
$this->setContacts($this->generalData['contacts']);
$this->pageName = $currentService->i18n->page_name;
$this->setSEOParams($currentService->i18n->title, $currentService->i18n->keywords, $currentService->i18n->description);
$this->render('view', array(
'currentService' => $currentService,
'currentCategory' => $currentCategory,
));
}
public function actionCenter($center)
{
/** @var $currentCenter ServiceCenter */
$currentCenter = ServiceCenter::model()->with('i18n')->findByAttributes(array(
'link' => $center,
));
if (empty($currentCenter))
throw new CHttpException(404);
$this->sectionGalleryId = $currentCenter->gallery_id;
$this->setContacts(explode(',', $currentCenter->contacts_data));
$this->setContacts($this->generalData['contacts']);
$this->pageName = $currentCenter->i18n->page_name;
$this->setSEOParams($currentCenter->i18n->title, $currentCenter->i18n->keywords, $currentCenter->i18n->description);
$this->render('center', array(
'currentCenter' => $currentCenter,
));
}
/**
* @return ServiceCategory[]
*/
public function getServiceCategories()
{
return ServiceCategory::model()->with('i18n')->findAll(array(
'order' => 'rank asc',
'condition' => 'not t.hidden'
));
}
/**
* @return ServiceCenter[]
*/
public function getServiceCenters()
{
return ServiceCenter::model()->with('i18n')->findAll(array(
'order' => 'rank asc',
'condition' => 'not t.hidden',
));
}
}