Exemple #1
0
 public function SetValue($value)
 {
     if (!StringUtils::IsNullOrEmpty($value)) {
         $this->value = SMDateTime::Parse($value, $this->format);
     } else {
         $this->value = null;
     }
 }
 public static function SetTimeZoneIfNeed($timezoneIdentifier)
 {
     if (SystemUtils::GetPHPMinorVersion() >= 3) {
         if (StringUtils::IsNullOrEmpty(ini_get('date.timezone'))) {
             date_default_timezone_set($timezoneIdentifier);
         }
     }
 }
 public function GetStyleString()
 {
     $result = '';
     foreach ($this->styles as $paramName => $paramValue) {
         StringUtils::AddStr($result, "{$paramName}: {$paramValue};", ' ');
     }
     foreach ($this->styleStrings as $styleString) {
         if (!StringUtils::IsNullOrEmpty($styleString) && !StringUtils::EndsBy($styleString, ';')) {
             $styleString .= ';';
         }
         StringUtils::AddStr($result, $styleString, ' ');
     }
     return $result;
 }
Exemple #4
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();
 }
 public function HasAlias()
 {
     return !StringUtils::IsNullOrEmpty($this->alias);
 }
 public function ApplyHighlight($value, $currentFieldName, $displayFieldName, $term)
 {
     if ($currentFieldName == $displayFieldName && !StringUtils::IsNullOrEmpty($term)) {
         $patterns = array();
         $patterns[0] = '/(' . preg_quote($term) . ')/i';
         $replacements = array();
         $replacements[0] = '<em class="highlight_autocomplete">' . '$1' . '</em>';
         return preg_replace($patterns, $replacements, $value);
     } else {
         return $value;
     }
 }
Exemple #7
0
 /**
  * @return string
  */
 public function GetInputAttributes($suppressRequiredValidation = false)
 {
     $result = '';
     $validationAttr = '';
     foreach ($this->list as $validator) {
         if ($suppressRequiredValidation && SMReflection::ClassName($validator) == 'RequiredValidator') {
             continue;
         }
         StringUtils::AddStr($validationAttr, $validator->GetValidatorName(), ' ');
         StringUtils::AddStr($result, $validator->GetAdditionalAttributes(), ' ');
     }
     if (!StringUtils::IsNullOrEmpty($validationAttr)) {
         StringUtils::AddStr($result, StringUtils::Format('data-validation="%s"', $validationAttr), ' ');
     }
     return $result;
 }
 public static function SetDatasetFieldValue(Dataset $dataSet, $fieldName, $value)
 {
     if (!StringUtils::IsNullOrEmpty($fieldName)) {
         $dataSet->SetFieldValueByName($fieldName, $value);
     }
 }
 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);
 }
Exemple #10
0
 public function UpdateSearchControls()
 {
     /** @var AdvancedSearchControl $advancedSearch  */
     $advancedSearch = $this->GetPage()->AdvancedSearchControl;
     if ($advancedSearch != null) {
         foreach ($advancedSearch->GetSearchColumns() as $searchColumn) {
             $columnName = $searchColumn->GetFieldName();
             $column = $this->FindViewColumnByName($columnName);
             /** @var Field $field */
             if (!StringUtils::IsNullOrEmpty($column)) {
                 $field = $this->dataset->GetFieldByName($column->GetName());
             } else {
                 $field = $this->dataset->GetFieldByName($columnName);
             }
             if ($field && $searchColumn) {
                 if ($searchColumn instanceof LookupSearchColumn) {
                     $this->filterBuilder->AddField($searchColumn, $searchColumn->GetFieldName(), $searchColumn->GetCaption(), $field->GetEngFieldType(), 'Typeahead', array('handler' => $searchColumn->GetHandlerName()));
                     $searchColumnViewData['Value'] = $searchColumn->GetDisplayValue();
                 } else {
                     if ($field instanceof DateTimeField || $field instanceof DateField) {
                         $formatOptions = array('fdow' => GetFirstDayOfWeek());
                         if (!StringUtils::IsNullOrEmpty($column) && $column instanceof DateTimeViewColumn) {
                             $formatOptions['format'] = $column->GetOSDateTimeFormat();
                         }
                         $this->filterBuilder->AddField($searchColumn, $searchColumn->GetFieldName(), $searchColumn->GetCaption(), $field->GetEngFieldType(), null, $formatOptions);
                     } else {
                         $this->filterBuilder->AddField($searchColumn, $searchColumn->GetFieldName(), $searchColumn->GetCaption(), $field->GetEngFieldType(), null, null);
                     }
                 }
             }
         }
     }
 }
 private function GetNameInContext($name)
 {
     return StringUtils::IsNullOrEmpty($this->context) ? $name : $this->context . '_' . $name;
 }
 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);
 }
 private function getActualParamName($paramName)
 {
     return StringUtils::IsNullOrEmpty($this->prefix) ? $paramName : $this->prefix . '_' . $paramName;
 }
Exemple #14
0
 public function SetValue($value)
 {
     if (!StringUtils::IsNullOrEmpty($value)) {
         $this->value = SMDateTime::Parse($value, $this->showsTime ? 'Y-m-d H:i:s' : 'Y-m-d');
     } else {
         $this->value = null;
     }
 }