本文整理汇总了PHP中t3lib_div::mkdir方法的典型用法代码示例。如果您正苦于以下问题:PHP t3lib_div::mkdir方法的具体用法?PHP t3lib_div::mkdir怎么用?PHP t3lib_div::mkdir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类t3lib_div
的用法示例。
在下文中一共展示了t3lib_div::mkdir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*/
public function __construct()
{
// we check for existance of our targetDirectory
if (!is_dir(PATH_site . $this->targetDirectory)) {
t3lib_div::mkdir(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)) {
t3lib_div::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 (t3lib_div::testInt($compressionLevel)) {
$this->gzipCompressionLevel = intval($compressionLevel);
}
}
}
示例2: __construct
/**
* Check if the icon cache has to be rebuild, instantiate and call the handler class if so.
*
* @param boolean Suppress regeneration if false (useful for feediting)
* @return void
*/
function __construct($allowRegeneration = TRUE)
{
// Create temp directory if missing
if (!is_dir(PATH_site . self::$tempPath)) {
t3lib_div::mkdir(PATH_site . self::$tempPath);
}
// Backwards compatibility handling for API calls <= 4.3, will be removed in 4.7
$this->compatibilityCalls();
// Create cache filename, the hash includes all icons, registered CSS styles registered and the extension list
$this->tempFileName = PATH_site . self::$tempPath . md5(serialize($GLOBALS['TBE_STYLES']['spritemanager']) . md5(serialize($GLOBALS['TBE_STYLES']['spriteIconApi']['coreSpriteImageNames'])) . $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList']) . '.inc';
// Regenerate cache file if not already existing
if (!@file_exists($this->tempFileName)) {
if ($allowRegeneration) {
$handlerClass = $GLOBALS['TYPO3_CONF_VARS']['BE']['spriteIconGenerator_handler'] ? $GLOBALS['TYPO3_CONF_VARS']['BE']['spriteIconGenerator_handler'] : 't3lib_spritemanager_SimpleHandler';
$this->handler = t3lib_div::makeInstance($handlerClass);
// Throw exception if handler class does not implement required interface
if (!$this->handler || !$this->handler instanceof t3lib_spritemanager_SpriteIconGenerator) {
throw new Exception("class in TYPO3_CONF_VARS[BE][spriteIconGenerator_handler] does not exist,\n\t\t\t\t\t\tor does not implement t3lib_spritemanager_SpriteIconGenerator");
}
$this->rebuildCache();
} else {
// Set tempFileName to existing file if regeneration is not allowed
list($this->tempFileName) = t3lib_div::getFilesInDir(PATH_site . self::$tempPath, 'inc', TRUE);
}
}
}
示例3: __construct
/**
* class constructor checks if cache has to be rebuild and initiates the rebuild
* instantiates the handler class
*
* @param boolean $regenerate with set to false, cache won't be regenerated if needed (useful for feediting)
* @return void
*/
function __construct($regenerate = TRUE)
{
// we check for existance of our targetDirectory
if (!is_dir(PATH_site . self::$tempPath)) {
t3lib_div::mkdir(PATH_site . self::$tempPath);
}
// create a fileName, the hash includes all icons and css-styles registered and the extlist
$this->tempFileName = PATH_site . self::$tempPath . md5(serialize($GLOBALS['TBE_STYLES']['spritemanager']) . md5(serialize($GLOBALS['TBE_STYLES']['spriteIconApi']['coreSpriteImageNames'])) . $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList']) . '.inc';
// if no cache-file for the current config ist present, regenerate it
if (!@file_exists($this->tempFileName)) {
// regenerate if allowed
if ($regenerate) {
$handlerClass = $GLOBALS['TYPO3_CONF_VARS']['BE']['spriteIconGenerator_handler'] ? $GLOBALS['TYPO3_CONF_VARS']['BE']['spriteIconGenerator_handler'] : 't3lib_spritemanager_SimpleHandler';
$this->handler = t3lib_div::makeInstance($handlerClass);
// check if the handler could be loaded and implements the needed interface
if (!$this->handler || !$this->handler instanceof t3lib_spritemanager_SpriteIconGenerator) {
throw new Exception("class in TYPO3_CONF_VARS[BE][spriteIconGenerator_handler] does not exist,\n\t\t\t\t\t\tor does not implement t3lib_spritemanager_SpriteIconGenerator");
}
// all went good? to go for rebuild
$this->rebuildCache();
} else {
// use old file if present
list($this->tempFileName) = t3lib_div::getFilesInDir(PATH_site . self::$tempPath, 'inc', 1);
}
}
}
示例4: init
/**
* Initializes the Module
* @return void
*/
function init() {
global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
parent::init();
$this->extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['rzdummyimage']);
$store_path = $this->extConf['storePath'];
if($store_path == '') $store_path = 'fileadmin/user_upload/rzdummyimage';
t3lib_div::mkdir(PATH_site . $store_path);
}
示例5: getFileSystemStatus
/**
* Checks for several directories being writable.
*
* @return tx_reports_reports_status_Status An tx_reports_reports_status_Status object indicating the status of the file system
*/
protected function getFileSystemStatus()
{
$value = $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_writable');
$message = '';
$severity = tx_reports_reports_status_Status::OK;
// Requirement level
// -1 = not required, but if it exists may be writable or not
// 0 = not required, if it exists the dir should be writable
// 1 = required, don't has to be writable
// 2 = required, has to be writable
$checkWritable = array('typo3temp/' => 2, 'typo3temp/pics/' => 2, 'typo3temp/temp/' => 2, 'typo3temp/llxml/' => 2, 'typo3temp/cs/' => 2, 'typo3temp/GB/' => 2, 'typo3temp/locks/' => 2, 'typo3conf/' => 2, 'typo3conf/ext/' => 0, 'typo3conf/l10n/' => 0, TYPO3_mainDir . 'ext/' => -1, 'uploads/' => 2, 'uploads/pics/' => 0, 'uploads/media/' => 0, 'uploads/tf/' => 0, $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] => -1, $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . '_temp_/' => 0);
foreach ($checkWritable as $relPath => $requirementLevel) {
if (!@is_dir(PATH_site . $relPath)) {
// If the directory is missing, try to create it
t3lib_div::mkdir(PATH_site . $relPath);
}
if (!@is_dir(PATH_site . $relPath)) {
if ($requirementLevel > 0) {
// directory is required
$value = $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_missingDirectory');
$message .= sprintf($GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_directoryDoesNotExistCouldNotCreate'), $relPath) . '<br />';
$severity = tx_reports_reports_status_Status::ERROR;
} else {
$message .= sprintf($GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_directoryDoesNotExist'), $relPath);
if ($requirementLevel == 0) {
$message .= ' ' . $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_directoryShouldAlsoBeWritable');
}
$message .= '<br />';
if ($severity < tx_reports_reports_status_Status::WARNING) {
$value = $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_nonExistingDirectory');
$severity = tx_reports_reports_status_Status::WARNING;
}
}
} else {
if (!is_writable(PATH_site . $relPath)) {
switch ($requirementLevel) {
case 0:
$message .= sprintf($GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_directoryShouldBeWritable'), PATH_site . $relPath) . '<br />';
if ($severity < tx_reports_reports_status_Status::WARNING) {
$value = $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_recommendedWritableDirectory');
$severity = tx_reports_reports_status_Status::WARNING;
}
break;
case 2:
$value = $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_requiredWritableDirectory');
$message .= sprintf($GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_directoryMustBeWritable'), PATH_site . $relPath) . '<br />';
$severity = tx_reports_reports_status_Status::ERROR;
break;
}
}
}
}
return t3lib_div::makeInstance('tx_reports_reports_status_Status', $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_fileSystem'), $value, $message, $severity);
}
示例6: setUp
/**
* (non-PHPdoc)
* @see tx_mklib_tests_DBTestCaseSkeleton::setUp()
*/
public function setUp()
{
if (!t3lib_extMgm::isLoaded('dam')) {
$this->markTestSkipped('DAM ist nicht installiert');
}
parent::setUp();
$this->sTempFolder = t3lib_extMgm::extPath('mklib') . 'tests/typo3temp';
t3lib_div::mkdir($this->sTempFolder);
$sImageFile = 'test.jpg';
$this->sAbsoluteImagePath = $this->sTempFolder . '/' . $sImageFile;
touch($this->sAbsoluteImagePath);
$this->sRelativeImagePath = 'typo3conf/ext/mklib/tests/typo3temp/' . $sImageFile;
}
示例7: createTestfiles
private static function createTestfiles($testfolder)
{
t3lib_div::mkdir($testfolder);
$files = array(array($testfolder . '/', 'test.zip'), array($testfolder . '/', 'test.xml'), array($testfolder . '/', 'test.tmp'), array($testfolder . '/', 'test.dat'), array($testfolder . '/sub/', 'test.zip'), array($testfolder . '/sub/', 'test.tmp'), array($testfolder . '/sub/sub/', 'test.xml'), array($testfolder . '/sub/sub/', 'test.dat'));
foreach ($files as $file) {
$path = $file[0];
$file = $file[1];
if (!is_dir($path)) {
t3lib_div::mkdir($path);
}
$iH = fopen($path . $file, "w+");
fwrite($iH, 'This is an automatic generated testfile and can be removed.');
fclose($iH);
}
}
示例8: head
function head()
{
global $TYPO3_CONF_VARS;
global $TYPO3_CONF_VARS, $FILEMOUNTS;
if (!is_object($GLOBALS['SOBE']->basicFF)) {
$GLOBALS['SOBE']->basicFF = t3lib_div::makeInstance('t3lib_basicFileFunctions');
$GLOBALS['SOBE']->basicFF->init($FILEMOUNTS, $TYPO3_CONF_VARS['BE']['fileExtensions']);
}
$this->pObj->guiCmdIconsDeny[] = 'popup';
$this->cronUploadsFolder = PATH_site . $this->cronUploadsFolder;
if (!is_dir($this->cronUploadsFolder)) {
t3lib_div::mkdir($this->cronUploadsFolder);
}
return parent::head();
}
示例9: __construct
/**
* Constructor
*/
public function __construct()
{
// we check for existance of our targetDirectory
if (!is_dir(PATH_site . $this->targetDirectory)) {
t3lib_div::mkdir(PATH_site . $this->targetDirectory);
}
// 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 (t3lib_div::testInt($compressionLevel)) {
$this->gzipCompressionLevel = $compressionLevel;
}
}
}
示例10: setCacheDirectoryThrowsExceptionOnNonWritableDirectory
/**
* @test
* @author Robert Lemke <robert@typo3.org>
*/
public function setCacheDirectoryThrowsExceptionOnNonWritableDirectory()
{
if (TYPO3_OS == 'WIN') {
$this->markTestSkipped('test not reliable in Windows environment');
}
// Create test directory and remove write permissions
$directoryName = PATH_site . 'typo3temp/' . uniqid('test_');
t3lib_div::mkdir($directoryName);
chmod($directoryName, 1551);
try {
$this->backend->setCacheDirectory($directoryName);
$this->fail('setCacheDirectory did not throw an exception on a non writable directory');
} catch (t3lib_cache_Exception $e) {
// Remove created test directory
t3lib_div::rmdir($directoryName);
}
}
示例11: generate
/**
* Interface function. This will be called from the sprite manager to
* refresh all caches.
*
* @return void
*/
public function generate()
{
$this->generatorInstance = t3lib_div::makeInstance('t3lib_spritemanager_SpriteGenerator', 'GeneratorHandler');
$this->generatorInstance->setOmmitSpriteNameInIconName(TRUE)->setIncludeTimestampInCSS(TRUE)->setSpriteFolder(t3lib_SpriteManager::$tempPath)->setCSSFolder(t3lib_SpriteManager::$tempPath);
$iconsToProcess = array_merge((array) $GLOBALS['TBE_STYLES']['spritemanager']['singleIcons'], $this->collectTcaSpriteIcons());
foreach ($iconsToProcess as $iconName => $iconFile) {
$iconsToProcess[$iconName] = t3lib_div::resolveBackPath('typo3/' . $iconFile);
}
$generatorResponse = $this->generatorInstance->generateSpriteFromArray($iconsToProcess);
if (!is_dir(PATH_site . t3lib_SpriteManager::$tempPath . 'ie6')) {
t3lib_div::mkdir(PATH_site . t3lib_SpriteManager::$tempPath . 'ie6');
}
t3lib_div::upload_copy_move($generatorResponse['spriteGifImage'], t3lib_div::dirname($generatorResponse['spriteGifImage']) . '/ie6/' . basename($generatorResponse['spriteGifImage']));
unlink($generatorResponse['spriteGifImage']);
t3lib_div::upload_copy_move($generatorResponse['cssGif'], t3lib_div::dirname($generatorResponse['cssGif']) . '/ie6/' . basename($generatorResponse['cssGif']));
unlink($generatorResponse['cssGif']);
$this->iconNames = array_merge($this->iconNames, $generatorResponse['iconNames']);
parent::generate();
}
示例12: backupExtension
/**
*
* @param Tx_ExtensionBuilder_Domain_Model_Extension $extension
* @param string $backupDir
*
* @return void
*/
static function backupExtension($extension, $backupDir)
{
if (empty($backupDir)) {
throw new Exception('Please define a backup directory in extension configuration!');
} else {
if (!t3lib_div::validPathStr($backupDir)) {
throw new Exception('Backup directory is not a valid path: ' . $backupDir);
} else {
if (t3lib_div::isAbsPath($backupDir)) {
if (!t3lib_div::isAllowedAbsPath($backupDir)) {
throw new Exception('Backup directory is not an allowed absolute path: ' . $backupDir);
}
} else {
$backupDir = PATH_site . $backupDir;
}
}
}
if (strrpos($backupDir, '/') < strlen($backupDir) - 1) {
$backupDir .= '/';
}
if (!is_dir($backupDir)) {
throw new Exception('Backup directory does not exist: ' . $backupDir);
} else {
if (!is_writable($backupDir)) {
throw new Exception('Backup directory is not writable: ' . $backupDir);
}
}
$backupDir .= $extension->getExtensionKey();
// create a subdirectory for this extension
if (!is_dir($backupDir)) {
t3lib_div::mkdir($backupDir);
}
if (strrpos($backupDir, '/') < strlen($backupDir) - 1) {
$backupDir .= '/';
}
$backupDir .= date('Y-m-d-') . time();
if (!is_dir($backupDir)) {
t3lib_div::mkdir($backupDir);
}
$extensionDir = substr($extension->getExtensionDir(), 0, strlen($extension->getExtensionDir()) - 1);
try {
self::recurse_copy($extensionDir, $backupDir);
} catch (Exception $e) {
throw new Exception('Code generation aborted:' . $e->getMessage());
}
t3lib_div::devlog('Backup created in ' . $backupDir, 'extension_builder', 0);
}
示例13: checkOrCreateDir
/**
* Returns true if directory exists and if it doesn't it will create directory and return true if that succeeded.
*
* @param string Directory to create. Having a trailing slash. Must be in fileadmin/. Relative to PATH_site
* @return boolean True, if directory exists (was created)
*/
function checkOrCreateDir($dirPrefix)
{
// Split dir path and remove first directory (which should be "fileadmin")
$filePathParts = explode('/', $dirPrefix);
$firstDir = array_shift($filePathParts);
if ($firstDir === $this->fileadminFolderName && t3lib_div::getFileAbsFileName($dirPrefix)) {
$pathAcc = '';
foreach ($filePathParts as $dirname) {
$pathAcc .= '/' . $dirname;
if (strlen($dirname)) {
if (!@is_dir(PATH_site . $this->fileadminFolderName . $pathAcc)) {
if (!t3lib_div::mkdir(PATH_site . $this->fileadminFolderName . $pathAcc)) {
$this->error('ERROR: Directory could not be created....B');
return FALSE;
}
}
} elseif ($dirPrefix === $this->fileadminFolderName . $pathAcc) {
return TRUE;
} else {
$this->error('ERROR: Directory could not be created....A');
}
}
}
}
示例14: writeFileToTypo3tempDir
/**
* Writes $content to a filename in the typo3temp/ folder (and possibly a subfolder...)
* Accepts an additional subdirectory in the file path!
*
* @param string Absolute filepath to write to inside "typo3temp/". First part of this string must match PATH_site."typo3temp/"
* @param string Content string to write
* @return string Returns false on success, otherwise an error string telling about the problem.
*/
function writeFileToTypo3tempDir($filepath, $content)
{
// Parse filepath into directory and basename:
$fI = pathinfo($filepath);
$fI['dirname'] .= '/';
// Check parts:
if (t3lib_div::validPathStr($filepath) && $fI['basename'] && strlen($fI['basename']) < 60) {
if (defined('PATH_site')) {
$dirName = PATH_site . 'typo3temp/';
// Setting main temporary directory name (standard)
if (@is_dir($dirName)) {
if (t3lib_div::isFirstPartOfStr($fI['dirname'], $dirName)) {
// Checking if the "subdir" is found:
$subdir = substr($fI['dirname'], strlen($dirName));
if ($subdir) {
if (ereg('^[[:alnum:]_]+\\/$', $subdir)) {
$dirName .= $subdir;
if (!@is_dir($dirName)) {
t3lib_div::mkdir($dirName);
}
} else {
return 'Subdir, "' . $subdir . '", was NOT on the form "[a-z]/"';
}
}
// Checking dir-name again (sub-dir might have been created):
if (@is_dir($dirName)) {
if ($filepath == $dirName . $fI['basename']) {
t3lib_div::writeFile($filepath, $content);
if (!@is_file($filepath)) {
return 'File not written to disk! Write permission error in filesystem?';
}
} else {
return 'Calculated filelocation didn\'t match input $filepath!';
}
} else {
return '"' . $dirName . '" is not a directory!';
}
} else {
return '"' . $fI['dirname'] . '" was not within directory PATH_site + "typo3temp/"';
}
} else {
return 'PATH_site + "typo3temp/" was not a directory!';
}
} else {
return 'PATH_site constant was NOT defined!';
}
} else {
return 'Input filepath "' . $filepath . '" was generally invalid!';
}
}
示例15: createTempSubDir
/**
* Creates subdirectory in typo3temp/ if not already found.
*
* @param string Name of sub directory
* @return boolean Result of t3lib_div::mkdir(), true if it went well.
*/
function createTempSubDir($dirName)
{
// Checking if the this->tempPath is already prefixed with PATH_site and if not, prefix it with that constant.
if (t3lib_div::isFirstPartOfStr($this->tempPath, PATH_site)) {
$tmpPath = $this->tempPath;
} else {
$tmpPath = PATH_site . $this->tempPath;
}
// Making the temporary filename:
if (!@is_dir($tmpPath . $dirName)) {
return t3lib_div::mkdir($tmpPath . $dirName);
}
}