PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.1
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
← All changes | back/Controllers/Forms/Edition.php +0 -156 11.0.3 → 11.1.1 View file →
@@ -1,156 +1,0 @@
1 -<?php
2 -
3 -namespace AcyMailing\Controllers\Forms;
4 -
5 -use AcyMailing\Classes\FormClass;
6 -
7 -trait Edition
8 -{
9 - public function newForm(): void
10 - {
11 - acym_setVar('layout', 'new_form');
12 -
13 - if (ACYM_CMS === 'joomla') {
14 - $moduleId = acym_loadResult('SELECT extension_id FROM #__extensions WHERE element = "mod_acym"');
15 -
16 - if (empty($moduleId)) {
17 - $widgetUrl = 'index.php?option=com_modules&view=select';
18 - } else {
19 - $widgetUrl = 'index.php?option=com_modules&task=module.add&eid='.intval($moduleId);
20 - }
21 - } else {
22 - if (current_theme_supports('widgets')) {
23 - $widgetUrl = 'widgets.php';
24 - } else {
25 - $widgetUrl = 'site-editor.php';
26 - }
27 - }
28 -
29 - $data = [
30 - 'widget_link' => acym_route($widgetUrl),
31 - 'popup_link' => acym_completeLink('forms&task=edit&type=popup'),
32 - 'header_link' => acym_completeLink('forms&task=edit&type=header'),
33 - 'footer_link' => acym_completeLink('forms&task=edit&type=footer'),
34 - ];
35 -
36 - if (ACYM_CMS === 'wordpress') {
37 - $data['shortcode_link'] = acym_completeLink('forms&task=edit&type=shortcode');
38 - }
39 -
40 - parent::display($data);
41 - }
42 -
43 - public function edit(): void
44 - {
45 - acym_setVar('layout', 'edit');
46 - $formClass = new FormClass();
47 - $id = acym_getVar('int', 'id', 0);
48 - $type = acym_getVar('string', 'type', ACYM_CMS === 'wordpress' ? FormClass::SUB_FORM_TYPE_SHORTCODE : FormClass::SUB_FORM_TYPE_POPUP);
49 - if (
50 - !acym_level(ACYM_ENTERPRISE)
51 - && in_array($type, [FormClass::SUB_FORM_TYPE_POPUP, FormClass::SUB_FORM_TYPE_HEADER, FormClass::SUB_FORM_TYPE_FOOTER])
52 - ) {
53 - acym_enqueueMessage(acym_translation('ACYM_NOT_ALLOWED_CREATE_TYPE_FORM'), 'info');
54 - $this->listing();
55 -
56 - return;
57 - }
58 -
59 - if (empty($id)) {
60 - $form = $formClass->initEmptyForm($type);
61 - $this->breadcrumb[acym_translation('ACYM_NEW_FORM')] = acym_completeLink('forms&task=edit&id=0&type='.$type);
62 - } else {
63 - $form = $formClass->getOneById($id);
64 - $form = $formClass->getFormWithMissingParams(get_object_vars($form));
65 - $this->breadcrumb[$form->name] = acym_completeLink('forms&task=edit&id='.$id);
66 - }
67 -
68 - if (empty($form)) {
69 - $this->listing();
70 -
71 - return;
72 - }
73 -
74 - $allPagesCMS = ['all' => acym_translation('ACYM_ALL_PAGES')];
75 - $allPagesCMS = array_replace($allPagesCMS, acym_getAllPages());
76 -
77 -
78 - $languagesName = ['all' => acym_translation('ACYM_ALL_LANGUAGE_NAME')];
79 - foreach (acym_getLanguages() as $languageCode => $languageArray) {
80 - $languagesName[$languageCode] = $languageArray->name;
81 - }
82 -
83 - $data = [
84 - 'all_languages' => $languagesName,
85 - 'form' => $form,
86 - 'all_pages' => $allPagesCMS,
87 - 'menu_render_settings' => $formClass->prepareMenuHtml($form, 'options'),
88 - 'menu_render_style' => $formClass->prepareMenuHtml($form, 'styles'),
89 - ];
90 -
91 - parent::display($data);
92 - }
93 -
94 - public function updateFormPreview(): void
95 - {
96 - $formArray = acym_getVar('array', 'form');
97 - if (empty($formArray)) {
98 - acym_sendAjaxResponse(acym_translation('ACYM_COULD_NOT_GET_FORM_INFORMATION'), [], false);
99 - }
100 -
101 - $formClass = new FormClass();
102 - $form = $formClass->getFormWithMissingParams($formArray);
103 -
104 - $data = [
105 - 'html' => $formClass->renderForm($form, true),
106 - ];
107 -
108 - if (empty($data['html'])) {
109 - acym_sendAjaxResponse(acym_translation('ACYM_SOMETHING_WENT_WRONG_GENERATION_FORM'), [], false);
110 - }
111 -
112 - acym_sendAjaxResponse('', $data);
113 - }
114 -
115 - public function saveAjax(): void
116 - {
117 - wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
118 - $formArray = acym_getVar('array', 'form');
119 - if (empty($formArray)) {
120 - acym_sendAjaxResponse(acym_translation('ACYM_COULD_NOT_GET_FORM_INFORMATION'), [], false);
121 - }
122 -
123 - $formClass = new FormClass();
124 - $form = $formClass->getFormWithMissingParams($formArray);
125 - foreach ($form as $column => $value) {
126 - if (is_array($value)) {
127 - $form->$column = json_encode($value);
128 - } else {
129 - $form->$column = $value;
130 - }
131 - }
132 -
133 - $id = $formClass->save($form);
134 - if (empty($id)) {
135 - acym_sendAjaxResponse(acym_translation('ACYM_SOMETHING_WENT_WRONG_FORM_SAVING'), [], false);
136 - } else {
137 - acym_sendAjaxResponse(acym_translation('ACYM_FORM_WELL_SAVED'), ['id' => $id]);
138 - }
139 - }
140 -
141 - public function getArticles(): void
142 - {
143 - $searchedTerm = acym_getVar('string', 'searchedterm', '');
144 -
145 - echo json_encode(acym_getArticles($searchedTerm));
146 - exit;
147 - }
148 -
149 - public function getArticlesById(): void
150 - {
151 - $id = acym_getVar('int', 'article_id', 0);
152 -
153 - echo json_encode(acym_getArticleById($id));
154 - exit;
155 - }
156 -}