1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Base class for rendering a filter form on index pages. It provides an |
5
|
|
|
* abstract method (renderControls()) which should render the filter controls, |
6
|
|
|
* as well as an overridable renderButtons() method in case the default setup |
7
|
|
|
* is not enough. |
8
|
|
|
* |
9
|
|
|
* @author Sam Stenvall <[email protected]> |
10
|
|
|
* @copyright Copyright © Sam Stenvall 2013- |
11
|
|
|
* @license https://www.gnu.org/licenses/gpl.html The GNU General Public License v3.0 |
12
|
|
|
*/ |
13
|
|
|
abstract class VideoFilter extends CWidget |
14
|
|
|
{ |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @var VideoFilterForm the form model |
18
|
|
|
*/ |
19
|
|
|
public $model; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var FilterActiveForm the form |
23
|
|
|
*/ |
24
|
|
|
protected $form; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Renders the filter controls |
28
|
|
|
*/ |
29
|
|
|
abstract protected function renderControls(); |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Initializes the widget |
33
|
|
|
*/ |
34
|
|
|
public function init() |
35
|
|
|
{ |
36
|
|
|
$this->form = $this->beginWidget($this->getFormClassName(), array( |
37
|
|
|
'layout'=>TbHtml::FORM_LAYOUT_INLINE, |
38
|
|
|
'method'=>'get')); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Renders the widget |
43
|
|
|
*/ |
44
|
|
|
public function run() |
45
|
|
|
{ |
46
|
|
|
?> |
47
|
|
|
<div class="movie-filter-form well"> |
48
|
|
|
<div class="row-fluid"> |
49
|
|
|
<div class="span10"> |
50
|
|
|
<div class="row-fluid"> |
51
|
|
|
<div class="span12"> |
52
|
|
|
<?php $this->renderControls(); ?> |
53
|
|
|
</div> |
54
|
|
|
</div> |
55
|
|
|
</div> |
56
|
|
|
|
57
|
|
|
<div class="span2"> |
58
|
|
|
<div class="buttons"> |
59
|
|
|
<?php $this->renderButtons(); ?> |
60
|
|
|
</div> |
61
|
|
|
</div> |
62
|
|
|
</div> |
63
|
|
|
</div> |
64
|
|
|
<?php |
65
|
|
|
|
66
|
|
|
$this->endWidget(); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Renders the form buttons |
71
|
|
|
*/ |
72
|
|
|
protected function renderButtons() |
73
|
|
|
{ |
74
|
|
|
echo TbHtml::submitButton(Yii::t('FilterForm', 'Apply filter'), array( |
75
|
|
|
'color'=>TbHtml::BUTTON_COLOR_PRIMARY)); |
76
|
|
|
|
77
|
|
|
$controller = Yii::app()->controller; |
78
|
|
|
|
79
|
|
|
// Disable when no filter is defined |
80
|
|
|
echo TbHtml::linkButton(Yii::t('FilterForm', 'Clear filter'), array( |
81
|
|
|
'color'=>TbHtml::BUTTON_COLOR_INFO, |
82
|
|
|
'disabled'=>$this->model->isEmpty(), |
83
|
|
|
'url'=>$controller->createUrl($controller->route))); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @return string the name of the active form class to use |
88
|
|
|
*/ |
89
|
|
|
protected function getFormClassName() |
90
|
|
|
{ |
91
|
|
|
return 'FilterActiveForm'; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @return bool whether auto-complete functionality should be enabled on actor fields |
97
|
|
|
*/ |
98
|
|
|
protected function enableActorTypeahead() |
99
|
|
|
{ |
100
|
|
|
return Setting::getBoolean('enableActorTypeahead'); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
} |
104
|
|
|
|