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/LanguageController.php +0 -207 10.0.1 → 11.1.1 View file →
@@ -1,207 +1,0 @@
1 -<?php
2 -
3 -namespace AcyMailing\Controllers;
4 -
5 -use AcyMailing\Helpers\MailerHelper;
6 -use AcyMailing\Helpers\UpdateHelper;
7 -use AcyMailing\Helpers\UpdatemeHelper;
8 -use AcyMailing\Core\AcymController;
9 -
10 -class LanguageController extends AcymController
11 -{
12 - public function saveLanguage($fromShare = false)
13 - {
14 - acym_checkToken();
15 -
16 - $code = acym_getVar('cmd', 'code');
17 - acym_setVar('code', $code);
18 -
19 - $content = acym_getVar('string', 'content', '', '', ACYM_ALLOWRAW);
20 - $content = str_replace('</textarea>', '', $content);
21 -
22 - if (empty($code) || empty($content)) {
23 - return $this->displayLanguage();
24 - }
25 -
26 - $customcontent = acym_getVar('string', 'customcontent', '', '', ACYM_ALLOWRAW);
27 - $customcontent = str_replace('</textarea>', '', $customcontent);
28 -
29 - $path = acym_getLanguagePath(ACYM_ROOT, $code).DS.$code.'.com_acym.ini';
30 - $result = acym_writeFile($path, $content);
31 - if ($result) {
32 - acym_enqueueMessage(acym_translation('ACYM_SUCCESSFULLY_SAVED'), 'success');
33 - $js = 'let langIcon = window.top.document.getElementById("image'.$code.'"); langIcon.className = langIcon.className.replace("acymicon-add", "") + " acymicon-edit"';
34 - acym_addScript(true, $js);
35 -
36 - $updateHelper = new UpdateHelper();
37 - $updateHelper->installBackLanguages($code);
38 - } else {
39 - acym_enqueueMessage(acym_translationSprintf('ACYM_FAIL_SAVE_FILE', $path), 'error');
40 - }
41 -
42 - $custompath = acym_getLanguagePath(ACYM_ROOT, $code).DS.$code.'.com_acym_custom.ini';
43 - $customresult = acym_writeFile($custompath, $customcontent);
44 - if (!$customresult) {
45 - acym_enqueueMessage(acym_translationSprintf('ACYM_FAIL_SAVE_FILE', $custompath), 'error');
46 - }
47 -
48 - if ($code == acym_getLanguageTag()) {
49 - acym_loadLanguage();
50 - }
51 -
52 - $updateHelper = new UpdateHelper();
53 - $updateHelper->installBackLanguages();
54 -
55 - if ($fromShare) {
56 - return $result;
57 - } else {
58 - return $this->displayLanguage();
59 - }
60 - }
61 -
62 - public function share()
63 - {
64 - acym_checkToken();
65 -
66 - if ($this->saveLanguage(true)) {
67 - acym_setVar('layout', 'share');
68 -
69 - $file = new \stdClass();
70 - $file->name = acym_getVar('cmd', 'code');
71 -
72 - return parent::display(['file' => $file]);
73 - } else {
74 - return $this->displayLanguage();
75 - }
76 - }
77 -
78 - public function send()
79 - {
80 - acym_checkToken();
81 -
82 - $bodyEmail = acym_getVar('string', 'mailbody');
83 - $code = acym_getVar('cmd', 'code');
84 - acym_setVar('code', $code);
85 -
86 - if (empty($code)) {
87 - return;
88 - }
89 -
90 - $mailer = new MailerHelper();
91 - $mailer->Subject = '[ACYMAILING LANGUAGE FILE] '.$code;
92 - $mailer->Body = 'The website '.ACYM_LIVE.' using AcyMailing '.$this->config->get('level').' '.$this->config->get('version').' sent a language file : '.$code;
93 - $mailer->Body .= "\n\n\n".$bodyEmail;
94 -
95 - $file = acym_getLanguagePath(ACYM_ROOT, $code).DS.$code.'.com_acym.ini';
96 - if (!file_exists($file)) {
97 - return;
98 - }
99 -
100 - $translation = acym_fileGetContent($file);
101 -
102 - $customFile = acym_getLanguagePath(ACYM_ROOT, $code).DS.$code.'.com_acym_custom.ini';
103 -
104 - if (file_exists($customFile)) {
105 - $customTranslation = acym_fileGetContent($customFile);
106 -
107 - if (!empty($customTranslation)) {
108 - $newKeys = [];
109 - $customKeys = [];
110 - preg_match_all('#([0-9A-Z_]+)="((?:[^"]|"_QQ_")+)"#is', $customTranslation, $customKeys);
111 -
112 - if (!empty($customKeys)) {
113 - $mainKeys = [];
114 - preg_match_all('#([0-9A-Z_]+)="((?:[^"]|"_QQ_")+)"#is', $translation, $mainKeys);
115 -
116 - foreach ($customKeys[1] as $index => $oneKey) {
117 - $position = array_search($oneKey, $mainKeys[1]);
118 - if ($position !== false) {
119 - $translation = str_replace($mainKeys[0][$position], $customKeys[0][$index], $translation);
120 - } else {
121 - $newKeys[] = $customKeys[0][$index];
122 - }
123 - }
124 -
125 - if (!empty($newKeys)) {
126 - $mailer->Body .= "\n\n\nCustom content:\n".implode("\n", $newKeys);
127 - }
128 - }
129 - }
130 - }
131 -
132 - $mailer->addStringAttachment($translation, $code.'.com_acym.ini');
133 -
134 - $mailer->AddAddress(acym_currentUserEmail(), acym_currentUserName());
135 - $mailer->AddAddress('[email protected]', 'Acyba Translation Team');
136 - $mailer->report = false;
137 -
138 - $result = $mailer->send();
139 -
140 - if ($result) {
141 - acym_enqueueMessage(acym_translation('ACYM_THANK_YOU_SHARING').'<br>'.acym_translation('ACYM_MESSAGE_SENT'), 'success');
142 - } else {
143 - acym_enqueueMessage($mailer->reportMessage, 'error');
144 - }
145 -
146 - $this->displayLanguage();
147 - }
148 -
149 - public function displayLanguage()
150 - {
151 - acym_setVar('layout', 'default');
152 -
153 - $code = acym_getVar('string', 'code');
154 - if (empty($code)) {
155 - acym_display(acym_translation('ACYM_LANGUAGE_CODE_NOT_FOUND'), 'error');
156 -
157 - return;
158 - }
159 -
160 - $file = new \stdClass();
161 - $file->name = $code;
162 - $path = acym_getLanguagePath(ACYM_ROOT, $code).DS.$code.'.com_acym.ini';
163 - $file->path = $path;
164 - $file->customcontent = '';
165 -
166 - if (file_exists($path)) {
167 - $file->content = acym_fileGetContent($path);
168 - if (empty($file->content)) {
169 - acym_display(acym_translationSprintf('ACYM_FILE_NOT_FOUND', $path), 'error');
170 - }
171 - } else {
172 - if (ACYM_CMS === 'joomla') {
173 - $message = acym_translation('ACYM_LOAD_ENGLISH_1');
174 - $message .= '<br />'.acym_translation('ACYM_LOAD_ENGLISH_2');
175 - $message .= '<br />'.acym_translation('ACYM_LOAD_ENGLISH_3');
176 - acym_enqueueMessage($message, 'info');
177 - }
178 - $file->content = acym_fileGetContent(acym_getLanguagePath(ACYM_ROOT, ACYM_DEFAULT_LANGUAGE).DS.ACYM_DEFAULT_LANGUAGE.'.com_acym.ini');
179 - }
180 -
181 - $customPath = acym_getLanguagePath(ACYM_ROOT, $code).DS.$code.'.com_acym_custom.ini';
182 - if (file_exists($customPath)) {
183 - $file->customcontent = acym_fileGetContent($customPath);
184 - }
185 -
186 - if (!file_exists(acym_getLanguagePath(ACYM_ROOT, $code))) {
187 - acym_enqueueMessage(acym_translationSprintf('ACYM_LANGUAGE_NOT_INSTALLED', $code), 'warning');
188 - }
189 -
190 - $data = [
191 - 'file' => $file,
192 - ];
193 -
194 - parent::display($data);
195 - }
196 -
197 - public function getLatestTranslationAjax()
198 - {
199 - $languagesContent = UpdatemeHelper::call('public/download/translations?version=latest&codes='.acym_getVar('cmd', 'code'));
200 -
201 - if (empty($languagesContent['translations'])) {
202 - acym_sendAjaxResponse(acym_translation('ACYM_ERROR_LOAD_LATEST_TRANSLATION'), [], false);
203 - }
204 -
205 - acym_sendAjaxResponse('', ['translations' => array_pop($languagesContent['translations'])]);
206 - }
207 -}