| @@ -1,177 +1,0 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -namespace AcyMailing\Core; | |
| 4 | - | |
| 5 | -use AcyMailing\Helpers\HeaderHelper; | |
| 6 | - | |
| 7 | -abstract class AcymView extends AcymObject | |
| 8 | -{ | |
| 9 | - public string $name = ''; | |
| 10 | - // Array of workflow steps: task => title | |
| 11 | - protected array $steps = []; | |
| 12 | - // Step to display | |
| 13 | - protected string $step = ''; | |
| 14 | - | |
| 15 | - public array $tabs = []; | |
| 16 | - | |
| 17 | - public function __construct() | |
| 18 | - { | |
| 19 | - parent::__construct(); | |
| 20 | - | |
| 21 | - $classname = get_class($this); | |
| 22 | - $classname = substr($classname, strrpos($classname, '\\') + 1); | |
| 23 | - $this->name = strtolower(substr($classname, 0, -4)); | |
| 24 | - $this->step = acym_getVar('string', 'nextstep', ''); | |
| 25 | - if (empty($this->step)) { | |
| 26 | - $this->step = acym_getVar('string', 'step', ''); | |
| 27 | - } | |
| 28 | - } | |
| 29 | - | |
| 30 | - public function getName(): string | |
| 31 | - { | |
| 32 | - return $this->name; | |
| 33 | - } | |
| 34 | - | |
| 35 | - public function getLayout(): string | |
| 36 | - { | |
| 37 | - return acym_getVar('cmd', 'layout', acym_getVar('cmd', 'task', 'listing')); | |
| 38 | - } | |
| 39 | - | |
| 40 | - public function display(object $controller, array $data = []): void | |
| 41 | - { | |
| 42 | - $name = $this->getName(); | |
| 43 | - $view = $this->getLayout(); | |
| 44 | - | |
| 45 | - if (method_exists($this, $view)) $this->$view(); | |
| 46 | - | |
| 47 | - $viewFolder = acym_isAdmin() ? ACYM_VIEW : ACYM_VIEW_FRONT; | |
| 48 | - if (!file_exists($viewFolder.ucfirst($name).DS.'tmpl'.DS.$view.'.php')) { | |
| 49 | - $view = 'listing'; | |
| 50 | - } | |
| 51 | - $getCleanView = ($name !== 'archive' && $view !== 'listing') && ($name !== 'frontusers' || $view !== 'profile'); | |
| 52 | - if (ACYM_CMS === 'wordpress' && $getCleanView) { | |
| 53 | - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- WordPress generated content temporary held to allow redirections (headers sent). | |
| 54 | - echo ob_get_clean(); | |
| 55 | - } | |
| 56 | - | |
| 57 | - // Load the needed scripts and styles | |
| 58 | - if ( | |
| 59 | - ACYM_CMS !== 'wordpress' | |
| 60 | - || ($name === 'frontusers' && ($view === 'unsubscribe' || $view === 'unsubscribepage')) | |
| 61 | - || !defined('DOING_AJAX') | |
| 62 | - || !DOING_AJAX | |
| 63 | - || ($name === 'archive' && $view === 'view') | |
| 64 | - ) { | |
| 65 | - acym_loadAssets($name, $view); | |
| 66 | - $controller->loadScripts($view); | |
| 67 | - } | |
| 68 | - | |
| 69 | - // Display enqueued messages | |
| 70 | - $notifications = acym_getVar('array', 'acynotif', [], 'SESSION'); | |
| 71 | - if (!empty($notifications)) { | |
| 72 | - echo implode('', $notifications); | |
| 73 | - acym_setSession('acynotif', []); | |
| 74 | - } | |
| 75 | - | |
| 76 | - // On pages with the editor, we need to put the wrapper inside the form | |
| 77 | - $outsideForm = (strpos($name, 'mails') !== false && $view === 'edit') || (strpos($name, 'campaigns') !== false && $view === 'edit_email'); | |
| 78 | - if ($outsideForm) { | |
| 79 | - echo '<form id="acym_form" action="'.esc_url( | |
| 80 | - acym_completeLink( | |
| 81 | - acym_getVar('cmd', 'ctrl') | |
| 82 | - ) | |
| 83 | - ).'" class="acym__form__mail__edit" method="post" name="acyForm" data-abide novalidate enctype="multipart/form-data">'; | |
| 84 | - } | |
| 85 | - | |
| 86 | - // Open wrapper and display the header | |
| 87 | - if (acym_getVar('cmd', 'task') !== 'ajaxEncoding') { | |
| 88 | - echo '<div id="acym_wrapper" class="'.esc_attr($name).'_'.esc_attr($view).' cms_'.esc_attr(ACYM_CMS).' cms_v_'.esc_attr(substr(ACYM_CMSV, 0, 1)).'">'; | |
| 89 | - } | |
| 90 | - | |
| 91 | - //if joomla we add the left menu and a div for the content | |
| 92 | - if (acym_isLeftMenuNecessary()) { | |
| 93 | - acym_displayLeftMenu($name); | |
| 94 | - echo '<div id="acym_content">'; | |
| 95 | - } | |
| 96 | - | |
| 97 | - if (!empty($data['breadcrumb'])) { | |
| 98 | - $headerHelper = new HeaderHelper(); | |
| 99 | - $headerHelper->display($data['breadcrumb']); | |
| 100 | - } | |
| 101 | - | |
| 102 | - $remindme = json_decode($this->config->get('remindme', '[]'), true); | |
| 103 | - if ($this->config->get('walk_through', 0) == 0) { | |
| 104 | - if (acym_isAdmin()) { | |
| 105 | - if (!in_array('multilingual', $remindme) && acym_level(ACYM_ESSENTIAL) && $this->config->get('multilingual', '0') === '0') { | |
| 106 | - if (count(acym_getLanguages(false, true)) > 1) { | |
| 107 | - $message = acym_translation('ACYM_MULTILINGUAL_OPTIONS_PROMPT'); | |
| 108 | - $message .= ' <a id="acym__multilingual__reminder" href="'.acym_completeLink('configuration&task=multilingual').'&'.acym_getFormToken().'">'.acym_translation('ACYM_YES').'</a>'; | |
| 109 | - $message .= ' / <a href="#" title="multilingual" class="acym__do__not__remindme__multilingual">'.acym_translation('ACYM_NO').'</a>'; | |
| 110 | - acym_display($message, 'info', false); | |
| 111 | - } else { | |
| 112 | - $remindme[] = 'multilingual'; | |
| 113 | - $this->config->saveConfig(['remindme' => json_encode($remindme)]); | |
| 114 | - } | |
| 115 | - } | |
| 116 | - | |
| 117 | - $maliciousScan = $this->config->get('malicious_scan', 0); | |
| 118 | - if (!empty($maliciousScan)) { | |
| 119 | - $this->config->saveConfig(['malicious_scan' => 0]); | |
| 120 | - acym_display(acym_translation('ACYM_NEW_SECURITY_TOOL'), 'info'); | |
| 121 | - } | |
| 122 | - } | |
| 123 | - } | |
| 124 | - | |
| 125 | - acym_trigger('acym_displayTrackingMessage', [&$message], 'plgAcymWoocommerce'); | |
| 126 | - | |
| 127 | - if (acym_isAdmin()) { | |
| 128 | - acym_trigger('onAcymDisplayPage'); | |
| 129 | - acym_displayMessages(); | |
| 130 | - } | |
| 131 | - | |
| 132 | - include acym_getView($name, $view); | |
| 133 | - | |
| 134 | - // Close the wrapper and the content if CMS = Joomla | |
| 135 | - if (acym_isLeftMenuNecessary()) { | |
| 136 | - echo '</div>'; | |
| 137 | - } | |
| 138 | - | |
| 139 | - if (acym_getVar('cmd', 'task') !== 'ajaxEncoding') { | |
| 140 | - echo '</div>'; | |
| 141 | - } | |
| 142 | - | |
| 143 | - if ($outsideForm) { | |
| 144 | - echo '</form>'; | |
| 145 | - } | |
| 146 | - | |
| 147 | - if (ACYM_CMS !== 'wordpress' || !acym_isAdmin() || in_array($controller->name, ['dashboard', 'language', 'campaigns']) || acym_isAjax()) { | |
| 148 | - return; | |
| 149 | - } | |
| 150 | - | |
| 151 | - $remind = json_decode($this->config->get('remindme', '[]')); | |
| 152 | - $installationDate = $this->config->get('install_date', time()); | |
| 153 | - $sevenDaysAgo = time() - 7 * 86400; | |
| 154 | - | |
| 155 | - if (!in_array('reviews', $remind) && $installationDate < $sevenDaysAgo) { | |
| 156 | - echo '<div id="acym__reviews__footer" style="margin: 0 0 30px 30px;">'; | |
| 157 | - echo wp_kses( | |
| 158 | - acym_translationSprintf( | |
| 159 | - 'ACYM_REVIEW_FOOTER', | |
| 160 | - '<a title="reviews" id="acym__reviews__footer__link" target="_blank" href="https://wordpress.org/support/plugin/acymailing/reviews/?rate=5#new-post"> | |
| 161 | - '.str_repeat('<i class="acymicon-star"></i>', 5).'</a>' | |
| 162 | - ), | |
| 163 | - [ | |
| 164 | - 'a' => [ | |
| 165 | - 'title' => true, | |
| 166 | - 'id' => true, | |
| 167 | - 'href' => true, | |
| 168 | - ], | |
| 169 | - 'i' => [ | |
| 170 | - 'class' => true, | |
| 171 | - ], | |
| 172 | - ] | |
| 173 | - ); | |
| 174 | - echo '</div>'; | |
| 175 | - } | |
| 176 | - } | |
| 177 | -} | |