You are here

protected function TaxoFacets::__construct in Taxonomy Facets 7.3

File

classes/SelectedFilters.php, line 34

Class

TaxoFacets

Namespace

taxonomyFacets

Code

protected function __construct() {
  $url = drupal_encode_path($_GET['q']);
  $this->term_names = explode('/', $url);

  // Chop off first term as it is just word used for page callback
  // and its not an actual term, we will need it for checks later on so put it in to
  // the variable.
  $first_url_argument = array_shift($this->term_names);

  // If first argument was not reserved word as per settings it means we are on the node body page, so get filters
  // from the url category parameter, i.e the format is:
  // http://mysite.dev/content/dell-tower-2025/?categories=croatia/dell
  if ($first_url_argument != variable_get('taxonomy_facets_first_argument', 'items_list')) {
    if (array_key_exists('categories', $_GET)) {
      if ($url = drupal_encode_path(check_url($_GET['categories']))) {
        $this->term_names = explode('/', $url);
      }
    }
  }

  // Set filters
  foreach ($this->term_names as $term_name) {
    if ($tid = self::getTermIdFromUrlAlias($term_name)) {
      $term = taxonomy_term_load($tid);
      $term->term_path_alias = $term_name;
      $this->tids[] = $tid;
      $this->terms[] = $term;
    }
  }

  // Sort by vocabulary id so we alwys get same order of filters, to avoid
  // duplicate urls for same pages.
  if ($this->term_names) {
    usort($this->terms, 'taxonomy_facets_sort_by_vid');
  }
}