From 52892e8b85240f3d88770897465d5ad111a95664 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sun, 9 Jun 2013 08:02:55 -0700 Subject: [PATCH] Create parent for Import/Form/Summary CRM-11254 ---------------------------------------- * CRM-11254: Create parent class for import http://issues.civicrm.org/jira/browse/CRM-11254 --- CRM/Activity/Import/Form/Summary.php | 28 +---------- CRM/Activity/Import/Parser.php | 8 +-- CRM/Contact/Import/Form/Summary.php | 28 +---------- CRM/Contact/Import/Parser.php | 40 +++++++-------- CRM/Contribute/Import/Form/Summary.php | 29 +---------- CRM/Contribute/Import/Parser.php | 6 +-- CRM/Event/Import/Form/Summary.php | 28 +---------- CRM/Event/Import/Parser.php | 10 ++-- CRM/Import/Form/Summary.php | 70 ++++++++++++++++++++++++++ CRM/Member/Import/Form/Summary.php | 28 +---------- CRM/Member/Import/Parser.php | 10 ++-- 11 files changed, 112 insertions(+), 173 deletions(-) create mode 100644 CRM/Import/Form/Summary.php diff --git a/CRM/Activity/Import/Form/Summary.php b/CRM/Activity/Import/Form/Summary.php index d4ef8bb257..158303e844 100644 --- a/CRM/Activity/Import/Form/Summary.php +++ b/CRM/Activity/Import/Form/Summary.php @@ -36,7 +36,7 @@ /** * This class summarizes the import results */ -class CRM_Activity_Import_Form_Summary extends CRM_Core_Form { +class CRM_Activity_Import_Form_Summary extends CRM_Import_Form_Summary { /** * Function to set variables up before form is built @@ -101,31 +101,5 @@ class CRM_Activity_Import_Form_Summary extends CRM_Core_Form { } } - /** - * Function to actually build the form - * - * @return None - * @access public - */ - public function buildQuickForm() { - $this->addButtons(array( - array( - 'type' => 'next', - 'name' => ts('Done'), - 'isDefault' => TRUE, - ), - ) - ); - } - - /** - * Return a descriptive name for the page, used in wizard header - * - * @return string - * @access public - */ - public function getTitle() { - return ts('Summary'); - } } diff --git a/CRM/Activity/Import/Parser.php b/CRM/Activity/Import/Parser.php index 32460b7f74..227551cf9c 100644 --- a/CRM/Activity/Import/Parser.php +++ b/CRM/Activity/Import/Parser.php @@ -69,8 +69,8 @@ abstract class CRM_Activity_Import_Parser extends CRM_Import_Parser { $seperator = ',', &$mapper, $skipColumnHeader = FALSE, - $mode = self::MODE_PREVIEW, - $onDuplicate = self::DUPLICATE_SKIP + $mode = self::MODE_PREVIEW, + $onDuplicate = self::DUPLICATE_SKIP ) { if (!is_array($fileName)) { CRM_Core_Error::fatal(); @@ -92,8 +92,8 @@ abstract class CRM_Activity_Import_Parser extends CRM_Import_Parser { $this->_invalidRowCount = $this->_validCount = 0; $this->_totalCount = $this->_conflictCount = 0; - $this->_errors = array(); - $this->_warnings = array(); + $this->_errors = array(); + $this->_warnings = array(); $this->_conflicts = array(); $this->_fileSize = number_format(filesize($fileName) / 1024.0, 2); diff --git a/CRM/Contact/Import/Form/Summary.php b/CRM/Contact/Import/Form/Summary.php index 7575669e4d..f9cd833cc0 100644 --- a/CRM/Contact/Import/Form/Summary.php +++ b/CRM/Contact/Import/Form/Summary.php @@ -36,7 +36,7 @@ /** * This class summarizes the import results */ -class CRM_Contact_Import_Form_Summary extends CRM_Core_Form { +class CRM_Contact_Import_Form_Summary extends CRM_Import_Form_Summary { /** * Function to set variables up before form is built @@ -110,23 +110,6 @@ class CRM_Contact_Import_Form_Summary extends CRM_Core_Form { $session->pushUserContext(CRM_Utils_System::url('civicrm/import/contact', 'reset=1')); } - /** - * Function to actually build the form - * - * @return None - * @access public - */ - public function buildQuickForm() { - $this->addButtons(array( - array( - 'type' => 'next', - 'name' => ts('Done'), - 'isDefault' => TRUE, - ), - ) - ); - } - /** * Clean up the import table we used * @@ -145,14 +128,5 @@ class CRM_Contact_Import_Form_Summary extends CRM_Core_Form { } } - /** - * Return a descriptive name for the page, used in wizard header - * - * @return string - * @access public - */ - public function getTitle() { - return ts('Summary'); - } } diff --git a/CRM/Contact/Import/Parser.php b/CRM/Contact/Import/Parser.php index 6546d9a8f6..6837f84c59 100644 --- a/CRM/Contact/Import/Parser.php +++ b/CRM/Contact/Import/Parser.php @@ -89,16 +89,16 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { function run($tableName, &$mapper, - $mode = self::MODE_PREVIEW, - $contactType = self::CONTACT_INDIVIDUAL, - $primaryKeyName = '_id', - $statusFieldName = '_status', - $onDuplicate = self::DUPLICATE_SKIP, - $statusID = NULL, - $totalRowCount = NULL, - $doGeocodeAddress = FALSE, - $timeout = CRM_Contact_Import_Parser::DEFAULT_TIMEOUT, - $contactSubType = NULL, + $mode = self::MODE_PREVIEW, + $contactType = self::CONTACT_INDIVIDUAL, + $primaryKeyName = '_id', + $statusFieldName = '_status', + $onDuplicate = self::DUPLICATE_SKIP, + $statusID = NULL, + $totalRowCount = NULL, + $doGeocodeAddress = FALSE, + $timeout = CRM_Contact_Import_Parser::DEFAULT_TIMEOUT, + $contactSubType = NULL, $dedupeRuleGroupID = NULL ) { @@ -158,9 +158,9 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { if ($statusID) { $skip = 50; // $skip = 1; - $config = CRM_Core_Config::singleton(); + $config = CRM_Core_Config::singleton(); $statusFile = "{$config->uploadDir}status_{$statusID}.txt"; - $status = "
  " . ts('No processing status reported yet.') . "
"; + $status = "
  " . ts('No processing status reported yet.') . "
"; //do not force the browser to display the save dialog, CRM-7640 $contents = json_encode(array(0, $status)); @@ -175,8 +175,8 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { if ($mode == self::MODE_IMPORT) { $query .= " WHERE $statusFieldName = 'NEW'"; } - $dao = new CRM_Core_DAO(); - $db = $dao->getDatabaseConnection(); + $dao = new CRM_Core_DAO(); + $db = $dao->getDatabaseConnection(); $result = $db->query($query); while ($values = $result->fetchRow(DB_FETCHMODE_ORDERED)) { @@ -208,14 +208,14 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { $returnCode = $this->import($onDuplicate, $values, $doGeocodeAddress); if ($statusID && (($this->_rowCount % $skip) == 0)) { $currTimestamp = time(); - $totalTime = ($currTimestamp - $startTimestamp); - $time = ($currTimestamp - $prevTimestamp); - $recordsLeft = $totalRowCount - $this->_rowCount; + $totalTime = ($currTimestamp - $startTimestamp); + $time = ($currTimestamp - $prevTimestamp); + $recordsLeft = $totalRowCount - $this->_rowCount; if ($recordsLeft < 0) { $recordsLeft = 0; } $estimatedTime = ($recordsLeft / $skip) * $time; - $estMinutes = floor($estimatedTime / 60); + $estMinutes = floor($estimatedTime / 60); $timeFormatted = ''; if ($estMinutes > 1) { $timeFormatted = $estMinutes . ' ' . ts('minutes') . ' '; @@ -733,9 +733,9 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { $db = $dao->getDatabaseConnection(); $query = "UPDATE $this->_tableName - SET $statusFieldName = ?, + SET $statusFieldName = ?, ${statusFieldName}Msg = ? - WHERE $primaryKeyName = ?"; + WHERE $primaryKeyName = ?"; $args = array( $params[$statusFieldName], CRM_Utils_Array::value("${statusFieldName}Msg", $params), diff --git a/CRM/Contribute/Import/Form/Summary.php b/CRM/Contribute/Import/Form/Summary.php index ea3bb9edbc..44f17ee325 100644 --- a/CRM/Contribute/Import/Form/Summary.php +++ b/CRM/Contribute/Import/Form/Summary.php @@ -36,7 +36,7 @@ /** * This class summarizes the import results */ -class CRM_Contribute_Import_Form_Summary extends CRM_Core_Form { +class CRM_Contribute_Import_Form_Summary extends CRM_Import_Form_Summary { /** * Function to set variables up before form is built @@ -112,31 +112,4 @@ class CRM_Contribute_Import_Form_Summary extends CRM_Core_Form { } } - /** - * Function to actually build the form - * - * @return None - * @access public - */ - public function buildQuickForm() { - $this->addButtons(array( - array( - 'type' => 'next', - 'name' => ts('Done'), - 'isDefault' => TRUE, - ), - ) - ); - } - - /** - * Return a descriptive name for the page, used in wizard header - * - * @return string - * @access public - */ - public function getTitle() { - return ts('Summary'); - } } - diff --git a/CRM/Contribute/Import/Parser.php b/CRM/Contribute/Import/Parser.php index 907eaec1ce..61615641a3 100644 --- a/CRM/Contribute/Import/Parser.php +++ b/CRM/Contribute/Import/Parser.php @@ -119,9 +119,9 @@ abstract class CRM_Contribute_Import_Parser extends CRM_Import_Parser { $seperator = ',', &$mapper, $skipColumnHeader = FALSE, - $mode = self::MODE_PREVIEW, - $contactType = self::CONTACT_INDIVIDUAL, - $onDuplicate = self::DUPLICATE_SKIP + $mode = self::MODE_PREVIEW, + $contactType = self::CONTACT_INDIVIDUAL, + $onDuplicate = self::DUPLICATE_SKIP ) { if (!is_array($fileName)) { CRM_Core_Error::fatal(); diff --git a/CRM/Event/Import/Form/Summary.php b/CRM/Event/Import/Form/Summary.php index dcbc8f0fbd..7e9e33ff3f 100644 --- a/CRM/Event/Import/Form/Summary.php +++ b/CRM/Event/Import/Form/Summary.php @@ -36,7 +36,7 @@ /** * This class summarizes the import results */ -class CRM_Event_Import_Form_Summary extends CRM_Core_Form { +class CRM_Event_Import_Form_Summary extends CRM_Import_Form_Summary { /** * Function to set variables up before form is built @@ -100,31 +100,5 @@ class CRM_Event_Import_Form_Summary extends CRM_Core_Form { } } - /** - * Function to actually build the form - * - * @return None - * @access public - */ - public function buildQuickForm() { - $this->addButtons(array( - array( - 'type' => 'next', - 'name' => ts('Done'), - 'isDefault' => TRUE, - ), - ) - ); - } - - /** - * Return a descriptive name for the page, used in wizard header - * - * @return string - * @access public - */ - public function getTitle() { - return ts('Summary'); - } } diff --git a/CRM/Event/Import/Parser.php b/CRM/Event/Import/Parser.php index 2ba6883b9d..d2162ae544 100644 --- a/CRM/Event/Import/Parser.php +++ b/CRM/Event/Import/Parser.php @@ -69,9 +69,9 @@ abstract class CRM_Event_Import_Parser extends CRM_Import_Parser { $seperator = ',', &$mapper, $skipColumnHeader = FALSE, - $mode = self::MODE_PREVIEW, - $contactType = self::CONTACT_INDIVIDUAL, - $onDuplicate = self::DUPLICATE_SKIP + $mode = self::MODE_PREVIEW, + $contactType = self::CONTACT_INDIVIDUAL, + $onDuplicate = self::DUPLICATE_SKIP ) { if (!is_array($fileName)) { CRM_Core_Error::fatal(); @@ -106,8 +106,8 @@ abstract class CRM_Event_Import_Parser extends CRM_Import_Parser { $this->_invalidRowCount = $this->_validCount = 0; $this->_totalCount = $this->_conflictCount = 0; - $this->_errors = array(); - $this->_warnings = array(); + $this->_errors = array(); + $this->_warnings = array(); $this->_conflicts = array(); $this->_fileSize = number_format(filesize($fileName) / 1024.0, 2); diff --git a/CRM/Import/Form/Summary.php b/CRM/Import/Form/Summary.php new file mode 100644 index 0000000000..9e004d0a0b --- /dev/null +++ b/CRM/Import/Form/Summary.php @@ -0,0 +1,70 @@ +addButtons(array( + array( + 'type' => 'next', + 'name' => ts('Done'), + 'isDefault' => TRUE, + ), + ) + ); + } + + /** + * Return a descriptive name for the page, used in wizard header + * + * @return string + * @access public + */ + public function getTitle() { + return ts('Summary'); + } +} + diff --git a/CRM/Member/Import/Form/Summary.php b/CRM/Member/Import/Form/Summary.php index 9a6a5ccb61..126bfd235e 100644 --- a/CRM/Member/Import/Form/Summary.php +++ b/CRM/Member/Import/Form/Summary.php @@ -36,7 +36,7 @@ /** * This class summarizes the import results */ -class CRM_Member_Import_Form_Summary extends CRM_Core_Form { +class CRM_Member_Import_Form_Summary extends CRM_Import_Form_Summary { /** * Function to set variables up before form is built @@ -101,31 +101,5 @@ class CRM_Member_Import_Form_Summary extends CRM_Core_Form { } } - /** - * Function to actually build the form - * - * @return None - * @access public - */ - public function buildQuickForm() { - $this->addButtons(array( - array( - 'type' => 'next', - 'name' => ts('Done'), - 'isDefault' => TRUE, - ), - ) - ); - } - - /** - * Return a descriptive name for the page, used in wizard header - * - * @return string - * @access public - */ - public function getTitle() { - return ts('Summary'); - } } diff --git a/CRM/Member/Import/Parser.php b/CRM/Member/Import/Parser.php index 70338e2800..ab7d7b332a 100644 --- a/CRM/Member/Import/Parser.php +++ b/CRM/Member/Import/Parser.php @@ -69,9 +69,9 @@ abstract class CRM_Member_Import_Parser extends CRM_Import_Parser { $seperator = ',', &$mapper, $skipColumnHeader = FALSE, - $mode = self::MODE_PREVIEW, - $contactType = self::CONTACT_INDIVIDUAL, - $onDuplicate = self::DUPLICATE_SKIP + $mode = self::MODE_PREVIEW, + $contactType = self::CONTACT_INDIVIDUAL, + $onDuplicate = self::DUPLICATE_SKIP ) { if (!is_array($fileName)) { CRM_Core_Error::fatal(); @@ -106,8 +106,8 @@ abstract class CRM_Member_Import_Parser extends CRM_Import_Parser { $this->_invalidRowCount = $this->_validCount = 0; $this->_totalCount = $this->_conflictCount = 0; - $this->_errors = array(); - $this->_warnings = array(); + $this->_errors = array(); + $this->_warnings = array(); $this->_conflicts = array(); $this->_fileSize = number_format(filesize($fileName) / 1024.0, 2); -- 2.25.1