View source
<?php
include_once drupal_get_path('module', 'flowplayer') . '/' . 'flowplayer.admin.inc';
include_once drupal_get_path('module', 'flowplayer') . '/' . 'flowplayer.jq.inc';
function flowplayer_help($section) {
switch ($section) {
case 'admin/settings/flowplayer':
return t('The following provides the default Flowplayer settings when the player is displayed. This does not mean it is how it will be displayed everywhere, it will just be the defaults if these settings are not explicitly sent through to the player.');
case 'admin/help#flowplayer':
$output = '<p>' . t('The following is a demonstration of <a href="@flowplayer">Flowplayer</a>. Note that you can change the defaults of how it looks in the <a href="@settings">Flowplayer settings</a>.', array(
'@flowplayer' => 'http://flowplayer.org',
'@settings' => url('admin/settings/flowplayer'),
)) . '</p>';
$output .= '<p>' . t("To create Flowplayer elements, you can either use the theme('flowplayer') function, or the flowplayer_add() function. The theme function will add the JavaScript to the page, as well as create the markup for you, while the <code>flowplayer_add()</code> function will just add the JavaScript.") . '</p>';
$output .= '<h3>' . t('Theme Funciton') . '</h3>';
$output .= '<p>' . t("Calling <code>theme('flowplayer')</code> will not only add the correct JavaScript to the page, but also construct the markup for you. The second argument passed through here is the video URL, but you can pass the <a href='http://flowplayer.org/documentation/configuration.html'>configuration options</a> instead as seen below.") . '</p>';
$output .= theme('flowplayer', 'http://e1h13.simplecdn.net/flowplayer/flowplayer.flv');
$output .= '<h3>' . t('Flowplayer Add') . '</h3>';
$output .= '<p>' . t("The <code>flowplayer_add()</code> function will add the Flowplayer JavaScript to the page, as well as register the Drupal JavaScript behaviors to load the Flowplayer appropriately. The first argument is the jQuery selector to apply the Flowplayer element to. The second argument is the <a href='http://flowplayer.org/documentation/configuration.html'>configuration options</a>. Using <code>flowplayer_add</code> requires you to already have the markup created.") . '</p>';
$output .= '<a href="http://e1h13.simplecdn.net/flowplayer/flowplayer.flv' . '" id="player" class="flowplayer"></a>';
flowplayer_add('#player', array(
'clip' => array(
'autoPlay' => FALSE,
'linkUrl' => 'http://flowplayer.org',
),
));
return $output;
break;
}
}
function flowplayer_add($selector = NULL, $config = NULL) {
static $flowplayer_added = FALSE;
static $flowplayer_selectors = array();
if ($flowplayer_added === FALSE) {
drupal_add_js(drupal_get_path('module', 'flowplayer') . '/flowplayer/flowplayer.min.js');
drupal_add_css(drupal_get_path('module', 'flowplayer') . '/flowplayer.css');
$settings = array(
'flowplayerSwf' => base_path() . drupal_get_path('module', 'flowplayer') . '/flowplayer/flowplayer.swf',
);
drupal_add_js($settings, 'setting');
$flowplayer_added = TRUE;
}
if (isset($selector) && !isset($flowplayer_selectors[$selector])) {
if (empty($flowplayer_selectors)) {
drupal_add_js(drupal_get_path('module', 'flowplayer') . '/flowplayer.js');
}
if (is_string($config)) {
$config = array(
'clip' => array(
'url' => $config,
),
);
}
if (!isset($config['key'])) {
$key = variable_get('flowplayer_key', NULL);
if (!empty($key)) {
$config['key'] = $key;
}
}
if (!isset($config['clip']['scaling'])) {
$config['clip']['scaling'] = variable_get('flowplayer_scaling', 'fit');
}
$colors = array(
'backgroundColor',
'sliderColor',
'buttonColor',
'buttonOverColor',
'durationColor',
'timeColor',
'progressColor',
'bufferColor',
);
foreach ($colors as $color) {
if (!isset($config['plugins']['controls'][$color])) {
$color_value = variable_get('flowplayer_color_' . $color, NULL);
if (!empty($color_value)) {
$config['plugins']['controls'][$color] = $color_value;
}
}
}
$buttons = variable_get('flowplayer_buttons', array());
foreach ($buttons as $button => $enabled) {
if (!isset($config['plugins']['controls'][$button])) {
$config['plugins']['controls'][$button] = $enabled ? TRUE : FALSE;
}
}
if (!isset($config['plugins']['controls']['backgroundGradient'])) {
$gradient = variable_get('flowplayer_background_gradient', NULL);
if (!empty($gradient)) {
$config['plugins']['controls']['backgroundGradient'] = $gradient;
}
}
if (!isset($config['plugins']['controls']['borderRadius'])) {
$radius = variable_get('flowplayer_border_radius', NULL);
if (!empty($radius)) {
$config['plugins']['controls']['borderRadius'] = $radius;
}
}
drupal_add_js(array(
'flowplayer' => array(
$selector => $config,
),
), 'setting');
$flowplayer_selectors[$selector] = TRUE;
}
}
function flowplayer_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array(
'path' => 'admin/settings/flowplayer',
'title' => 'Flowplayer',
'callback' => 'drupal_get_form',
'description' => 'Manage how Flowplayer is used on your site.',
'access' => user_access('administer site configuration'),
'callback arguments' => array(
'flowplayer_admin_settings',
),
);
}
return $items;
}
function theme_flowplayer($config = NULL, $id = 'flowplayer', $attributes = array(), $contents = '') {
$id = form_clean_id($id);
if (isset($attributes['class'])) {
$attributes['class'] .= ' flowplayer';
}
else {
$attributes['class'] = 'flowplayer';
}
$attributes = drupal_attributes($attributes);
flowplayer_add('#' . $id, $config);
return "<div id='{$id}' {$attributes}>{$contents}</div>";
}