You are here

function imagepicker_views_handler_filter_group_id::value_form in Image Picker 7

Provide a simple textfield for equality.

Overrides views_handler_filter_string::value_form

File

handlers/imagepicker_views_handler_filter_group_id.inc, line 38
@author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Class

imagepicker_views_handler_filter_group_id
@file @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function value_form(&$form, &$form_state) {
  $opts = array();
  $public_enabled = imagepicker_variable_get('imagepicker_public_enabled', 1);
  if ($public_enabled) {
    module_load_include('inc', 'imagepicker', 'imagepicker.group');
    $grouplist = array(
      '0' => 'All',
    );
    $query = db_select('imagepicker_user_groups', 'g');
    $query
      ->fields('g', array(
      'gid',
      'group_name',
    ));
    $query
      ->distinct();
    $query
      ->join('imagepicker_group_images', 'i', 'g.gid = i.gid');
    $query
      ->condition('g.public', 1);
    $rows = $query
      ->execute();
    foreach ($rows as $row) {
      $ct = imagepicker_get_group_images_count($row->gid);
      $group_name = $row->group_name;
      $grouplist[$row->gid] = $row->gid . ' - ' . t('!ct images', array(
        '!ct' => $ct,
      )) . ' - ' . t('Name: !n', array(
        '!n' => $group_name,
      ));
    }
    if (count($grouplist) > 1) {
      $form['value'] = array(
        '#type' => 'select',
        '#title' => t('Group name'),
        '#options' => $grouplist,
        '#default_value' => $this->value,
      );
    }
    else {
      $form['value'] = array(
        '#markup' => t('There are no Public groups available.'),
      );
    }
  }
  else {
    $form['value'] = array(
      '#markup' => t('Public groups has not been enabled.'),
    );
  }
}