View source
<?php
define('ONEPIXELOUT', 'onepixelout');
function onepixelout_swftools_methods() {
$methods = array();
$media_player = array(
'name' => ONEPIXELOUT,
'module' => 'onepixelout',
'file' => 'soundFile',
'version' => '7',
'shared_file' => '1pixelout/player.swf',
'title' => t('1 Pixel Out MP3 Player'),
);
$methods[SWFTOOLS_MP3_DISPLAY][ONEPIXELOUT] = $media_player;
return $methods;
}
function onepixelout_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array(
'path' => 'admin/media/swf/onepixelout',
'title' => t('1 Pixel Out'),
'callback' => 'drupal_get_form',
'callback arguments' => 'onepixelout_admin_form',
'description' => 'Settings for ' . l('1 Pixel Out MP3 Player', 'http://www.1pixelout.net/code/audio-player-wordpress-plugin/') . '.',
);
}
return $items;
}
function onepixelout_admin_form() {
include_once drupal_get_path('module', 'onepixelout') . '/onepixelout.admin.inc';
return _onepixelout_admin_form();
}
function onepixelout_admin_form_submit($form_id, &$form_values) {
include_once drupal_get_path('module', 'onepixelout') . '/onepixelout.admin.inc';
return _onepixelout_admin_form_submit($form_id, $form_values);
}
function theme_onepixelout_admin_form($form_values) {
$output = drupal_render($form_values['onepixelout_mediaplayer']['autostart']);
$output .= drupal_render($form_values['onepixelout_mediaplayer']['loop']);
$output .= '<img src="http://www.1pixelout.net/wp-content/plugins/audio-player/map.gif" alt="Player Map" />';
$output .= drupal_render($form_values);
return $output;
}
function _onepixelout_settings() {
$saved = variable_get('swftools_' . ONEPIXELOUT, array());
$defaults = array(
'autostart' => 'no',
'loop' => 'no',
'bg' => '',
'leftbg' => '',
'rightbg' => '',
'rightbghover' => '',
'lefticon' => '',
'righticon' => '',
'righticonhover' => '',
'text' => '',
'slider' => '',
'loader' => '',
'track' => '',
'border' => '',
);
return array_merge($defaults, $saved);
}
function onepixelout_swftools_flashvars($action, &$methods, &$vars) {
$saved = _onepixelout_flashvars();
$saved = array_merge($saved, $vars->flashvars);
return $saved;
}
function _onepixelout_flashvars() {
static $flashvars = array();
if (!count($flashvars)) {
$saved = _onepixelout_settings();
foreach ($saved as $key => $setting) {
if (!$setting || $setting == 'default') {
unset($saved[$key]);
}
}
}
return $saved;
}
function onepixelout_swf($filepath, $params = SWFDEFAULT, $flashvars = SWFDEFAULT, $othervars = SWFDEFAULT, $methods = SWFDEFAULT, $debug = FALSE) {
$methods['player'] = ONEPIXELOUT;
return swf($filepath, $params, $flashvars, $othervars, $methods);
}
function onepixelout_swftools_variable_mapping() {
return array(
ONEPIXELOUT => array(
'loop' => 'flashvars',
'autostart' => 'flashvars',
'leftbg' => 'flashvars',
'lefticon' => 'flashvars',
'rightbg' => 'flashvars',
'righticon' => 'flashvars',
'rightbghover' => 'flashvars',
'righticonhover' => 'flashvars',
),
);
}