SaleController.php
1.96 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
<?php
class SaleController extends NodeSiteController
{
/** @var SaleRoot */
public $saleRoot;
public function init()
{
parent::init();
$this->saleRoot = SaleRoot::model()->with('i18n')->findByPk($this->getNode()->data_id);
$this->headerGalleryId = $this->saleRoot->header_gallery_id;
}
public function actionIndex()
{
$sort = new CSort();
$sort->defaultOrder = array(
'rank' => false,
);
$vehicles = Vehicle::model()->with('i18n')->findAll(array(
'condition' => 'not t.hidden and t.sale_root_id = ' . $this->saleRoot->id,
'order' => 'rank asc, t.id desc',
));
$this->pageName = $this->saleRoot->i18n->page_name;
$this->setSEOParams($this->saleRoot->i18n->title, $this->saleRoot->i18n->keywords, $this->saleRoot->i18n->description);
$this->setContacts(explode(',', $this->saleRoot->contacts_data));
$this->render('index', array(
'vehicles' => $vehicles,
));
}
public function actionView($link)
{
/** @var $vehicle Vehicle */
$vehicle = Vehicle::model()->with('i18n')->findByAttributes(array(
'sale_root_id' => $this->saleRoot->id,
'link' => $link,
));
if (empty($vehicle)) throw new CHttpException(404);
$this->pageName = $vehicle->i18n->page_name;
$this->setSEOParams($vehicle->i18n->title, $vehicle->i18n->keywords, $vehicle->i18n->description);
$this->setContacts(explode(',', $vehicle->contacts_data));
$this->setContacts(explode(',', $this->saleRoot->contacts_data));
$vehicles = Vehicle::model()->with('i18n')->findAll(array(
'condition' => 'not t.hidden and t.sale_root_id = ' . $this->saleRoot->id,
'order' => 'rank asc, t.id desc',
));
$this->render('view', array(
'vehicles' => $vehicles,
'vehicle' => $vehicle,
));
}
}