You are here

function addtocal_render in Add to Cal 7

Generate a render array for the addtocal widget.

Parameters

$entity_type:

$entity_id:

$start_date:

$end_date:

$timezone:

$url:

$ics_url:

$google_url:

$yahoo_url:

Return value

array

2 calls to addtocal_render()
addtocal_field_formatter_view in ./addtocal.module
Implements hook_field_formatter_view().
addtocal_tokens in ./addtocal.tokens.inc
Implements hook_tokens().

File

./addtocal.module, line 478
addtocal.module General functions and hook implementations.

Code

function addtocal_render($entity_type, $entity_id, $start_date, $end_date, $timezone, $url, $ics_url, $google_url, $yahoo_url, $email_format = false) {
  $rfc_dates = addtocal_rfc_3339_date($start_date, $end_date, $timezone);
  $element_id = 'addtocal_' . $entity_type . '_' . $entity_id;
  $render = array(
    'button' => array(
      '#markup' => t('Add to Calendar'),
      '#prefix' => '<div class="addtocal" id="' . $element_id . '">',
      '#suffix' => '</div>',
      '#weight' => 1,
    ),
    'menu' => array(
      '#weight' => 2,
      '#theme' => 'item_list',
      '#items' => array(
        l(t('iCalendar'), $ics_url, array()),
        l(t('Outlook'), $ics_url, array()),
        l(t('Google'), $google_url, array(
          'attributes' => array(
            'target' => '_blank',
          ),
        )),
        l(t('Yahoo'), $yahoo_url, array(
          'attributes' => array(
            'target' => '_blank',
          ),
        )),
      ),
      '#type' => 'ul',
      '#attributes' => array(
        'id' => $element_id . '_menu',
        'class' => array(
          'addtocal_menu',
        ),
      ),
    ),
  );
  if (!$email_format) {
    $render['#attached'] = array();
    $render['#attached']['js'] = array(
      drupal_get_path('module', 'addtocal') . '/addtocal.js',
    );
    $render['#attached']['css'] = array(
      drupal_get_path('module', 'addtocal') . '/addtocal.css',
    );
  }
  return $render;
}