Beispiel #1
0
 /**
  * @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();
 }
Beispiel #2
0
function FormatDatasetFieldsTemplate($dataset, $template)
{
    return DatasetUtils::FormatDatasetFieldsTemplate($dataset, $template);
}
Beispiel #3
0
 /**
  * @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();
 }
 public function DoSetDatasetValuesFromPost($value)
 {
     if ($value) {
         $tempFileName = FileUtils::GetTempFileName();
         $imageString = file_get_contents($value);
         $this->imageFilter->ApplyFilter($imageString, $tempFileName);
         $this->GetDataset()->SetFieldValueAsFileNameByName($this->GetFieldName(), $tempFileName);
         $postWrapper = ArrayWrapper::createPostWrapper();
         $filesWrapper = ArrayWrapper::createFilesWrapper();
         DatasetUtils::SetDatasetFieldValue($this->GetDataset(), $this->GetFileTypeFieldName(), $this->GetEditControl()->extractFileTypeFromArray($postWrapper, $filesWrapper));
         DatasetUtils::SetDatasetFieldValue($this->GetDataset(), $this->GetFileNameFieldName(), $this->GetEditControl()->extractFileNameFromArray($postWrapper, $filesWrapper));
         DatasetUtils::SetDatasetFieldValue($this->GetDataset(), $this->GetFileSizeFieldName(), filesize($tempFileName));
     } else {
         $this->GetDataset()->SetFieldValueByName($this->GetFieldName(), null);
     }
 }
Beispiel #5
0
 public function DoSetDatasetValuesFromPost($value)
 {
     if ($value) {
         $tempFileName = FileUtils::GetTempFileName();
         $this->imageFilter->ApplyFilter(file_get_contents($value), $tempFileName);
         $this->GetDataset()->SetFieldValueAsFileNameByName($this->GetFieldName(), $tempFileName);
         DatasetUtils::SetDatasetFieldValue($this->GetDataset(), $this->GetFileTypeFieldName(), $this->GetEditControl()->ExtractFileTypeFromPost());
         DatasetUtils::SetDatasetFieldValue($this->GetDataset(), $this->GetFileNameFieldName(), $this->GetEditControl()->ExtractFileNameFromPost());
         DatasetUtils::SetDatasetFieldValue($this->GetDataset(), $this->GetFileSizeFieldName(), filesize($tempFileName));
     } else {
         $this->GetDataset()->SetFieldValueByName($this->GetFieldName(), null);
     }
 }