You are here

private function MenuLeaf::buildLinkUrl in Taxonomy Facets 7.3

1 call to MenuLeaf::buildLinkUrl()
MenuLeaf::__construct in classes/MenuLeaf.php

File

classes/MenuLeaf.php, line 64

Class

MenuLeaf

Namespace

taxonomyFacets

Code

private function buildLinkUrl() {
  $url = array();
  $noTermFromCurrentVocabularyFound = true;
  if ($filters = $this->filtersObject
    ->getAppliedFilters()) {

    // Loop trough applied filters.
    foreach ($filters as $filter) {

      // if filter is from current vocabulary than apply this leaf url alias
      // instead of already applied filter
      if ($filter->vid == $this->vid) {
        $obj = new \stdClass();
        $obj->vid = $this->vid;
        $obj->url = $this->urlAlias;
        $url[] = $obj;
        $noTermFromCurrentVocabularyFound = false;
      }
      else {
        $obj = new \stdClass();
        $obj->vid = $filter->vid;
        $obj->url = $filter->term_path_alias;
        $url[] = $obj;
      }
    }
  }

  // If filters from this vocabulary were not in the applied filters than
  // also apply the alias from the current leaf
  if ($noTermFromCurrentVocabularyFound == true) {
    $obj = new \stdClass();
    $obj->vid = $this->vid;
    $obj->url = $this->urlAlias;
    $url[] = $obj;
  }
  $this->linkUrl = self::taxonomy_facets_prepend_language_prefix() . '/' . variable_get('taxonomy_facets_first_argument', 'items_list');

  // Now order url aliases (filters) by vocabulary id so that we preserve
  // order, so we don't end up with duplicate pages for same filter
  // combinations.
  usort($url, 'taxonomy_facets_sort_by_vid');
  foreach ($url as $u) {
    $this->linkUrl .= '/' . $u->url;
  }
}