예제 #1
0
 /**
  * 
  * @return boolean TRUE on success
  * @throws FileMakerException
  */
 private function _commitEditChild()
 {
     $modifiedFields = [];
     foreach ($this->fields as $fieldName => $repetitions) {
         foreach ($repetitions as $repetition => $value) {
             if (!empty($this->_modifiedFields[$fieldName][$repetition])) {
                 $modifiedFields[$fieldName . '.' . $this->recordId][$repetition] = $value;
             }
         }
     }
     $editCommand = $this->fm->newEditCommand($this->parent->layout->getName(), $this->parent->getRecordId(), $modifiedFields);
     $result = $editCommand->execute();
     $records = $result->getRecords();
     $firstRecord = $records[0];
     $relatedSet = $firstRecord->getRelatedSet($this->layout->getName());
     foreach ($relatedSet as $record) {
         if ($record->getRecordId() == $this->recordId) {
             return $this->_updateFrom($record);
             break;
         }
     }
     throw new FileMakerException('Failed to find the updated child in the response.');
 }
예제 #2
0
 public function setLayout(Layout $layout)
 {
     if (!$this->_isParsed) {
         throw new FileMakerException($this->_fm, 'Attempt to get a layout object before parsing data.');
     }
     if ($this->_layout) {
         $layout =& $this->_layout;
         return true;
     }
     $layout->name = $this->_parsedHead['layout'];
     $layout->database = $this->_parsedHead['database'];
     foreach ($this->_fieldList as $fieldInfos) {
         $field = new Field($layout);
         $field->name = $fieldInfos['name'];
         $field->autoEntered = (bool) ($fieldInfos['auto-enter'] == 'yes');
         $field->global = (bool) ($fieldInfos['global'] == 'yes');
         $field->maxRepeat = (int) $fieldInfos['max-repeat'];
         $field->result = $fieldInfos['result'];
         $field->type = $fieldInfos['type'];
         if ($fieldInfos['not-empty'] == 'yes') {
             $field->validationRules[FileMaker::RULE_NOTEMPTY] = true;
             $field->validationMask |= FileMaker::RULE_NOTEMPTY;
         }
         if ($fieldInfos['numeric-only'] == 'yes') {
             $field->validationRules[FileMaker::RULE_NUMERICONLY] = true;
             $field->validationMask |= FileMaker::RULE_NUMERICONLY;
         }
         if (array_key_exists('max-characters', $fieldInfos)) {
             $field->maxCharacters = (int) $fieldInfos['max-characters'];
             $field->validationRules[FileMaker::RULE_MAXCHARACTERS] = true;
             $field->validationMask |= FileMaker::RULE_MAXCHARACTERS;
         }
         if ($fieldInfos['four-digit-year'] == 'yes') {
             $field->validationRules[FileMaker::RULE_FOURDIGITYEAR] = true;
             $field->validationMask |= FileMaker::RULE_FOURDIGITYEAR;
         }
         if ($fieldInfos['time-of-day'] == 'yes') {
             $field->validationRules[FileMaker::RULE_TIMEOFDAY] = true;
             $field->validationMask |= FileMaker::RULE_TIMEOFDAY;
         }
         if ($fieldInfos['four-digit-year'] == 'no' && $fieldInfos['result'] == 'timestamp') {
             $field->validationRules[FileMaker::RULE_TIMESTAMP_FIELD] = true;
             $field->validationMask |= FileMaker::RULE_TIMESTAMP_FIELD;
         }
         if ($fieldInfos['four-digit-year'] == 'no' && $fieldInfos['result'] == 'date') {
             $field->validationRules[FileMaker::RULE_DATE_FIELD] = true;
             $field->validationMask |= FileMaker::RULE_DATE_FIELD;
         }
         if ($fieldInfos['time-of-day'] == 'no' && $fieldInfos['result'] == 'time') {
             $field->validationRules[FileMaker::RULE_TIME_FIELD] = true;
             $field->validationMask |= FileMaker::RULE_TIME_FIELD;
         }
         $layout->fields[$field->getName()] = $field;
     }
     foreach ($this->_relatedSetNames as $relatedSetName => $fields) {
         $relatedSet = new RelatedSet($layout);
         $relatedSet->name = $relatedSetName;
         foreach ($fields as $fieldInfos) {
             $field = new Field($layout);
             $field->name = $fieldInfos['name'];
             $field->autoEntered = (bool) ($fieldInfos['auto-enter'] == 'yes');
             $field->global = (bool) ($fieldInfos['global'] == 'yes');
             $field->maxRepeat = (int) $fieldInfos['max-repeat'];
             $field->result = $fieldInfos['result'];
             $field->type = $fieldInfos['type'];
             if ($fieldInfos['not-empty'] == 'yes') {
                 $field->validationRules[FileMaker::RULE_NOTEMPTY] = true;
                 $field->validationMask |= FileMaker::RULE_NOTEMPTY;
             }
             if ($fieldInfos['numeric-only'] == 'yes') {
                 $field->validationRules[FileMaker::RULE_NUMERICONLY] = true;
                 $field->validationMask |= FileMaker::RULE_NUMERICONLY;
             }
             if (array_key_exists('max-characters', $fieldInfos)) {
                 $field->maxCharacters = (int) $fieldInfos['max-characters'];
                 $field->validationRules[FileMaker::RULE_MAXCHARACTERS] = true;
                 $field->validationMask |= FileMaker::RULE_MAXCHARACTERS;
             }
             if ($fieldInfos['four-digit-year'] == 'yes') {
                 $field->validationRules[FileMaker::RULE_FOURDIGITYEAR] = true;
                 $field->validationMask |= FileMaker::RULE_FOURDIGITYEAR;
             }
             if ($fieldInfos['time-of-day'] == 'yes' || $fieldInfos['result'] == 'time') {
                 $field->validationRules[FileMaker::RULE_TIMEOFDAY] = true;
                 $field->validationMask |= FileMaker::RULE_TIMEOFDAY;
             }
             if ($fieldInfos['four-digit-year'] == 'no' && $fieldInfos['result'] == 'timestamp') {
                 $field->validationRules[FileMaker::RULE_TIMESTAMP_FIELD] = true;
                 $field->validationMask |= FileMaker::RULE_TIMESTAMP_FIELD;
             }
             if ($fieldInfos['four-digit-year'] == 'no' && $fieldInfos['result'] == 'date') {
                 $field->validationRules[FileMaker::RULE_DATE_FIELD] = true;
                 $field->validationMask |= FileMaker::RULE_DATE_FIELD;
             }
             if ($fieldInfos['time-of-day'] == 'no' && $fieldInfos['result'] == 'time') {
                 $field->validationRules[FileMaker::RULE_TIME_FIELD] = true;
                 $field->validationMask |= FileMaker::RULE_TIME_FIELD;
             }
             $relatedSet->fields[$field->getName()] = $field;
         }
         $layout->relatedSets[$relatedSet->getName()] = $relatedSet;
     }
     $this->_layout = $layout;
     return true;
 }