CMS  Version 3.9
TaxonomyFacetFilter Class Reference

Inherits AbstractFacetFilter.

Public Member Functions

 __construct ($taxonomy)
 
 getID ()
 
 onTagItem ($item, $attrs)
 
 writeScript ()
 
 drawFacet ()
 
 getTerms ()
 
 renderCheckboxes ($items)
 

Public Attributes

 $taxonomy
 
 $width = "200px"
 
 $height = "100px"
 
 $dropdown = true
 
 $dropdownMaxWidth = "200px"
 
 $dropdownMessage = "Click to Select Terms"
 

Detailed Description

Definition at line 41 of file taxonomy_facet_filter.inc.

Constructor & Destructor Documentation

◆ __construct()

TaxonomyFacetFilter::__construct (   $taxonomy)

Definition at line 51 of file taxonomy_facet_filter.inc.

52  {
53  $this->taxonomy = $taxonomy;
54  }

Member Function Documentation

◆ drawFacet()

TaxonomyFacetFilter::drawFacet ( )

Definition at line 92 of file taxonomy_facet_filter.inc.

93  {
94  $items = $this->getTerms();
95 
96  if (count($items) == 0) return;
97 
98  if ($this->width && $this->height)
99  {
100  $width = is_numeric($this->width) ? "{$this->width}px" : $this->width;
101  $height = is_numeric($this->height) ? "{$this->height}px" : $this->height;
102 
103  $padding = ($width == "auto") ? "padding-right: 20px; overflow-x: hidden" : "";
104 
105  $resizable = (!$this->dropdown && $this->resizable) ? " resizable": "";
106  $dropdown = $this->dropdown ? " multi_select_dropdown_list" : "";
107  echo "<div id='{$this->taxonomy->identifier}_container' class='scrollbox{$resizable}{$dropdown}' style='width: {$width}; height: {$height};overflow: auto; $padding'>\n";
108  }
109 
110  $this->renderCheckBoxes($items);
111 
112  if ($this->width && $this->height)
113  {
114  echo "</div>\n";
115  }
116 
117  }
$columnSelect dropdown
$helpTree width
Definition: tree.inc:45
$desc height
Definition: event_edit.inc:64

◆ getID()

TaxonomyFacetFilter::getID ( )

Definition at line 56 of file taxonomy_facet_filter.inc.

57  {
58  return $this->taxonomy->identifier;
59  }

◆ getTerms()

TaxonomyFacetFilter::getTerms ( )

Definition at line 119 of file taxonomy_facet_filter.inc.

120  {
121  return $this->taxonomy->Terms("ORDER BY sort_order, term");
122  }

◆ onTagItem()

TaxonomyFacetFilter::onTagItem (   $item,
  $attrs 
)

Definition at line 61 of file taxonomy_facet_filter.inc.

62  {
63  // Need to work with underlying object if passed is a search result container
64  if ($item instanceof AbstractSearchResult) $item = $item->item;
65 
66  $term_ids = $this->taxonomy->getAssociatedTermIds($item);
67  if ($term_ids)
68  {
69  $attrs["data-taxonomy-{$this->taxonomy->identifier}"] = $term_ids;
70  }
71 
72  return $attrs;
73  }

◆ renderCheckboxes()

TaxonomyFacetFilter::renderCheckboxes (   $items)

Definition at line 124 of file taxonomy_facet_filter.inc.

125  {
126  foreach($items as $item)
127  {
128  $p = $item->term_id;
129 
130  echo "<label for='checkbox_{$this->taxonomy->identifier}_$p'><input type='checkbox' class='checkbox' name='{$this->taxonomy->identifier}[$p]' id='checkbox_{$this->taxonomy->identifier}_$p' value='$p'";
131  if (array_key_exists($p, $selected))
132  {
133  echo " checked";
134  }
135  echo ">".$item->term."";
136  echo "</label>";
137  }
138  }

◆ writeScript()

TaxonomyFacetFilter::writeScript ( )

Definition at line 75 of file taxonomy_facet_filter.inc.

76  {
77  ob_start();
78 
79  if ($this->dropdown)
80  {
81 ?>
82  var <?echo $this->taxonomy->identifier?>_select = new MultiSelect('<?echo $this->taxonomy->identifier?>_container', {maxWidth: '<?echo $this->dropdownMaxWidth?>', message: '<?echo jsSafe($this->dropdownMessage)?>'});
83  var <?echo $this->taxonomy->identifier?>_handler = new TaxonomyFacetHandler('<?echo $this->taxonomy->identifier?>', <?echo $this->taxonomy->identifier?>_select, <?echo $this->manager->target->getID()?>_facet_manager);
84 <?
85  }
86 
87  $script = ob_get_contents();
88  ob_end_clean();
89  return $script;
90  }
$email message

Member Data Documentation

◆ $dropdown

TaxonomyFacetFilter::$dropdown = true

Definition at line 47 of file taxonomy_facet_filter.inc.

◆ $dropdownMaxWidth

TaxonomyFacetFilter::$dropdownMaxWidth = "200px"

Definition at line 48 of file taxonomy_facet_filter.inc.

◆ $dropdownMessage

TaxonomyFacetFilter::$dropdownMessage = "Click to Select Terms"

Definition at line 49 of file taxonomy_facet_filter.inc.

◆ $height

TaxonomyFacetFilter::$height = "100px"

Definition at line 46 of file taxonomy_facet_filter.inc.

◆ $taxonomy

TaxonomyFacetFilter::$taxonomy

Definition at line 43 of file taxonomy_facet_filter.inc.

◆ $width

TaxonomyFacetFilter::$width = "200px"

Definition at line 45 of file taxonomy_facet_filter.inc.


The documentation for this class was generated from the following file: