You are here

function theme_emvideo_flickr_sets_imagerotator in Media: Flickr 6

Outputs a custom player, such as JW Image Rotator, and pulls in the XML feed for the videos.

File

providers/emvideo/flickr_sets.inc, line 267
This include processes flickr.com photosets for use by emfield/emvideo.module.

Code

function theme_emvideo_flickr_sets_imagerotator($item, $width, $height, $autoplay, $options = array()) {
  global $base_path;
  $formatter = isset($options['formatter']) ? $options['formatter'] : 'video';
  $delay = isset($options['rotatetime']) ? $options['rotatetime'] : (isset($options['field']['widget']['media_flickr_rotatetime_' . $formatter]) ? $options['field']['widget']['media_flickr_rotatetime_' . $formatter] : variable_get('media_flickr_options_rotatetime', 5));

  // Currently, for best performance, we need the
  // Media: Flickr -- XSPF Playlist module to continue.
  if (module_exists('media_flickr')) {
    $captions = isset($options['captions']) ? $options['captions'] : (isset($options['field']['widget']['media_flickr_ir_captions_' . $formatter]) ? $options['field']['widget']['media_flickr_ir_captions_' . $formatter] : variable_get('media_flickr_xspf_caption_type', MEDIA_FLICKR_XSPF_CAPTION_TYPE_TITLE));
    $flashvars['file'] = url('media/flickr/photoset/' . $item['value'] . '/xspf/' . $delay . '/' . $width . '/' . $height . '/' . $captions, array(
      'absolute' => TRUE,
    ));
  }
  else {

    // Grab a playlist from Flickr for this. However, this has a limit of
    // 20 items in the feed, and has no duration.
    $flashvars['file'] = url('media/flickr/remote/' . $item['value'], array(
      'absolute' => TRUE,
    ));
  }
  $params['width'] = $width;
  $params['height'] = $height;
  $params['allowfullscreen'] = isset($options['allowfullscreen']) ? $options['allowfullscreen'] : (isset($options['field']['widget']['media_flickr_ir_allowfullscreen_' . $formatter]) ? $options['field']['widget']['media_flickr_ir_allowfullscreen_' . $formatter] : variable_get('media_flickr_options_ir_allowfullscreen', TRUE));
  $params['allowfullscreen'] = $params['allowfullscreen'] ? 'true' : 'false';
  $params['allowscriptaccess'] = isset($options['allowscriptaccess']) ? $options['allowscriptaccess'] : (isset($options['field']['widget']['media_flickr_ir_allowscriptaccess_' . $formatter]) ? $options['field']['widget']['media_flickr_ir_allowscriptaccess_' . $formatter] : variable_get('media_flickr_options_ir_allowscriptaccess', 'always'));

  // The following behaviors are defined by the Image Rotator flash itself.
  $flashvars['usefullscreen'] = $params['allowfullscreen'];
  $flashvars['autostart'] = $autoplay ? 'true' : 'false';
  $flashvars['repeat'] = isset($options['repeat']) ? $options['repeat'] : (isset($options['field']['widget']['media_flickr_ir_repeat_' . $formatter]) ? $options['field']['widget']['media_flickr_ir_repeat_' . $formatter] : variable_get('media_flickr_options_ir_repeat', 'list'));
  $flashvars['shownavigation'] = isset($options['shownavigation']) ? $options['shownavigation'] : (isset($options['field']['widget']['media_flickr_ir_shownavigation_' . $formatter]) ? $options['field']['widget']['media_flickr_ir_shownavigation_' . $formatter] : variable_get('media_flickr_options_ir_shownavigation', TRUE));
  $flashvars['shownavigation'] = $flashvars['shownavigation'] ? 'true' : 'false';
  $flashvars['showicons'] = isset($options['showicons']) ? $options['showicons'] : (isset($options['field']['widget']['media_flickr_ir_showicons_' . $formatter]) ? $options['field']['widget']['media_flickr_ir_showicons_' . $formatter] : variable_get('media_flickr_options_ir_showicons', TRUE));
  $flashvars['showicons'] = $flashvars['showicons'] ? 'true' : 'false';
  $flashvars['shuffle'] = isset($options['shuffle']) ? $options['shuffle'] : (isset($options['field']['widget']['media_flickr_ir_shuffle_' . $formatter]) ? $options['field']['widget']['media_flickr_ir_shuffle_' . $formatter] : variable_get('media_flickr_options_ir_shuffle', FALSE));
  $flashvars['shuffle'] = $flashvars['shuffle'] ? 'true' : 'false';
  $flashvars['transition'] = isset($options['transition']) ? $options['transition'] : (isset($options['field']['widget']['media_flickr_ir_transition_' . $formatter]) ? $options['field']['widget']['media_flickr_ir_transition_' . $formatter] : variable_get('media_flickr_options_ir_transition', 'random'));
  $flashvars['enablejs'] = 'true';
  $logo = isset($options['logo']) ? $options['logo'] : (isset($options['field']['widget']['media_flickr_ir_logo_' . $formatter]) ? $options['field']['widget']['media_flickr_ir_logo_' . $formatter] : variable_get('media_flickr_options_ir_logo', ''));
  if ($logo) {
    $flashvars['logo'] = url($logo);
  }

  // Comply with http://www.w3.org/TR/WCAG10-HTML-TECHS/#applet-text-equivalent
  // and add a text element to the object when embedding directly.
  $accessibility_title = isset($options['title']) ? $options['title'] : variable_get('media_flickr_sets_title_default', t('Flickr Photoset'));
  if (function_exists('emfield_imagerotator_url')) {
    $path = emfield_imagerotator_url();
  }
  if ($path && variable_get('emfield_swfobject', FALSE) && module_exists('swfobject_api')) {
    return theme('swfobject_api', $base_path . $path, $params, $flashvars);
  }
  else {
    if ($path) {
      static $count;
      $count++;
      $id = 'emvideo-flickr-' . $count;
      $object_id = $id . '-rotator';
      $path = $base_path . $path;

      // Width & Height need to be set explicity in the flashvars, or else it
      // doesn't display properly with wmode transparent.
      $flashvars['width'] = $width;
      $flashvars['height'] = $height;
      $flashvars = drupal_query_string_encode($flashvars);

      // Fix IE security popup; see http://jira.atlassian.com/browse/CONF-6284.
      $base_root = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';
      $output = <<<EMBED
    <div id="{<span class="php-variable">$id</span>}">
      <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
          codebase="{<span class="php-variable">$base_root</span>}://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
          width="{<span class="php-variable">$width</span>}" height="{<span class="php-variable">$height</span>}" id="{<span class="php-variable">$object_id</span>}">
        <param name="movie" value="{<span class="php-variable">$path</span>}" />
        <param name="allowfullscreen" value="true" />
        <param name="wmode" value="transparent" />
        <param name="flashvars" value="{<span class="php-variable">$flashvars</span>}" />
        <!--[if !IE]> -->
          <object type="application/x-shockwave-flash" data="{<span class="php-variable">$path</span>}" name="rotator" width="{<span class="php-variable">$width</span>}" height="{<span class="php-variable">$height</span>}" id="{<span class="php-variable">$object_id</span>}">
            <param name="movie" value="{<span class="php-variable">$path</span>}" />
            <param name="allowfullscreen" value="true" />
            <param name="wmode" value="transparent" />
            <param name="flashvars" value="{<span class="php-variable">$flashvars</span>}" />
            {<span class="php-variable">$accessibility_title</span>}
          </object>
        <!-- <![endif]-->
      </object>
    </div>
EMBED;
      return $output;
    }
  }

  // Fallback if things fail from here.
  return theme('emvideo_flickr_sets_flash', $item, $width, $height, $autoplay, $options);
}