You are here

function finder::defaults in Finder 7.2

Finder defaults.

Set up defaults on database based finders.

1 call to finder::defaults()
finder::create_element in includes/finder.inc
Finder create element.

File

includes/finder.inc, line 33
finder.inc

Class

finder
An object to contain all of the data to generate a finder, plus the member functions to build the finder, and render the output.

Code

function defaults() {
  if (!empty($this->id)) {
    if (!isset($this->title)) {
      $this->title = t('Finder') . ' ' . $this->id;
    }
    if (!isset($this->path)) {
      $this->path = 'finder_' . !empty($this->name) ? $this->name : $this->id;
    }
    if (!isset($this->block)) {
      $this->block = TRUE;
    }
    if (!isset($this->status)) {
      $this->status = TRUE;
    }
    $finder_settings = array(
      'block' => TRUE,
      'form_on_page' => TRUE,
      'find_button' => TRUE,
      'find_text' => t('Find'),
      'go_text' => t('Go'),
      'ajax_effect' => 'none',
      'show_results' => 'completed',
      'results_style' => 'views',
      'no_results' => 'default',
      'pager' => 10,
      'redirect' => 'never',
      'element_logic' => 'AND',
      'url' => 'enabled',
      'url_delimiter' => ',',
    );
    foreach ($finder_settings as $key => $default) {
      if (!isset($this->settings[$key])) {
        $this->settings[$key] = $default;
      }
    }
    if (!empty($this->elements)) {
      foreach ($this->elements as &$element) {
        if (!empty($element->id)) {
          if (!$element->title) {
            $element->title = t('Element !id', array(
              '!id' => $element->id,
            ));
          }
          if ($element->element_handler['type'] == 'form') {
            $element_settings = array(
              'field_logic' => 'OR',
              'value_logic' => 'AND',
              'match' => 'e',
            );
          }
          elseif ($element->element_handler['type'] == 'container') {
            $element_settings = array(
              'element_logic' => 'AND',
            );
          }
          if (!isset($element->parent)) {
            $element->parent = NULL;
          }
          foreach ($element_settings as $key => $default) {
            if (!isset($element->settings[$key])) {
              $element->settings[$key] = $default;
            }
          }
        }
      }
    }
    else {
      $this->elements = array();
    }
  }
}