View source
<?php
function swftools_status() {
include_once './includes/install.inc';
$html = '';
$html .= t('<p>The following tables show the status of SWF Tools and its supporting modules. This information can help to diagnose an installation that is not working correctly. Warnings indicate an issue that may prevent SWF Tools from performing as expected but are not necessarily an immediate problem. Errors show that there is an issue that will prevent SWF Tools from working.</p>');
$html .= _swftools_status_embedding();
$html .= _swftools_status_players();
return $html;
}
function _swftools_status_embedding() {
$requirements = array();
$requirements[0] = array();
$player_directory = swftools_get_player_path() . '/';
$methods = swftools_methods_available(SWFTOOLS_EMBED_METHOD);
$current_method = variable_get(SWFTOOLS_EMBED_METHOD, SWFTOOLS_NOJAVASCRIPT);
$method_found = FALSE;
if (count($methods)) {
foreach ($methods as $method => $info) {
if ($info['name'] == $current_method) {
$current_method = $info['title'];
$method_found = TRUE;
}
if ($info['shared_file']) {
if (!file_exists($player_directory . $info['shared_file'])) {
$requirements[] = array(
'title' => $info['title'],
'value' => t('Missing'),
'severity' => $current_method == $info['title'] ? REQUIREMENT_ERROR : REQUIREMENT_WARNING,
'description' => t('<a href="@url">Download</a> the required supporting file and upload it to %path.', array(
'@url' => $info['download'],
'%path' => $player_directory . $info['shared_file'],
)),
);
if ($current_method == $info['title']) {
$requirements[0] = array(
'severity' => REQUIREMENT_ERROR,
'description' => t('The required supporting file is not available. See below for more information.'),
);
}
}
else {
$requirements[] = array(
'title' => $info['title'],
'value' => t('OK'),
);
}
}
}
}
if ($method_found) {
$requirements[0] += array(
'title' => t('Default method'),
'value' => $current_method,
'severity' => REQUIREMENT_OK,
);
}
else {
$requirements[0] += array(
'title' => t('Default method'),
'value' => $current_method,
'severity' => REQUIREMENT_ERROR,
'description' => t('This method no longer appears to be available. Check the <a href="@modules">modules page</a> to ensure that the necessary module is enabled, or choose a different embedding method on the <a href="@settings">embedding settings</a> page.', array(
'@modules' => url('admin/build/modules'),
'@settings' => url('admin/settings/swftools/embed'),
)),
);
}
$html = '';
$html .= t('<h3>Embedding methods</h3>');
$html .= t('<p>The current default and available methods are listed in the table below. A warning will be shown if the method is not ready for use, and an error will be shown if the method is not ready <em>and</em> it is currently set as the default embedding method. The default embedding method can be set on the <a href="@settings">embedding settings</a> page.</p>', array(
'@settings' => url('admin/settings/swftools/embed'),
));
$html .= theme('status_report', $requirements);
$html .= _swftools_test_content($requirements[0]['severity'], $requirements[0]['value']);
return $html;
}
function _swftools_status_players() {
$player_requirements = array();
$playback_defaults = array();
$player_directory = swftools_get_player_path() . '/';
$types = array(
SWFTOOLS_FLV_DISPLAY => 'Single flv',
SWFTOOLS_FLV_DISPLAY_LIST => 'List of flvs',
SWFTOOLS_MP3_DISPLAY => 'Single mp3',
SWFTOOLS_MP3_DISPLAY_LIST => 'List of mp3s',
SWFTOOLS_MEDIA_DISPLAY_LIST => 'List of mixed media',
SWFTOOLS_SWF_DISPLAY => 'Single swf',
SWFTOOLS_IMAGE_DISPLAY_LIST => 'List of images',
);
foreach ($types as $type => $description) {
$methods = swftools_methods_available($type);
$playback_defaults[$type] = array(
'title' => $types[$type],
'value' => swftools_get_player($type),
'description' => $playback_defaults[$type]['value'] == t('None') ? '' : t('The specified player no longer appears to be available. Check the <a href="@modules">modules page</a> to ensure that the necessary module is enabled, or choose a different player on the <a href="@handling">file handling</a> page.', array(
'@modules' => url('admin/build/modules'),
'@handling' => url('admin/settings/swftools/handling'),
)),
'severity' => REQUIREMENT_ERROR,
);
if (!$playback_defaults[$type]['value']) {
$playback_defaults[$type]['value'] = t('None');
$playback_defaults[$type]['severity'] = REQUIREMENT_OK;
$playback_defaults[$type]['description'] = '';
}
if (count($methods)) {
foreach ($methods as $method => $player) {
if (!$player_requirements[$player['title']]) {
if (!file_exists($player_directory . $player['shared_file'])) {
$player_requirements[$player['title']] = array(
'title' => $player['title'],
'value' => t('Missing'),
'description' => t('<a href="@url">Download</a> the required supporting file and upload it to %path.', array(
'@url' => $player['download'],
'%path' => $player_directory . $player['shared_file'],
)),
'severity' => REQUIREMENT_WARNING,
);
}
else {
$player_requirements[$player['title']] = array(
'title' => $player['title'],
'value' => t('OK'),
'severity' => REQUIREMENT_OK,
);
}
}
if ($playback_defaults[$type]['value'] == $method) {
$playback_defaults[$type]['value'] = $player['title'];
if ($player_requirements[$player['title']]['severity'] == REQUIREMENT_OK) {
$playback_defaults[$type]['severity'] = REQUIREMENT_OK;
$playback_defaults[$type]['description'] = '';
}
else {
$playback_defaults[$type]['severity'] = REQUIREMENT_ERROR;
$playback_defaults[$type]['description'] = $player_requirements[$player['title']]['description'];
$player_requirements[$player['title']]['severity'] = REQUIREMENT_ERROR;
}
}
}
}
}
asort($player_requirements);
$html = '';
$html .= t('<h3>Playback defaults</h3>');
$html .= t('<p>The table below shows the default methods that have been assigned to different types of media. An error indicates that a player has been specified but the supporting player file is not available, or the method cannot be found. Default playback methods can be configured on the <a href="@handling">file handling settings</a> page.</p>', array(
'@handling' => url('admin/settings/swftools/handling'),
));
$html .= theme('status_report', $playback_defaults);
$html .= t('<h3>Players</h3>');
$html .= t('<p>This table shows which media players are currently enabled and ready for use. A warning is shown if the required supporting file is not available, and an error is shown if the supporting file is not available <em>and</em> the method is currently set as a playback default for any media type.</p>');
$html .= theme('status_report', $player_requirements);
return $html;
}
function _swftools_test_content($severity, $method) {
$html = '';
$html .= t('<h3>Test content</h3>');
if ($severity == REQUIREMENT_ERROR) {
$html .= t('<p>SWF Tools cannot currently generate test content as the chosen embedding method is not available. Refer to the table above for assistance in fixing the problem.</p>');
}
else {
$file = url(drupal_get_path('module', 'swftools') . '/shared/swftools_test_file.swf', array(
'absolute' => TRUE,
));
$html .= t('<p>SWF Tools is now trying to generate some flash content using the currrently configured embedding method (%current). If you can see an animation below then SWF Tools appears to be installed correctly.</p>', array(
'%current' => $method,
));
$html .= swf($file, array(
'params' => array(
'height' => 150,
'width' => 150,
),
));
$html .= t('<p> If the animation does not appear then check that your browser has the necessary Flash plug-in, and that JavaScript is enabled (if required). Also try clearing your browser\'s cache.</p>');
}
return $html;
}