/** * Export the database * * @param string $packageKey Package key where the .sql file will be exported (into [PACKAGE_KEY]/Resources/Private/Content/ directory) * @param string $sqlFile Relative path to .sql file * @param string $mode Choose 'content' (default) for content only tables or 'all' for whole database dump. */ public function exportCommand($packageKey = NULL, $sqlFile = NULL, $mode = self::DUMP_MODE_CONTENT_ONLY) { $dbName = $this->backendOptions['dbname']; $tablesToExport = $this->getTablesToExport($mode); if ($packageKey) { $sqlFile = $this->getContentDirectoryForPackageKey($packageKey, TRUE) . $this->getFilenameForDump($mode); $sqlFile = str_replace(FLOW_PATH_ROOT, '', $sqlFile); } elseif ($sqlFile) { } else { $this->outputLine('You have to specify either "--package-key" or "--sql-file"'); $this->quit(1); } $cmd = 'mysqldump -v' . $this->getSqlConnectionParams() . " {$dbName} {$tablesToExport} > {$sqlFile}"; $result = $this->exec($cmd); $size = filesize($sqlFile); // Note: make it compatible with Flow 2.2 where Files::bytesToSizeString() is not available $sizeFormatted = method_exists('TYPO3\\Flow\\Utility\\Files', 'bytesToSizeString') ? Files::bytesToSizeString($size) : round($size / 1024) . ' kB'; $this->outputLine(); $this->outputLine("Database '{$dbName}' has been exported to '{$sqlFile}' file."); $this->outputLine("Exported {$sqlFile} file size: " . $sizeFormatted); $this->outputLine(); $this->outputLine("Exported tables: " . ($tablesToExport ? $tablesToExport : '[all]') . '.'); $this->outputLine(); $this->sendAndExit($result); }
/** * Applies htmlspecialchars() on the specified value. * * @param array $arguments * @param \Closure $renderChildrenClosure * @param \TYPO3\Fluid\Core\Rendering\RenderingContextInterface $renderingContext * @return string */ public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) { $value = $arguments['value']; if ($value === null) { $value = $renderChildrenClosure(); } if (!is_integer($value) && !is_float($value)) { if (is_numeric($value)) { $value = (double) $value; } else { $value = 0; } } return Files::bytesToSizeString($value, $arguments['decimals'], $arguments['decimalSeparator'], $arguments['thousandsSeparator']); }
/** * @param $bytes * @param $decimals * @param $decimalSeparator * @param $thousandsSeparator * @param $expected * @test * @dataProvider bytesToSizeStringDataProvider */ public function bytesToSizeStringTests($bytes, $decimals, $decimalSeparator, $thousandsSeparator, $expected) { $actualResult = Files::bytesToSizeString($bytes, $decimals, $decimalSeparator, $thousandsSeparator); $this->assertSame($expected, $actualResult); }
/** * @param Asset $asset * @return void */ public function replaceAssetResourceAction(Asset $asset) { $maximumFileUploadSize = $this->maximumFileUploadSize(); $this->view->assignMultiple(array('asset' => $asset, 'maximumFileUploadSize' => $maximumFileUploadSize, 'redirectPackageEnabled' => $this->packageManager->isPackageAvailable('Neos.RedirectHandler'), 'humanReadableMaximumFileUploadSize' => Files::bytesToSizeString($maximumFileUploadSize))); }
/** * Returns the lowest configured maximum upload file size * * @return string */ protected function renderMaximumFileUploadSize() { $maximumFileUploadSizeInBytes = min(Files::sizeStringToBytes(ini_get('post_max_size')), Files::sizeStringToBytes(ini_get('upload_max_filesize'))); return sprintf('"%d"; // %s, as configured in php.ini', $maximumFileUploadSizeInBytes, Files::bytesToSizeString($maximumFileUploadSizeInBytes)); }
/** * New asset form * * @return void */ public function newAction() { $maximumFileUploadSize = $this->maximumFileUploadSize(); $this->view->assignMultiple(array('tags' => $this->tagRepository->findAll(), 'assetCollections' => $this->assetCollectionRepository->findAll(), 'maximumFileUploadSize' => $maximumFileUploadSize, 'humanReadableMaximumFileUploadSize' => Files::bytesToSizeString($maximumFileUploadSize))); }