本文整理汇总了PHP中t3lib_div::mkdir_deep方法的典型用法代码示例。如果您正苦于以下问题:PHP t3lib_div::mkdir_deep方法的具体用法?PHP t3lib_div::mkdir_deep怎么用?PHP t3lib_div::mkdir_deep使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类t3lib_div
的用法示例。
在下文中一共展示了t3lib_div::mkdir_deep方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: downloadDBFileToDirectory
/**
* @param $dbDirEntry
*/
protected function downloadDBFileToDirectory($dbDirEntry)
{
$dbPathAndFileName = $dbDirEntry['path'];
t3lib_div::mkdir_deep($this->getFileadminPath(), $this->syncConfig->getLocalPath());
$dbFileName = basename($dbPathAndFileName);
$localPathAndFileName = $this->getFileadminPath() . $this->syncConfig->getLocalPath() . '/' . $dbFileName;
$fileContent = $this->dropbox->getFile($dbPathAndFileName);
file_put_contents($localPathAndFileName, $fileContent);
$this->fileTracker->updateFileMeta($localPathAndFileName, $dbDirEntry, $this->syncConfig, $this->runIdentifier);
$this->runInfo->logLocalFileAdded($dbPathAndFileName, $this->syncConfig->getLocalPath());
}
示例2: renderForm
/**
* Function rendering the status form and executing the splitting operation
*
* @param array XML file content as array!
* @param string The absolute file name the content is read from
* @return string HTML content.
*/
function renderForm($fileContent, $phpFile)
{
// Meta Data of file
$content .= 'Description: <b>' . htmlspecialchars($fileContent['meta']['description']) . '</b>';
if (!@is_writable($phpFile)) {
return 'ERROR: File "' . $phpFile . '" was not writeable!';
}
// Initiate:
$languages = explode('|', TYPO3_languages);
$createFile = t3lib_div::_POST('createFile');
$removePoint = t3lib_div::_POST('removePoint');
$log = array();
$saveOriginalBack = FALSE;
$tableRows = array();
foreach ($languages as $lKey) {
if ($lKey != 'default') {
$tableCells = array();
// Title:
$tableCells[] = htmlspecialchars($lKey);
// Content:
$tableCells[] = is_array($fileContent['data'][$lKey]) ? count($fileContent['data'][$lKey]) . ' labels locally' : htmlspecialchars($fileContent['data'][$lKey]);
// Status:
if (!is_array($fileContent['data'][$lKey]) && strlen(trim($fileContent['data'][$lKey]))) {
// An external file WAS configured - we only give status then:
$absFileName = t3lib_div::getFileAbsFileName($fileContent['data'][$lKey]);
if ($absFileName) {
if (@is_file($absFileName)) {
$tableCells[] = 'External file exists, OK.';
} else {
$tableCells[] = '<b>ERROR:</b> External file did not exist, should exist!
<hr>REMOVE POINTER: <input type="checkbox" name="removePoint[' . $lKey . ']" value="1" />';
if (t3lib_div::_GP('_create_') && $removePoint[$lKey]) {
$log[] = 'Removing pointer "' . $fileContent['data'][$lKey] . '"';
unset($fileContent['data'][$lKey]);
$saveOriginalBack = TRUE;
}
}
} else {
$tableCells[] = 'External file path did not resolve, maybe extension is not loaded.';
}
} else {
// No external file yet:
$fileName = t3lib_div::llXmlAutoFileName($phpFile, $lKey);
# str_replace('###LANGKEY###',$lKey,$fileContent['meta']['ext_filename_template']);
$absFileName = t3lib_div::getFileAbsFileName($fileName);
if ($absFileName) {
if (@is_file($absFileName)) {
$tableCells[] = 'External Automatic file exists, OK.';
} else {
if (t3lib_div::_GP('_create_')) {
if ($createFile[$lKey]) {
$OK = 1;
$dirname = dirname($absFileName);
if (!@is_dir($dirname)) {
$OK = 0;
if (t3lib_div::isFirstPartOfStr($dirname, PATH_site . 'typo3conf/l10n/')) {
$err = t3lib_div::mkdir_deep(PATH_site . 'typo3conf/l10n/', substr($dirname, strlen(PATH_site . 'typo3conf/l10n/')));
if ($err) {
$log[] = 'Creating directory ' . $dirname . ' failed';
} else {
$OK = 1;
}
} else {
$log[] = 'Creating directory ' . $dirname . ' failed (2)';
}
}
if ($OK) {
// Creating data for external file:
$extArray = array();
// Setting language specific information in the XML file array:
$extArray['data'][$lKey] = is_array($fileContent['data'][$lKey]) ? $fileContent['data'][$lKey] : array();
$extArray['orig_hash'][$lKey] = is_array($fileContent['orig_hash'][$lKey]) ? $fileContent['orig_hash'][$lKey] : array();
$extArray['orig_text'][$lKey] = is_array($fileContent['orig_text'][$lKey]) ? $fileContent['orig_text'][$lKey] : array();
// Create XML and save file:
$XML = $this->createXML($extArray, TRUE);
// Write file:
t3lib_div::writeFile($absFileName, $XML);
// Checking if the localized file was saved as it should be:
if (md5(t3lib_div::getUrl($absFileName)) == md5($XML)) {
$log[] = 'Saved external XML, validated OK';
// Prepare SAVING original:
// Setting reference to the external file:
unset($fileContent['data'][$lKey]);
// Unsetting the hash and original text for this language as well:
unset($fileContent['orig_hash'][$lKey]);
unset($fileContent['orig_text'][$lKey]);
$saveOriginalBack = TRUE;
} else {
$log[] = 'ERROR: MD5 sum of saved external file did not match XML going in!';
}
}
}
} else {
//.........这里部分代码省略.........
示例3: mkdir_deep
/**
* wrapper for t3lib_div::mkdir_deep
* checks for overwrite settings
*
* @param string $directory base path
* @param string $deepDirectory
*/
protected function mkdir_deep($directory, $deepDirectory)
{
$subDirectories = explode('/', $deepDirectory);
$tmpBasePath = $directory;
foreach ($subDirectories as $subDirectory) {
$overWriteMode = Tx_ExtensionBuilder_Service_RoundTrip::getOverWriteSettingForPath($tmpBasePath . $subDirectory, $this->extension);
//throw new Exception($directory . $subDirectory . '/' . $overWriteMode);
if ($overWriteMode === -1) {
// skip creation
return;
}
if (!is_dir($deepDirectory) || $this->roundTripEnabled && $overWriteMode < 2) {
t3lib_div::mkdir_deep($tmpBasePath, $subDirectory);
}
$tmpBasePath .= $subDirectory . '/';
}
}
示例4: createDirsInPath
/**
* Creates directories in $extDirPath
*
* @param array Array of directories to create relative to extDirPath, eg. "blabla", "blabla/blabla" etc...
* @param string Absolute path to directory.
* @return mixed Returns false on success or an error string
*/
public static function createDirsInPath($dirs, $extDirPath)
{
if (is_array($dirs)) {
foreach ($dirs as $dir) {
$error = t3lib_div::mkdir_deep($extDirPath, $dir);
if ($error) {
return $error;
}
}
}
return FALSE;
}
示例5: openFile
/**
* Öffnet eine Datei für den debug.
*
* @param string $path
* @param string $file
* @return int
*/
public static function openFile($path = '', $file = '')
{
$file = $file ? $file : 'mklib_debug_' . date('Y-m-d_H-i-s', time()) . '.txt';
if (!$path) {
$path = 'typo3temp/mklib/';
if (!is_writable(PATH_site . $path)) {
t3lib_div::mkdir_deep(PATH_site, $path);
}
$path = PATH_site . $path;
}
self::$file = fopen($path . $file, "a");
unset($path);
unset($file);
return self::$file;
}
示例6: lessPhp
/**
* lessPhp
*
* @return void
*/
public function lessPhp( $files )
{
require_once (t3lib_extMgm::extPath( 't3_less' ) . 'Resources/Private/Lib/' . $this->configuration['other']['lessPhpScriptPath']);
// create outputfolder if it does not exist
if( !is_dir( $this->outputfolder ) )
{
t3lib_div::mkdir_deep( '', $this->outputfolder );
}
$less = t3lib_div::makeInstance( 'lessc' );
$this->checkForAdditionalConfiguration( $less );
// compile each less-file
foreach( $files as $file )
{
//get only the name of less file
$filename = array_pop( explode( '/', $file ) );
$md5 = md5( $filename . md5_file( $file ) );
$outputfile = $this->outputfolder . substr( $filename, 0, -5 ) . '_' . $md5 . '.css';
if( $this->configuration['other']['forceMode'] )
{
unlink( $outputfile );
}
if( !file_exists( $outputfile ) )
{
if( $this->configuration['other']['compressed'] )
{
$less->setFormatter( "compressed" );
lessc::ccompile( $file, $this->outputfolder . substr( $filename, 0, -5 ) . '_' . $md5 . '.css', $less );
}
else
{
lessc::ccompile( $file, $this->outputfolder . substr( $filename, 0, -5 ) . '_' . $md5 . '.css' );
}
t3lib_div::fixPermissions( $outputfile, FALSE );
}
}
// unlink compiled files which have no equal source less-file
if( $this->configuration['other']['unlinkCssFilesWithNoSourceFile'] == 1 )
{
$this->unlinkGeneratedFilesWithNoSourceFile( $files );
}
$files = t3lib_div::getFilesInDir( $this->outputfolder, "css" );
//respect given sort order defined in TS
usort( $files, array( $this, 'getSortOrderPhp' ) );
foreach( $files as $cssFile )
{
$excludeFromPageRender = isset( $this->configuration['phpcompiler']['filesettings'][substr( $cssFile, 0, -37 )]['excludeFromPageRenderer'] ) ? $this->configuration['phpcompiler']['filesettings'][substr( $cssFile, 0, -37 )]['excludeFromPageRenderer'] : 0;
if( !$excludeFromPageRender || $excludeFromPageRender == 0 )
{
// array with filesettings from TS
$tsOptions = $this->configuration['phpcompiler']['filesettings'][substr( $cssFile, 0, -37 )];
$GLOBALS['TSFE']->getPageRenderer()->addCssFile(
$this->outputfolder . $cssFile, $rel = 'stylesheet', $media = isset( $tsOptions['media'] ) ? $tsOptions['media'] : 'all', $title = isset( $tsOptions['title'] ) ? $tsOptions['title'] : '', $compress = isset( $tsOptions['compress'] ) && $tsOptions['compress'] >= '0' ? (boolean) $tsOptions['compress'] : TRUE, $forceOnTop = isset( $tsOptions['forceOnTop'] ) && $tsOptions['forceOnTop'] >= '0' ? (boolean) $tsOptions['forceOnTop'] : FALSE, $allWrap = isset( $tsOptions['allWrap'] ) ? $tsOptions['allWrap'] : '', $excludeFromConcatenation = isset( $tsOptions['excludeFromConcatenation'] ) && $tsOptions['excludeFromConcatenation'] >= '0' ? (boolean) $tsOptions['excludeFromConcatenation'] : FALSE
);
}
}
}
示例7: checkValue_group_select_file
//.........这里部分代码省略.........
}
}
}
// If MM relations for the files, we will set the relations as MM records and change the valuearray to contain a single entry with a count of the number of files!
if ($tcaFieldConf['MM']) {
$dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
/* @var $dbAnalysis t3lib_loadDBGroup */
$dbAnalysis->tableArray['files'] = array();
// dummy
foreach ($valueArray as $key => $theFile) {
// explode files
$dbAnalysis->itemArray[]['id'] = $theFile;
}
if ($status == 'update') {
$dbAnalysis->writeMM($tcaFieldConf['MM'], $id, 0);
$newFiles = implode(',', $dbAnalysis->getValueArray());
list(, , $recFieldName) = explode(':', $recFID);
if ($currentFilesForHistory != $newFiles) {
$this->mmHistoryRecords[$table . ':' . $id]['oldRecord'][$recFieldName] = $currentFilesForHistory;
$this->mmHistoryRecords[$table . ':' . $id]['newRecord'][$recFieldName] = $newFiles;
} else {
$this->mmHistoryRecords[$table . ':' . $id]['oldRecord'][$recFieldName] = '';
$this->mmHistoryRecords[$table . ':' . $id]['newRecord'][$recFieldName] = '';
}
} else {
$this->dbAnalysisStore[] = array($dbAnalysis, $tcaFieldConf['MM'], $id, 0);
// This will be traversed later to execute the actions
}
$valueArray = $dbAnalysis->countItems();
}
//store path relative to site root (if uploadfolder is not set or internal_type is file_reference)
} else {
if (count($valueArray)) {
if (!$this->bypassFileHandling) {
// If filehandling should NOT be bypassed, do processing:
$propArr = $this->getRecordProperties($table, $id);
// For logging..
foreach ($valueArray as &$theFile) {
// if alernative File Path is set for the file, then it was an import
if ($this->alternativeFilePath[$theFile]) {
// don't import the file if it already exists
if (@is_file(PATH_site . $this->alternativeFilePath[$theFile])) {
$theFile = PATH_site . $this->alternativeFilePath[$theFile];
// import the file
} elseif (@is_file($theFile)) {
$dest = dirname(PATH_site . $this->alternativeFilePath[$theFile]);
if (!@is_dir($dest)) {
t3lib_div::mkdir_deep(PATH_site, dirname($this->alternativeFilePath[$theFile]) . '/');
}
// Init:
$maxSize = intval($tcaFieldConf['max_size']);
$cmd = '';
$theDestFile = '';
// Must be cleared. Else a faulty fileref may be inserted if the below code returns an error!
$fileSize = filesize($theFile);
if (!$maxSize || $fileSize <= $maxSize * 1024) {
// Check file size:
// Prepare filename:
$theEndFileName = isset($this->alternativeFileName[$theFile]) ? $this->alternativeFileName[$theFile] : $theFile;
$fI = t3lib_div::split_fileref($theEndFileName);
// Check for allowed extension:
if ($this->fileFunc->checkIfAllowed($fI['fileext'], $dest, $theEndFileName)) {
$theDestFile = PATH_site . $this->alternativeFilePath[$theFile];
// Write the file:
if ($theDestFile) {
t3lib_div::upload_copy_move($theFile, $theDestFile);
$this->copiedFileMap[$theFile] = $theDestFile;
clearstatcache();
if (!@is_file($theDestFile)) {
$this->log($table, $id, 5, 0, 1, "Copying file '%s' failed!: The destination path (%s) may be write protected. Please make it write enabled!. (%s)", 16, array($theFile, dirname($theDestFile), $recFID), $propArr['event_pid']);
}
} else {
$this->log($table, $id, 5, 0, 1, "Copying file '%s' failed!: No destination file (%s) possible!. (%s)", 11, array($theFile, $theDestFile, $recFID), $propArr['event_pid']);
}
} else {
$this->log($table, $id, 5, 0, 1, "File extension '%s' not allowed. (%s)", 12, array($fI['fileext'], $recFID), $propArr['event_pid']);
}
} else {
$this->log($table, $id, 5, 0, 1, "Filesize (%s) of file '%s' exceeds limit (%s). (%s)", 13, array(t3lib_div::formatSize($fileSize), $theFile, t3lib_div::formatSize($maxSize * 1024), $recFID), $propArr['event_pid']);
}
// If the destination file was created, we will set the new filename in the value array, otherwise unset the entry in the value array!
if (@is_file($theDestFile)) {
$theFile = $theDestFile;
// The value is set to the new filename
} else {
unset($theFile);
// The value is set to the new filename
}
}
}
$theFile = t3lib_div::fixWindowsFilePath($theFile);
if (t3lib_div::isFirstPartOfStr($theFile, PATH_site)) {
$theFile = substr($theFile, strlen(PATH_site));
}
}
}
}
}
return $valueArray;
}
示例8: generateInitialModelClassFile
/**
* Builds an initial class file to test parsing and modifiying of existing classes
*
* This class file is generated based on the CodeTemplates
* @param string $modelName
*/
function generateInitialModelClassFile($modelName)
{
$domainObject = $this->buildDomainObject($modelName);
$classFileContent = $this->codeGenerator->generateDomainObjectCode($domainObject, $this->extension);
$modelClassDir = 'Classes/Domain/Model/';
$result = t3lib_div::mkdir_deep($this->extension->getExtensionDir(), $modelClassDir);
$absModelClassDir = $this->extension->getExtensionDir() . $modelClassDir;
$this->assertTrue(is_dir($absModelClassDir), 'Directory ' . $absModelClassDir . ' was not created');
$modelClassPath = $absModelClassDir . $domainObject->getName() . '.php';
t3lib_div::writeFile($modelClassPath, $classFileContent);
}
示例9: rewriteClass
/**
* generate a duplicate of a Class with an other Name
* Mage_Core_Model_App -> Flagbit_Typo3connect_Rewrite_Core_Model_App
*
* @param string $className
* @return string
*/
protected function rewriteClass($className)
{
// cache Path
$cachePath = $this->config['path'] . 'var/cache/';
// get Filename from Classname
$fileName = $this->_getClassPath($className);
// generate a new Version of Classfile if not exists
if (!file_exists($cachePath . $fileName)) {
// get source of the original Class
$content = file_get_contents($this->config['path'] . 'app/code/core/' . uc_words($className, DS) . '.php');
// change Classname
$content = preg_replace('/class(.*)' . $className . '/iU', 'class\\1Flagbit_Typo3connect_Rewrite_' . $className, $content);
// write new Class
$classPath = substr($fileName, 0, strrpos($fileName, '/') + 1);
t3lib_div::mkdir_deep($cachePath, substr($fileName, 0, strrpos($fileName, '/') + 1));
t3lib_div::writeFile($cachePath . $fileName, $content);
}
return $cachePath . $fileName;
}
示例10: _getXml
/**
* Reads and parse an xml file, and returns an array of XML
* Fresh or cached data, depending on $this->conf["cache."]["enabled"]
*
* @param string $sPath: abs server path to xml file
* @param boolean $isSubXml
* @return array xml data
*/
function _getXml($sPath, $isSubXml = FALSE, $bPlain = FALSE)
{
if (!file_exists($sPath)) {
if ($isSubXml === FALSE) {
$this->smartMayday_XmlFile($sPath);
} else {
$this->mayday("FORMIDABLE CORE - The given XML file path (<b>'" . $sPath . "'</b>) doesn't exists.");
}
} elseif (is_dir($sPath)) {
$this->mayday("FORMIDABLE CORE - The given XML file path (<b>'" . $sPath . "'</b>) is a directory, and should be a file.");
} elseif (!is_readable($sPath)) {
$this->mayday("FORMIDABLE CORE - The given XML file path (<b>'" . $sPath . "'</b>) exists but is not readable.");
} else {
$sHash = md5($sPath);
if (array_key_exists($sHash, $this->_aSubXmlCache)) {
return $this->_aSubXmlCache[$sHash];
} else {
$aConf = array();
if ($this->conf["cache."]["enabled"] == 1) {
$sProtection = "<?php die('Formidable - Cache protected'); ?><!--FORMIDABLE_CACHE-->";
//debug(stat($sPath));
$sHash = md5($sPath . "-" . @filemtime($sPath) . "-" . $this->sApiVersion);
$sFile = "formidablexmlcache_" . $sHash . ".php";
$sCacheDir = "ameos_formidable/cache/";
$sCachePath = PATH_site . "typo3temp/" . $sCacheDir . $sFile;
if (file_exists($sCachePath)) {
$aConf = unserialize(base64_decode(substr($this->file_readBin($sCachePath), strlen($sProtection) + 3)));
if (is_array($aConf)) {
reset($aConf);
}
}
}
if (empty($aConf)) {
$sXmlData = $this->file_readBin($sPath);
if (trim($sXmlData) === "") {
$this->smartMayday_XmlFile($sPath, "FORMIDABLE CORE - The given XML file path (<b>'" . $sPath . "'</b>) exists but is empty.");
}
$aMatches = array();
preg_match("/^<\\?xml(.*)\\?>/", $sXmlData, $aMatches);
// Check result
if (!empty($aMatches)) {
$sXmlProlog = $aMatches[0];
$sXmlData = preg_replace("/^<\\?xml(.*)\\?>/", "", $sXmlData);
} else {
$sXmlProlog = '<?xml version="1.0" encoding="utf-8" standalone="yes" ?>';
}
if ($isSubXml) {
$sXmlData = $sXmlProlog . "\n" . "<phparray>" . $sXmlData . "</phparray>";
} else {
$sXmlData = $sXmlProlog . "\n" . $sXmlData;
}
if ($bPlain === FALSE) {
$aConf = $this->div_xml2array($sXmlData);
} else {
$aConf = $this->div_xml2array_plain($sXmlData);
}
if (is_array($aConf)) {
if ($isSubXml && array_key_exists("phparray", $aConf) && is_array($aConf["phparray"])) {
$aConf = $aConf["phparray"];
}
reset($aConf);
} else {
$this->mayday("FORMIDABLE CORE - The given XML file (<b>'" . $sPath . "'</b>) isn't well-formed XML<br>Parser says : <b>" . $aConf . "</b>");
}
if ($this->conf["cache."]["enabled"] == 1) {
if (!@is_dir(PATH_site . "typo3temp/" . $sCacheDir)) {
if (function_exists("t3lib_div::mkdir_deep")) {
t3lib_div::mkdir_deep(PATH_site . "typo3temp/", $sCacheDir);
} else {
$this->div_mkdir_deep(PATH_site . "typo3temp/", $sCacheDir);
}
}
$this->file_writeBin($sCachePath, $sProtection . base64_encode(serialize($aConf)), TRUE);
}
}
reset($aConf);
$this->_aSubXmlCache[$sHash] = $aConf;
return $aConf;
}
}
}
示例11: updateTranslation
/**
* Install translations for all selected languages for an extension
*
* @param string $extKey The extension key to install the translations for
* @param string $lang Language code of translation to fetch
* @param string $mirrorURL Mirror URL to fetch data from
* @return mixed true on success, error string on fauilure
*/
function updateTranslation($extKey, $lang, $mirrorURL)
{
$l10n = $this->parentObject->terConnection->fetchTranslation($extKey, $lang, $mirrorURL);
if (is_array($l10n)) {
$file = PATH_site . 'typo3temp/' . $extKey . '-l10n-' . $lang . '.zip';
$path = 'l10n/' . $lang . '/';
if (!is_dir(PATH_typo3conf . $path)) {
t3lib_div::mkdir_deep(PATH_typo3conf, $path);
}
t3lib_div::writeFile($file, $l10n[0]);
// this prevent first update having errors
t3lib_div::rmdir(PATH_typo3conf . $path . $extKey, TRUE);
if (tx_em_Tools::unzip($file, PATH_typo3conf . $path)) {
return TRUE;
} else {
return $GLOBALS['LANG']->getLL('translation_unpacking_failed');
}
} else {
return $l10n;
}
}
示例12: writeSimpleControllerClassFromDomainObject
/**
* Write a simple model class for a non aggregate root domain object
*
* @depends checkRequirements
* @test
*/
function writeSimpleControllerClassFromDomainObject()
{
$domainObject = $this->buildDomainObject('ModelCgt6', true);
$action = t3lib_div::makeInstance('Tx_ExtensionBuilder_Domain_Model_DomainObject_Action');
$action->setName('list');
$domainObject->addAction($action);
$classFileContent = $this->codeGenerator->generateActionControllerCode($domainObject, $this->extension);
$controllerClassDir = 'Classes/Controller/';
$result = t3lib_div::mkdir_deep($this->extension->getExtensionDir(), $controllerClassDir);
$absControllerClassDir = $this->extension->getExtensionDir() . $controllerClassDir;
$this->assertTrue(is_dir($absControllerClassDir), 'Directory ' . $absControllerClassDir . ' was not created');
$controllerClassPath = $absControllerClassDir . $domainObject->getName() . 'Controller.php';
t3lib_div::writeFile($controllerClassPath, $classFileContent);
$this->assertFileExists($controllerClassPath, 'File was not generated: ' . $controllerClassPath);
$className = $domainObject->getControllerName();
include $controllerClassPath;
$this->assertTrue(class_exists($className), 'Class was not generated:' . $className);
}
示例13: setUpBackend
/**
* Sets up the PDO backend used for testing
*
* @return t3lib_cache_backend_PdoBackend
* @author Karsten Dambekalns <karsten@typo3.org>
*/
protected function setUpBackend()
{
$this->fixtureFolder = sys_get_temp_dir() . '/' . 'typo3pdobackendtest/';
t3lib_div::mkdir_deep(sys_get_temp_dir() . '/', 'typo3pdobackendtest/');
$this->fixtureDB = uniqid('Cache') . '.db';
$pdoHelper = t3lib_div::makeInstance('t3lib_PdoHelper', 'sqlite:' . $this->fixtureFolder . $this->fixtureDB, '', '');
$pdoHelper->importSql(PATH_t3lib . 'cache/backend/resources/ddl.sql');
$mockCache = $this->getMock('t3lib_cache_frontend_Frontend', array(), array(), '', FALSE);
$mockCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('TestCache'));
$backendOptions = array('dataSourceName' => 'sqlite:' . $this->fixtureFolder . $this->fixtureDB, 'username' => '', 'password' => '');
$backend = t3lib_div::makeInstance('t3lib_cache_backend_PdoBackend', $backendOptions);
$backend->setCache($mockCache);
return $backend;
}
示例14: getTempUploadFolder
/**
* Searches for upload folder settings in TypoScript setup.
* If no settings is found, the default upload folder is set.
*
* Here is an example:
* <code>
* plugin.Tx_Formhandler.settings.files.tmpUploadFolder = uploads/formhandler/tmp
* </code>
*
* The default upload folder is: '/uploads/formhandler/tmp/'
*
* @return void
* @static
* @author Reinhard Führicht <rf@typoheads.at>
*/
public static function getTempUploadFolder()
{
//set default upload folder
$uploadFolder = '/uploads/formhandler/tmp/';
//if temp upload folder set in TypoScript, take that setting
$settings = Tx_Formhandler_Globals::$session->get('settings');
if ($settings['files.']['uploadFolder']) {
$uploadFolder = Tx_Formhandler_StaticFuncs::getSingle($settings['files.'], 'uploadFolder');
$uploadFolder = Tx_Formhandler_StaticFuncs::sanitizePath($uploadFolder);
}
//if the set directory doesn't exist, print a message and try to create
if (!is_dir(Tx_Formhandler_StaticFuncs::getTYPO3Root() . $uploadFolder)) {
Tx_Formhandler_StaticFuncs::debugMessage('folder_doesnt_exist', array(Tx_Formhandler_StaticFuncs::getTYPO3Root() . '/' . $uploadFolder), 2);
t3lib_div::mkdir_deep(Tx_Formhandler_StaticFuncs::getTYPO3Root() . '/', $uploadFolder);
}
return $uploadFolder;
}
示例15: renderPreProcessorProc
/**
* Main hook function
*
* @param array $params Array of CSS/javascript and other
* files
* @param object $pagerendere Pagerenderer object
* @return null
*
*/
public function renderPreProcessorProc(&$params, $pagerenderer)
{
if (!is_array($params['cssFiles'])) {
return;
}
$setup = $GLOBALS['TSFE']->tmpl->setup;
if (is_array($setup['plugin.']['tx_wsless.']['variables.'])) {
$this->variables = $setup['plugin.']['tx_wsless.']['variables.'];
}
// we need to rebuild the CSS array to keep order of CSS
// files
$cssFiles = array();
foreach ($params['cssFiles'] as $file => $conf) {
$pathinfo = pathinfo($conf['file']);
if ($pathinfo['extension'] !== 'less') {
$cssFiles[$file] = $conf;
continue;
}
$outputdir = $this->defaultoutputdir;
// search settings for less file
foreach ($GLOBALS['TSFE']->pSetup['includeCSS.'] as $key => $subconf) {
if (is_string($GLOBALS['TSFE']->pSetup['includeCSS.'][$key]) && $GLOBALS['TSFE']->tmpl->getFileName($GLOBALS['TSFE']->pSetup['includeCSS.'][$key]) == $file) {
if (isset($GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['outputdir'])) {
$outputdir = trim($GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['outputdir']);
}
}
}
$outputdir = substr($outputdir, -1) == '/' ? $outputdir : $outputdir . "/";
if (!strcmp(substr($outputdir, 0, 4), 'EXT:')) {
$newFile = '';
list($extKey, $script) = explode('/', substr($outputdir, 4), 2);
if ($extKey && \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($extKey)) {
$extPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($extKey);
$outputdir = substr($extPath, strlen(PATH_site)) . $script;
}
}
$lessFilename = t3lib_div::getFileAbsFileName($conf['file']);
// create filename - hash is importand due to the possible
// conflicts with same filename in different folder
t3lib_div::mkdir_deep(PATH_site . $outputdir);
$cssRelativeFilename = $outputdir . $pathinfo['filename'] . ($outputdir == $this->defaultoutputdir ? "_" . hash('sha1', $file) : "") . ".css";
$cssFilename = PATH_site . $cssRelativeFilename;
$cache = $GLOBALS['typo3CacheManager']->getCache('ws_less');
$cacheKey = hash('sha1', $cssRelativeFilename);
$contentHash = $this->calculateContentHash($lessFilename);
$contentHashCache = '';
if ($cache->has($cacheKey)) {
$contentHashCache = $cache->get($cacheKey);
}
try {
if ($contentHashCache == '' || $contentHashCache != $contentHash) {
$this->compileScss($lessFilename, $cssFilename);
}
} catch (Exception $ex) {
// log the exception to the TYPO3 log as error
echo $ex->getMessage();
t3lib_div::sysLog($ex->getMessage(), t3lib_div::SYSLOG_SEVERITY_ERROR);
}
$cache->set($cacheKey, $contentHash, array());
$cssFiles[$cssRelativeFilename] = $params['cssFiles'][$file];
$cssFiles[$cssRelativeFilename]['file'] = $cssRelativeFilename;
}
$params['cssFiles'] = $cssFiles;
}