本文整理汇总了PHP中TYPO3\CMS\Core\Utility\GeneralUtility::mkdir_deep方法的典型用法代码示例。如果您正苦于以下问题:PHP GeneralUtility::mkdir_deep方法的具体用法?PHP GeneralUtility::mkdir_deep怎么用?PHP GeneralUtility::mkdir_deep使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Utility\GeneralUtility
的用法示例。
在下文中一共展示了GeneralUtility::mkdir_deep方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set
/**
* Saves data in the cache.
*
* @param string $entryIdentifier An identifier for this specific cache entry
* @param string $data The data to be stored
* @param array $tags Tags to associate with this cache entry. If the backend does not support tags, this option can be ignored.
* @param integer $lifetime Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.
*
* @return void
* @throws \TYPO3\CMS\Core\Cache\Exception if no cache frontend has been set.
* @throws \TYPO3\CMS\Core\Cache\Exception\InvalidDataException if the data is not a string
*/
public function set($entryIdentifier, $data, array $tags = [], $lifetime = null)
{
$databaseData = ['created' => $GLOBALS['EXEC_TIME'], 'expires' => $GLOBALS['EXEC_TIME'] + $this->getRealLifetime($lifetime)];
if (in_array('explanation', $tags)) {
$databaseData['explanation'] = $data;
parent::set($entryIdentifier, serialize($databaseData), $tags, $lifetime);
return;
}
// call set in front of the generation, because the set method
// of the DB backend also call remove
parent::set($entryIdentifier, serialize($databaseData), $tags, $lifetime);
$fileName = $this->getCacheFilename($entryIdentifier);
$cacheDir = PathUtility::pathinfo($fileName, PATHINFO_DIRNAME);
if (!is_dir($cacheDir)) {
GeneralUtility::mkdir_deep($cacheDir);
}
// normal
GeneralUtility::writeFile($fileName, $data);
// gz
if ($this->configuration->get('enableStaticFileCompression')) {
$contentGzip = gzencode($data, $this->getCompressionLevel());
if ($contentGzip) {
GeneralUtility::writeFile($fileName . '.gz', $contentGzip);
}
}
// htaccess
$this->writeHtAccessFile($fileName, $lifetime);
}
示例2: getVirtualTestDir
/**
* Create a random directory in the virtual file system and return the path.
*
* @param string $prefix
* @return string
*/
protected function getVirtualTestDir($prefix = 'root_')
{
$root = vfsStream::setup();
$path = $root->url() . '/typo3temp/' . $this->getUniqueId($prefix);
\TYPO3\CMS\Core\Utility\GeneralUtility::mkdir_deep($path);
return $path;
}
示例3: __construct
/**
* Constructor
*/
public function __construct()
{
// we check for existence of our targetDirectory
if (!is_dir(PATH_site . $this->targetDirectory)) {
GeneralUtility::mkdir_deep(PATH_site . $this->targetDirectory);
}
// if enabled, we check whether we should auto-create the .htaccess file
if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['generateApacheHtaccess']) {
// check whether .htaccess exists
$htaccessPath = PATH_site . $this->targetDirectory . '.htaccess';
if (!file_exists($htaccessPath)) {
GeneralUtility::writeFile($htaccessPath, $this->htaccessTemplate);
}
}
// decide whether we should create gzipped versions or not
$compressionLevel = $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['compressionLevel'];
// we need zlib for gzencode()
if (extension_loaded('zlib') && $compressionLevel) {
$this->createGzipped = true;
// $compressionLevel can also be TRUE
if (MathUtility::canBeInterpretedAsInteger($compressionLevel)) {
$this->gzipCompressionLevel = (int) $compressionLevel;
}
}
$this->setInitialPaths();
}
示例4: getCroppedImageSrcByFile
/**
* Get the cropped image by File Object
*
* @param FileInterface $file
* @param string $ratio
*
* @return string The new filename
*/
public function getCroppedImageSrcByFile(FileInterface $file, $ratio)
{
$absoluteImageName = GeneralUtility::getFileAbsFileName($file->getPublicUrl());
$focusPointX = MathUtility::forceIntegerInRange((int) $file->getProperty('focus_point_x'), -100, 100, 0);
$focusPointY = MathUtility::forceIntegerInRange((int) $file->getProperty('focus_point_y'), -100, 100, 0);
$tempImageFolder = 'typo3temp/focuscrop/';
$tempImageName = $tempImageFolder . $file->getSha1() . '-' . str_replace(':', '-', $ratio) . '-' . $focusPointX . '-' . $focusPointY . '.' . $file->getExtension();
$absoluteTempImageName = GeneralUtility::getFileAbsFileName($tempImageName);
if (is_file($absoluteTempImageName)) {
return $tempImageName;
}
$absoluteTempImageFolder = GeneralUtility::getFileAbsFileName($tempImageFolder);
if (!is_dir($absoluteTempImageFolder)) {
GeneralUtility::mkdir_deep($absoluteTempImageFolder);
}
$this->graphicalFunctions = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Imaging\\GraphicalFunctions');
$imageSizeInformation = getimagesize($absoluteImageName);
$width = $imageSizeInformation[0];
$height = $imageSizeInformation[1];
// dimensions
/** @var \HDNET\Focuspoint\Service\DimensionService $service */
$dimensionService = GeneralUtility::makeInstance('HDNET\\Focuspoint\\Service\\DimensionService');
list($focusWidth, $focusHeight) = $dimensionService->getFocusWidthAndHeight($width, $height, $ratio);
$cropMode = $dimensionService->getCropMode($width, $height, $ratio);
list($sourceX, $sourceY) = $dimensionService->calculateSourcePosition($cropMode, $width, $height, $focusWidth, $focusHeight, $focusPointX, $focusPointY);
// generate image
$sourceImage = $this->graphicalFunctions->imageCreateFromFile($absoluteImageName);
$destinationImage = imagecreatetruecolor($focusWidth, $focusHeight);
$this->graphicalFunctions->imagecopyresized($destinationImage, $sourceImage, 0, 0, $sourceX, $sourceY, $focusWidth, $focusHeight, $focusWidth, $focusHeight);
$this->graphicalFunctions->ImageWrite($destinationImage, $absoluteTempImageName, $GLOBALS['TYPO3_CONF_VARS']['GFX']['jpg_quality']);
return $tempImageName;
}
示例5: createFont
/**
* create Font via Python with FontForge
*
* @param int $fontUid
* @param object $currentFont
* @return array
*/
public static function createFont($fontUid, $currentFont)
{
// general vars
$extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['fontawesomeplus']);
$pathToPythonBin = escapeshellarg($extConf['pathToPython']);
$pathToScript = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('fontawesomeplus') . 'Resources/Private/Python/fontawesomeplus.py';
$iconRepository = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\FileRepository::class);
$iconReferences = $iconRepository->findByRelation('tx_fontawesomeplus_domain_model_font', 'icons', $fontUid);
$svgArray = array();
foreach ($iconReferences as $key => $value) {
$svgArray[$key] = PATH_site . 'fileadmin' . $value->getIdentifier();
}
$unicodeArray = array();
$i = hexdec(self::HEXADECIMAL);
foreach ($svgArray as $key => $value) {
$unicodeArray[$key] = $i . ',uni' . dechex($i);
$i++;
}
$fontPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('fontawesomeplus') . 'Resources/Public/Contrib/' . self::FACONTRIB . '/fonts/fontawesome-webfont.svg';
$fontForgeArray = CommandUtility::escapeShellArgument(json_encode(array_combine($svgArray, $unicodeArray), JSON_UNESCAPED_SLASHES));
$fontName = strtolower(preg_replace(array('/\\s+/', '/[^a-zA-Z0-9]/'), array('-', ''), $currentFont->getTitle()));
$comment = CommandUtility::escapeShellArgument(str_replace(array("\r\n", "\n", "\r"), ' ', $currentFont->getDescription()));
$copyright = CommandUtility::escapeShellArgument('netweiser');
$version = CommandUtility::escapeShellArgument($currentFont->getVersion());
GeneralUtility::mkdir_deep(PATH_site . 'fileadmin/' . $currentFont->getDestination(), $fontName . '/fonts/');
$savedir = PATH_site . 'fileadmin/' . $currentFont->getDestination() . $fontName . '/fonts/';
CommandUtility::exec("{$pathToPythonBin} {$pathToScript} {$fontPath} {$fontForgeArray} {$fontName} {$comment} {$copyright} {$version} {$savedir} 2>&1", $feedback, $returnCode);
if ((int) $returnCode !== 0) {
return $feedback;
}
}
示例6: getCheckedCacheFolder
/**
* Return the cache folder and check if the folder exists
*
* @return string
*/
protected function getCheckedCacheFolder()
{
$cacheFolder = GeneralUtility::getFileAbsFileName('typo3temp/calendarize/');
if (!is_dir($cacheFolder)) {
GeneralUtility::mkdir_deep($cacheFolder);
}
return $cacheFolder;
}
示例7: writeFileAndCreateFolder
/**
* Write a file and create the target folder, if the folder do not exists
*
* @param string $absoluteFileName
* @param string $content
*
* @return bool
* @throws Exception
*/
public static function writeFileAndCreateFolder($absoluteFileName, $content)
{
$dir = PathUtility::dirname($absoluteFileName) . '/';
if (!is_dir($dir)) {
GeneralUtility::mkdir_deep($dir);
}
if (is_file($absoluteFileName) && !is_writable($absoluteFileName)) {
throw new Exception('The autoloader try to add same content to ' . $absoluteFileName . ' but the file is not writable for the autoloader. Please fix it!', 234627835);
}
return GeneralUtility::writeFile($absoluteFileName, $content);
}
示例8: backupFolder
/**
* @param string $folder
*
* @return bool
*/
protected function backupFolder($folder)
{
GeneralUtility::mkdir_deep($this->backupPath);
$compressedFileName = $folder . '_' . time() . '.tar';
$phar = new \PharData($this->backupPath . $compressedFileName);
if ($phar->buildFromDirectory(PATH_site . $folder, '/^(?!_temp_|_processed_|_recycler_).*/')) {
BackupUtility::generateBackupLog($folder, $compressedFileName . '.gz', $this->backupPath, $this->backupsToKeep);
BackupUtility::gzCompressFile($this->backupPath . $compressedFileName);
return true;
}
return false;
}
示例9: createFolder
/**
* @param string $folderPath
* @return boolean
* @throws \Exception
*/
public function createFolder($folderPath)
{
if (TRUE === $this->dry) {
return TRUE;
}
try {
GeneralUtility::mkdir_deep($folderPath);
} catch (\InvalidArgumentException $exception) {
throw new \Exception('Unable to create directory "' . $folderPath . '"', 1371692697);
}
return TRUE;
}
示例10: createMockPackageManagerWithMockPackage
/**
* @param string $packageKey
* @param array $packageMethods
* @return object
*/
protected function createMockPackageManagerWithMockPackage($packageKey, $packageMethods = array('getPackagePath', 'getPackageKey'))
{
$packagePath = PATH_site . 'typo3temp/test_ext/' . $packageKey . '/';
\TYPO3\CMS\Core\Utility\GeneralUtility::mkdir_deep($packagePath);
$package = $this->getMockBuilder('TYPO3\\CMS\\Core\\Package\\Package')->disableOriginalConstructor()->setMethods($packageMethods)->getMock();
$packageManager = $this->getMock('TYPO3\\CMS\\Core\\Package\\PackageManager', array('isPackageActive', 'getPackage', 'getActivePackages'));
$package->expects($this->any())->method('getPackagePath')->will($this->returnValue($packagePath));
$package->expects($this->any())->method('getPackageKey')->will($this->returnValue($packageKey));
$packageManager->expects($this->any())->method('isPackageActive')->will($this->returnValueMap(array(array(NULL, FALSE), array($packageKey, TRUE))));
$packageManager->expects($this->any())->method('getPackage')->with($this->equalTo($packageKey))->will($this->returnValue($package));
$packageManager->expects($this->any())->method('getActivePackages')->will($this->returnValue(array($packageKey => $package)));
return $packageManager;
}
示例11: execute
/**
*
* @return boolean
*/
public function execute()
{
$extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['jh_browscap']);
if (isset($extConf['cachePath']) && preg_match('/^typo3temp\\//', $extConf['cachePath'])) {
$this->cachePath = rtrim($extConf['cachePath'], '/');
}
if (!is_dir(PATH_site . $this->cachePath)) {
GeneralUtility::mkdir_deep(PATH_site, $this->cachePath);
}
/** @var Browscap $browscap */
$browscap = new Browscap(PATH_site . $this->cachePath);
return $browscap->updateCache();
}
示例12: execute
/**
* @return FlashMessage
*/
public function execute()
{
$this->controller->headerMessage(LocalizationUtility::translate('moveDamRecordsToStorageCommand', 'dam_falmigration', array($this->storageObject->getName())));
if (!$this->isTableAvailable('tx_dam')) {
return $this->getResultMessage('damTableNotFound');
}
$this->fileIndexRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\Index\\FileIndexRepository');
$result = $this->execSelectNotMigratedDamRecordsQuery();
$counter = 0;
$total = $this->database->sql_num_rows($result);
$this->controller->infoMessage('Found ' . $total . ' DAM records without a connection to a sys_file storage');
$relativeTargetFolderBasePath = $this->storageBasePath . $this->targetFolderBasePath;
while ($damRecord = $this->database->sql_fetch_assoc($result)) {
$counter++;
try {
$relativeSourceFilePath = GeneralUtility::fixWindowsFilePath($this->getFullFileName($damRecord));
$absoluteSourceFilePath = PATH_site . $relativeSourceFilePath;
if (!file_exists($absoluteSourceFilePath)) {
throw new \RuntimeException('No file found for DAM record. DAM uid: ' . $damRecord['uid'] . ': "' . $relativeSourceFilePath . '"', 1441110613);
}
list($_, $directory) = explode('/', dirname($relativeSourceFilePath), 2);
$relativeTargetFolder = $relativeTargetFolderBasePath . rtrim($directory, '/') . '/';
$absoluteTargetFolder = PATH_site . $relativeTargetFolder;
if (!is_dir($absoluteTargetFolder)) {
GeneralUtility::mkdir_deep($absoluteTargetFolder);
}
$basename = basename($relativeSourceFilePath);
$absoluteTargetFilePath = $absoluteTargetFolder . $basename;
if (!file_exists($absoluteTargetFilePath)) {
GeneralUtility::upload_copy_move($absoluteSourceFilePath, $absoluteTargetFilePath);
} elseif (filesize($absoluteSourceFilePath) !== filesize($absoluteTargetFilePath)) {
throw new \RuntimeException('File already exists. DAM uid: ' . $damRecord['uid'] . ': "' . $relativeSourceFilePath . '"', 1441112138);
}
$fileIdentifier = substr($relativeTargetFolder, strlen($this->storageBasePath)) . $basename;
$fileObject = $this->storageObject->getFile($fileIdentifier);
$this->fileIndexRepository->add($fileObject);
$this->updateDamFilePath($damRecord['uid'], $relativeTargetFolder);
$this->amountOfMigratedRecords++;
} catch (\Exception $e) {
$this->setDamFileMissingByUid($damRecord['uid']);
$this->controller->warningMessage($e->getMessage());
$this->amountOfFilesNotFound++;
continue;
}
}
$this->database->sql_free_result($result);
$this->controller->message('Not migrated dam records at start of task: ' . $total . '. Migrated files after task: ' . $this->amountOfMigratedRecords . '. Files not found: ' . $this->amountOfFilesNotFound . '.');
return $this->getResultMessage();
}
示例13: getBrowser
/**
* getBrowser
*
* @param string $user_agent the user agent string
* @param bool $return_array whether return an array or an object
*
* @return \stdClass|array the object containing the browsers details. Array if
* $return_array is set to true.
*/
public static function getBrowser($user_agent = null, $return_array = false)
{
$cachePath = self::CACHE_PATH;
$extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['jh_browscap']);
if (preg_match('/^typo3temp\\//', $extConf['cachePath'])) {
$cachePath = rtrim($extConf['cachePath'], '/');
}
if (!is_dir(PATH_site . $cachePath)) {
GeneralUtility::mkdir_deep(PATH_site, $cachePath);
}
/** @var Browscap $browscap */
$browscap = new Browscap($cachePath);
$browscap->doAutoUpdate = false;
return $browscap->getBrowser($user_agent, $return_array);
}
示例14: backupTable
/**
* TODO: replace the $link stuff by usage of $GLOBALS['TYPO3_DB']
*
* @param string $outputFolder
* @return string
*/
public static function backupTable($outputFolder)
{
GeneralUtility::mkdir_deep($outputFolder);
$host = $GLOBALS['TYPO3_CONF_VARS']['DB']['host'];
$user = $GLOBALS['TYPO3_CONF_VARS']['DB']['username'];
$pass = $GLOBALS['TYPO3_CONF_VARS']['DB']['password'];
$name = $GLOBALS['TYPO3_CONF_VARS']['DB']['database'];
$link = mysqli_connect($host, $user, $pass);
mysqli_select_db($link, $name);
$listDbTables = array_column(mysqli_fetch_all($link->query('SHOW TABLES')), 0);
$listDbTables = self::removeCacheAndLogTables($listDbTables);
$return = '';
foreach ($listDbTables as $table) {
$result = mysqli_query($link, 'SELECT * FROM ' . $table);
$numFields = mysqli_num_fields($result);
$return .= 'DROP TABLE ' . $table . ';';
$row2 = mysqli_fetch_row(mysqli_query($link, 'SHOW CREATE TABLE ' . $table));
$return .= "\n\n" . $row2[1] . ";\n\n";
for ($i = 0; $i < $numFields; $i++) {
while ($row = mysqli_fetch_row($result)) {
$return .= 'INSERT INTO ' . $table . ' VALUES(';
for ($j = 0; $j < $numFields; $j++) {
$row[$j] = addslashes($row[$j]);
$row[$j] = str_replace("\n", "\\n", $row[$j]);
if (isset($row[$j])) {
$return .= '"' . $row[$j] . '"';
} else {
$return .= '""';
}
if ($j < $numFields - 1) {
$return .= ',';
}
}
$return .= ");\n";
}
}
$return .= "\n\n\n";
}
//save file
$backupFileName = 'db-backup_' . time() . '.sql';
$handle = fopen($outputFolder . $backupFileName, 'w+');
fwrite($handle, $return);
fclose($handle);
self::generateBackupLog($name, $backupFileName . '.gz', $outputFolder, 3);
return self::gzCompressFile($outputFolder . 'db-backup_' . time() . '.sql');
}
示例15: checkCshFile
/**
* Check if the given file is already existing
*
* @param $path
* @param $modelClass
*
* @return void
*/
protected function checkCshFile($path, $modelClass)
{
if (is_file($path)) {
return;
}
$dir = PathUtility::dirname($path);
if (!is_dir($dir)) {
GeneralUtility::mkdir_deep($dir);
}
$information = SmartObjectInformationService::getInstance()->getCustomModelFieldTca($modelClass);
$properties = array_keys($information);
$templatePath = 'Resources/Private/Templates/ContextSensitiveHelp/LanguageDescription.xml';
$standaloneView = GeneralUtility::makeInstance('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
$standaloneView->setTemplatePathAndFilename(ExtensionManagementUtility::extPath('autoloader', $templatePath));
$standaloneView->assign('properties', $properties);
$content = $standaloneView->render();
FileUtility::writeFileAndCreateFolder($path, $content);
}