3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * This class previews the uploaded file and returns summary statistics.
21 * TODO: CRM-11254 - if preProcess and postProcess functions can be reconciled between the 5 child classes,
22 * those classes can be removed entirely and this class will not need to be abstract
24 abstract class CRM_Import_Form_Preview
extends CRM_Import_Forms
{
27 * Return a descriptive name for the page, used in wizard header.
31 public function getTitle() {
36 * Assign common values to the template.
38 public function preProcess() {
39 $this->assign('skipColumnHeader', $this->getSubmittedValue('skipColumnHeader'));
40 $this->assign('rowDisplayCount', $this->getSubmittedValue('skipColumnHeader') ?
3 : 2);
44 * Build the form object.
46 public function buildQuickForm() {
48 // FIXME: This is a hack...
49 // The tpl contains javascript that starts the import on form submit
50 // Since our back/cancel buttons are of html type "submit" we have to prevent a form submit event when they are clicked
51 // Hacking in some onclick js to make them act more like links instead of buttons
52 $path = CRM_Utils_System
::currentPath();
53 $query = ['_qf_MapField_display' => 'true'];
54 $qfKey = CRM_Utils_Request
::retrieve('qfKey', 'String');
55 if (CRM_Utils_Rule
::qfKey($qfKey)) {
56 $query['qfKey'] = $qfKey;
58 $previousURL = CRM_Utils_System
::url($path, $query, FALSE, NULL, FALSE);
59 $cancelURL = CRM_Utils_System
::url($path, 'reset=1', FALSE, NULL, FALSE);
64 'name' => ts('Previous'),
65 'js' => ['onclick' => "location.href='{$previousURL}'; return false;"],
69 'name' => ts('Import Now'),
70 'spacing' => ' ',
75 'name' => ts('Cancel'),
76 'js' => ['onclick' => "location.href='{$cancelURL}'; return false;"],
82 * Set status url for ajax.
84 public function setStatusUrl() {
85 $statusID = $this->get('statusID');
87 $statusID = md5(uniqid(rand(), TRUE));
88 $this->set('statusID', $statusID);
90 $statusUrl = CRM_Utils_System
::url('civicrm/ajax/status', "id={$statusID}", FALSE, NULL, FALSE);
91 $this->assign('statusUrl', $statusUrl);