/** * @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(); }
/** * @param FieldFilter $filter * @return void */ public function VisitFieldFilter($filter) { if ($filter->GetIgnoreFieldDataType()) { if ($filter->GetFilterType() == 'LIKE') { $this->resultCondition = $this->engCommandImp->GetCaseSensitiveLikeExpression($this->field, $filter->GetValue()); } elseif ($filter->GetFilterType() == 'ILIKE') { $this->resultCondition = $this->engCommandImp->GetCaseInsensitiveLikeExpression($this->field, $filter->GetValue()); } else { $this->resultCondition = $this->engCommandImp->GetCastedToCharFieldExpression($this->field) . ' ' . $filter->GetFilterType() . ' ' . $this->engCommandImp->GetValueAsSQLString($filter->GetValue()); } } else { $value = $filter->GetValue(); if ($value === '' && $this->field->FieldType == ftNumber) { if ($filter->GetFilterType() == '=') { $this->resultCondition = $this->engCommandImp->GetIsNullCoditition($this->engCommandImp->GetFieldFullName($this->field)); } elseif ($filter->GetFilterType() == '<>') { $this->resultCondition = sprintf('NOT (%s)', $this->engCommandImp->GetIsNullCoditition($this->engCommandImp->GetFieldFullName($this->field))); } } elseif (isset($value)) { if ($filter->GetFilterType() == 'LIKE') { $this->resultCondition = $this->engCommandImp->GetCaseSensitiveLikeExpression($this->field, $filter->GetValue()); } elseif ($filter->GetFilterType() == 'ILIKE') { $this->resultCondition = $this->engCommandImp->GetCaseInsensitiveLikeExpression($this->field, $filter->GetValue()); } else { $this->resultCondition = $this->engCommandImp->GetFieldFullName($this->field) . ' ' . $filter->GetFilterType() . ' ' . $this->engCommandImp->GetFieldValueAsSQL($this->field, $filter->GetValue()); } } else { if ($filter->GetFilterType() == '=') { $this->resultCondition = $this->engCommandImp->GetIsNullCoditition($this->engCommandImp->GetFieldFullName($this->field)); } elseif ($filter->GetFilterType() == '<>') { $this->resultCondition = sprintf('NOT (%s)', $this->engCommandImp->GetIsNullCoditition($this->engCommandImp->GetFieldFullName($this->field))); } } } }
public function Render(Renderer $renderer) { $result = array(); $this->dataset->AddFieldFilter($this->captionFieldName, FieldFilter::Contains($this->globals->GetGetValue(self::SearchTermParamName))); $highLightCallback = Delegate::CreateFromMethod($this, 'ApplyHighlight')->Bind(array(Argument::$Arg3 => $this->captionFieldName, Argument::$Arg4 => $this->globals->GetGetValue(self::SearchTermParamName))); if (!StringUtils::IsNullOrEmpty($this->parentIdFieldName) && $this->globals->IsGetValueSet(self::ParentParamName)) { $this->dataset->AddFieldFilter($this->parentIdFieldName, FieldFilter::Equals($this->globals->GetGetValue(self::ParentParamName))); } $this->dataset->Open(); while ($this->dataset->Next()) { $result[] = array('id' => $this->dataset->GetFieldValueByName($this->idFieldName), 'value' => $this->dataset->GetFieldValueByName($this->captionFieldName), 'label' => $highLightCallback->Call($this->dataset->GetFieldValueByName($this->captionFieldName), $this->captionFieldName)); } $this->dataset->Close(); echo SystemUtils::ToJSON($result); }
/** * @param Renderer $renderer * @return void */ public function Render(Renderer $renderer) { $params = ArrayWrapper::createGetWrapper(); $term = $params->isValueSet('term') ? $params->getValue('term') : ''; if ($params->isValueSet('term')) { $this->dataset->AddFieldFilter($this->valueField, new FieldFilter('%' . $term . '%', 'ILIKE', true)); } if ($params->isValueSet('id')) { $this->dataset->AddFieldFilter($this->idField, FieldFilter::Equals($params->getValue('id'))); } if ($this->itemCount > 0) { $this->dataset->SetUpLimit(0); $this->dataset->SetLimit($this->itemCount); } $this->dataset->Open(); $result = array(); $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), "label" => $highLightCallback->Call($this->dataset->GetFieldValueByName($this->valueField), $this->valueField), "value" => $this->dataset->GetFieldValueByName($this->valueField)); } echo SystemUtils::ToJSON($result); $this->dataset->Close(); }
public function Render(Renderer $renderer) { $result = array(); $this->dataset->AddFieldFilter($this->captionFieldName, FieldFilter::Contains($this->arrayWrapper->GetValue(self::SearchTermParamName))); if (!StringUtils::IsNullOrEmpty($this->parentIdFieldName) && $this->arrayWrapper->IsValueSet(self::ParentParamName)) { $this->dataset->AddFieldFilter($this->parentIdFieldName, FieldFilter::Equals($this->arrayWrapper->GetValue(self::ParentParamName))); } $this->dataset->Open(); $valueCount = 0; while ($this->dataset->Next()) { $result[] = array('id' => $this->dataset->GetFieldValueByName($this->idFieldName), 'value' => $this->dataset->GetFieldValueByName($this->captionFieldName)); if (++$valueCount >= 20) { break; } } $this->dataset->Close(); echo SystemUtils::ToJSON($result); }