key = $facet['name']; // TODO Do we need the realm here too ? dont know } /** * Renders the data */ public function execute() { $element = &$this->build[$this->facet['field alias']]; $all = $this->buildListItems($element); $element = array( '#theme' => 'item_list', '#items' => $all, '#attributes' => $this->build['#attributes'], ); } /** * Recursive function that converts the render array into an array that can be * passed to theme_item_list(). * * @param array $build * The facet's render array. * * @return array * The "items" parameter for theme_item_list(). */ function buildListItems($build) { $settings = $this->settings->settings; $result = array( 'data' => array(), ); // Builds rows. $items = array(); foreach ($build as $value => $item) { if ((($item['#active']) && (count($item['#item_children']) > 0)) || (!empty($settings['show_expanded']))) { //if ($item['#active'] || !empty($settings['show_expanded'])) { return $this->buildListItems($item['#item_children']); } else { $result['data'][$item['#indexed_value']] = array ( 'name' => $item['#markup'], 'count' => $item['#count'], 'path' => $item['#path'], ); } } return $result['data']; } /** * Adds the soft limit setting. */ function settingsForm(&$form, &$form_state) { return; $form['widget']['widget_settings']['nothing'][$this->id]['title'] = array( '#type' => 'textfield', '#title' => t('Nothing'), '#default_value' => $this->settings->settings['title'], '#weight' => -20, '#states' => array( 'visible' => array( 'select[name="widget"]' => array('value' => $this->id), ), ), ); // @see http://drupal.org/node/1370342 $form['widget']['widget_settings']['links'][$this->id]['flot'][$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.'), '#states' => array( 'visible' => array( 'select[name="widget"]' => array('value' => $this->id), ), ), ); } /** * Returns defaults for the settings this widget provides. */ function getDefaultSettings() { return array( 'title' => $this->facet['label'], 'nofollow' => 1, ); } }