SportController.php
2.14 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
<?php
class SportController extends NodeSiteController
{
/** @var SportRoot */
public $sportRoot;
public function init()
{
parent::init();
$this->sportRoot = SportRoot::model()->with('i18n')->findByPk($this->getNode()->data_id);
$this->headerGalleryId = $this->sportRoot->header_gallery_id;
}
public function actionIndex()
{
$this->render('index', array(
'show_silk_way' => $this->sportRoot->show_silk_way,
'study_title' => $this->sportRoot->i18n->study_title,
'study_image' => $this->sportRoot->i18n->study_image,
'study_content' => $this->sportRoot->i18n->study_content,
'study_button' => $this->sportRoot->i18n->study_button,
'awards_content' => $this->sportRoot->i18n->awards_content,
'awards_button' => $this->sportRoot->i18n->study_button,
'champions_content' => $this->sportRoot->i18n->champions_content,
'qualifications_content' => $this->sportRoot->i18n->qualifications_content,
'study_link' => $this->sportRoot->i18n->study_link,
'awards_link' => $this->sportRoot->i18n->awards_link,
'team_link' => $this->sportRoot->i18n->team_link,
));
}
/**
* @param int $limit
* @return News[]
*/
public static function getLatestNews($limit = 3)
{
return News::model()->with('i18n')->findAll(array(
'order' => 'date desc',
'condition' => 'not t.hidden and t.news_category_id=2',
'limit' => $limit,
));
}
/**
* @param string $country
* @return SportEvent[]
*/
public static function getNearestEvents($country = 'all')
{
$criteria = new CDbCriteria(array(
'order' => 'start_date asc',
'condition' => 'end_date>=:today',
'limit' => 3,
'params' => array(
':today' => date('Y-m-d'),
)
));
if ($country != 'all') {
$criteria->addCondition('country_id = ' . $country);
}
return SportEvent::model()->with('i18n')->findAll($criteria);
}
}