You are here

function theme_availability_calendar_viewport in Availability Calendars 7.3

Same name and namespace in other branches
  1. 7.5 availability_calendar.theme.inc \theme_availability_calendar_viewport()
  2. 7.4 availability_calendar.theme.inc \theme_availability_calendar_viewport()

Themes the availability calendar field in a viewport.

Parameters

array $variables:

Return value

string

File

./availability_calendar.theme.inc, line 39

Code

function theme_availability_calendar_viewport($variables) {

  // Add the necessary js for the viewport functionality.
  availability_calendar_add_viewport_js($variables['cid'], $variables['name'], $variables['settings'], $variables['mode']);

  // Theme the buttons
  $viewport_settings = $variables['settings']['viewport'];
  $placement = $viewport_settings['button_placement'];
  if ($placement !== 'not') {
    $scroll = $viewport_settings['scroll'] * ($viewport_settings['rows'] > 1 ? $viewport_settings['cols'] : 1);
    $button_back = theme('availability_calendar_viewport_button', array(
      'direction' => 'back',
      'scroll' => $scroll,
    ));
    $button_forward = theme('availability_calendar_viewport_button', array(
      'direction' => 'forward',
      'scroll' => $scroll,
    ));
  }
  $output = '<div id="cal-' . $variables['cid'] . '" class="cal clearfix">' . "\n";
  if (!empty($variables['name'])) {
    $output .= '<div class="field-label">' . $variables['name'] . ':&nbsp;</div>' . "\n";
  }
  if ($placement === 'before') {
    $output .= "<div class=\"cal-buttons\">{$button_back} {$button_forward}</div>";
  }
  else {
    if ($placement === 'before_after') {
      $output .= "<div class=\"cal-buttons cal-buttons-before\">{$button_back}</div>";
    }
  }
  $output .= '<div class="cal-viewport"><div class="cal-viewport-inner">' . "\n";
  $output .= theme('availability_calendar_months', $variables);
  $output .= "</div></div>\n";
  if ($placement === 'before_after') {
    $output .= "<div class=\"cal-buttons cal-buttons-after\">{$button_forward}</div>";
  }
  else {
    if ($placement === 'after') {
      $output .= "<div class=\"cal-buttons\">{$button_back} {$button_forward}</div>";
    }
  }
  $output .= "</div>\n";
  return $output;
}