|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Description of ResultHelper |
|
5
|
|
|
* |
|
6
|
|
|
* @author Sam Stenvall <[email protected]> |
|
7
|
|
|
*/ |
|
8
|
|
|
class ResultHelper |
|
9
|
|
|
{ |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Returns the configuration for the pager to be used in result views. |
|
13
|
|
|
* @return array |
|
14
|
|
|
*/ |
|
15
|
|
|
public static function getDefaultPagerConfiguration() |
|
16
|
|
|
{ |
|
17
|
|
|
return array( |
|
18
|
|
|
'class'=>'bootstrap.widgets.TbPager', |
|
19
|
|
|
'maxButtonCount'=>10, |
|
20
|
|
|
'htmlOptions'=>array('align'=>TbHtml::PAGINATION_ALIGN_RIGHT), |
|
21
|
|
|
); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Renders the specified summary along with a display mode toggle |
|
26
|
|
|
* @param string $summary the HTML for the original summary |
|
27
|
|
|
*/ |
|
28
|
|
|
public static function renderDisplayModeToggle($summary, $context) |
|
29
|
|
|
{ |
|
30
|
|
|
?> |
|
31
|
|
|
<div class="row-fluid"> |
|
32
|
|
|
<div class="span12 pull-right display-mode-toggle"> |
|
33
|
|
|
<?php |
|
34
|
|
|
|
|
35
|
|
|
echo $summary; |
|
36
|
|
|
|
|
37
|
|
|
/* @var $ctrl MediaController */ |
|
38
|
|
|
$ctrl = Yii::app()->controller; |
|
39
|
|
|
|
|
40
|
|
|
// Get the current display mode so we can show an icon next to it |
|
41
|
|
|
$currentMode = $ctrl->getDisplayMode($context); |
|
42
|
|
|
|
|
43
|
|
|
echo TbHtml::buttonDropdown(Yii::t('DisplayMode', 'Display mode'), array( |
|
44
|
|
|
array('label'=>Yii::t('DisplayMode', 'Grid view'), 'url'=>array( |
|
45
|
|
|
'setDisplayMode', 'mode'=>DisplayMode::MODE_GRID, 'context'=>$context), |
|
46
|
|
|
'icon'=>$currentMode === DisplayMode::MODE_GRID ? TbHtml::ICON_OK : ''), |
|
47
|
|
|
array('label'=>Yii::t('DisplayMode', 'List view'), 'url'=>array( |
|
48
|
|
|
'setDisplayMode', 'mode'=>DisplayMode::MODE_LIST, 'context'=>$context), |
|
49
|
|
|
'icon'=>$currentMode === DisplayMode::MODE_LIST? TbHtml::ICON_OK : ''), |
|
50
|
|
|
), array( |
|
51
|
|
|
'color'=>TbHtml::BUTTON_COLOR_INFO, |
|
52
|
|
|
'class'=>'fa fa-bars' |
|
53
|
|
|
)); |
|
54
|
|
|
|
|
55
|
|
|
?> |
|
56
|
|
|
</div> |
|
57
|
|
|
</div> |
|
58
|
|
|
<?php |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Formats a rating |
|
63
|
|
|
* @param float $rating the rating |
|
64
|
|
|
* @return string the formatted rating |
|
65
|
|
|
*/ |
|
66
|
|
|
public static function formatRating($rating) |
|
67
|
|
|
{ |
|
68
|
|
|
return number_format($rating, 1); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
} |
|
72
|
|
|
|