60 $this->facets = array();
62 $this->target->addFacetTaggingHandler(array($this,
onTagItem));
67 $this->facets[$title] = $facet;
68 $facet->manager = $this;
75 if ($item instanceof AbstractSearchResult)
80 foreach ($this->facets as $title => $facet)
82 $attrs = $facet->onTagItem($item, $attrs);
90 $script =
"<script type=\"text/javascript\">\nwindow.addEvent('domready', function()\n{\n\tvar {$this->target->getID()}_facet_manager = new FacetManager('{$this->target->getID()}');\n";
92 foreach($this->facets as $facet)
94 $script .= $facet->writeScript();
97 $script .=
"\n});\n</script>";
104 <div
id=
'<?echo $this->id?>' class=
'facet_form'>
106 foreach($this->facets as $title => $facet)
109 <span style=
'display: inline-block'><label
for=
'<?echo $facet->getID()?>'><?echo $title?></label>
130 $this->
id = $target->getID().
"_facet_manager";
132 $this->facets = array();
137 $this->facets[$title] = $facet;
138 $facet->manager = $this;
145 $mgr = $this->target->getID().
"_facet_manager";
146 $panel = $this->target->getID();
148 $script = <<<ENDSCRIPT
149 <script type=
"text/javascript">
150 window.addEvent(
'domready',
function()
154 onFilterChanged:
function()
156 document.id(
'{$panel}').loadPanel(
'{$this->target->handler}?' + {$mgr}.getQueryString());
162 foreach($this->facets as $facet)
167 $script .=
"\n});\n</script>";
174 <div
id=
'<?echo $this->id?>' class=
'facet_form'>
176 foreach($this->facets as $title => $facet)
179 <span style=
'display: inline-block'><label
for=
'<?echo $facet->getID()?>'><?echo $title?></label>
198 $this->field = $field;
208 if ($item->hasField($this->field))
210 $attrs[
"data-{$this->field}"] = strtolower($item->format(
"{".$this->field.
":xml}"));
220 var <?echo $this->getID()?>_handler =
new StringFacetHandler(
'<?echo $this->getID()?>',
'<?echo $this->getID()?>_facet', <?echo $this->manager->target->getID()?>_facet_manager);
222 $script = ob_get_contents();
230 <input type=
'text' name=
'<?echo $this->field?>' id=
'<?echo $this->getID()?>_facet' value=
'' autocomplete=
'off'/>
242 $this->field = $field;
243 $this->expression = $expression;
253 $attrs[
"data-{$this->field}"] = strtolower($item->format($this->expression));
262 var <?echo $this->getID()?>_handler =
new StringFacetHandler(
'<?echo $this->getID()?>',
'<?echo $this->getID()?>_facet', <?echo $this->manager->target->getID()?>_facet_manager);
264 $script = ob_get_contents();
272 <input type=
'text' name=
'<?echo $this->field?>' id=
'<?echo $this->getID()?>_facet' value=
'' autocomplete=
'off'/>
282 var $width =
"200px";
283 var $height =
"100px";
284 var $dropdown =
true;
285 var $dropdownMaxWidth =
"200px";
286 var $dropdownMessage =
"Click to Select Terms";
291 $this->formatAdapters = $formatAdapters;
301 $cl = get_class($item);
303 if (array_key_exists($cl, $this->formatAdapters))
305 $value = $item->format($this->formatAdapters[$cl]);
310 $attrs[
"data-{$this->id}"] = $value;
323 var <?echo $this->
id?>_select =
new MultiSelect(
'<?echo $this->id?>_container', {maxWidth:
'<?echo $this->dropdownMaxWidth?>', message:
'<?echo jsSafe($this->dropdownMessage)?>'});
324 var <?echo $this->
id?>_handler =
new MultiSelectFacetHandler(
'<?echo $this->id?>', <?echo $this->
id?>_select, <?echo $this->manager->target->getID()?>_facet_manager);
328 $script = ob_get_contents();
336 if ($this->width && $this->height)
338 $resizable = (!$this->dropdown && $this->resizable) ?
" resizable":
"";
339 $dropdown = $this->dropdown ?
" multi_select_dropdown_list" :
"";
340 echo
"<div id='{$this->id}_container' class='scrollbox{$resizable}{$dropdown}' style='width: {$this->width}; height: {$this->height}; overflow: auto'></div>\n";
352 var $width =
"200px";
353 var $height =
"100px";
354 var $dropdown =
true;
355 var $dropdownMaxWidth =
"200px";
356 var $dropdownMessage =
"Click to Select Terms";
361 $this->xrefAdapters = $xrefAdapters;
362 $this->format = $format;
363 $this->related = array();
373 $cl = get_class($item);
375 if (array_key_exists($cl, $this->xrefAdapters))
377 $adapter = $this->xrefAdapters[$cl];
378 $related = $adapter($item);
379 if (!is_array($related)) $related = array($related);
380 $value =
formatItems($related,
"{getPrimaryKeyValue()}",
",");
381 foreach($related as $r)
383 $this->related[$r->getPrimaryKeyValue()] = $r;
389 $attrs[
"data-{$this->id}"] = $value;
402 var <?echo $this->
id?>_select =
new MultiSelect(
'<?echo $this->id?>_container', {maxWidth:
'<?echo $this->dropdownMaxWidth?>', message:
'<?echo jsSafe($this->dropdownMessage)?>'});
403 var <?echo $this->
id?>_handler =
new CrossReferenceFacetHandler(
'<?echo $this->id?>', <?echo $this->
id?>_select, <?echo $this->manager->target->getID()?>_facet_manager);
407 $script = ob_get_contents();
416 foreach($this->related as $pk => $r)
418 $options[$pk] = $r->format($this->format);
423 foreach($options as
$id => $option)
425 echo
"<label for='checkbox_{$this->id}_{$id}'><input type='checkbox' class='checkbox' name='checkbox_{$this->id}_{$id}' id='checkbox_{$this->id}_{$id}' value='{$id}'";
426 echo
">".$option.
"</label>";
432 if ($this->width && $this->height)
434 $resizable = (!$this->dropdown && $this->resizable) ?
" resizable":
"";
435 $dropdown = $this->dropdown ?
" multi_select_dropdown_list" :
"";
436 echo
"<div id='{$this->id}_container' class='scrollbox{$resizable}{$dropdown}' style='width: {$this->width}; height: {$this->height}; overflow: auto'>";
437 echo $this->renderCheckboxes();
449 var $width =
"200px";
450 var $height =
"100px";
451 var $dropdown =
true;
452 var $dropdownMaxWidth =
"200px";
453 var $dropdownMessage =
"Click to Select Terms";
458 $this->options = $options;
459 $this->related = array();
469 $cl = get_class($item);
471 $value = $item->get($this->
id);
474 $attrs[
"data-{$this->id}"] = $value;
487 var <?echo $this->
id?>_select =
new MultiSelect(
'<?echo $this->id?>_container', {maxWidth:
'<?echo $this->dropdownMaxWidth?>', message:
'<?echo jsSafe($this->dropdownMessage)?>'});
488 var <?echo $this->
id?>_handler =
new CheckListFacetHandler(
'<?echo $this->id?>', <?echo $this->
id?>_select, <?echo $this->manager->target->getID()?>_facet_manager);
492 $script = ob_get_contents();
500 foreach($this->options as
$id => $option)
502 echo
"<label for='checkbox_{$this->id}_{$id}'><input type='checkbox' class='checkbox' name='checkbox_{$this->id}_{$id}' id='checkbox_{$this->id}_{$id}' value='{$id}'";
503 echo
">".$option.
"</label>";
509 if ($this->width && $this->height)
511 $resizable = (!$this->dropdown && $this->resizable) ?
" resizable":
"";
512 $dropdown = $this->dropdown ?
" multi_select_dropdown_list" :
"";
513 echo
"<div id='{$this->id}_container' class='scrollbox{$resizable}{$dropdown}' style='width: {$this->width}; height: {$this->height}; overflow: auto'>";
514 echo $this->renderCheckboxes();
__construct($id, $options)
__construct($id, $xrefAdapters, $format)
__construct($field, $expression)
__construct($id, $target)
__construct($id, $formatAdapters)
formatItems($items, $template, $separator="")
Format a list of DataItems using the specified templated.
addFacetTaggingHandler($handler)