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/Helpers/Update/Cms.php +0 -142 11.1.0 → 11.1.1 View file →
@@ -1,142 +1,0 @@
1 -<?php
2 -
3 -namespace AcyMailing\Helpers\Update;
4 -
5 -use AcyMailing\Helpers\UpdatemeHelper;
6 -
7 -trait Cms
8 -{
9 - public function installTables(): void
10 - {
11 - $queries = file_get_contents(ACYM_BACK.'tables.sql');
12 - $tables = explode('CREATE TABLE IF NOT EXISTS', $queries);
13 -
14 - foreach ($tables as $oneTable) {
15 - $oneTable = trim($oneTable);
16 - if (empty($oneTable)) {
17 - continue;
18 - }
19 - acym_query('CREATE TABLE IF NOT EXISTS'.$oneTable);
20 - }
21 - }
22 -
23 - public function installLanguages(): void
24 - {
25 - $siteLanguages = acym_getLanguages();
26 - if (!empty($siteLanguages[ACYM_DEFAULT_LANGUAGE])) {
27 - unset($siteLanguages[ACYM_DEFAULT_LANGUAGE]);
28 - }
29 -
30 - $installedLanguages = array_keys($siteLanguages);
31 - if (empty($installedLanguages) || !class_exists(UpdatemeHelper::class)) {
32 - return;
33 - }
34 -
35 - ob_start();
36 - $languagesContent = UpdatemeHelper::call('public/download/translations?version=latest&codes='.implode(',', $installedLanguages));
37 - $warnings = ob_get_clean();
38 - if (!empty($warnings) && acym_isDebug()) {
39 - acym_enqueueMessage($warnings, 'warning');
40 - }
41 -
42 - if (empty($languagesContent) || $languagesContent['status'] === 'error') {
43 - acym_enqueueMessage(acym_translation('ACYM_ERROR_LOAD_LANGUAGES'), 'error');
44 -
45 - return;
46 - }
47 -
48 - $decodedLanguages = $languagesContent['translations'];
49 -
50 - $success = [];
51 - $error = [];
52 - $errorLoad = [];
53 -
54 - foreach ($decodedLanguages as $code => $content) {
55 - if (empty($content)) {
56 - $errorLoad[] = $code;
57 - continue;
58 - }
59 -
60 - $path = acym_getLanguagePath(ACYM_ROOT, $code).DS.$code.'.'.ACYM_LANGUAGE_FILE.'.ini';
61 - if (acym_writeFile($path, $content)) {
62 - $this->installBackLanguages($code);
63 - $success[] = $code;
64 - } else {
65 - $error[] = acym_translationSprintf('ACYM_FAIL_SAVE_FILE', $path);
66 - }
67 - }
68 -
69 - if (!empty($success)) acym_enqueueMessage(acym_translationSprintf('ACYM_TRANSLATION_INSTALLED', implode(', ', $success)));
70 - if (!empty($error)) acym_enqueueMessage($error, 'error');
71 - if (!empty($errorLoad)) acym_enqueueMessage(acym_translationSprintf('ACYM_ERROR_LOAD_LANGUAGE', implode(', ', $errorLoad)), 'warning');
72 - }
73 -
74 - // translates the Acy menus on back-end and Joomla menus
75 - public function installBackLanguages(string $onlyCode = ''): void
76 - {
77 - if (ACYM_CMS !== 'joomla') {
78 - return;
79 - }
80 -
81 - $menuStrings = [
82 - 'ACYM_DASHBOARD',
83 - 'ACYM_SUBSCRIBERS',
84 - 'ACYM_CUSTOM_FIELDS',
85 - 'ACYM_LISTS',
86 - 'ACYM_SEGMENTS',
87 - 'ACYM_EMAILS',
88 - 'ACYM_TEMPLATES',
89 - 'ACYM_AUTOMATION',
90 - 'ACYM_QUEUE',
91 - 'ACYM_STATISTICS',
92 - 'ACYM_BOUNCE_HANDLING',
93 - 'ACYM_ADD_ONS',
94 - 'ACYM_CONFIGURATION',
95 - 'ACYM_MENU_PROFILE',
96 - 'ACYM_MENU_PROFILE_DESC',
97 - 'ACYM_MENU_ARCHIVE',
98 - 'ACYM_MENU_ARCHIVE_DESC',
99 - 'ACYM_MENU_LISTS',
100 - 'ACYM_MENU_LISTS_DESC',
101 - 'ACYM_MENU_SUBSCRIBERS',
102 - 'ACYM_MENU_SUBSCRIBERS_DESC',
103 - 'ACYM_MENU_CAMPAIGNS',
104 - 'ACYM_MENU_CAMPAIGNS_DESC',
105 - 'ACYM_SUBSCRIPTION_FORMS',
106 - 'ACYM_EMAILS_OVERRIDE',
107 - 'ACYM_MAILBOX_ACTIONS',
108 - 'ACYM_GOPRO',
109 - 'ACYM_SCENARIO',
110 - ];
111 -
112 - $siteLanguages = empty($onlyCode) ? array_keys(acym_getLanguages()) : [$onlyCode];
113 -
114 - foreach ($siteLanguages as $code) {
115 - $path = acym_getLanguagePath(ACYM_ROOT, $code).DS.$code.'.com_acym.ini';
116 - if (!file_exists($path)) continue;
117 -
118 - $content = file_get_contents($path);
119 - if (empty($content)) continue;
120 -
121 - // The first key is to translate "Acym" into "AcyMailing blabla" in the Joomla Extension manager
122 - // The second key is to translate "com_acym" into "AcyMailing" in the Joomla global configuration page
123 - // DON'T CHANGE THE KEY !!
124 - $menuFileContent = 'ACYM="AcyMailing"'."\r\n";
125 - $menuFileContent .= 'COM_ACYM="AcyMailing"'."\r\n";
126 - $menuFileContent .= 'COM_ACYM_CONFIGURATION="AcyMailing"'."\r\n";
127 -
128 - foreach ($menuStrings as $oneString) {
129 - preg_match('#[^_]'.$oneString.'="(.*)"#i', $content, $matches);
130 - if (empty($matches[1])) continue;
131 -
132 - $menuFileContent .= $oneString.'="'.$matches[1].'"'."\r\n";
133 - }
134 -
135 - $menuPath = ACYM_ROOT.'administrator'.DS.'language'.DS.$code.DS.$code.'.com_acym.sys.ini';
136 -
137 - if (!acym_writeFile($menuPath, $menuFileContent)) {
138 - acym_enqueueMessage(acym_translationSprintf('ACYM_FAIL_SAVE_FILE', $menuPath), 'error');
139 - }
140 - }
141 - }
142 -}