diff --git a/profiles/abs/modules/facetapi/plugins/facetapi/widget_links.inc b/profiles/abs/modules/facetapi/plugins/facetapi/widget_links.inc
index 81075b2..7b1165d 100644
--- a/profiles/abs/modules/facetapi/plugins/facetapi/widget_links.inc
+++ b/profiles/abs/modules/facetapi/plugins/facetapi/widget_links.inc
@@ -87,10 +87,7 @@ class FacetapiWidgetLinks extends FacetapiWidget {
*/
function buildListItems($build) {
$settings = $this->settings->settings;
-
- // Initializes links attributes, adds rel="nofollow" if configured.
- $attributes = ($settings['nofollow']) ? array('rel' => 'nofollow') : array();
- $attributes += array('class' => $this->getItemClasses());
+ $attributes = array('class' => $this->getItemClasses());
// Builds rows.
$items = array();
@@ -109,6 +106,10 @@ class FacetapiWidgetLinks extends FacetapiWidget {
),
);
+ if ($this->itemGetsNoFollow($item)) {
+ $variables['options']['attributes']['rel'] = 'nofollow';
+ }
+
// Adds the facetapi-zero-results class to items that have no results.
if (!$item['#count']) {
$variables['options']['attributes']['class'][] = 'facetapi-zero-results';
@@ -146,6 +147,35 @@ class FacetapiWidgetLinks extends FacetapiWidget {
}
/**
+ * Determines whether the rel attribute should be set to nofollow for an item.
+ *
+ * @param $item
+ * The current item.
+ *
+ * @return bool
+ * Whether the rel attribute should be set to nofollow.
+ */
+ function itemGetsNoFollow($item) {
+ // Statically cache whether we enable no-follow on active and inactive
+ // facets.
+ static $active, $inactive;
+
+ if (!isset($active)) {
+ $settings = $this->settings->settings;
+ // BC support.
+ if (empty($settings['nofollow_depth'])) {
+ $settings['nofollow_depth'] = !empty($settings['nofollow']) ? 0 : 100;
+ }
+
+ $current_depth = count($this->facet->getAdapter()->getAllActiveItems());
+ $inactive = $current_depth + 1 > $settings['nofollow_depth'];
+ $active = $current_depth - 1 > $settings['nofollow_depth'];
+ }
+
+ return ($item['#active'] && $active || !$item['#active'] && $inactive);
+ }
+
+ /**
* Gets the base class array for a facet item.
*
* Classes that extend FacetapiWidgetLinks will often overide this method to
@@ -179,12 +209,20 @@ class FacetapiWidgetLinks extends FacetapiWidget {
),
);
+ $options = array('0' => t('All links'));
+ for ($n = 1; $n <= 10; $n++) {
+ $options[$n] = t('for >@n active facets', array('@n' => $n));
+ }
+ $options[100] = t('disabled');
+
// @see http://drupal.org/node/1370342
- $form['widget']['widget_settings']['links'][$this->id]['nofollow'] = array(
- '#type' => 'checkbox',
- '#title' => t('Prevent crawlers from following facet links'),
- '#default_value' => !empty($this->settings->settings['nofollow']),
- '#description' => t('Add the rel="nofollow"
attribute to facet links to maximize SEO by preventing crawlers from indexing duplicate content and getting stuck in loops.'),
+ $form['widget']['widget_settings']['links'][$this->id]['nofollow_depth'] = array(
+ '#type' => 'select',
+ '#title' => t('Set nofollow on facet links'),
+ // We support the nofollow setting for BC.
+ '#default_value' => isset($this->settings->settings['nofollow_depth']) ? $this->settings->settings['nofollow_depth'] : (!empty($this->settings->settings['nofollow']) ? 0 : 100),
+ '#description' => t('Adding the rel="nofollow"
attribute to facet links to maximize SEO by preventing crawlers from indexing duplicate content and getting stuck in loops.'),
+ '#options' => $options,
'#states' => array(
'visible' => array(
'select[name="widget"]' => array('value' => $this->id),