예제 #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();
 }
예제 #2
0
 private function GetHiddenValuesJson()
 {
     return SystemUtils::ToJSON($this->GetHiddenValues());
 }
 public function GetAllUsersAsJson()
 {
     $usersDataset = $this->CreateUsersDataset();
     $usersDataset->Open();
     $users = array();
     if ($this->allowGuest) {
         array_push($users, array('id' => -1, 'name' => 'guest', 'password' => '******', 'editable' => false));
     }
     array_push($users, array('id' => 0, 'name' => 'PUBLIC (All users)', 'password' => '******', 'editable' => false));
     while ($usersDataset->Next()) {
         $user = array('id' => $usersDataset->GetFieldValueByName($this->users_UserId), 'name' => $usersDataset->GetFieldValueByName($this->users_UserName), 'password' => '******', 'editable' => true);
         array_push($users, $user);
     }
     $usersDataset->Close();
     return SystemUtils::ToJSON($users);
 }
 /**
  * @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();
 }
예제 #5
0
 /**
  * @param Renderer $renderer
  * @return void
  */
 public function Render(Renderer $renderer)
 {
     if (GetApplication()->GetSuperGlobals()->IsGetValueSet('term')) {
         $this->dataset->AddFieldFilter($this->valueField, new FieldFilter('%' . GetApplication()->GetSuperGlobals()->GetGetValue('term') . '%', 'ILIKE', true));
     }
     $this->dataset->Open();
     $result = array();
     $highLightCallback = Delegate::CreateFromMethod($this, 'ApplyHighlight')->Bind(array(Argument::$Arg3 => $this->valueField, Argument::$Arg4 => GetApplication()->GetSuperGlobals()->GetGetValue('term')));
     $this->dataset->SetLimit(20);
     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();
 }
 function RenderGrid(Grid $grid)
 {
     $columnEditors = array();
     $dataset = $grid->GetDataset();
     if ($grid->GetErrorMessage() != '') {
         foreach ($grid->GetViewColumns() as $column) {
             $editor = $column->GetInsertOperationEditor();
             if (isset($editor)) {
                 $columnEditors[$column->GetName()]['Html'] = $this->Render($editor, false, true);
                 $columnEditors[$column->GetName()]['Script'] = $this->Render($editor, true, false);
             }
         }
         $this->DisplayTemplate('inline_operations/grid_edit_error_response.tpl', array('ErrorCaption' => 'ErrorsDuringInsertProcess', 'ErrorMessage' => $grid->GetErrorMessage(), 'ColumnEditors' => $columnEditors), array());
         return;
     }
     $cellClasses = array();
     $rowStyleByColumns = $grid->GetRowStylesByColumn($grid->GetDataset()->GetFieldValues(), $cellClasses);
     $columns = array();
     foreach ($grid->GetViewColumns() as $column) {
         $columnName = $dataset->IsLookupField($column->GetName()) ? $dataset->IsLookupFieldNameByDisplayFieldName($column->GetName()) : $column->GetName();
         $columns[$column->GetName()]['Value'] = $grid->RenderColumn($this, $column);
         $columns[$column->GetName()]['AfterRowControl'] = $this->Render($column->GetAfterRowControl());
         $columns[$column->GetName()]['Style'] = $rowStyleByColumns[$columnName];
     }
     $primaryKeys = array();
     if ($grid->GetAllowDeleteSelected()) {
         $primaryKeys = $grid->GetDataset()->GetPrimaryKeyValues();
     }
     $actionsRowViewData = array();
     foreach ($grid->getActions()->getOperations() as $operation) {
         $operationName = $dataset->IsLookupField($operation->GetName()) ? $dataset->IsLookupFieldNameByDisplayFieldName($operation->GetName()) : $operation->GetName();
         $actionsRowViewData[$operationName] = array('OperationName' => $operationName, 'Data' => $operation->GetValue());
     }
     $detailsViewData = $grid->GetDetailsViewData();
     $this->DisplayTemplate('inline_operations/grid_insert_commit_response.tpl', array('encoding' => $grid->GetPage()->GetContentEncoding(), 'AllowDeleteSelected' => $grid->GetAllowDeleteSelected(), 'PrimaryKeys' => $primaryKeys, 'Columns' => $columns, 'Actions' => $actionsRowViewData, 'RecordUID' => Random::GetIntRandom(), 'HasDetails' => $grid->GetHasDetails(), 'Details' => array('Items' => $detailsViewData, 'JSON' => htmlspecialchars(SystemUtils::ToJSON($detailsViewData)))), array());
 }
예제 #7
0
 public final function GetViewData()
 {
     $result = array();
     $fieldData = array();
     foreach ($this->fields as $name => $data) {
         $fieldData[] = array('Name' => $name, 'Caption' => $data['caption'], 'Type' => $this->FieldTypeToJSFieldType($data['type']), 'EditorClass' => $data['editorClass'] ? $data['editorClass'] : $this->GetEditorClassByType($data['type']), 'EditorOptions' => $data['editorOptions'] ? SystemUtils::ToJSON($data['editorOptions']) : '{}');
     }
     $result['Fields'] = $fieldData;
     return $result;
 }
예제 #8
0
 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);
 }
 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);
 }
예제 #10
0
 /**
  * @param array $parameters
  * @return string
  */
 public function HandleRequest($parameters)
 {
     try {
         $result = $this->RouteRequest($parameters);
         $status = 'OK';
     } catch (Exception $e) {
         $result = $e->getMessage();
         $status = 'error';
     }
     return SystemUtils::ToJSON(array('status' => $status, 'result' => $result));
 }
예제 #11
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();
 }
예제 #12
0
 public function AsJson()
 {
     return SystemUtils::ToJSON($this->GetRoot()->SaveToArray($this->contentEncoding));
 }