Project

General

Profile

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"><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>';
18
	}
19
	
20
	// Format a single statistic.
21
	// $statistic the statistic to format
22
	// $baseUrl the base URL to use for links
23
	// return a string containing the full HTML for the statistic or an empty string if any errors occur
24
	public static function formatStatistic($statistic, $baseUrl) {
25
		// TODO JRoute :: _ keeps decoding urlencoded values, so this is just a hack to cope with this
26
		$data = ($statistic -> data == NULL) ? NULL : array_map(function ($row) use ($statistic, $baseUrl) {return '<a href="' . JRoute :: _($baseUrl .  '&amp;' . urlencode($statistic -> id) . '=' . urlencode($row -> id)) . '" class="entry" title="' . $row -> name . '">' . ((strlen($row -> name) > BrowseHelper :: MAX_ROW) ? (substr($row -> name, 0, BrowseHelper :: MAX_ROW - strlen('...')) . '...') : $row -> name) . '</a>&nbsp;<span>(' . $row -> count . ')</span>';}, $statistic -> data);
27
		return '<div class="searchCol"><h5>' . $statistic -> title . '</h5>' . (($statistic -> data == NULL) ? ('<div class="box-info">' . $statistic -> error . '</div>') : ('<div><p>' . implode('<br />', array_slice($data, 0, BrowseHelper :: MAX_ROWS)) . ((count($data) > BrowseHelper :: MAX_ROWS) ? ('<br /><span class="viewmore">' . JText :: _('VIEW_MORE') . '</span>') : '') . '</p></div>')) . ((count($data) > BrowseHelper :: MAX_ROWS) ? ('<div style="display: none;"><div class="viewallpop"><div class="header"><h5>' . $statistic -> title . '</h5></div><p>' . implode('<br />', $data) . '</p></div></div>') : '') . '</div>';
28
	}
29
}
30

    
31

    
32

    
33

    
(1-1/15)