/** * Tests for formatDisplayText */ public function testFormatDisplayText() { $this->assertEquals($this->helper->formatDisplayText('0/Sound/'), 'Sound'); $this->assertEquals($this->helper->formatDisplayText('1/Sound/Noisy/'), 'Noisy'); $this->assertEquals($this->helper->formatDisplayText('1/Sound/Noisy/', true), 'Sound/Noisy'); $this->assertEquals($this->helper->formatDisplayText('1/Sound/Noisy/', true, ' - '), 'Sound - Noisy'); }
/** * Format a facet field according to the settings * * @param string $facet Facet field * @param string $value Facet value * * @return string Formatted field */ protected function formatFacetField($facet, $value) { if (in_array($facet, $this->translatedFacets)) { $value = $this->translator->translate($value); } $allLevels = isset($this->displayStyles[$facet]) ? $this->displayStyles[$facet] == 'full' : false; $separator = isset($this->separators[$facet]) ? $this->separators[$facet] : '/'; $value = $this->facetHelper->formatDisplayText($value, $allLevels, $separator); return $value; }
/** * Format a facet field according to the settings * * @param string $facet Facet field * @param string $value Facet value * @param bool $last Whether this is the last of multiple values * * @return string Formatted field */ protected function formatFacetField($facet, $value, $last) { $allLevels = isset($this->displayStyles[$facet]) ? $this->displayStyles[$facet] == 'full' : false; $separator = isset($this->separators[$facet]) ? $this->separators[$facet] : '/'; $value = $this->facetHelper->formatDisplayText($value, $allLevels, $separator); // If full display style is used, clear out default display text for all but // the last value: if ($allLevels && !$last) { $value = new \VuFind\I18n\TranslatableString((string) $value, ''); } return $value; }