You are here

function cctags_page in cctags 6

Same name and namespace in other branches
  1. 7 cctags.page.inc \cctags_page()

@file

1 string reference to 'cctags_page'
cctags_menu in ./cctags.module
Implementation of hook_menu

File

./cctags.page.inc, line 7

Code

function cctags_page($item) {
  global $pager_page_array, $pager_total, $pager_total_items;
  $cctid = $item['cctid'];
  $title = $item['page_title'];
  $m = _cctags_get_select_list('amount_tags');
  $amount = $m[$item['page_amount']];
  $mode = $item['page_mode'];
  $vocname = $item['page_vocname'];
  if ($cctid == NULL) {
    return drupal_not_found();
  }
  drupal_set_title($title == '<none>' ? '' : $title);
  $terms = cctags_get_level_tags($cctid, 'page');
  $count_terms = 0;
  foreach ($terms as $k => $v) {
    $count_terms += count($v);
  }
  $page = !isset($_GET['page']) || $amount == 0 || $count_terms < $amount ? 0 : $_GET['page'];
  $content = theme('cctags_level', $terms, $amount, $page, $mode, $vocname, 'page');
  $pager = NULL;
  if ($amount > 0 and $count_terms > $amount) {
    $pager_page_array = explode(',', $page);
    $pager_total_items[0] = $count_terms;
    $pager_total[0] = ceil($pager_total_items[0] / $amount);
    $pager_page_array[0] = max(0, min((int) $pager_page_array[0], (int) $pager_total[0] - 1));
    $pager = theme('pager', NULL, $amount, 0);
  }
  $output = theme('cctags_page', $cctid, $content, $pager);
  return $output;
}