ActionController.php
4.27 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
122
123
124
125
126
<?php
class ActionController 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->sectionGalleryId = $data['gallery_id'];
$this->setContacts($data['contacts']);
$this->setContacts($this->generalData['contacts']);
/** @var $actions Action[] */
$actions = Action::model()->with('i18n', 'actionCategory')->findAll(array(
// 'condition' => 'not t.hidden and not actionCategory.hidden and not is_finished',
'order' => 't.rank asc',
));
$this->render('index', array(
'actions' => $actions,
'content' => $data['content'],
));
}
public function actionCategory($link)
{
/** @var $category ActionCategory */
$category = ActionCategory::model()->with('i18n')->findByAttributes(array(
'link' => $link,
));
if (empty($category))
throw new CHttpException(404);
$this->sectionGalleryId = $category->gallery_id;
$this->pageName = $category->i18n->page_name;
$this->setSEOParams($category->i18n->title, $category->i18n->keywords, $category->i18n->description);
$this->setContacts(explode(',', $category->contacts_data));
$this->setContacts($this->generalData['contacts']);
/** @var $actions Action[] */
$actions = Action::model()->with('i18n', 'actionCategory')->findAll(array(
'condition' => 'not t.hidden and not is_finished and action_category_id =' . $category->id,
'order' => 't.rank asc',
));
$this->render('index', array(
'actions' => $actions,
'content' => $category->i18n->content,
'currentCategory' => $category,
));
}
public function actionFinished()
{
$data = $this->loadStaticPage($this->id, $this->action->id);
$this->sectionGalleryId = $data['gallery_id'];
$this->setContacts($data['contacts']);
$this->setContacts($this->generalData['contacts']);
/** @var $actions Action[] */
$actions = Action::model()->with('i18n', 'actionCategory')->findAll(array(
'condition' => 'not t.hidden and is_finished',
'order' => 't.rank asc',
));
$this->render('index', array(
'actions' => $actions,
'content' => $data['content'],
));
}
public function actionView($category, $link)
{
/** @var $category ActionCategory */
$category = ActionCategory::model()->with('i18n')->findByAttributes(array(
'link' => $category,
));
if (empty($category))
throw new CHttpException(404);
$this->sectionGalleryId = $category->gallery_id;
/** @var $action Action */
$action = Action::model()->with('i18n')->findByAttributes(array(
'link' => $link,
'action_category_id' => $category->id,
));
if (empty($action))
throw new CHttpException(404);
$this->pageName = $action->i18n->page_name;
$this->setSEOParams($action->i18n->title, $action->i18n->keywords, $action->i18n->description);
$this->setContacts(explode(',', $action->contacts_data));
$this->setContacts(explode(',', $category->contacts_data));
$this->setContacts($this->generalData['contacts']);
$this->render('view', array(
'currentCategory' => $category,
'currentAction' => $action,
'content' => $action->i18n->content,
));
}
/**
* @return ActionCategory[]
*/
public function getActionCategories()
{
return ActionCategory::model()->with('i18n')->findAll(array(
'order' => 'rank asc',
'condition'=>'not t.hidden',
));
}
}