You are here

function _swftools_status_embedding in SWF Tools 6.3

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

Generates a status report for embedding methods.

Called from swftools_status() and returns markup.

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

File

includes/swftools.admin.status.inc, line 46
Generates status reports for SWF Tools.

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 list of available embedding methods
  $methods = swftools_get_methods('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_direct');
  $method_found = FALSE;

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

      // Make sure all required elements are on the array
      $info += array(
        'name' => '',
        'module' => '',
        'title' => '',
        'download' => '',
        'library' => '',
      );

      // 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['library']) {

        // If the file doesn't exist then indicate the shared file to be missing
        if (!file_exists($info['library'])) {
          $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' => $info['library'],
            )),
          );

          // 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 = 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;
}