public function FacetapiWidget::init in Facet API 6.3
Same name and namespace in other branches
- 7.2 plugins/facetapi/widget.inc \FacetapiWidget::init()
- 7 plugins/facetapi/widget.inc \FacetapiWidget::init()
Initializes the build, must be invoked prior to executing this widget.
Return value
FacetapiWidget An instance of this class.
1 call to FacetapiWidget::init()
- FacetapiWidgetCheckboxLinks::init in plugins/
facetapi/ widget_links.inc - Adds JavaScript settings.
1 method overrides FacetapiWidget::init()
- FacetapiWidgetCheckboxLinks::init in plugins/
facetapi/ widget_links.inc - Adds JavaScript settings.
File
- plugins/
facetapi/ widget.inc, line 90 - Abstract widget plugin class.
Class
- FacetapiWidget
- Base class for widget plugins.
Code
public function init() {
// Captures searcher for code readability.
$searcher = $this->facet
->getAdapter()
->getSearcher();
$classes = implode(' ', array(
"facetapi-" . $this->id,
"facetapi-facet-{$this->facet['name']}",
));
// Initializes render array.
$this->build = array(
'#title' => $this->facet['label'],
'#description' => $this->facet['description'],
'#weight' => $this->facet['weight'],
'#adapter' => $this->facet
->getAdapter(),
'#realm_name' => $this->realm['name'],
'#facet' => $this->facet
->getFacet(),
'#settings' => $this->settings,
$this->facet['field alias'] => $this->facet
->getBuild(),
'#attributes' => array(
'class' => $classes,
'id' => 'facetapi-' . facetapi_hash_delta("facet-{$searcher}-{$this->realm['name']}-{$this->facet['name']}"),
),
);
// Applies sorting algorithms to the render array.
$this
->sortFacet($this->build);
// Initializes JavaScript settings.
$this->jsSettings += array(
'id' => $this->build['#attributes']['id'],
'searcher' => $searcher,
'realmName' => $this->realm['name'],
'facetName' => $this->facet['name'],
'queryType' => $this->facet['query type'],
'widget' => $this->settings->settings['widget'],
);
// Add our accessibility CSS
drupal_add_css(drupal_get_path('module', 'facetapi') . '/facetapi.css');
return $this;
}