You are here

function node_filter_form in Drupal 6

Same name and namespace in other branches
  1. 4 modules/node.module \node_filter_form()
  2. 5 modules/node/node.module \node_filter_form()
  3. 7 modules/node/node.admin.inc \node_filter_form()

Return form for node administration filters.

1 call to node_filter_form()
node_admin_content in modules/node/node.admin.inc
Menu callback: content administration.
1 string reference to 'node_filter_form'
node_admin_content in modules/node/node.admin.inc
Menu callback: content administration.

File

modules/node/node.admin.inc, line 203
Content administration and module settings UI.

Code

function node_filter_form() {
  $session =& $_SESSION['node_overview_filter'];
  $session = is_array($session) ? $session : array();
  $filters = node_filters();
  $i = 0;
  $form['filters'] = array(
    '#type' => 'fieldset',
    '#title' => t('Show only items where'),
    '#theme' => 'node_filters',
  );
  $form['#submit'][] = 'node_filter_form_submit';
  foreach ($session as $filter) {
    list($type, $value) = $filter;
    if ($type == 'category') {

      // Load term name from DB rather than search and parse options array.
      $value = module_invoke('taxonomy', 'get_term', $value);
      $value = $value->name;
    }
    else {
      if ($type == 'language') {
        $value = empty($value) ? t('Language neutral') : module_invoke('locale', 'language_name', $value);
      }
      else {
        $value = $filters[$type]['options'][$value];
      }
    }
    if ($i++) {
      $form['filters']['current'][] = array(
        '#value' => t('<em>and</em> where <strong>%a</strong> is <strong>%b</strong>', array(
          '%a' => $filters[$type]['title'],
          '%b' => $value,
        )),
      );
    }
    else {
      $form['filters']['current'][] = array(
        '#value' => t('<strong>%a</strong> is <strong>%b</strong>', array(
          '%a' => $filters[$type]['title'],
          '%b' => $value,
        )),
      );
    }
    if (in_array($type, array(
      'type',
      'language',
    ))) {

      // Remove the option if it is already being filtered on.
      unset($filters[$type]);
    }
  }
  foreach ($filters as $key => $filter) {
    $names[$key] = $filter['title'];
    $form['filters']['status'][$key] = array(
      '#type' => 'select',
      '#options' => $filter['options'],
    );
  }
  $form['filters']['filter'] = array(
    '#type' => 'radios',
    '#options' => $names,
    '#default_value' => 'status',
  );
  $form['filters']['buttons']['submit'] = array(
    '#type' => 'submit',
    '#value' => count($session) ? t('Refine') : t('Filter'),
  );
  if (count($session)) {
    $form['filters']['buttons']['undo'] = array(
      '#type' => 'submit',
      '#value' => t('Undo'),
    );
    $form['filters']['buttons']['reset'] = array(
      '#type' => 'submit',
      '#value' => t('Reset'),
    );
  }
  drupal_add_js('misc/form.js', 'core');
  return $form;
}