You are here

function theme_imageapi_optimize_pipeline_processors in Image Optimize (or ImageAPI Optimize) 7.2

Returns HTML for a listing of the effects within a specific image pipeline.

Parameters

$variables: An associative array containing:

  • form: A render element representing the form.
1 theme call to theme_imageapi_optimize_pipeline_processors()
imageapi_optimize_pipeline_form in ./imageapi_optimize.admin.inc
Form builder; Edit an image pipeline name and effects order.

File

./imageapi_optimize.admin.inc, line 546

Code

function theme_imageapi_optimize_pipeline_processors($variables) {
  $form = $variables['form'];
  $rows = array();
  foreach (element_children($form) as $key) {
    $row = array();
    $form[$key]['weight']['#attributes']['class'] = array(
      'image-effect-order-weight',
    );
    if (is_numeric($key)) {
      $summary = drupal_render($form[$key]['summary']);
      $row[] = drupal_render($form[$key]['label']) . (empty($summary) ? '' : ' - ' . $summary);
      $row[] = drupal_render($form[$key]['weight']);
      $row[] = drupal_render($form[$key]['configure']);
      $row[] = drupal_render($form[$key]['remove']);
    }
    else {

      // Add the row for adding a new image effect.
      $row[] = '<div class="image-style-new">' . drupal_render($form['new']['new']) . drupal_render($form['new']['add']) . '</div>';
      $row[] = drupal_render($form['new']['weight']);
      $row[] = array(
        'data' => '',
        'colspan' => 2,
      );
    }
    if (!isset($form[$key]['#access']) || $form[$key]['#access']) {
      $rows[] = array(
        'data' => $row,
        'class' => !empty($form[$key]['weight']['#access']) || $key == 'new' ? array(
          'draggable',
        ) : array(),
      );
    }
  }
  $header = array(
    t('Processor'),
    t('Weight'),
    array(
      'data' => t('Operations'),
      'colspan' => 2,
    ),
  );
  if (count($rows) == 1 && $form['new']['#access']) {
    array_unshift($rows, array(
      array(
        'data' => t('There are currently no processors in this pipeline. Add one by selecting an option below.'),
        'colspan' => 4,
      ),
    ));
  }
  $output = theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => array(
      'id' => 'image-style-effects',
    ),
  ));
  drupal_add_tabledrag('image-style-effects', 'order', 'sibling', 'image-effect-order-weight');
  return $output;
}