| @@ -17,9 +17,8 @@ | ||
| 17 | 17 | use Packetery\Module\Framework\WcAdapter; |
| 18 | 18 | use Packetery\Module\Framework\WpAdapter; |
| 19 | 19 | use Packetery\Module\Log\DbLogger; |
| 20 | 20 | use Packetery\Module\ModuleHelper; |
| 21 | -use Packetery\Module\WpdbAdapter; | |
| 22 | 21 | use Packetery\Nette\Http; |
| 23 | 22 | use Packetery\Tracy\Debugger; |
| 24 | 23 | |
| 25 | 24 | /** |
| @@ -75,13 +74,8 @@ | ||
| 75 | 74 | * @var CarrierUpdater |
| 76 | 75 | */ |
| 77 | 76 | private $carrierUpdater; |
| 78 | 77 | |
| 79 | - /** | |
| 80 | - * @var WpdbAdapter | |
| 81 | - */ | |
| 82 | - private $wpdbAdapter; | |
| 83 | - | |
| 84 | 78 | public function __construct( |
| 85 | 79 | Http\Request $httpRequest, |
| 86 | 80 | Engine $latteEngine, |
| 87 | 81 | CountryListingPage $countryListingPage, |
| @@ -89,10 +83,9 @@ | ||
| 89 | 83 | DbLogger $dbLogger, |
| 90 | 84 | ModuleHelper $moduleHelper, |
| 91 | 85 | WpAdapter $wpAdapter, |
| 92 | 86 | WcAdapter $wcAdapter, |
| 93 | - CarrierUpdater $carrierUpdater, | |
| 94 | - WpdbAdapter $wpdbAdapter | |
| 87 | + CarrierUpdater $carrierUpdater | |
| 95 | 88 | ) { |
| 96 | 89 | $this->httpRequest = $httpRequest; |
| 97 | 90 | $this->latteEngine = $latteEngine; |
| 98 | 91 | $this->countryListingPage = $countryListingPage; |
| @@ -101,9 +94,8 @@ | ||
| 101 | 94 | $this->moduleHelper = $moduleHelper; |
| 102 | 95 | $this->wpAdapter = $wpAdapter; |
| 103 | 96 | $this->wcAdapter = $wcAdapter; |
| 104 | 97 | $this->carrierUpdater = $carrierUpdater; |
| 105 | - $this->wpdbAdapter = $wpdbAdapter; | |
| 106 | 98 | } |
| 107 | 99 | |
| 108 | 100 | /** |
| 109 | 101 | * Prepares and outputs export text. |
| @@ -108,8 +100,10 @@ | ||
| 108 | 100 | /** |
| 109 | 101 | * Prepares and outputs export text. |
| 110 | 102 | */ |
| 111 | 103 | public function outputExportTxt(): void { |
| 104 | + global $wpdb; | |
| 105 | + | |
| 112 | 106 | if ( |
| 113 | 107 | $this->httpRequest->getQuery( 'page' ) !== Page::SLUG || |
| 114 | 108 | $this->httpRequest->getQuery( 'action' ) !== self::ACTION_EXPORT_SETTINGS |
| 115 | 109 | ) { |
| @@ -115,18 +109,8 @@ | ||
| 115 | 109 | ) { |
| 116 | 110 | return; |
| 117 | 111 | } |
| 118 | 112 | |
| 119 | - $txtContents = $this->getExportContent(); | |
| 120 | - header( 'Content-Type: text/plain' ); | |
| 121 | - header( 'Content-Transfer-Encoding: Binary' ); | |
| 122 | - header( 'Content-Length: ' . strlen( $txtContents ) ); | |
| 123 | - header( 'Content-Disposition: attachment; filename="packeta_options_export_' . gmdate( 'Y-m-d-H-i-s' ) . '.txt"' ); | |
| 124 | - ModuleHelper::renderString( $txtContents ); | |
| 125 | - exit; | |
| 126 | - } | |
| 127 | - | |
| 128 | - public function getExportContent(): string { | |
| 129 | 113 | $globalSettings = $this->optionsProvider->getAllOptions(); |
| 130 | 114 | if ( isset( $globalSettings[ OptionNames::PACKETERY ]['api_password'] ) ) { |
| 131 | 115 | $globalSettings[ OptionNames::PACKETERY ]['api_password'] = sprintf( |
| 132 | 116 | '%s...%s (%s)', |
| @@ -164,9 +148,9 @@ | ||
| 164 | 148 | 'wpVersion' => get_bloginfo( 'version' ), |
| 165 | 149 | 'wcVersion' => WC_VERSION, |
| 166 | 150 | 'template' => $activeTheme->name . ' ' . $activeTheme->version . $themeLatestVersionInfo, |
| 167 | 151 | 'phpVersion' => PHP_VERSION, |
| 168 | - 'dbServer' => $this->wpdbAdapter->dbServerInfo(), | |
| 152 | + 'dbServer' => $wpdb->db_server_info(), | |
| 169 | 153 | 'soap' => wc_bool_to_string( extension_loaded( 'soap' ) ), |
| 170 | 154 | 'wpDebug' => wc_bool_to_string( WP_DEBUG ), |
| 171 | 155 | 'packetaDebug' => wc_bool_to_string( Debugger::isEnabled() ), |
| 172 | 156 | 'globalSettings' => $this->formatVariable( $globalSettings ), |
| @@ -186,9 +170,17 @@ | ||
| 186 | 170 | 'currencySwitchers' => $this->formatVariable( CurrencySwitcherService::$supportedCurrencySwitchers ), |
| 187 | 171 | ]; |
| 188 | 172 | update_option( OptionNames::LAST_SETTINGS_EXPORT, gmdate( DATE_ATOM ) ); |
| 189 | 173 | |
| 190 | - return $this->latteEngine->renderToString( PACKETERY_PLUGIN_DIR . '/template/options/export.latte', $latteParams ); | |
| 174 | + $txtContents = $this->latteEngine->renderToString( PACKETERY_PLUGIN_DIR . '/template/options/export.latte', $latteParams ); | |
| 175 | + header( 'Content-Type: text/plain' ); | |
| 176 | + header( 'Content-Transfer-Encoding: Binary' ); | |
| 177 | + header( 'Content-Length: ' . strlen( $txtContents ) ); | |
| 178 | + header( 'Content-Disposition: attachment; filename="packeta_options_export_' . gmdate( 'Y-m-d-H-i-s' ) . '.txt"' ); | |
| 179 | + // @codingStandardsIgnoreStart | |
| 180 | + echo $txtContents; | |
| 181 | + // @codingStandardsIgnoreEnd | |
| 182 | + exit; | |
| 191 | 183 | } |
| 192 | 184 | |
| 193 | 185 | /** |
| 194 | 186 | * Format plugins. |