* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/
-abstract class CRM_Custom_Import_Parser extends CRM_Contact_Import_Parser {
+abstract class CRM_Custom_Import_Parser extends CRM_Import_Parser {
protected $_fileName;
*/
public function run(
$fileName,
- $separator = ',',
- &$mapper,
+ $separator,
+ $mapper,
$skipColumnHeader = FALSE,
$mode = self::MODE_PREVIEW,
$contactType = self::CONTACT_INDIVIDUAL,
if ($returnCode & self::WARNING) {
$this->_warningCount++;
if ($this->_warningCount < $this->_maxWarningCount) {
- $this->_warningCount[] = $line;
+ $this->_warnings[] = $this->_lineCount;
}
}
}
if ($returnCode & self::DUPLICATE) {
- if ($returnCode & self::MULTIPLE_DUPE) {
- /* TODO: multi-dupes should be counted apart from singles
- * on non-skip action */
- }
$this->_duplicateCount++;
$recordNumber = $this->_lineCount;
if ($this->_haveColumnHeader) {
ts('Reason'),
], $customHeaders);
$this->_errorFileName = self::errorFileName(self::ERROR);
- self::exportCSV($this->_errorFileName, $headers, $this->_errors);
+ CRM_Contact_Import_Parser_Contact::exportCSV($this->_errorFileName, $headers, $this->_errors);
}
if ($this->_conflictCount) {
$headers = array_merge([
ts('Reason'),
], $customHeaders);
$this->_conflictFileName = self::errorFileName(self::CONFLICT);
- self::exportCSV($this->_conflictFileName, $headers, $this->_conflicts);
+ CRM_Contact_Import_Parser_Contact::exportCSV($this->_conflictFileName, $headers, $this->_conflicts);
}
if ($this->_duplicateCount) {
$headers = array_merge([
], $customHeaders);
$this->_duplicateFileName = self::errorFileName(self::DUPLICATE);
- self::exportCSV($this->_duplicateFileName, $headers, $this->_duplicates);
+ CRM_Contact_Import_Parser_Contact::exportCSV($this->_duplicateFileName, $headers, $this->_duplicates);
}
}
return $this->fini();
}
}
+ /**
+ * @param string $name
+ * @param $title
+ * @param int $type
+ * @param string $headerPattern
+ * @param string $dataPattern
+ * @param bool $hasLocationType
+ */
+ public function addField(
+ $name, $title, $type = CRM_Utils_Type::T_INT,
+ $headerPattern = '//', $dataPattern = '//',
+ $hasLocationType = FALSE
+ ) {
+ $this->_fields[$name] = new CRM_Custom_Import_Field($name, $title, $type, $headerPattern, $dataPattern, $hasLocationType);
+ if (empty($name)) {
+ $this->_fields['doNotImport'] = new CRM_Custom_Import_Field($name, $title, $type, $headerPattern, $dataPattern, $hasLocationType);
+ }
+ }
+
}