/**
* Build the form object.
*
- * @throws \CiviCRM_API3_Exception
+ * @throws \CRM_Core_Exception
*/
- public function buildQuickForm() {
+ public function buildQuickForm(): void {
$savedMappingID = (int) $this->getSubmittedValue('savedMapping');
$this->buildSavedMappingFields($savedMappingID);
$this->addFormRule(['CRM_Activity_Import_Form_MapField', 'formRule']);
$defaults = [];
$headerPatterns = $this->getHeaderPatterns();
- $dataPatterns = $this->getDataPatterns();
$fieldMappings = $this->getFieldMappings();
$columnHeaders = $this->getColumnHeaders();
$hasHeaders = $this->getSubmittedValue('skipColumnHeader');
if ($hasHeaders) {
$defaults["mapper[$i]"] = [$this->defaultFromHeader($columnHeader, $headerPatterns)];
}
- else {
- $defaults["mapper[$i]"] = [$this->defaultFromData($dataPatterns, $i)];
- }
}
// End of load mapping.
}
0,
];
}
- else {
- // Otherwise guess the default from the form of the data
- $defaults["mapper[$i]"] = [$this->defaultFromData($dataPatterns, $i), 0];
- }
}
$sel->setOptions([$sel1]);
];
}
}
- else {
- // Otherwise guess the default from the form of the data
- $defaults["mapper[$i]"] = [
- $this->defaultFromData($this->getDataPatterns(), $i),
- ];
- }
$last_key = array_key_last($defaults["mapper[$i]"]) ?? 0;
}
// Call swapOptions on the deepest select element to hide the empty select lists above it.
return CRM_Utils_Array::collect('headerPattern', $this->getContactImportMetadata());
}
- /**
- * Get an array of header patterns for importable keys.
- *
- * @return array
- */
- public function getDataPatterns(): array {
- return CRM_Utils_Array::collect('dataPattern', $this->getContactImportMetadata());
- }
-
/**
* Get an array of header patterns for importable keys.
*
$mapperKeys = array_keys($this->_mapperFields);
$hasHeaders = $this->getSubmittedValue('skipColumnHeader');
$headerPatterns = $this->getHeaderPatterns();
- $dataPatterns = $this->getDataPatterns();
$mapperKeysValues = $this->getSubmittedValue('mapper');
$columnHeaders = $this->getColumnHeaders();
$fieldMappings = $this->getFieldMappings();
if ($hasHeaders) {
$defaults["mapper[$i]"] = [$this->defaultFromHeader($columnHeader, $headerPatterns)];
}
- else {
- $defaults["mapper[$i]"] = [$this->defaultFromData($dataPatterns, $i)];
- }
}
//end of load mapping
}
];
}
}
- else {
- // Otherwise guess the default from the form of the data
- $defaults["mapper[$i]"] = [
- $this->defaultFromData($dataPatterns, $i),
- 0,
- ];
- }
if (!empty($mapperKeysValues) && ($mapperKeysValues[$i][0] ?? NULL) === 'soft_credit') {
$softCreditField = $mapperKeysValues[$i][1];
$softCreditTypeID = $mapperKeysValues[$i][2];
$mapperKeys = array_keys($this->_mapperFields);
$hasHeaders = $this->getSubmittedValue('skipColumnHeader');
$headerPatterns = $this->getHeaderPatterns();
- $dataPatterns = $this->getDataPatterns();
$fieldMappings = $this->getFieldMappings();
/* Initialize all field usages to false */
if ($hasHeaders) {
$defaults["mapper[$i]"] = [$this->defaultFromHeader($columnHeader, $headerPatterns)];
}
- else {
- $defaults["mapper[$i]"] = [$this->defaultFromData($dataPatterns, $i)];
- }
}
//end of load mapping
}
0,
];
}
- else {
- // Otherwise guess the default from the form of the data
- $defaults["mapper[$i]"] = [
- $this->defaultFromData($dataPatterns, $i),
- // $defaultLocationType->id
- 0,
- ];
- }
}
$sel->setOptions([$sel1]);
}
return [];
}
- /**
- * Get the data patterns to pattern match the incoming data.
- *
- * @return array
- */
- public function getDataPatterns(): array {
- return $this->getParser()->getDataPatterns();
- }
-
/**
* Get the data patterns to pattern match the incoming data.
*
return $values;
}
- /**
- * @deprecated
- *
- * @return array
- */
- public function getDataPatterns():array {
- $values = [];
- foreach ($this->_fields as $name => $field) {
- $values[$name] = $field->_dataPattern;
- }
- return $values;
- }
-
/**
* Remove single-quote enclosures from a value array (row).
*
/**
* Build the form object.
*
- * @return void
+ * @throws \CRM_Core_Exception
*/
- public function buildQuickForm() {
+ public function buildQuickForm(): void {
$this->buildSavedMappingFields($this->getSubmittedValue('savedMapping'));
$this->addFormRule(array('CRM_Member_Import_Form_MapField', 'formRule'), $this);
$columnHeaders = $this->getColumnHeaders();
$hasHeaders = $this->getSubmittedValue('skipColumnHeader');
$headerPatterns = $this->getHeaderPatterns();
- $dataPatterns = $this->getDataPatterns();
// For most fields using the html label is a good thing
// but for contact ID we really want to specify ID.
$this->_mapperFields['membership_contact_id'] = ts('Contact ID');
if ($hasHeaders) {
$defaults["mapper[$i]"] = array($this->defaultFromHeader($columnHeader, $headerPatterns));
}
- else {
- $defaults["mapper[$i]"] = array($this->defaultFromData($dataPatterns, $i));
- }
}
//end of load mapping
}
0,
);
}
- else {
- // Otherwise guess the default from the form of the data
- $defaults["mapper[$i]"] = array(
- $this->defaultFromData($dataPatterns, $i),
- // $defaultLocationType->id
- 0,
- );
- }
}
$sel->setOptions([$sel1]);
}