|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Base class for a widget that displays media results as a simple list. |
|
5
|
|
|
* |
|
6
|
|
|
* @author Sam Stenvall <[email protected]> |
|
7
|
|
|
* @copyright Copyright © Sam Stenvall 2014- |
|
8
|
|
|
* @license https://www.gnu.org/licenses/gpl.html The GNU General Public License v3.0 |
|
9
|
|
|
*/ |
|
10
|
|
|
Yii::import('bootstrap.widgets.TbGridView'); |
|
11
|
|
|
|
|
12
|
|
|
abstract class ResultList extends TbGridView |
|
13
|
|
|
{ |
|
14
|
|
|
use ResultTrait; |
|
|
|
|
|
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Returns the column definitions |
|
18
|
|
|
*/ |
|
19
|
|
|
abstract public function getColumnDefinitions(); |
|
20
|
|
|
|
|
21
|
|
|
public function beforeParentInit() |
|
22
|
|
|
{ |
|
23
|
|
|
// Configure columns |
|
24
|
|
|
$this->columns = $this->getColumnDefinitions(); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Returns the column definition for the label column |
|
29
|
|
|
* @return array |
|
30
|
|
|
*/ |
|
31
|
|
|
protected function getLabelColumn() |
|
32
|
|
|
{ |
|
33
|
|
|
return array( |
|
34
|
|
|
'name'=>'label', |
|
35
|
|
|
'header'=>Yii::t('GenericList', 'Title'), |
|
36
|
|
|
'type'=>'html', |
|
37
|
|
|
'value'=>function($data) { |
|
38
|
|
|
/* @var $data Media */ |
|
39
|
|
|
echo CHtml::link($data->label, Yii::app()->controller->createUrl('details', array('id'=>$data->getId()))); |
|
40
|
|
|
echo $data->getWatchedIcon(); |
|
41
|
|
|
}, |
|
42
|
|
|
); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Returns the column definition for the year column |
|
47
|
|
|
* @return array |
|
48
|
|
|
*/ |
|
49
|
|
|
protected function getYearColumn() |
|
50
|
|
|
{ |
|
51
|
|
|
return array( |
|
52
|
|
|
'name'=>'premiered', |
|
53
|
|
|
'header'=>Yii::t('GenericList', 'Year'), |
|
54
|
|
|
'value'=>function($data) { |
|
55
|
|
|
/** @var Movie|TVShow $data */ |
|
56
|
|
|
echo $data->getRenderedYear(); |
|
57
|
|
|
}, |
|
58
|
|
|
); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Returns the column definition for the genre column |
|
63
|
|
|
* @return array |
|
64
|
|
|
*/ |
|
65
|
|
|
protected function getGenreColumn() |
|
66
|
|
|
{ |
|
67
|
|
|
return array( |
|
68
|
|
|
'name'=>'genre', |
|
69
|
|
|
'header'=>Yii::t('GenericList', 'Genre'), |
|
70
|
|
|
'value'=>function($data) { |
|
71
|
|
|
/* @var $data Media */ |
|
72
|
|
|
return $data->getGenreString(); |
|
73
|
|
|
} |
|
74
|
|
|
); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
} |
|
78
|
|
|
|