Merge pull request #23570 from ufundo/mailing-group-token-frontend-title
[civicrm-core.git] / CRM / Import / Form / Preview.php
CommitLineData
f532671f
CW
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
f532671f 5 | |
bc77d7c0
TO
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 |
f532671f 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
f532671f
CW
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
f532671f
CW
16 */
17
18/**
2b4bc760 19 * This class previews the uploaded file and returns summary statistics.
20 *
f532671f
CW
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
23 */
9d7974eb 24abstract class CRM_Import_Form_Preview extends CRM_Import_Forms {
971e129b 25
f532671f 26 /**
2b4bc760 27 * Return a descriptive name for the page, used in wizard header.
f532671f
CW
28 *
29 * @return string
f532671f
CW
30 */
31 public function getTitle() {
32 return ts('Preview');
33 }
34
9d7974eb
EM
35 /**
36 * Assign common values to the template.
37 */
38 public function preProcess() {
39 $this->assign('skipColumnHeader', $this->getSubmittedValue('skipColumnHeader'));
40 $this->assign('rowDisplayCount', $this->getSubmittedValue('skipColumnHeader') ? 3 : 2);
41 }
42
f532671f 43 /**
fe482240 44 * Build the form object.
f532671f
CW
45 */
46 public function buildQuickForm() {
4c7e1926
CW
47
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;
57 }
58 $previousURL = CRM_Utils_System::url($path, $query, FALSE, NULL, FALSE);
59 $cancelURL = CRM_Utils_System::url($path, 'reset=1', FALSE, NULL, FALSE);
60
be2fb01f 61 $this->addButtons([
4c7e1926
CW
62 [
63 'type' => 'back',
64 'name' => ts('Previous'),
65 'js' => ['onclick' => "location.href='{$previousURL}'; return false;"],
66 ],
67 [
68 'type' => 'next',
69 'name' => ts('Import Now'),
70 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
71 'isDefault' => TRUE,
72 ],
73 [
74 'type' => 'cancel',
75 'name' => ts('Cancel'),
76 'js' => ['onclick' => "location.href='{$cancelURL}'; return false;"],
77 ],
971e129b 78 ]);
f532671f
CW
79 }
80
8cebffb2
JP
81 /**
82 * Set status url for ajax.
83 */
84 public function setStatusUrl() {
85 $statusID = $this->get('statusID');
86 if (!$statusID) {
87 $statusID = md5(uniqid(rand(), TRUE));
88 $this->set('statusID', $statusID);
89 }
90 $statusUrl = CRM_Utils_System::url('civicrm/ajax/status', "id={$statusID}", FALSE, NULL, FALSE);
91 $this->assign('statusUrl', $statusUrl);
92 }
93
f532671f 94}