| 154 |
'#options' => array('no' => t('No'), 'yes' => t('Yes')), |
'#options' => array('no' => t('No'), 'yes' => t('Yes')), |
| 155 |
'#description' => t('Indicates that the mp3 file urls are encoded.'), |
'#description' => t('Indicates that the mp3 file urls are encoded.'), |
| 156 |
); |
); |
| 157 |
|
|
| 158 |
|
$form['mp3player_suppress'] = array( |
| 159 |
|
'#type' => 'select', |
| 160 |
|
'#title' => t('Suppress cache messages'), |
| 161 |
|
'#default_value' => variable_get('mp3player_suppress', 'no'), |
| 162 |
|
'#options' => array('no' => t('No'), 'yes' => t('Yes')), |
| 163 |
|
'#description' => t('Suppress all messages about the MP3 Player cache being rebuilt.'), |
| 164 |
|
); |
| 165 |
|
|
| 166 |
if (module_exists('filefieldmp3player')) { |
if (module_exists('filefieldmp3player')) { |
| 167 |
$form['mp3player_description'] = array( |
$form['mp3player_description'] = array( |
| 168 |
'#type' => 'select', |
'#type' => 'select', |
| 173 |
); |
); |
| 174 |
} |
} |
| 175 |
|
|
| 176 |
|
$page_options = array( |
| 177 |
|
'page_enable' => t('Load only on the listed pages.'), |
| 178 |
|
'page_disable' => t('Load on every page except the listed pages.'), |
| 179 |
|
); |
| 180 |
|
$form['mp3player_page_init']['mp3player_page_init_action'] = array( |
| 181 |
|
'#type' => 'radios', |
| 182 |
|
'#options' => $page_options, |
| 183 |
|
'#title' => t('Enable MP3 Player on specific pages'), |
| 184 |
|
'#default_value' => variable_get('mp3player_page_init_action', 'page_disable'), |
| 185 |
|
); |
| 186 |
|
// Add text input for list of pages to take specific action on. |
| 187 |
|
$form['mp3player_page_init']['mp3player_page_list'] = array( |
| 188 |
|
'#type' => 'textarea', |
| 189 |
|
'#title' => t('Pages'), |
| 190 |
|
'#description' => t('List one page per line as Drupal paths. The * character is a wildcard. Example paths are "node/add/page" and "node/add/*". Use <front> to match the front page.'), |
| 191 |
|
'#default_value' => variable_get('mp3player_page_list', ''), |
| 192 |
|
); |
| 193 |
|
|
| 194 |
return system_settings_form($form); |
return system_settings_form($form); |
| 195 |
} |
} |
| 196 |
} |
} |
| 893 |
* Implementation of hook_init(). |
* Implementation of hook_init(). |
| 894 |
*/ |
*/ |
| 895 |
function mp3player_init() { |
function mp3player_init() { |
| 896 |
if(!file_exists(drupal_get_path('module', 'mp3player').'/mp3player/audio-player.js') || !file_exists(drupal_get_path('module', 'mp3player').'/mp3player/player.swf')) { |
if (mp3player_exclude_these_paths() != 1) { |
| 897 |
drupal_set_message(t('%file1 or %file2 were not found in %directory, download the <a href="http://wpaudioplayer.com/download">standalone WordPress Audio Player</a>.', array('%file1' => 'audio-player.js', '%file2' => 'player.swf', '%directory' => '/'.drupal_get_path('module', 'mp3player').'/mp3player/')), 'error'); |
if(!file_exists(drupal_get_path('module', 'mp3player').'/mp3player/audio-player.js') || !file_exists(drupal_get_path('module', 'mp3player').'/mp3player/player.swf')) { |
| 898 |
} |
drupal_set_message(t('%file1 or %file2 were not found in %directory, download the <a href="http://wpaudioplayer.com/download">standalone WordPress Audio Player</a>.', array('%file1' => 'audio-player.js', '%file2' => 'player.swf', '%directory' => '/'.drupal_get_path('module', 'mp3player').'/mp3player/')), 'error'); |
| 899 |
|
} |
| 900 |
|
|
| 901 |
drupal_add_js(drupal_get_path('module', 'mp3player').'/mp3player/audio-player.js'); |
drupal_add_js(drupal_get_path('module', 'mp3player').'/mp3player/audio-player.js'); |
| 902 |
drupal_add_js(drupal_get_path('module', 'mp3player').'/mp3player.js'); |
drupal_add_js(drupal_get_path('module', 'mp3player').'/mp3player.js'); |
| 903 |
|
|
| 904 |
//If cache isn't set, set it. |
//If cache isn't set, set it. |
| 905 |
if(cache_get('mp3player_default') == '') { |
if(cache_get('mp3player_default') == '') { |
| 906 |
mp3player_rebuild_cache(); |
mp3player_rebuild_cache(); |
| 907 |
} |
} |
| 908 |
|
|
| 909 |
$js_audio_settings = cache_get('mp3player_default'); |
$js_audio_settings = cache_get('mp3player_default'); |
| 910 |
|
|
| 911 |
drupal_add_js($js_audio_settings->data, 'inline'); |
drupal_add_js($js_audio_settings->data, 'inline'); |
| 912 |
|
} |
| 913 |
} |
} |
| 914 |
|
|
| 915 |
/** |
/** |
| 1133 |
|
|
| 1134 |
drupal_rebuild_theme_registry(); |
drupal_rebuild_theme_registry(); |
| 1135 |
|
|
| 1136 |
drupal_set_message(t('MP3 Player cache updated.')); |
if (variable_get('mp3player_suppress', 'no') == 'no') { |
| 1137 |
|
drupal_set_message(t('MP3 Player cache updated.')); |
| 1138 |
|
} |
| 1139 |
} |
} |
| 1140 |
|
|
| 1141 |
/** ======================================== |
/** ======================================== |
| 1195 |
else { |
else { |
| 1196 |
$audio_url = $file; |
$audio_url = $file; |
| 1197 |
} |
} |
| 1198 |
|
|
| 1199 |
|
$extras = str_replace('"', "", $extras); |
| 1200 |
|
$extras = str_replace(":", "=", $extras); |
| 1201 |
|
$extras = str_replace(" ", "", $extras); |
| 1202 |
|
$extras = str_replace(",", "&", $extras); |
| 1203 |
|
|
| 1204 |
//Add JS for player |
return '<p id="mp3player_'.$mp3_player_id.'" class="mp3player" data="soundFile='.$audio_url.$extras.'">'.t("You may need: <a href='http://get.adobe.com/flashplayer/'>Adobe Flash Player</a>.").'</p>'. $description; |
|
drupal_add_js( |
|
|
array('mp3player' => |
|
|
array( |
|
|
'mp3player_' . $mp3_player_id => array( |
|
|
'extras' => $extras, |
|
|
'audio_url' => $audio_url, |
|
|
), |
|
|
), |
|
|
), |
|
|
'setting' |
|
|
); |
|
|
|
|
|
return '<p id="mp3player_'.$mp3_player_id.'" class="mp3player">'.t("You may need: <a href='http://get.adobe.com/flashplayer/'>Adobe Flash Player</a>.").'</p>'. $description; |
|
| 1205 |
} |
} |
| 1206 |
|
|
| 1207 |
/** |
/** |
| 1235 |
); |
); |
| 1236 |
break; |
break; |
| 1237 |
} |
} |
| 1238 |
|
} |
| 1239 |
|
|
| 1240 |
|
/** |
| 1241 |
|
* Return TRUE if current path is disabled for mp3player according to |
| 1242 |
|
* mp3player_page_list and mp3player_page_init_action. |
| 1243 |
|
*/ |
| 1244 |
|
function mp3player_exclude_these_paths() { |
| 1245 |
|
$action = variable_get('mp3player_page_init_action', 'page_disable'); |
| 1246 |
|
$page_list = variable_get('mp3player_page_list', ''); |
| 1247 |
|
|
| 1248 |
|
if (!empty($page_list)) { |
| 1249 |
|
// Retrieve Drupal alias for the current path (if exists). |
| 1250 |
|
$alias = drupal_get_path_alias($_GET['q']); |
| 1251 |
|
|
| 1252 |
|
if (drupal_match_path($_GET['q'], $page_list) || drupal_match_path($alias, $page_list)) { |
| 1253 |
|
return ($action == 'page_disable' ? 1 : 0); |
| 1254 |
|
} |
| 1255 |
|
} |
| 1256 |
|
|
| 1257 |
|
return ($action == 'page_disable' ? 0 : 1); |
| 1258 |
} |
} |