You are here

function _swftools_status_embedding in SWF Tools 6

Same name and namespace in other branches
  1. 6.3 includes/swftools.admin.status.inc \_swftools_status_embedding()
  2. 6.2 swftools.admin.status.inc \_swftools_status_embedding()

Generate a status report for embedding methods Called from swftools_status() and returns markup

1 call to _swftools_status_embedding()
swftools_status in ./swftools.admin.status.inc
Generate a status report for SWF Tools methods / players / media defaults

File

./swftools.admin.status.inc, line 32

Code

function _swftools_status_embedding() {

  // Initialise requirements array
  $requirements = array();

  // Initialise an empty array in position zero - will need this later.
  $requirements[0] = array();

  // Get player directory
  $player_directory = swftools_get_player_path() . '/';

  // Get list of available embedding methods
  $methods = swftools_methods_available(SWFTOOLS_EMBED_METHOD);

  // Retrieve current embedding method and initialise flag to track if we find it later
  $current_method = variable_get(SWFTOOLS_EMBED_METHOD, SWFTOOLS_NOJAVASCRIPT);
  $method_found = FALSE;

  // Iterate through available methods
  if (count($methods)) {
    foreach ($methods as $method => $info) {

      // If method name is the current method then we found it, and it is available
      if ($info['name'] == $current_method) {
        $current_method = $info['title'];
        $method_found = TRUE;
      }

      // If the method defines a shared file then check that it exists
      if ($info['shared_file']) {

        // If the file doesn't exist then indicate the shared file to be missing
        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 the missing file relates to the current method set the default to a warning
          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 the specified embedding method was found then set the default entry to show 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'),
      )),
    );
  }

  // Construct output string
  $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);

  // Try to generate some test content
  $html .= _swftools_test_content($requirements[0]['severity'], $requirements[0]['value']);
  return $html;
}