function _classified_page_overview in Classified Ads 6.3
Same name and namespace in other branches
- 7.3 classified.module \_classified_page_overview()
Page callback for 'classified'.
Build a page listing ad categories and the number of ads in them. This is a bit heavy on CPU so we cache the whole overview.
Return value
string The listing.
1 string reference to '_classified_page_overview'
- classified_menu in ./
classified.module - Implements hook_menu().
File
- ./
classified.module, line 460 - A pure D6 classified ads module inspired by the ed_classified module.
Code
function _classified_page_overview() {
$cid = 'classified:overview';
$admin_access = user_access('administer nodes') || user_access('administer classified ads');
$cached = $admin_access ? FALSE : cache_get($cid);
if ($cached) {
list($header, $rows, $total) = $cached->data;
}
else {
$vid = _classified_get('vid');
$terms = taxonomy_get_tree($vid);
$header = array(
t('Ad category'),
array(
'class' => 'classified-number',
'data' => t('# Ads'),
),
);
$rows = array();
foreach ($terms as $term) {
$count = taxonomy_term_count_nodes($term->tid, 'classified');
$params = array(
'!link' => l($term->name, taxonomy_term_path($term)),
'!description' => filter_xss_admin($term->description),
);
$category = empty($term->description) ? $params['!link'] : t('!link - !description', $params);
$rows[] = array(
theme('indentation', $term->depth) . $category,
array(
'class' => 'classified-number',
'data' => $count,
),
);
}
$total = taxonomy_term_count_nodes(0, 'classified');
if (!$admin_access) {
// One minute minimum lifetime.
cache_set($cid, array(
$header,
$rows,
$total,
), 'cache', $_SERVER['REQUEST_TIME'] + 60);
}
}
$link = url('node/add/classified');
$caption = user_access('create classified ad content') ? format_plural($total, 'Only one Classified Ad. <a href="!link">Add one</a>', '@count Classified Ads. <a href="!link">Add one</a>', array(
'!link' => $link,
)) : format_plural($total, 'Only one Classified Ad.', '@count Classified Ads');
$ret = theme(array(
'classified_overview',
'table',
), $header, $rows, array(
'class' => 'classified-term-list',
), $caption);
return $ret;
}