View source
<?php
define('SIMPLEVIEWER', 'simpleviewer');
function simpleviewer_swftools_methods() {
$methods = array();
$image_rotator = array(
'name' => SIMPLEVIEWER,
'module' => 'simpleviewer',
'shared_file' => 'simpleviewer/viewer.swf',
'file' => 'xmlDataPath',
'version' => '7',
'title' => t('SimpleViewer'),
'download' => 'http://www.airtightinteractive.com/simpleviewer/',
);
$methods[SWFTOOLS_IMAGE_DISPLAY_LIST][SIMPLEVIEWER] = $image_rotator;
return $methods;
}
function simpleviewer_menu() {
$items = array();
$items['admin/settings/swftools/simpleviewer'] = array(
'title' => 'SimpleViewer',
'description' => 'Settings for <a href="http://www.airtightinteractive.com/simpleviewer/">Airtight Interactive\'s SimpleViewer</a> image gallery.',
'weight' => 1,
'access arguments' => array(
'administer flash',
),
'page callback' => 'drupal_get_form',
'page arguments' => array(
'simpleviewer_admin_form',
),
'file' => 'simpleviewer.admin.inc',
'file path' => drupal_get_path('module', 'simpleviewer'),
);
return $items;
}
function simpleviewer_swftools_flashvars($action, &$methods, &$vars) {
$sv_vars = _simpleviewer_vars();
if (is_array($sv_vars['other'])) {
$vars->othervars = array_merge($sv_vars['other'], $vars->othervars);
}
return $sv_vars['swf'];
}
function _simpleviewer_vars() {
include_once drupal_get_path('module', 'simpleviewer') . '/simpleviewer.admin.inc';
$sv_vars = simpleviewer_admin_form(TRUE);
foreach (element_children($sv_vars) as $name) {
$name_parts = explode('_', $name);
if ($name_parts[1] == 'xml') {
$return['xml'][$name_parts[2]] = $sv_vars[$name]['#default_value'];
}
elseif ($name_parts[1] == 'swf') {
$return['swf'][$name_parts[2]] = $sv_vars[$name]['#default_value'];
}
else {
$return['other'][$name_parts[2]] = $sv_vars[$name]['#default_value'];
}
}
return $return;
}
function swftools_simpleviewer_playlist($playlist_data, &$method, &$vars) {
$sv_vars = _simpleviewer_vars();
$xml_vars = array_merge($sv_vars['xml'], $vars->flashvars);
$xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$xml .= '<simpleviewerGallery ' . 'maxImageWidth="' . $xml_vars['maxImageWidth'] . '" ' . 'maxImageHeight="' . $xml_vars['maxImageHeight'] . '" ' . 'textColor="' . str_replace('#', '0x', $xml_vars['textColor']) . '" ' . 'frameColor="' . str_replace('#', '0x', $xml_vars['frameColor']) . '" ' . 'frameWidth="' . $xml_vars['frameWidth'] . '" ' . 'stagePadding="' . $xml_vars['stagePadding'] . '" ' . 'thumbnailColumns="' . $xml_vars['thumbnailColumns'] . '" ' . 'thumbnailRows="' . $xml_vars['thumbnailRows'] . '" ' . 'navPosition="' . $xml_vars['navPosition'] . '" ' . 'title="' . $xml_vars['title'] . '" ' . 'imagePath="' . $vars->params['base'] . '/" ' . 'thumbPath="' . $vars->params['base'] . '/" ' . 'enableRightClickOpen="' . $xml_vars['enableRightClickOpen'] . '" ' . 'backgroundImagePath="' . $xml_vars['backgroundImagePath'] . '">';
foreach ($playlist_data['playlist'] as $track => $details) {
$xml .= '
<image>
<filename>' . $details['filename'] . '</filename>
<caption>' . $details['description'] . '</caption>
</image>';
}
$xml .= "\n</simpleviewerGallery>";
return $xml;
}