PartnersSectionController.php
2.56 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
<?php
class PartnersSectionController extends NodeSectionController
{
/** @var AboutRoot */
public $_aboutRoot;
/** @var PartnersSection */
public $section;
public function init()
{
parent::init();
/** @var $section PartnersSection */
$section = PartnersSection::model()->with('i18n')->findByPk($this->getNode()->data_id);
$this->headerGalleryId = $section->header_gallery_id;
$this->section = $section;
}
public function actionPartners()
{
$section = $this->section;
$this->pageName = $section->i18n->page_name;
$this->setSEOParams($section->i18n->title, $section->i18n->keywords, $section->i18n->description);
$this->setContacts(explode(',', $section->contacts_data));
$this->setContacts(explode(',', $this->getAboutRoot()->contacts_data));
$partners = Partner::model()->with('i18n')->findAll(array(
'order' => 'rank asc',
'condition' => 'not t.hidden and t.partners_section_id = ' . $this->getNode()->data_id,
));
$this->render('partners', array(
'content1' => $section->i18n->content1,
'content2' => $section->i18n->content1,
'partners' => $partners,
));
}
public function actionPartner($link)
{
/** @var $partner Partner */
$partner = Partner::model()->with('i18n')->findByAttributes(array(
'link' => $link,
));
if (!isset($partner))
throw new CHttpException(404);
if ($partner->headerGalleryBehavior->getGalleryPhotoCount() > 0) {
$this->sectionGalleryId = $partner->header_gallery_id;
}
$this->pageName = $partner->i18n->page_name;
$this->setSEOParams($partner->i18n->title, $partner->i18n->keywords, $partner->i18n->description);
$this->setContacts(explode(',', $partner->contacts_data));
$this->setContacts(explode(',', $this->getAboutRoot()->contacts_data));
$partners = Partner::model()->with('i18n')->findAll(array(
'order' => 'rank asc',
'condition' => 'not t.hidden and t.partners_section_id = ' . $this->getNode()->data_id,
));
$this->render('partner', array(
'partner' => $partner,
'partners' => $partners,
));
}
/**
* @return AboutRoot|CActiveRecord
*/
public function getAboutRoot()
{
if (!isset($this->_aboutRoot)) $this->_aboutRoot = AboutRoot::model()->findByPk($this->getRootNode()->data_id);
return $this->_aboutRoot;
}
}