View source
<?php
define('WIJERING_IMAGEROTATOR', 'wijering_imagerotator');
define('IMAGEROTATOR_DOWNLOAD', 'http://www.jeroenwijering.com/?item=jw_image_rotator');
function imagerotator_swftools_methods() {
$methods = array();
$image_rotator = array(
'name' => WIJERING_IMAGEROTATOR,
'module' => 'imagerotator',
'file' => 'file',
'version' => '7',
'shared_file' => 'flash_image_rotator/imagerotator.swf',
'title' => t('JW Image Rotator 3'),
'download' => IMAGEROTATOR_DOWNLOAD,
);
$methods[SWFTOOLS_IMAGE_DISPLAY_LIST][WIJERING_IMAGEROTATOR] = $image_rotator;
return $methods;
}
function imagerotator_menu() {
$items = array();
$items['admin/settings/swftools/imagerotator'] = array(
'title' => 'JW Image Rotator 3',
'description' => 'Plug-in for ' . l('Jeroen Wijering\'s Image Rotator 3', IMAGEROTATOR_DOWNLOAD) . '.',
'access arguments' => array(
'administer flash',
),
'page callback' => 'drupal_get_form',
'page arguments' => array(
'imagerotator_admin_form',
),
'file' => 'imagerotator.admin.inc',
'file path' => drupal_get_path('module', 'imagerotator'),
);
return $items;
}
function _imagerotator_settings($player) {
$opts = _imagerotator_options();
switch ($player) {
case WIJERING_IMAGEROTATOR:
$defaults['boolean'] = array(
'shuffle' => 'default',
'shownavigation' => 'default',
'linkfromdisplay' => 'default',
'showicons' => 'default',
'enablejs' => 'default',
);
$defaults['color'] = array(
'backcolor' => '',
'frontcolor' => '',
'lightcolor' => '',
);
$defaults['url'] = array(
'logo' => '',
'link' => '',
);
$defaults['integer'] = array(
'width' => '400',
'height' => '320',
'rotatetime' => '3',
);
$defaults['other'] = array(
'transition' => 'default',
'linktarget' => 'default',
'overstretch' => 'default',
);
$saved_settings = variable_get('swftools_' . WIJERING_IMAGEROTATOR, array());
break;
}
foreach ($defaults as $category => $vars) {
foreach ($vars as $key => $setting) {
if (isset($saved_settings[$key])) {
$defaults[$category][$key] = $saved_settings[$key];
}
}
}
return $defaults;
}
function imagerotator_swftools_flashvars($action, &$methods, &$vars) {
$saved_settings = _imagerotator_flashvars($methods->player['name']);
$saved = array();
foreach ($saved_settings as $category => $settings) {
$saved = array_merge($saved, $settings);
}
$flashvars = array_merge($saved, $vars->flashvars);
if (isset($flashvars['image']) && !valid_url($flashvars['image'], TRUE)) {
$flashvars['image'] = swftools_get_media_url(swftools_get_media_path() . $flashvars['image']);
}
if ($vars->params['width']) {
$flashvars['width'] = $vars->params['width'];
}
if ($vars->params['height']) {
$flashvars['height'] = $vars->params['height'];
}
return $flashvars;
}
function _imagerotator_flashvars($this_player) {
static $flashvars = array();
if (!count($flashvars)) {
foreach (array(
WIJERING_IMAGEROTATOR,
) as $player) {
$defaults = _imagerotator_settings($player);
foreach ($defaults as $category => $vars) {
foreach ($vars as $key => $setting) {
if (!$setting || $setting == 'default') {
unset($defaults[$category][$key]);
}
else {
switch ($category) {
case 'color':
$defaults['color'][$key] = str_replace('#', '0x', $defaults['color'][$key]);
break;
case 'boolean':
$defaults['boolean'][$key] = _swftools_tf($defaults['boolean'][$key]);
break;
}
}
}
}
if ($defaults['integer']['displaywidth']) {
unset($defaults['integer']['displayheight']);
}
else {
unset($defaults['integer']['displaywidth']);
}
$flashvars[$player] = $defaults;
}
}
return $flashvars[$this_player];
}
function _imagerotator_options() {
$options['overstretch'] = array(
'default' => 'default',
'false' => 'false',
'true' => 'true',
'fit' => 'fit',
'none' => 'none',
);
$options['repeat'] = array(
'default' => 'default',
'false' => 'false',
'true' => 'true',
'list' => 'list',
);
$options['linktarget'] = array(
'default' => 'default',
'_self' => '_self',
'_blank' => '_blank',
);
$options['transition'] = array(
'default' => 'default',
'fade' => 'fade',
'bgfade' => 'bgfade',
'blocks' => 'blocks',
'bubbles' => 'bubbles',
'circles' => 'circles',
'flash' => 'flash',
'fluids' => 'fluids',
'lines' => 'lines',
'slowfade' => 'slowfade',
'random' => 'random',
);
$options['bool'] = array(
'default' => 'default',
'true' => 'true',
'false' => 'false',
);
return $options;
}
function swftools_wijering_imagerotator_playlist($xml_data, &$method, &$vars) {
$xml = '<playlist version="1" xmlns="http://xspf.org/ns/0/">
<title>' . $xml_data['header']['title'] . '</title>
<info></info>
<annotation></annotation>
<trackList>
';
foreach ($xml_data['playlist'] as $track => $details) {
$xml .= "<track>\n";
$xml .= "<title>" . $details['title'] . "</title>\n";
$xml .= "<creator></creator>\n";
$xml .= "<location>" . $details['fileurl'] . "</location>\n";
$xml .= "<info>" . $details['fileurl'] . "</info>\n";
$xml .= "</track>\n";
}
$xml .= '</trackList>
</playlist>';
return $xml;
}
function imagerotator_swftools_variable_mapping() {
return array(
WIJERING_IMAGEROTATOR => array(
'shuffle' => 'flashvars',
'shownavigation' => 'flashvars',
'linkfromdisplay' => 'flashvars',
'showicons' => 'flashvars',
'enablejs' => 'flashvars',
'backcolor' => 'flashvars',
'frontcolor' => 'flashvars',
'lightcolor' => 'flashvars',
'logo' => 'flashvars',
'link' => 'flashvars',
'rotatetime' => 'flashvars',
'transition' => 'flashvars',
'linktarget' => 'flashvars',
'overstretch' => 'flashvars',
),
);
}
function imagerotator_help($path, $arg) {
switch ($path) {
case 'admin/settings/swftools/imagerotator':
return '<p>' . t('These are the settings for Jeroen Wijering\'s imagerotator.swf
and correspond (by category and order) to the
<a href="@imagerotator">Media Player and Image Rotator read me</a>.
It is possible that you do not need to change any of
these settings and blank values will defer to friendly
defaults. Note that the label in (<em>brackets</em>)
is the actual flashvar name and corresponds to the read me.', array(
'@imagerotator' => 'http://jeroenwijering.com/extras/readme.html',
)) . '</p>';
}
}