1 filter.install filter_update_1004()

Add an exposed filename filter to the image_library view.

Related topics

File

core/modules/filter/filter.install, line 485
Install, update, and uninstall functions for the Filter module.

Code

function filter_update_1004() {
  // See if the image_library view has been modified on this site.
  $config = config('views.view.image_library');

  // Only update if view isn't overridden
  if ($config->get('storage') == VIEWS_STORAGE_DEFAULT) {
    $view_config = $config->get();
    $view_config['display']['default']['display_options']['exposed_form'] = array(
      'type' => 'basic',
      'options' => array(
        "reset_button" => 0,
        "reset_button_label" => "Reset",
        "exposed_sorts_label" => "Sort by",
        "expose_sort_order" => 1,
        "sort_asc_label" => "Asc",
        "sort_desc_label" => "Desc",
        "autosubmit" => 0,
        "autosubmit_hide" => 1
      ),
    );
    $view_config['display']['default']['display_options']['filters']['filename'] = array(
      'id' => 'filename',
      'table' => 'file_managed',
      'field' => 'filename',
      'relationship' => 'none',
      'group_type' => 'group',
      'ui_name' => '',
      'operator' => 'contains',
      'value' => '',
      'group' => '1',
      'exposed' => TRUE,
      'expose' => array(
        'operator_id' => 'filename_op',
        'label' => 'Filename',
        'description' => '',
        'use_operator' => FALSE,
        'operator' => 'filename_op',
        'identifier' => 'filename',
        'required' => FALSE,
        'remember' => FALSE,
        'multiple' => FALSE,
        'remember_roles' => array(
          'authenticated' => 'authenticated',
        ),
      ),
      'is_grouped' => FALSE,
      'group_info' => array(
        'label' => '',
        'description' => '',
        'identifier' => '',
        'optional' => TRUE,
        'widget' => 'select',
        'multiple' => FALSE,
        'remember' => 0,
        'default_group' => 'All',
        'default_group_multiple' => array(),
        'group_items' => array(),
      ),
    );
    $view_config['display']['default']['display_options']['hide_admin_links'] = TRUE;
    $config->setData($view_config);
    $config->save();
  }
}