You are here

function theme_js_library_edit in jQuery Plugin Handler (JQP) 6.2

Theme function for the js_library_edit form. Creates a table in which each tr contans all form elements for a single file.

File

./jqp.admin.inc, line 250
This file includes all functionality for the libraries configuration pages

Code

function theme_js_library_edit($form) {
  if (!empty($form['files']['#value'])) {

    // Set the table header.
    $header = array(
      t('Filename'),
      t('Path'),
      t('Type'),
      t('Version'),
      t('Operations'),
      t('Status'),
    );
    ksort($form['files']['#value']);
    foreach ($form['files']['#value'] as $index => $file) {
      $version = $form["file-{$index}-version"]['#value'];
      if ($new = $form['add']['#value']) {
        unset($form["file-{$index}-name"]['#title']);
      }
      else {
        $form["file-{$index}-name"]['#type'] = 'hidden';
        $name = $form["file-{$index}-name"]['#value'];
        $form["file-{$index}-type"]['#type'] = 'hidden';
        $type = $form["file-{$index}-type"]['#value'];
      }
      unset($form["file-{$index}-path"]['#title'], $form["file-{$index}-type"]['#title']);
      if ($form['version']['#value'] !== $version) {
        $version = l($version == 0 ? t('default') : $version, "admin/build/jqp/" . $form['js_library']['#value']->name . "/{$version}");
      }
      else {
        $version = $version == 0 ? t('default') : $version;
      }
      $status = $form["file-{$index}-status"]['#value'] ? 'ok' : 'warning';
      $rows[] = array(
        'data' => array(
          $new ? drupal_render($form["file-{$index}-name"]) : $name,
          drupal_render($form["file-{$index}-path"]),
          $new ? drupal_render($form["file-{$index}-type"]) : $form["file-{$index}-type"]['#options'][$type],
          $version,
          drupal_render($form["file-{$index}-operations"]),
          theme('image', "misc/watchdog-{$status}.png", $status, $status, NULL, FALSE),
        ),
        'class' => $status,
      );
    }
    $path = drupal_get_path('module', 'jqp');
    drupal_add_css("{$path}/jqp.admin.css");
    drupal_add_js("{$path}/jqp.admin.js");
    drupal_add_js(array(
      'jqp_module_path' => $path,
    ), 'setting');
    return theme('table', $header, $rows, array(
      'class' => 'js_libraries_table',
    )) . drupal_render($form);
  }
}