|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
Yii::import('bootstrap.widgets.TbModal'); |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Base class for the modals that show watch/download buttons and links |
|
7
|
|
|
* |
|
8
|
|
|
* @author Sam Stenvall <[email protected]> |
|
9
|
|
|
* @copyright Copyright © Sam Stenvall 2014- |
|
10
|
|
|
* @license https://www.gnu.org/licenses/gpl.html The GNU General Public License v3.0 |
|
11
|
|
|
*/ |
|
12
|
|
|
abstract class WatchMediaModal extends TbModal |
|
13
|
|
|
{ |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @var Media the media operated on |
|
17
|
|
|
*/ |
|
18
|
|
|
public $media; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @return string the name of the class that should be rendered inside the |
|
22
|
|
|
* modal body |
|
23
|
|
|
*/ |
|
24
|
|
|
abstract protected function getInnerWidgetClass(); |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @return array the options for the Watch button |
|
28
|
|
|
*/ |
|
29
|
|
|
abstract protected function getWatchButtonOptions(); |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Initializes the widget |
|
33
|
|
|
*/ |
|
34
|
|
|
public function init() |
|
35
|
|
|
{ |
|
36
|
|
|
// Generate a unique ID. We can't rely on the built-in counter in |
|
37
|
|
|
// CWidget::getId() because these modals may be rendered from AJAX |
|
38
|
|
|
// request and the counter will be zero then |
|
39
|
|
|
$this->id = uniqid($this->getId()); |
|
40
|
|
|
|
|
41
|
|
|
parent::init(); |
|
42
|
|
|
|
|
43
|
|
|
TbHtml::addCssClass('watch-modal', $this->htmlOptions); |
|
44
|
|
|
$this->header = Yii::t('Movies', 'Watch / Download'); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Renders the modal body |
|
49
|
|
|
*/ |
|
50
|
|
|
public function renderModalBody() |
|
51
|
|
|
{ |
|
52
|
|
|
echo CHtml::openTag('div', array('class'=>'modal-body')); |
|
53
|
|
|
|
|
54
|
|
|
$this->widget($this->getInnerWidgetClass(), array( |
|
55
|
|
|
'details'=>$this->media, |
|
56
|
|
|
)); |
|
57
|
|
|
|
|
58
|
|
|
echo CHtml::closeTag('div'); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Renders the button that triggers the modal |
|
63
|
|
|
* @param array $htmlOptions (optional) options for the button |
|
64
|
|
|
*/ |
|
65
|
|
|
public function renderTriggerButton($htmlOptions = array()) |
|
66
|
|
|
{ |
|
67
|
|
|
$commonOptions = array( |
|
68
|
|
|
'class'=>'fa fa-play watch-modal-button', |
|
69
|
|
|
'data-toggle'=>'modal', |
|
70
|
|
|
'data-target'=>'#'.$this->id); |
|
71
|
|
|
|
|
72
|
|
|
echo TbHtml::button(Yii::t('RetrieveMediaWidget', 'Watch'), array_merge( |
|
73
|
|
|
$commonOptions, $this->getWatchButtonOptions(), $htmlOptions)); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
} |
|
77
|
|
|
|