<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
* $Id$
*
*/
-
-
abstract class CRM_Import_Parser {
/**
* Settings
*/
- CONST MAX_ERRORS = 250, MAX_WARNINGS = 25, DEFAULT_TIMEOUT = 30;
+ const MAX_ERRORS = 250, MAX_WARNINGS = 25, DEFAULT_TIMEOUT = 30;
/**
* Return codes
*/
- CONST VALID = 1, WARNING = 2, ERROR = 4, CONFLICT = 8, STOP = 16, DUPLICATE = 32, MULTIPLE_DUPE = 64, NO_MATCH = 128, UNPARSED_ADDRESS_WARNING = 256;
+ const VALID = 1, WARNING = 2, ERROR = 4, CONFLICT = 8, STOP = 16, DUPLICATE = 32, MULTIPLE_DUPE = 64, NO_MATCH = 128, UNPARSED_ADDRESS_WARNING = 256;
/**
* Parser modes
*/
- CONST MODE_MAPFIELD = 1, MODE_PREVIEW = 2, MODE_SUMMARY = 4, MODE_IMPORT = 8;
+ const MODE_MAPFIELD = 1, MODE_PREVIEW = 2, MODE_SUMMARY = 4, MODE_IMPORT = 8;
/**
* Codes for duplicate record handling
*/
- CONST DUPLICATE_SKIP = 1, DUPLICATE_REPLACE = 2, DUPLICATE_UPDATE = 4, DUPLICATE_FILL = 8, DUPLICATE_NOCHECK = 16;
+ const DUPLICATE_SKIP = 1, DUPLICATE_REPLACE = 2, DUPLICATE_UPDATE = 4, DUPLICATE_FILL = 8, DUPLICATE_NOCHECK = 16;
/**
* Contact types
*/
- CONST CONTACT_INDIVIDUAL = 1, CONTACT_HOUSEHOLD = 2, CONTACT_ORGANIZATION = 4;
+ const CONTACT_INDIVIDUAL = 1, CONTACT_HOUSEHOLD = 2, CONTACT_ORGANIZATION = 4;
/**
/**
* Class constructor
*/
- function __construct() {
+ public function __construct() {
$this->_maxLinesToProcess = 0;
$this->_maxErrorCount = self::MAX_ERRORS;
}
/**
- * Abstract function definitions
+ * Abstract function definitions.
*/
- abstract function init();
+ abstract protected function init();
/**
* @return mixed
*/
- abstract function fini();
+ abstract protected function fini();
/**
* @param $values
*
* @return mixed
*/
- abstract function mapField(&$values);
+ abstract protected function mapField(&$values);
/**
* @param $values
*
* @return mixed
*/
- abstract function preview(&$values);
+ abstract protected function preview(&$values);
/**
* @param $values
*
* @return mixed
*/
- abstract function summary(&$values);
+ abstract protected function summary(&$values);
/**
* @param $onDuplicate
*
* @return mixed
*/
- abstract function import($onDuplicate, &$values);
+ abstract protected function import($onDuplicate, &$values);
/**
- * Set and validate field values
+ * Set and validate field values.
*
- * @param $elements : array
- * @param $erroneousField : reference
+ * @param array $elements
+ * array.
+ * @param $erroneousField
+ * reference.
*
* @return int
*/
- function setActiveFieldValues($elements, &$erroneousField) {
+ public function setActiveFieldValues($elements, &$erroneousField) {
$maxCount = count($elements) < $this->_activeFieldCount ? count($elements) : $this->_activeFieldCount;
for ($i = 0; $i < $maxCount; $i++) {
$this->_activeFields[$i]->setValue($elements[$i]);
}
/**
- * 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
+ * @return array
+ * (reference) associative array of name/value pairs
*/
- function &getActiveFieldParams() {
+ public function &getActiveFieldParams() {
$params = array();
for ($i = 0; $i < $this->_activeFieldCount; $i++) {
if (isset($this->_activeFields[$i]->_value)
/**
* @return array
*/
- function getSelectValues() {
+ public function getSelectValues() {
$values = array();
foreach ($this->_fields as $name => $field) {
$values[$name] = $field->_title;
/**
* @return array
*/
- function getSelectTypes() {
+ public function getSelectTypes() {
$values = array();
foreach ($this->_fields as $name => $field) {
if (isset($field->_hasLocationType)) {
/**
* @return array
*/
- function getHeaderPatterns() {
+ public function getHeaderPatterns() {
$values = array();
foreach ($this->_fields as $name => $field) {
if (isset($field->_headerPattern)) {
/**
* @return array
*/
- function getDataPatterns() {
+ public function getDataPatterns() {
$values = array();
foreach ($this->_fields as $name => $field) {
$values[$name] = $field->_dataPattern;
* @param string $enclosure
*
* @return void
- * @static
- * @access public
*/
- static function encloseScrub(&$values, $enclosure = "'") {
+ public static function encloseScrub(&$values, $enclosure = "'") {
if (empty($values)) {
return;
}
}
/**
- * Setter function
+ * Setter function.
*
* @param int $max
*
* @return void
- * @access public
*/
- function setMaxLinesToProcess($max) {
+ public function setMaxLinesToProcess($max) {
$this->_maxLinesToProcess = $max;
}
/**
- * Determines the file extension based on error code
+ * Determines the file extension based on error code.
*
* @var $type error code constant
* @return string
- * @static
*/
- static function errorFileName($type) {
+ public static function errorFileName($type) {
$fileName = NULL;
if (empty($type)) {
return $fileName;
}
/**
- * Determines the file name based on error code
+ * Determines the file name based on error code.
*
* @var $type error code constant
* @return string
- * @static
*/
- static function saveFileName($type) {
+ public static function saveFileName($type) {
$fileName = NULL;
if (empty($type)) {
return $fileName;