You are here

function template_preprocess_osmplayer in MediaFront 7

Same name and namespace in other branches
  1. 6.2 players/osmplayer/osmplayer.module \template_preprocess_osmplayer()
  2. 6 players/osmplayer/osmplayer.module \template_preprocess_osmplayer()

The template preprocess function for the osm media player.

Parameters

$variables - The:

Return value

unknown_type

1 string reference to 'template_preprocess_osmplayer'
osmplayer_theme in players/osmplayer/osmplayer.module
Implements hook_theme()

File

players/osmplayer/osmplayer.module, line 723

Code

function template_preprocess_osmplayer(&$variables) {
  global $base_url, $user;

  // Let the mediafront populate all the variables for us.
  mediafront_template_preprocess($variables);

  // Get the params.
  $params =& $variables['params'];

  // Get the templates.
  $templates =& $variables['templates'];

  // Get the media player.
  $player = osmplayer_get_player_object($params);
  if ($player) {
    $params['id'] = $player
      ->getId();

    // Add the javascript for this player.
    osmplayer_add_js($player);

    // Add the CSS files for this player.
    osmplayer_add_css($player, $params['preset']);

    // Make sure they always have a template, theme, and version...
    $template = $params['template'] = $player
      ->getTemplate();
    $params['theme'] = $player
      ->getTheme();
    $params['version'] = $player->template
      ->getVersion();

    // Get the player prefix.
    $params['prefix'] = $player
      ->getPrefix();

    // Make sure we call the template_preprocess.
    template_preprocess($variables, 'osmplayer_' . $params['template']);

    // Now set up our templates within a template.
    $hooks = theme_get_registry(FALSE);
    $subtemplates = array(
      'controlBar' => 'controlbar',
      'titlebar' => 'titlebar',
      'menu' => 'menu',
      'node' => 'node',
      'teaser' => 'teaser',
      'scrollBar' => 'scrollbar',
      'pager' => 'pager',
      'playlist' => 'playlist',
    );

    // Iterate through all the possible subtemplates.
    foreach ($subtemplates as $name => $subtemplate) {
      $hook = 'osmplayer_' . $template . '_' . $subtemplate;
      $templates[$name] = isset($hooks[$hook]) ? theme($hook, array(
        'params' => $params,
        'templates' => $templates,
      )) : '';
    }

    // Determine the width and height.
    $width = $params['playlistOnly'] && $params['vertical'] ? '' : 'width:' . $params['width'] . 'px;';
    $variables['width'] = $params['fluidWidth'] ? 'width:100%;' : $width;
    $height = $params['playlistOnly'] && !$params['vertical'] || $params['controllerOnly'] ? '' : 'height:' . $params['height'] . 'px;';
    $variables['height'] = $params['fluidHeight'] ? 'height:100%;' : $height;
  }
}