TranslateFormBase::translateFilterValues

protected TranslateFormBase::translateFilterValues($reset = FALSE)

Builds an array out of search criteria specified in request variables.

Parameters

bool $reset: If the list of values should be reset.

Return value

array The filter values.

File

core/modules/locale/src/Form/TranslateFormBase.php, line 121

Class

TranslateFormBase
Defines the locale user interface translation form base.

Namespace

Drupal\locale\Form

Code

protected function translateFilterValues($reset = FALSE) {
  if (!$reset && static::$filterValues) {
    return static::$filterValues;
  }

  $filter_values = array();
  $filters = $this->translateFilters();
  foreach ($filters as $key => $filter) {
    $filter_values[$key] = $filter['default'];
    // Let the filter defaults be overwritten by parameters in the URL.
    if ($this->getRequest()->query->has($key)) {
      // Only allow this value if it was among the options, or
      // if there were no fixed options to filter for.
      $value = $this->getRequest()->query->get($key);
      if (!isset($filter['options']) || isset($filter['options'][$value])) {
        $filter_values[$key] = $value;
      }
    }
    elseif (isset($_SESSION['locale_translate_filter'][$key])) {
      // Only allow this value if it was among the options, or
      // if there were no fixed options to filter for.
      if (!isset($filter['options']) || isset($filter['options'][$_SESSION['locale_translate_filter'][$key]])) {
        $filter_values[$key] = $_SESSION['locale_translate_filter'][$key];
      }
    }
  }

  return static::$filterValues = $filter_values;
}
doc_Drupal
2016-10-29 09:49:12
Comments
Leave a Comment

Please login to continue.