<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
*
*/
-
abstract class CRM_Contribute_Import_Parser extends CRM_Import_Parser {
/**
* Contribution-specific result codes
* @see CRM_Import_Parser result code constants
*/
- CONST SOFT_CREDIT = 512, SOFT_CREDIT_ERROR = 1024, PLEDGE_PAYMENT = 2048, PLEDGE_PAYMENT_ERROR = 4096;
+ const SOFT_CREDIT = 512, SOFT_CREDIT_ERROR = 1024, PLEDGE_PAYMENT = 2048, PLEDGE_PAYMENT_ERROR = 4096;
protected $_fileName;
- /**#@+
- * @access protected
- * @var integer
- */
-
/**
- * imported file size
+ * Imported file size
*/
protected $_fileSize;
/**
- * seperator being used
+ * Seperator being used
*/
protected $_seperator;
/**
- * total number of lines in file
+ * Total number of lines in file
*/
protected $_lineCount;
/**
- * running total number of valid soft credit rows
+ * Running total number of valid soft credit rows
*/
protected $_validSoftCreditRowCount;
/**
- * running total number of invalid soft credit rows
+ * Running total number of invalid soft credit rows
*/
protected $_invalidSoftCreditRowCount;
/**
- * running total number of valid pledge payment rows
+ * Running total number of valid pledge payment rows
*/
protected $_validPledgePaymentRowCount;
/**
- * running total number of invalid pledge payment rows
+ * Running total number of invalid pledge payment rows
*/
protected $_invalidPledgePaymentRowCount;
/**
- * array of pledge payment error lines, bounded by MAX_ERROR
+ * Array of pledge payment error lines, bounded by MAX_ERROR
*/
protected $_pledgePaymentErrors;
/**
- * array of pledge payment error lines, bounded by MAX_ERROR
+ * Array of pledge payment error lines, bounded by MAX_ERROR
*/
protected $_softCreditErrors;
/**
- * filename of pledge payment error data
+ * Filename of pledge payment error data
*
* @var string
*/
protected $_pledgePaymentErrorsFileName;
/**
- * filename of soft credit error data
+ * Filename of soft credit error data
*
* @var string
*/
protected $_softCreditErrorsFileName;
/**
- * whether the file has a column header or not
+ * Whether the file has a column header or not
*
* @var boolean
*/
protected $_haveColumnHeader;
+ /**
+ * @param string $fileName
+ * @param string $seperator
+ * @param $mapper
+ * @param bool $skipColumnHeader
+ * @param int $mode
+ * @param int $contactType
+ * @param int $onDuplicate
+ *
+ * @return mixed
+ * @throws Exception
+ */
function run($fileName,
$seperator = ',',
&$mapper,
self::exportCSV($this->_duplicateFileName, $headers, $this->_duplicates);
}
}
- //echo "$this->_totalCount,$this->_invalidRowCount,$this->_conflictCount,$this->_duplicateCount";
return $this->fini();
}
*
* @param array mapped array of values
*
-pppp * @return void
- * @access public
+ * @return void
*/
- function setActiveFields($fieldKeys) {
+ public function setActiveFields($fieldKeys) {
$this->_activeFieldCount = count($fieldKeys);
foreach ($fieldKeys as $key) {
if (empty($this->_fields[$key])) {
}
}
- function setActiveFieldSoftCredit($elements) {
+ /**
+ * @param array $elements
+ */
+ public function setActiveFieldSoftCredit($elements) {
for ($i = 0; $i < count($elements); $i++) {
$this->_activeFields[$i]->_softCreditField = $elements[$i];
}
}
- function setActiveFieldSoftCreditType($elements) {
+ /**
+ * @param array $elements
+ */
+ public function setActiveFieldSoftCreditType($elements) {
for ($i = 0; $i < count($elements); $i++) {
$this->_activeFields[$i]->_softCreditType = $elements[$i];
}
}
+
/**
- * function to format the field values for input to the api
+ * Format the field values for input to the api
*
* @return array (reference ) associative array of name/value pairs
- * @access public
*/
- function &getActiveFieldParams() {
+ public function &getActiveFieldParams() {
$params = array();
for ($i = 0; $i < $this->_activeFieldCount; $i++) {
if (isset($this->_activeFields[$i]->_value)) {
return $params;
}
- function addField($name, $title, $type = CRM_Utils_Type::T_INT, $headerPattern = '//', $dataPattern = '//') {
+ /**
+ * @param string $name
+ * @param $title
+ * @param int $type
+ * @param string $headerPattern
+ * @param string $dataPattern
+ */
+ public function addField($name, $title, $type = CRM_Utils_Type::T_INT, $headerPattern = '//', $dataPattern = '//') {
if (empty($name)) {
$this->_fields['doNotImport'] = new CRM_Contribute_Import_Field($name, $title, $type, $headerPattern, $dataPattern);
}
*
* @param CRM_Core_Session $store
*
+ * @param int $mode
+ *
* @return void
- * @access public
*/
- function set($store, $mode = self::MODE_SUMMARY) {
+ public function set($store, $mode = self::MODE_SUMMARY) {
$store->set('fileSize', $this->_fileSize);
$store->set('lineCount', $this->_lineCount);
$store->set('seperator', $this->_seperator);
$store->set('duplicatesFileName', $this->_duplicateFileName);
}
}
- //echo "$this->_totalCount,$this->_invalidRowCount,$this->_conflictCount,$this->_duplicateCount";
}
/**
* Export data to a CSV file
*
- * @param string $filename
+ * @param string $fileName
* @param array $header
- * @param data $data
+ * @param array $data
*
* @return void
- * @access public
*/
- static function exportCSV($fileName, $header, $data) {
+ public static function exportCSV($fileName, $header, $data) {
$output = array();
$fd = fopen($fileName, 'w');
fclose($fd);
}
- static function errorFileName($type) {
+ /**
+ * Determines the file extension based on error code
+ *
+ * @param int $type error code constant
+ *
+ * @return string
+ */
+ public static function errorFileName($type) {
$fileName = NULL;
if (empty($type)) {
return $fileName;
return $fileName;
}
- static function saveFileName($type) {
+ /**
+ * Determines the file name based on error code
+ *
+ * @param int $type error code constant
+ *
+ * @return string
+ */
+ public static function saveFileName($type) {
$fileName = NULL;
if (empty($type)) {
return $fileName;
return $fileName;
}
}
-