/** * @param Renderer $renderer * @return void */ public function Render(Renderer $renderer) { /** @var string $term */ $term = ''; if ($this->GetSuperGlobals()->IsGetValueSet('term')) { $term = $this->GetSuperGlobals()->GetGetValue('term'); } if (!StringUtils::IsNullOrEmpty($term)) { $this->dataset->AddFieldFilter($this->valueField, new FieldFilter('%' . $term . '%', 'ILIKE', true)); } $id = null; if ($this->GetSuperGlobals()->IsGetValueSet('id')) { $id = $this->GetSuperGlobals()->GetGetValue('id'); } if (!StringUtils::IsNullOrEmpty($id)) { $this->dataset->AddFieldFilter($this->idField, FieldFilter::Equals($id)); } header('Content-Type: text/html; charset=utf-8'); $this->dataset->Open(); $result = array(); $valueCount = 0; while ($this->dataset->Next()) { $result[] = array("id" => $this->dataset->GetFieldValueByName($this->idField), "value" => StringUtils::IsNullOrEmpty($this->captionTemplate) ? $this->dataset->GetFieldValueByName($this->valueField) : DatasetUtils::FormatDatasetFieldsTemplate($this->dataset, $this->captionTemplate)); if (++$valueCount >= 20) { break; } } echo SystemUtils::ToJSON($result); $this->dataset->Close(); }
private function GetDisplayValueFromDataset() { if (!StringUtils::IsNullOrEmpty($this->captionTemplate)) { $this->lookupDataset->AddFieldFilter($this->lookupIdFieldName, new FieldFilter($this->GetDataset()->GetFieldValueByName($this->GetFieldName()), '=')); $this->lookupDataset->Open(); if ($this->lookupDataset->Next()) { $displayValue = DatasetUtils::FormatDatasetFieldsTemplate($this->lookupDataset, $this->captionTemplate); return $displayValue; } $this->lookupDataset->Close(); } return $this->GetDataset()->GetFieldValueByName($this->displayFieldName); }
function FormatDatasetFieldsTemplate($dataset, $template) { return DatasetUtils::FormatDatasetFieldsTemplate($dataset, $template); }
/** * @param Renderer $renderer * @return void */ public function Render(Renderer $renderer) { /** @var string $term */ $term = ''; if ($this->GetSuperGlobals()->IsGetValueSet('term')) { $term = $this->GetSuperGlobals()->GetGetValue('term'); } if (!StringUtils::IsNullOrEmpty($term)) { $this->dataset->AddFieldFilter($this->valueField, new FieldFilter('%' . $term . '%', 'ILIKE', true)); } header('Content-Type: text/html; charset=utf-8'); $this->dataset->Open(); $result = array(); $valueCount = 0; $highLightCallback = Delegate::CreateFromMethod($this, 'ApplyHighlight')->Bind(array(Argument::$Arg3 => $this->valueField, Argument::$Arg4 => $term)); while ($this->dataset->Next()) { $result[] = array("id" => $this->dataset->GetFieldValueByName($this->idField), "value" => StringUtils::IsNullOrEmpty($this->captionTemplate) ? $this->dataset->GetFieldValueByName($this->valueField) : DatasetUtils::FormatDatasetFieldsTemplate($this->dataset, $this->captionTemplate, $highLightCallback)); if ($valueCount >= 20) { break; } } echo SystemUtils::ToJSON($result); $this->dataset->Close(); }