You are here

function pretty_calendar_links_loader in Pretty Calendar 7

AJAX response for preloading node links.

Parameters

int $year: Selected year in "YYYY" format.

int $month: Selected month in "MM" format.

int $day: Selected day in "DD" format.

Return value

string Rendered list of links.

1 string reference to 'pretty_calendar_links_loader'
pretty_calendar_menu in ./pretty_calendar.module
Implements hook_menu().

File

./pretty_calendar.module, line 444
Simple nice calendar module that displays the materials by date.

Code

function pretty_calendar_links_loader($year, $month, $day) {
  header('Content-Type: text/html; charset=utf-8');
  $date = mktime(0, 0, 0, (int) $month, (int) $day, (int) $year);
  $result = pretty_calendar_select_nodes($date, TRUE);
  if (count($result) == 0) {
    print 'Error';
    drupal_exit();
  }
  $tooltip_count = variable_get('pretty_calendar_tooltip_count', '5');
  $counter = 0;
  $list = array();
  foreach ($result as $row) {
    $list['items'][] = l($row->title, 'node/' . $row->nid);
    $counter++;
    if ($counter >= $tooltip_count) {
      break;
    }
  }
  print theme('item_list', $list);
  $more_links = count($result) - $tooltip_count;
  if ($more_links > 0) {
    $links = pretty_calendar_plural($more_links);
    print '<p class="tooltip_summary">' . l(t('more @count', array(
      '@count' => $links,
    )), "calendar/{$year}/{$month}/{$day}") . '</p>';
  }
  drupal_exit();
}