You are here

function theme_field_validation_ui_manage_overview in Field Validation 7.2

Themable function to list the rules assigned to a field instance.

1 theme call to theme_field_validation_ui_manage_overview()
field_validation_ui_manage in ./field_validation_ui.admin.inc
Menu callback function to show an overview of the existing validation rules, and the option to add a rule.

File

./field_validation_ui.admin.inc, line 371
Manages validation rules administration UI.

Code

function theme_field_validation_ui_manage_overview($variables) {
  $rules = $variables['rules'];
  $instance = $variables['instance'];
  $header = array(
    t('Rule name'),
    t('Validator'),
    array(
      'data' => t('Operations'),
      'colspan' => 2,
    ),
  );
  ctools_include('plugins');
  $validators = ctools_get_plugins('field_validation', 'validator');
  if (!empty($rules)) {
    foreach ($rules as $rule) {
      $row = array();
      $row[] = array(
        'data' => $rule->rulename,
      );
      $row[] = array(
        'data' => $validators[$rule->validator]['label'],
      );
      $path = isset($_GET['q']) ? $_GET['q'] : '';
      if (!empty($rule->ruleid)) {
        $row[] = array(
          'data' => l(t('Edit'), $path . '/edit/' . $rule->validator . '/' . $rule->ruleid, array(
            "query" => drupal_get_destination(),
          )),
        );
        $row[] = array(
          'data' => l(t('Delete'), $path . '/delete/' . $rule->ruleid, array(
            "query" => drupal_get_destination(),
          )),
        );
      }
      else {
        $row[] = array(
          'data' => l(t('Overwrite'), $path . '/overwrite/' . $rule->validator . '/' . $rule->name, array(
            "query" => drupal_get_destination(),
          )),
          'colspan' => 2,
        );
      }
      $rows[] = $row;
    }
  }
  else {
    $rows[][] = array(
      'data' => t('No validation rules available.'),
      'colspan' => 5,
    );
  }
  return theme('table', array(
    'header' => $header,
    'rows' => $rows,
  ));
}