1
|
<?php
|
2
|
|
3
|
defined('_JEXEC') or die('Access denied');
|
4
|
|
5
|
jimport('joomla.methods');
|
6
|
|
7
|
// This helper formats paging.
|
8
|
abstract class BrowseHelper {
|
9
|
const MAX_ROWS = 5;
|
10
|
const MAX_ROW = 24;
|
11
|
|
12
|
// Format browse.
|
13
|
// $statistics the statistics to format
|
14
|
// $baseUrl the base URL to use for links
|
15
|
// return a string containing the full HTML for browse or an empty string if any errors occur
|
16
|
public static function formatBrowse($statistics, $baseUrl) {
|
17
|
return '<div class="quickViewSelections"><div class="flowWrapper">' . (($statistics == NULL) ? ('<div class="error">' . JText :: _('ERROR_RETRIEVING_STATISTICS') . '</div>') : implode('', array_map(function ($statistic) use ($baseUrl) {return BrowseHelper :: formatStatistic($statistic, $baseUrl);}, $statistics))) . '</div></div>';
|
18
|
//return '<div class="quickViewSelections"><h3>' . JText :: _('AT_A_GLANCE') . '</h3><div class="flowWrapper">' . (($statistics == NULL) ? ('<div class="error">' . JText :: _('ERROR_RETRIEVING_STATISTICS') . '</div>') : implode('', array_map(function ($statistic) use ($baseUrl) {return BrowseHelper :: formatStatistic($statistic, $baseUrl);}, $statistics))) . '</div></div>';
|
19
|
|
20
|
}
|
21
|
|
22
|
// Format a single statistic.
|
23
|
// $statistic the statistic to format
|
24
|
// $baseUrl the base URL to use for links
|
25
|
// return a string containing the full HTML for the statistic or an empty string if any errors occur
|
26
|
public static function formatStatistic($statistic, $baseUrl, $type="") {
|
27
|
// TODO JRoute :: _ keeps decoding urlencoded values, so this is just a hack to cope with this
|
28
|
mb_internal_encoding('UTF-8');
|
29
|
$data = ($statistic -> data == NULL) ? NULL : array_map(function ($row) use ($statistic, $baseUrl) {
|
30
|
//encode '&' to '%26' otherwise it takes it as a parameter
|
31
|
$row -> id= str_replace('&','%26',$row -> id);
|
32
|
return '<a href="' . JRoute :: _($baseUrl . '&' . urlencode($statistic -> id) . '=' . urlencode($row -> id)) . '" class="entry" title="' . $row -> name . '">' . ((strlen($row -> name) > BrowseHelper :: MAX_ROW) ? (mb_substr($row -> name, 0, BrowseHelper :: MAX_ROW - strlen('...')) . '...') : $row -> name) . '</a> <span>(' . $row -> count . ')</span>';}, $statistic -> data);
|
33
|
return '<div class="searchCol"><h5>' . $statistic -> title . '</h5>' . (($statistic -> data == NULL) ? ('<div class="box-info">' . $statistic -> error . '</div>') : ('' . implode('<br />', array_slice($data, 0, BrowseHelper :: MAX_ROWS)) . ((count($data) > BrowseHelper :: MAX_ROWS) ? ('<br /><span class="viewmore">' . JText :: _('VIEW_MORE') . '</span>') : '') . '')) . ((count($data) > BrowseHelper :: MAX_ROWS) ? ('<div style="display: none;"><div class="viewallpop" id="' . $statistic -> id .$type. 'More"><div class="header"><h5>' . $statistic -> title . '</h5></div><p>' . implode('<br />', $data) . '</p></div></div>') : '') . '</div>';
|
34
|
}
|
35
|
}
|
36
|
|
37
|
|
38
|
|
39
|
|