| 1 |
<?php
|
| 2 |
// $Id: onepixelout.module,v 1.5 2009/03/06 19:48:01 stuartgreenfield Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* SWF Tools - Onepixelout's Flash Players
|
| 6 |
*
|
| 7 |
* Enables the use of Onepixelout's mp3 player
|
| 8 |
*
|
| 9 |
*/
|
| 10 |
|
| 11 |
define('ONEPIXELOUT', 'onepixelout'); // 'player', plays a single mp3
|
| 12 |
|
| 13 |
|
| 14 |
/**
|
| 15 |
* Implementation of hook_swftools_methods().
|
| 16 |
*/
|
| 17 |
function onepixelout_swftools_methods() {
|
| 18 |
|
| 19 |
$methods = array();
|
| 20 |
|
| 21 |
$media_player = array(
|
| 22 |
'name' => ONEPIXELOUT,
|
| 23 |
'module' => 'onepixelout',
|
| 24 |
'file' => 'soundFile', // Define which flashvar to assign a 'file to play' variable.
|
| 25 |
'version' => '7',
|
| 26 |
'shared_file' => '1pixelout/player.swf',
|
| 27 |
'title' => t('1 Pixel Out MP3 Player'),
|
| 28 |
'download' => 'http://www.1pixelout.net/code/audio-player-wordpress-plugin/',
|
| 29 |
'width' => '290',
|
| 30 |
'height' => '24',
|
| 31 |
);
|
| 32 |
|
| 33 |
$methods[SWFTOOLS_MP3_DISPLAY][ONEPIXELOUT] = $media_player;
|
| 34 |
|
| 35 |
return $methods;
|
| 36 |
}
|
| 37 |
|
| 38 |
/**
|
| 39 |
* Implementation of hook_menu().
|
| 40 |
*/
|
| 41 |
function onepixelout_menu() {
|
| 42 |
$items = array();
|
| 43 |
|
| 44 |
//$items['admin/media/swf/onepixelout'] = array(
|
| 45 |
$items['admin/settings/swftools/onepixelout'] = array(
|
| 46 |
'title' => '1 Pixel Out',
|
| 47 |
'description' => 'Settings for '. l('1 Pixel Out MP3 Player', 'http://www.1pixelout.net/code/audio-player-wordpress-plugin/') .'.',
|
| 48 |
'access arguments' => array('administer flash'),
|
| 49 |
'page callback' => 'drupal_get_form',
|
| 50 |
'page arguments' => array('onepixelout_admin_form'),
|
| 51 |
'file' => 'onepixelout.admin.inc',
|
| 52 |
'file path' => drupal_get_path('module', 'onepixelout'),
|
| 53 |
);
|
| 54 |
|
| 55 |
return $items;
|
| 56 |
}
|
| 57 |
|
| 58 |
|
| 59 |
/**
|
| 60 |
* These are the default settings as they are stored in the database and displayed
|
| 61 |
* on the settings page.
|
| 62 |
*/
|
| 63 |
function _onepixelout_settings() {
|
| 64 |
|
| 65 |
$saved = variable_get('swftools_'. ONEPIXELOUT, array());
|
| 66 |
|
| 67 |
$defaults = array(
|
| 68 |
'autostart' => 'no',
|
| 69 |
'loop' => 'no',
|
| 70 |
'bg' => '',
|
| 71 |
'leftbg' => '',
|
| 72 |
'rightbg' => '',
|
| 73 |
'rightbghover' => '',
|
| 74 |
'lefticon' => '',
|
| 75 |
'righticon' => '',
|
| 76 |
'righticonhover' => '',
|
| 77 |
'text' => '',
|
| 78 |
'slider' => '',
|
| 79 |
'loader' => '',
|
| 80 |
'track' => '',
|
| 81 |
'border' => '',
|
| 82 |
);
|
| 83 |
|
| 84 |
return array_merge($defaults, $saved);
|
| 85 |
}
|
| 86 |
|
| 87 |
/**
|
| 88 |
* Implementation of swftools_flashvars hook.
|
| 89 |
* Return an array of flashvars.
|
| 90 |
*/
|
| 91 |
function onepixelout_swftools_flashvars($action, &$methods, &$vars) {
|
| 92 |
$saved = _onepixelout_flashvars();
|
| 93 |
|
| 94 |
// Combine user and admin defaults, overwriting defaults.
|
| 95 |
$saved = array_merge($saved, $vars->flashvars);
|
| 96 |
return $saved;
|
| 97 |
}
|
| 98 |
|
| 99 |
/**
|
| 100 |
* This function takes the module settings and massages them
|
| 101 |
* as required for flashvar output.
|
| 102 |
*
|
| 103 |
*/
|
| 104 |
function _onepixelout_flashvars() {
|
| 105 |
// Cache this.
|
| 106 |
static $flashvars = array();
|
| 107 |
if (!count($flashvars)) {
|
| 108 |
// Get saved settings for this method.
|
| 109 |
$saved = _onepixelout_settings();
|
| 110 |
foreach ($saved AS $key => $setting) {
|
| 111 |
if (!$setting || $setting == 'default') {
|
| 112 |
// Don't pass out any undefined values.
|
| 113 |
unset($saved[$key]);
|
| 114 |
}
|
| 115 |
}
|
| 116 |
}
|
| 117 |
return $saved;
|
| 118 |
}
|
| 119 |
|
| 120 |
|
| 121 |
/*
|
| 122 |
* Implementation of hook_swftools_variable_mapping.
|
| 123 |
*
|
| 124 |
*/
|
| 125 |
function onepixelout_swftools_variable_mapping() {
|
| 126 |
return array(
|
| 127 |
ONEPIXELOUT => array(
|
| 128 |
'loop' => 'flashvars',
|
| 129 |
'autostart' => 'flashvars',
|
| 130 |
'leftbg' => 'flashvars',
|
| 131 |
'lefticon' => 'flashvars',
|
| 132 |
'rightbg' => 'flashvars',
|
| 133 |
'righticon' => 'flashvars',
|
| 134 |
'rightbghover' => 'flashvars',
|
| 135 |
'righticonhover' => 'flashvars',
|
| 136 |
),
|
| 137 |
);
|
| 138 |
}
|