function nodereferrer_theme_formatter in NodeReferrer 6
Same name and namespace in other branches
- 7 nodereferrer.module \nodereferrer_theme_formatter()
Generic formatter function
4 calls to nodereferrer_theme_formatter()
- theme_nodereferrer_formatter_default in ./
nodereferrer.module - Theme functions for 'default' field formatter.
- theme_nodereferrer_formatter_full in ./
nodereferrer.module - Theme function for 'full' field formatter.
- theme_nodereferrer_formatter_plain in ./
nodereferrer.module - Theme function for 'plain' field formatter.
- theme_nodereferrer_formatter_teaser in ./
nodereferrer.module - Theme function for 'teaser' field formatter.
File
- ./
nodereferrer.module, line 245 - Defines a field type for backlinking referencing nodes.
Code
function nodereferrer_theme_formatter($formatter, $info) {
$items = isset($info['#item']['items']) ? $info['#item']['items'] : array();
$limit = isset($info['#item']['limit']) ? $info['#item']['limit'] : 0;
$element = isset($info['#item']['element']) ? $info['#item']['element'] : array();
$pager = '';
if ($limit) {
// Fake the values set by pager query...
global $pager_page_array, $pager_total, $pager_total_items;
$page = isset($_GET['page']) ? $_GET['page'] : '';
// Convert comma-separated $page to an array, used by other functions.
$pager_page_array = explode(',', $page);
// We calculate the total of pages as ceil(items / limit).
$pager_total_items[$element] = count($items);
$pager_total[$element] = ceil($pager_total_items[$element] / $limit);
$pager_page_array[$element] = max(0, min((int) $pager_page_array[$element], (int) $pager_total[$element] - 1));
// only display the select elements.
if (is_array($items)) {
$items = array_slice($items, $pager_page_array[$element] * $limit, $limit);
}
$pager = theme('pager', array(), $limit, $element);
}
$themed_items = array();
foreach ($items as $i) {
$i['field'] = $info;
// Add some extra information the themer might like to have
$themed_items[] = theme('nodereferrer_field_' . $formatter, $i);
}
$out = theme('item_list', $themed_items) . $pager;
return $out;
}