You are here

function theme_field_validation_manage_overview in Field Validation 7

Themable function to list the rules assigned to a field instance

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

File

./field_validation.admin.inc, line 66
Manages validation rules administration UI

Code

function theme_field_validation_manage_overview($variables) {
  $rules = $variables['rules'];
  $instance = $variables['instance'];
  $header = array(
    t('Rule name'),
    t('Validator'),
    array(
      'data' => t('Operations'),
      'colspan' => 2,
    ),
  );
  $validators = field_validation_get_validators_selection();
  if (!empty($rules)) {
    foreach ($rules as $rule) {
      $row = array();
      $row[] = array(
        'data' => $rule->rulename,
      );
      $row[] = array(
        'data' => $validators[$rule->validator],
      );
      $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,
  ));
}