You are here

function properties_admin_attributes_list in Dynamic properties 7

Menu callback; Display a list of attributes.

1 string reference to 'properties_admin_attributes_list'
properties_menu in ./properties.module
Implements hook_menu().

File

./properties.admin.inc, line 49
Contains admin menu callbacks for properties.module.

Code

function properties_admin_attributes_list($form, $form_state) {
  $header = array(
    array(
      'data' => t('Name'),
      'field' => 'name',
    ),
    array(
      'data' => t('Label'),
      'field' => 'label',
      'sort' => 'asc',
    ),
    t('Operations'),
  );
  $options = array(
    'header' => $header,
  );
  if (!empty($form_state['values']['search'])) {
    $options['search'] = $form_state['values']['search'];
  }
  $attributes = properties_attribute_load_paging(20, $options);
  $rows = array();
  $url_options = array(
    'query' => drupal_get_destination(),
  );
  foreach ($attributes as $attribute) {
    $links = array(
      l(t('edit'), 'admin/config/content/properties/attributes/edit/' . $attribute->name, $url_options),
      l(t('delete'), 'admin/config/content/properties/attributes/delete/' . $attribute->name, $url_options),
    );
    $rows[] = array(
      check_plain($attribute->name),
      check_plain($attribute->label),
      implode(' ', $links),
    );
  }
  drupal_add_css(drupal_get_path('module', 'properties') . '/properties.css');
  $form['filter'] = array(
    '#prefix' => '<div class="clearfix">',
    '#suffix' => '</div>',
  );
  $form['filter']['search'] = array(
    '#type' => 'textfield',
    '#title' => t('Search'),
    '#title_display' => 'invisible',
    '#size' => 20,
    '#ajax' => array(
      'callback' => 'properties_admin_attributes_list_js',
      'wrapper' => 'attributes-list',
      'effect' => 'fade',
      'event' => 'blur',
    ),
  );
  $form['filter']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Search'),
  );
  $form['filter']['reset'] = array(
    '#type' => 'submit',
    '#value' => t('Reset'),
    '#submit' => array(
      'properties_admin_attributes_list_submit_reset',
    ),
  );
  $form['content'] = array(
    '#prefix' => '<div id="attributes-list">',
    '#suffix' => '</div>',
  );
  $form['content']['table'] = array(
    '#theme' => 'table',
    '#rows' => $rows,
    '#header' => $header,
    '#empty' => t('No attributes found.'),
  );
  $form['content']['pager']['#markup'] = theme('pager');
  return $form;
}