productType = $options['productType']; } if(isset($options['htmlID'])){ $this->htmlID = $options['htmlID']; } if(isset($options['siteUrl'])){ $this->siteUrl = $options['siteUrl']; } if(isset($options['resultFormat'])){ $this->resultFormat = $options['resultFormat']; } if(!isset(App::Get()->settings['customSearchConfig'])){ echo '
No criteria config was found for the CustomSearchWidget.
'; return; } $criteriaConfig = App::Get()->settings['customSearchConfig']; // Build a representation of the criteria to be searched by the widget. // If, during this process, we encounter config values that don't make // sense or an incomplete config for a criterion, we'll simply skip to // the next index in the config array. $this->criteria = array(); $configIndex = 0; while(isset($criteriaConfig[$configIndex])){ $newCriterion = array(); // Look for a criteria type $newType = strtolower($criteriaConfig[$configIndex]); if($newType == 'term' or $newType == 'range'){ $newCriterion['type'] = $newType; $configIndex++; }else{ continue; // Let's skip this one and hope that we // find one that makes more sense later. } // Extract the metadata element associated with the criterion $newElement = $criteriaConfig[$configIndex]; if(isset($newElement)){ $newCriterion['element'] = $newElement; $configIndex++; }else{ continue; // This criterion wasn't finished. } // Extract the labels for the input field(s) $newLabel = $criteriaConfig[$configIndex]; if(isset($newLabel)){ if($newType == 'term'){ $newCriterion['termLabel'] = $newLabel; }else{ $newCriterion['minLabel'] = $newLabel; $configIndex++; $newLabel = $criteriaConfig[$configIndex]; if(isset($newLabel)){ $newCriterion['maxLabel'] = $newLabel; }else{ continue; // This criterion wasn't finished. } } }else{ continue; // This criterion wasn't finished. } array_push($this->criteria, $newCriterion); $configIndex++; } } // Using the criteria representation at this->criteria, we create the fields for // specifying the criteria values. We put a hidden input tag with an id of the // form termX or rangeX before the specification fields. The JS will find these // hidden tags and use them to understand whether the fields specify term or // range criteria. The number following the criterion type is only so that they // have unique IDs. public function render($bEcho = true){ $str = ''; for($i = 0; $i < count($this->criteria); $i++){ if($this->criteria[$i]['type'] == 'term'){ $str .= ''; $str .= $this->criteria[$i]['termLabel'] . ': 
'; }else{ $str .= ''; $str .= $this->criteria[$i]['minLabel'] . ': '; $str .= '     '; $str .= $this->criteria[$i]['maxLabel'] . ': 
'; } } $str .= ''; if ($bEcho) { echo $str; } else { return $str; } } public function renderScript($bEcho = true){ $module = App::Get()->loadModule(); $str = ''; $str .= ''; $str .= ''; $str .= ''; $str .= ''; $str .= ''; $str .= ''; if ($bEcho) { echo $str; } else { return $str; } } } ?>