/** * Calls addJsFile for each file in the given folder on the Instance of TYPO3\CMS\Core\Page\PageRenderer. * * @param string $name the file to include * @param string $extKey the extension, where the file is located * @param string $pathInsideExt the path to the file relative to the ext-folder * @param bool $recursive */ public function render($name = null, $extKey = null, $pathInsideExt = 'Resources/Public/JavaScript/', $recursive = false) { if ($extKey == null) { $extKey = $this->controllerContext->getRequest()->getControllerExtensionKey(); } $extPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($extKey); if (TYPO3_MODE === 'FE') { $extRelPath = substr($extPath, strlen(PATH_site)); } else { $extRelPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($extKey); } $absFolderPath = $extPath . $pathInsideExt . $name; // $files will include all files relative to $pathInsideExt if ($recursive === false) { $files = \TYPO3\CMS\Core\Utility\GeneralUtility::getFilesInDir($absFolderPath); foreach ($files as $hash => $filename) { $files[$hash] = $name . $filename; } } else { $files = \TYPO3\CMS\Core\Utility\GeneralUtility::getAllFilesAndFoldersInPath([], $absFolderPath, '', 0, 99, '\\.svn'); foreach ($files as $hash => $absPath) { $files[$hash] = str_replace($extPath . $pathInsideExt, '', $absPath); } } foreach ($files as $name) { $this->pageRenderer->addJsFile($extRelPath . $pathInsideExt . $name); } }
/** * This test creates an extension based on a JSON file, generated * with version 1.0 of the ExtensionBuilder and compares all * generated files with the originally created ones * This test should help, to find compatibility breaking changes * * @test */ function generateExtensionFromVersion3Configuration() { $this->configurationManager = $this->getMock($this->buildAccessibleProxy('EBT\\ExtensionBuilder\\Configuration\\ConfigurationManager'), array('dummy')); $this->extensionSchemaBuilder = $this->objectManager->get('EBT\\ExtensionBuilder\\Service\\ExtensionSchemaBuilder'); $testExtensionDir = $this->fixturesPath . 'TestExtensions/test_extension_v3/'; $jsonFile = $testExtensionDir . \EBT\ExtensionBuilder\Configuration\ConfigurationManager::EXTENSION_BUILDER_SETTINGS_FILE; if (file_exists($jsonFile)) { // compatibility adaptions for configurations from older versions $extensionConfigurationJSON = json_decode(file_get_contents($jsonFile), TRUE); $extensionConfigurationJSON = $this->configurationManager->fixExtensionBuilderJSON($extensionConfigurationJSON, FALSE); } else { $extensionConfigurationJSON = array(); $this->fail('JSON file not found'); } $this->extension = $this->extensionSchemaBuilder->build($extensionConfigurationJSON); $this->fileGenerator->setSettings(array('codeTemplateRootPath' => PATH_typo3conf . 'ext/extension_builder/Resources/Private/CodeTemplates/Extbase/', 'extConf' => array('enableRoundtrip' => '0'))); $newExtensionDir = vfsStream::url('testDir') . '/'; $this->extension->setExtensionDir($newExtensionDir . 'test_extension/'); $this->fileGenerator->build($this->extension); $referenceFiles = \TYPO3\CMS\Core\Utility\GeneralUtility::getAllFilesAndFoldersInPath(array(), $testExtensionDir); foreach ($referenceFiles as $referenceFile) { $createdFile = str_replace($testExtensionDir, $this->extension->getExtensionDir(), $referenceFile); if (!in_array(basename($createdFile), array('ExtensionBuilder.json'))) { $referenceFileContent = str_replace(array('2011-08-11T06:49:00Z', '2011-08-11', '###YEAR###', '2014'), array(date('Y-m-d\\TH:i:00\\Z'), date('Y-m-d'), date('Y'), date('Y')), file_get_contents($referenceFile)); $this->assertFileExists($createdFile, 'File ' . $createdFile . ' was not created!'); // do not compare files that contain a formatted DateTime, as it might have changed between file creation and this comparison if (strpos($referenceFile, 'xlf') === FALSE && strpos($referenceFile, 'yaml') === FALSE) { $originalLines = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, $referenceFileContent, TRUE); $generatedLines = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, file_get_contents($createdFile), TRUE); $this->assertEquals($originalLines, $generatedLines, 'File ' . $createdFile . ' was not equal to original file.'); } } } }
/** * create zip from created font * * @param object $currentFont * @return string */ public static function createZip($currentFont) { // general vars $cleanTitle = strtolower(preg_replace(array('/\\s+/', '/[^a-zA-Z0-9]/'), array('-', ''), $currentFont->getTitle())); $fontPath = PATH_site . 'fileadmin/' . $currentFont->getDestination() . $cleanTitle . '/'; $fileName = $destinationPath = PATH_site . 'fileadmin/' . $currentFont->getDestination() . $cleanTitle . '_' . $currentFont->getVersion() . '_' . date('YmdHi', $GLOBALS['EXEC_TIME']) . '.zip'; $zip = new \ZipArchive(); $zip->open($fileName, \ZipArchive::CREATE); // Get all the files of the extension, but exclude the ones specified in the excludePattern $files = GeneralUtility::getAllFilesAndFoldersInPath(array(), $fontPath, '', TRUE, PHP_INT_MAX); // Make paths relative to extension root directory. $files = GeneralUtility::removePrefixPathFromList($files, $fontPath); // Remove the one empty path that is the extension dir itself. $files = array_filter($files); foreach ($files as $file) { $fullPath = $fontPath . $file; // Distinguish between files and directories, as creation of the archive // fails on Windows when trying to add a directory with "addFile". if (is_dir($fullPath)) { $zip->addEmptyDir($file); } else { $zip->addFile($fullPath, $file); } } $zip->close(); return $fileName; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $icons = []; if (!class_exists('TYPO3\\CMS\\Core\\Imaging\\IconRegistry')) { return $icons; } $iconFolder = 'Resources/Public/Icon/'; $folder = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . $iconFolder; $extensionPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()); $files = GeneralUtility::getAllFilesAndFoldersInPath([], $folder, '', false, true); if (!sizeof($files)) { return $icons; } foreach ($files as $path) { $provider = 'TYPO3\\CMS\\Core\\Imaging\\IconProvider\\BitmapIconProvider'; if (substr(strtolower($path), -3) === 'svg') { $provider = 'TYPO3\\CMS\\Core\\Imaging\\IconProvider\\SvgIconProvider'; } $relativePath = str_replace($extensionPath, '', $path); $iconPath = str_replace($iconFolder, '', $relativePath); $pathElements = PathUtility::pathinfo(strtolower(str_replace('/', '-', $iconPath))); $icons[] = ['provider' => $provider, 'path' => 'EXT:' . $loader->getExtensionKey() . '/' . $relativePath, 'identifier' => str_replace('_', '-', $loader->getExtensionKey()) . '-' . $pathElements['filename']]; } return $icons; }
/** * Get all class names inside this namespace and return them as array. * * @param string $combinedExtensionKey Extension Key with (possibly) leading Vendor Prefix * @return array */ protected function getClassNamesInExtension($combinedExtensionKey) { $allViewHelperClassNames = array(); list($vendor, $extensionKey) = $this->getRealExtensionKeyAndVendorFromCombinedExtensionKey($combinedExtensionKey); $path = ExtensionManagementUtility::extPath($extensionKey, 'Classes/ViewHelpers/'); $filesInPath = GeneralUtility::getAllFilesAndFoldersInPath(array(), $path, 'php'); foreach ($filesInPath as $filePathAndFilename) { $className = $this->getRealClassNameBasedOnExtensionAndFilenameAndExistence($combinedExtensionKey, $filePathAndFilename); if (class_exists($className)) { $parent = $className; while ($parent = get_parent_class($parent)) { array_push($allViewHelperClassNames, $className); } } } $affectedViewHelperClassNames = array(); foreach ($allViewHelperClassNames as $viewHelperClassName) { $classReflection = new \ReflectionClass($viewHelperClassName); if ($classReflection->isAbstract() === TRUE) { continue; } $affectedViewHelperClassNames[] = $viewHelperClassName; } sort($affectedViewHelperClassNames); return $affectedViewHelperClassNames; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $autoLoader * @param int $type * * @return array */ public function prepareLoader(Loader $autoLoader, $type) { $languageOverride = []; if ($type === LoaderInterface::EXT_TABLES) { return $languageOverride; } $languageOverridePath = ExtensionManagementUtility::extPath($autoLoader->getExtensionKey()) . 'Resources/Private/Language/Overrides/'; if (!is_dir($languageOverridePath)) { return $languageOverride; } $files = GeneralUtility::getAllFilesAndFoldersInPath([], $languageOverridePath, 'xlf,php,xml', false, 99); foreach ($files as $file) { $file = str_replace($languageOverridePath, '', $file); $parts = GeneralUtility::trimExplode('/', $file, true); $extension = GeneralUtility::camelCaseToLowerCaseUnderscored($parts[0]); unset($parts[0]); $parts = array_values($parts); // language $language = 'default'; $fileParts = GeneralUtility::trimExplode('.', PathUtility::basename($file), true); if (strlen($fileParts[0]) === 2) { $language = $fileParts[0]; unset($fileParts[0]); $parts[sizeof($parts) - 1] = implode('.', $fileParts); } $languageOverride[] = ['language' => $language, 'original' => 'EXT:' . $extension . '/' . implode('/', $parts), 'override' => 'EXT:' . $autoLoader->getExtensionKey() . '/Resources/Private/Language/Overrides/' . $file]; } return $languageOverride; }
/** * @param string $path * @param string $extensions * @return array */ public static function getFilesRecursive($path, $extensions) { if ('/' !== substr($path, -1)) { $path .= '/'; } $files = GeneralUtility::getAllFilesAndFoldersInPath(array(), $path, $extensions); return array_values($files); }
/** * Find lost files in uploads/ folder * FIX METHOD: Simply delete the file... * * TODO: Add parameter to exclude filepath * TODO: Add parameter to list more file names/patterns to ignore * TODO: Add parameter to include RTEmagic images * * @return array * @todo Define visibility */ public function main() { global $TYPO3_DB; // Initialize result array: $resultArray = array('message' => $this->cli_help['name'] . LF . LF . $this->cli_help['description'], 'headers' => array('managedFiles' => array('Files related to TYPO3 records and managed by TCEmain', 'These files you definitely want to keep.', 0), 'ignoredFiles' => array('Ignored files (index.html, .htaccess etc.)', 'These files are allowed in uploads/ folder', 0), 'RTEmagicFiles' => array('RTE magic images - those found (and ignored)', 'These files are also allowed in some uploads/ folders as RTEmagic images.', 0), 'lostFiles' => array('Lost files - those you can delete', 'You can delete these files!', 3), 'warnings' => array('Warnings picked up', '', 2)), 'managedFiles' => array(), 'ignoredFiles' => array(), 'RTEmagicFiles' => array(), 'lostFiles' => array(), 'warnings' => array()); // Get all files: $fileArr = array(); $fileArr = \TYPO3\CMS\Core\Utility\GeneralUtility::getAllFilesAndFoldersInPath($fileArr, PATH_site . 'uploads/'); $fileArr = \TYPO3\CMS\Core\Utility\GeneralUtility::removePrefixPathFromList($fileArr, PATH_site); $excludePaths = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->cli_argValue('--excludePath', 0), TRUE); // Traverse files and for each, look up if its found in the reference index. foreach ($fileArr as $key => $value) { $include = TRUE; foreach ($excludePaths as $exclPath) { if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($value, $exclPath)) { $include = FALSE; } } $shortKey = \TYPO3\CMS\Core\Utility\GeneralUtility::shortmd5($value); if ($include) { // First, allow "index.html", ".htaccess" files since they are often used for good reasons if (substr($value, -11) == '/index.html' || substr($value, -10) == '/.htaccess') { unset($fileArr[$key]); $resultArray['ignoredFiles'][$shortKey] = $value; } else { // Looking for a reference from a field which is NOT a soft reference (thus, only fields with a proper TCA/Flexform configuration) $recs = $TYPO3_DB->exec_SELECTgetRows('*', 'sys_refindex', 'ref_table=' . $TYPO3_DB->fullQuoteStr('_FILE', 'sys_refindex') . ' AND ref_string=' . $TYPO3_DB->fullQuoteStr($value, 'sys_refindex') . ' AND softref_key=' . $TYPO3_DB->fullQuoteStr('', 'sys_refindex'), '', 'sorting DESC'); // If found, unset entry: if (count($recs)) { unset($fileArr[$key]); $resultArray['managedFiles'][$shortKey] = $value; if (count($recs) > 1) { $resultArray['warnings'][$shortKey] = 'Warning: File "' . $value . '" had ' . count($recs) . ' references from group-fields, should have only one!'; } } else { // When here it means the file was not found. So we test if it has a RTEmagic-image name and if so, we allow it: if (preg_match('/^RTEmagic[P|C]_/', basename($value))) { unset($fileArr[$key]); $resultArray['RTEmagicFiles'][$shortKey] = $value; } else { // We conclude that the file is lost...: unset($fileArr[$key]); $resultArray['lostFiles'][$shortKey] = $value; } } } } } asort($resultArray['ignoredFiles']); asort($resultArray['managedFiles']); asort($resultArray['RTEmagicFiles']); asort($resultArray['lostFiles']); asort($resultArray['warnings']); // $fileArr variable should now be empty with all contents transferred to the result array keys. return $resultArray; }
/** * @param string $path * @param array $excludePattern * @return array */ public function getChecksumsForPath($path, array $excludePattern = array()) { // Always ensure trailing slash // This is needed for relative path calculation $path = rtrim($path, '/') . '/'; $md5ChecksumArray = array(); $filesArray = GeneralUtility::getAllFilesAndFoldersInPath(array(), $path, '', false, 99, $this->generateExcludeExpression($excludePattern)); foreach ($filesArray as $file) { $relativeFileName = substr($file, strlen($path)); $fileContent = GeneralUtility::getUrl($file); $md5ChecksumArray[$relativeFileName] = substr(md5($fileContent), 0, 4); } return $md5ChecksumArray; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $tsConfiguration = []; $extPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()); $baseDir = $extPath . 'Configuration/TypoScript/'; if (!is_dir($baseDir)) { return $tsConfiguration; } $typoScriptFolder = GeneralUtility::getAllFilesAndFoldersInPath([], $baseDir, '', true, 99, '(.*)\\.(.*)'); $extensionName = GeneralUtility::underscoredToUpperCamelCase($loader->getExtensionKey()); foreach ($typoScriptFolder as $folder) { if (is_file($folder . 'setup.txt') || is_file($folder . 'constants.txt')) { $setupName = $extensionName . '/' . str_replace($baseDir, '', $folder); $setupName = implode(' - ', GeneralUtility::trimExplode('/', $setupName, true)); $folder = str_replace($extPath, '', $folder); $tsConfiguration[] = ['path' => $folder, 'title' => $setupName]; } } return $tsConfiguration; }
/** * Renders a Fluid Template Layout select field * * @param array $parameters * @param mixed $pObj * @return string */ public function addLayoutOptions(&$parameters, &$pObj) { $referringField = $parameters['config']['arguments']['referring_field']; $currentValue = $parameters['row'][$referringField]; $configuration = $this->configurationService->getViewConfigurationByFileReference($currentValue); $layoutRootPath = $configuration['layoutRootPath']; $layoutRootPath = GeneralUtility::getFileAbsFileName($layoutRootPath); $files = array(); $files = TRUE === is_dir($layoutRootPath) ? GeneralUtility::getAllFilesAndFoldersInPath($files, $layoutRootPath) : array(); foreach ($files as $file) { $file = substr($file, strlen($layoutRootPath)); if (0 !== strpos($file, '.')) { $dir = pathinfo($file, PATHINFO_DIRNAME); $file = pathinfo($file, PATHINFO_FILENAME); if ('.' !== $dir) { $file = $dir . '/' . $file; } array_push($parameters['items'], array($file, $file)); } } }
/** * Create a zip file from an extension * * @param array $extension * @return string Name and path of create zip file */ public function createZipFileFromExtension($extension) { $extensionPath = $this->getAbsoluteExtensionPath($extension); // Add trailing slash to the extension path, getAllFilesAndFoldersInPath explicitly requires that. $extensionPath = PathUtility::sanitizeTrailingSeparator($extensionPath); $version = $this->getExtensionVersion($extension); if (empty($version)) { $version = '0.0.0'; } if (!@is_dir(PATH_site . 'typo3temp/ExtensionManager/')) { GeneralUtility::mkdir(PATH_site . 'typo3temp/ExtensionManager/'); } $fileName = $this->getAbsolutePath('typo3temp/ExtensionManager/' . $extension . '_' . $version . '_' . date('YmdHi', $GLOBALS['EXEC_TIME']) . '.zip'); $zip = new \ZipArchive(); $zip->open($fileName, \ZipArchive::CREATE); $excludePattern = $GLOBALS['TYPO3_CONF_VARS']['EXT']['excludeForPackaging']; // Get all the files of the extension, but exclude the ones specified in the excludePattern $files = GeneralUtility::getAllFilesAndFoldersInPath(array(), $extensionPath, '', true, PHP_INT_MAX, $excludePattern); // Make paths relative to extension root directory. $files = GeneralUtility::removePrefixPathFromList($files, $extensionPath); // Remove the one empty path that is the extension dir itself. $files = array_filter($files); foreach ($files as $file) { $fullPath = $extensionPath . $file; // Distinguish between files and directories, as creation of the archive // fails on Windows when trying to add a directory with "addFile". if (is_dir($fullPath)) { $zip->addEmptyDir($file); } else { $zip->addFile($fullPath, $file); } } $zip->close(); return $fileName; }
/** * Indexing files from fileadmin * * @param array $cfgRec Indexing Configuration Record * @param array $session_data Session data for the indexing session spread over multiple instances of the script. Passed by reference so changes hereto will be saved for the next call! * @param array $params Parameters from the log queue. * @param object $pObj Parent object (from "crawler" extension!) * @return void */ public function crawler_execute_type2($cfgRec, &$session_data, $params, &$pObj) { // Prepare path, making it absolute and checking: $readpath = $params['url']; if (!GeneralUtility::isAbsPath($readpath)) { $readpath = GeneralUtility::getFileAbsFileName($readpath); } if (GeneralUtility::isAllowedAbsPath($readpath)) { if (@is_file($readpath)) { // If file, index it! // Get root line (need to provide this when indexing external files) $rl = $this->getUidRootLineForClosestTemplate($cfgRec['pid']); // (Re)-Indexing file on page. $indexerObj = GeneralUtility::makeInstance(\TYPO3\CMS\IndexedSearch\Indexer::class); $indexerObj->backend_initIndexer($cfgRec['pid'], 0, 0, '', $rl); $indexerObj->backend_setFreeIndexUid($cfgRec['uid'], $cfgRec['set_id']); $indexerObj->hash['phash'] = -1; // EXPERIMENT - but to avoid phash_t3 being written to file sections (otherwise they are removed when page is reindexed!!!) // Index document: $indexerObj->indexRegularDocument(\TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($readpath), TRUE); } elseif (@is_dir($readpath)) { // If dir, read content and create new pending items for log: // Select files and directories in path: $extList = implode(',', GeneralUtility::trimExplode(',', $cfgRec['extensions'], TRUE)); $fileArr = array(); $files = GeneralUtility::getAllFilesAndFoldersInPath($fileArr, $readpath, $extList, 0, 0); $directoryList = GeneralUtility::get_dirs($readpath); if (is_array($directoryList) && $params['depth'] < $cfgRec['depth']) { foreach ($directoryList as $subdir) { if ((string) $subdir != '') { $files[] = $readpath . $subdir . '/'; } } } $files = GeneralUtility::removePrefixPathFromList($files, PATH_site); // traverse the items and create log entries: foreach ($files as $path) { $this->instanceCounter++; if ($path !== $params['url']) { // Parameters: $nparams = array('indexConfigUid' => $cfgRec['uid'], 'url' => $path, 'procInstructions' => array('[Index Cfg UID#' . $cfgRec['uid'] . ']'), 'depth' => $params['depth'] + 1); $pObj->addQueueEntry_callBack($cfgRec['set_id'], $nparams, $this->callBack, $cfgRec['pid'], $GLOBALS['EXEC_TIME'] + $this->instanceCounter * $this->secondsPerExternalUrl); } } } } }
/** * @test */ public function getAllFilesAndFoldersInPathReturnsArrayWithMd5Keys() { $directory = PATH_site . 'typo3temp/' . $this->getUniqueId('directory_'); mkdir($directory); $filesAndDirectories = GeneralUtility::getAllFilesAndFoldersInPath(array(), $directory, '', true); $check = true; foreach ($filesAndDirectories as $md5 => $path) { if (!preg_match('/^[a-f0-9]{32}$/', $md5)) { $check = false; } } GeneralUtility::rmdir($directory); $this->assertTrue($check); }
/** * @validate $syntax NotEmpty * @validate $extensions NotEmpty * @validate $formats NotEmpty * @ignorevalidation $filteredFiles * @param array $syntax * @param array $extensions * @param array $formats * @param array $filteredFiles */ public function syntaxAction(array $syntax, array $extensions, array $formats, array $filteredFiles = []) { /** @var DocumentTemplate $document */ $document =& $GLOBALS['TBE_TEMPLATE']; $resourcePath = $document->backPath . ExtensionManagementUtility::extRelPath('builder') . 'Resources/Public/'; $pageRenderer = new PageRenderer(); $pageRenderer->addJsFile($resourcePath . 'Javascript/jqplot.min.js'); $pageRenderer->addJsFile($resourcePath . 'Javascript/jqplot.canvasTextRenderer.min.js'); $pageRenderer->addJsFile($resourcePath . 'Javascript/jqplot.canvasAxisTickRenderer.min.js'); $pageRenderer->addJsFile($resourcePath . 'Javascript/jqplot.cursor.min.js'); $pageRenderer->addJsFile($resourcePath . 'Javascript/jqplot.categoryAxisRenderer.min.js'); $pageRenderer->addJsFile($resourcePath . 'Javascript/jqplot.barRenderer.min.js'); $pageRenderer->addJsFile($resourcePath . 'Javascript/jqplot.pointLabels.min.js'); $pageRenderer->addJsFile($resourcePath . 'Javascript/plotter.js'); $reports = []; $csvFormats = trim(implode(',', $formats), ','); foreach ($extensions as $extensionKey) { if (true === empty($extensionKey)) { continue; } $extensionFolder = ExtensionManagementUtility::extPath($extensionKey); $reports[$extensionKey] = []; foreach ($syntax as $syntaxName) { if (true === empty($syntaxName)) { continue; } $reportsForSyntaxName = []; if ('php' === $syntaxName) { $reportsForSyntaxName = $this->syntaxService->syntaxCheckPhpFilesInPath($extensionFolder . '/Classes'); } elseif ('fluid' === $syntaxName) { $reportsForSyntaxName = $this->syntaxService->syntaxCheckFluidTemplateFilesInPath($extensionFolder . '/Resources', $csvFormats); } elseif ('profile' === $syntaxName) { $files = GeneralUtility::getAllFilesAndFoldersInPath([], $extensionFolder, $csvFormats); if (0 === count($filteredFiles)) { $filteredFiles = $files; } $this->view->assign('files', $files); $this->view->assign('basePathLength', strlen($extensionFolder . '/Resources/Private')); foreach ($files as $file) { if (0 < count($filteredFiles) && false === in_array($file, $filteredFiles)) { continue; } $shortFilename = substr($file, strlen($extensionFolder . '/Resources/Private')); /** @var TemplateAnalyzer $templateAnalyzer */ $templateAnalyzer = $this->objectManager->get(TemplateAnalyzer::class); $reportsForSyntaxName[$shortFilename] = $templateAnalyzer->analyzePathAndFilename($file); } $reports[$extensionKey][$syntaxName]['json'] = $this->encodeMetricsToJson($reportsForSyntaxName); } $reports[$extensionKey][$syntaxName]['reports'] = $reportsForSyntaxName; $reports[$extensionKey][$syntaxName]['errors'] = $this->syntaxService->countErrorsInResultCollection($reportsForSyntaxName); } } $this->view->assign('filteredFiles', $filteredFiles); $this->view->assign('reports', $reports); $this->view->assign('extensions', $extensions); $this->view->assign('formats', $formats); $this->view->assign('syntax', $syntax); $this->view->assign('view', 'Index'); }
/** * get files from given relative directory path array * @param array $directoryArray * @return array An Array containing all files of all valid directories */ public function getFilesFromDirectories(array $directoryArray) { $directoryArray = $this->getAbsoluteDirectoryPath($directoryArray); if (is_array($directoryArray) && count($directoryArray)) { $files = array(); foreach ($directoryArray as $directory) { $foundFiles = GeneralUtility::getAllFilesAndFoldersInPath(array(), $directory, $this->indexerConfig['fileext']); if (is_array($foundFiles) && count($foundFiles)) { foreach ($foundFiles as $file) { $files[] = $file; } } } return $files; } else { return array(); } }
} break; } } } exit; break; case 'admin_upload_redactor': if ($this->ADMIN_USER) { $continueUpload = 0; switch ($this->get['tx_multishop_pi1']['redactorType']) { case 'imageGetJson': $fileUploadPathRelative = 'uploads/tx_multishop/images/cmsimages'; $fileUploadPathAbsolute = $this->DOCUMENT_ROOT . $fileUploadPathRelative; if (is_dir($fileUploadPathAbsolute)) { $items = \TYPO3\CMS\Core\Utility\GeneralUtility::getAllFilesAndFoldersInPath(array(), $fileUploadPathAbsolute . '/'); if (count($items)) { $array = array(); foreach ($items as $item) { $path_parts = pathinfo($item); $file = array(); $file['title'] = $path_parts['filename']; $file['thumb'] = str_replace($this->DOCUMENT_ROOT, '', $item); $file['image'] = $file['thumb']; $file['folder'] = str_replace($fileUploadPathAbsolute, '', $path_parts['dirname']); $array[] = $file; } echo htmlspecialchars(json_encode($array), ENT_NOQUOTES); } } exit;
/** * Get all class names inside this namespace and return them as array. * * @param string $combinedExtensionKey Extension Key with (possibly) leading Vendor Prefix * @return array */ protected function getClassNamesInExtension($combinedExtensionKey) { $allViewHelperClassNames = []; list($vendor, $extensionKey) = $this->getRealExtensionKeyAndVendorFromCombinedExtensionKey($combinedExtensionKey); $path = ExtensionManagementUtility::extPath($extensionKey, 'Classes/ViewHelpers/'); $filesInPath = GeneralUtility::getAllFilesAndFoldersInPath([], $path, 'php'); foreach ($filesInPath as $filePathAndFilename) { $className = $this->getRealClassNameBasedOnExtensionAndFilenameAndExistence($combinedExtensionKey, $filePathAndFilename); if (class_exists($className)) { $parent = $className; while ($parent = get_parent_class($parent)) { if ($parent === 'TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper' || $parent === 'TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\AbstractViewHelper') { array_push($allViewHelperClassNames, $className); } } } } $affectedViewHelperClassNames = []; foreach ($allViewHelperClassNames as $viewHelperClassName) { $classReflection = new \ReflectionClass($viewHelperClassName); if ($classReflection->isAbstract() === true) { continue; } $namespace = $classReflection->getNamespaceName(); if (strncmp($namespace, $viewHelperClassName, strlen($namespace)) === 0) { $affectedViewHelperClassNames[] = $viewHelperClassName; } } sort($affectedViewHelperClassNames); return $affectedViewHelperClassNames; }
/** * Finds all files that are named like test files in the directory $directory * and recursively all its subdirectories. * * @param string $directory * the absolute path of the directory in which to look for test cases * * @return string[] * sorted file names of the test cases in the directory $directory relative * to $directory, will be empty if no test cases have been found * * @throws InvalidArgumentException */ public function findTestCaseFilesInDirectory($directory) { if ($directory === '') { throw new InvalidArgumentException('$directory must not be empty.', 1334439798); } if (!is_dir($directory)) { throw new InvalidArgumentException('The directory ' . $directory . ' does not exist.', 1334439804); } if (!is_readable($directory)) { throw new InvalidArgumentException('The directory ' . $directory . ' exists, but is not readable.', 1334439813); } $directoryLength = strlen($directory); $testFiles = array(); $allPhpFiles = GeneralUtility::getAllFilesAndFoldersInPath(array(), $directory, 'php'); foreach ($allPhpFiles as $filePath) { if ($this->isNotFixturesPath($filePath) && $this->isTestCaseFileName($filePath)) { $testFiles[] = substr($filePath, $directoryLength); } } sort($testFiles, SORT_STRING); return $testFiles; }
/** * Warm up essential caches such as class and core caches * * @param bool $triggerRequire * @return bool */ public function warmupEssentialCaches($triggerRequire = FALSE) { try { $this->cacheManager->getCache('cache_classes'); } catch (NoSuchCacheException $e) { $this->logger->warning('Warmup skipped due to lack of classes cache'); return FALSE; } // TODO: This currently only builds the classes cache! Find a way to build other system caches as well (like reflection caches, datamap caches …) // package namespace and aliases caches are implicitly built in extended bootstrap before we reach this point $phpParser = new PhpParser(); foreach ($this->packageManager->getActivePackages() as $package) { $classFiles = GeneralUtility::getAllFilesAndFoldersInPath(array(), $package->getClassesPath(), 'php'); foreach ($classFiles as $classFile) { try { $parsedResult = $phpParser->parseClassFile($classFile); $this->writeCacheEntryForClass($parsedResult->getFullyQualifiedClassName(), $classFile); } catch (ParsingException $e) { $this->logger->warning('Class file "' . PathUtility::stripPathSitePrefix($classFile) . '" does not contain a class definition. Skipping …'); } } } $this->packageManager->injectCoreCache($this->cacheManager->getCache('cache_core')); $this->packageManager->populatePackageCache(); return TRUE; }
/** * Add selector box items of more exotic kinds. * * @param array $items The array of items (label,value,icon) * @param array $fieldValue The "columns" array for the field (from TCA) * @param array $TSconfig TSconfig for the table/row * @param string $field The fieldname * @return array The $items array modified. * @todo Define visibility */ public function addSelectOptionsToItemArray($items, $fieldValue, $TSconfig, $field) { // Values from foreign tables: if ($fieldValue['config']['foreign_table']) { $items = $this->foreignTable($items, $fieldValue, $TSconfig, $field); if ($fieldValue['config']['neg_foreign_table']) { $items = $this->foreignTable($items, $fieldValue, $TSconfig, $field, 1); } } // Values from a file folder: if ($fieldValue['config']['fileFolder']) { $fileFolder = GeneralUtility::getFileAbsFileName($fieldValue['config']['fileFolder']); if (@is_dir($fileFolder)) { // Configurations: $extList = $fieldValue['config']['fileFolder_extList']; $recursivityLevels = isset($fieldValue['config']['fileFolder_recursions']) ? MathUtility::forceIntegerInRange($fieldValue['config']['fileFolder_recursions'], 0, 99) : 99; // Get files: $fileFolder = rtrim($fileFolder, '/') . '/'; $fileArr = GeneralUtility::getAllFilesAndFoldersInPath(array(), $fileFolder, $extList, 0, $recursivityLevels); $fileArr = GeneralUtility::removePrefixPathFromList($fileArr, $fileFolder); foreach ($fileArr as $fileRef) { $fI = pathinfo($fileRef); $icon = GeneralUtility::inList('gif,png,jpeg,jpg', strtolower($fI['extension'])) ? '../' . PathUtility::stripPathSitePrefix($fileFolder) . $fileRef : ''; $items[] = array($fileRef, $fileRef, $icon); } } } // If 'special' is configured: if ($fieldValue['config']['special']) { $lang = $this->getLanguageService(); switch ($fieldValue['config']['special']) { case 'tables': $temp_tc = array_keys($GLOBALS['TCA']); foreach ($temp_tc as $theTableNames) { if (!$GLOBALS['TCA'][$theTableNames]['ctrl']['adminOnly']) { // Icon: $icon = IconUtility::mapRecordTypeToSpriteIconName($theTableNames, array()); // Add help text $helpText = array(); $lang->loadSingleTableDescription($theTableNames); $helpTextArray = $GLOBALS['TCA_DESCR'][$theTableNames]['columns']['']; if (!empty($helpTextArray['description'])) { $helpText['description'] = $helpTextArray['description']; } // Item configuration: $items[] = array($this->sL($GLOBALS['TCA'][$theTableNames]['ctrl']['title']), $theTableNames, $icon, $helpText); } } break; case 'pagetypes': $theTypes = $GLOBALS['TCA']['pages']['columns']['doktype']['config']['items']; foreach ($theTypes as $theTypeArrays) { // Icon: $icon = 'empty-emtpy'; if ($theTypeArrays[1] != '--div--') { $icon = IconUtility::mapRecordTypeToSpriteIconName('pages', array('doktype' => $theTypeArrays[1])); } // Item configuration: $items[] = array($this->sL($theTypeArrays[0]), $theTypeArrays[1], $icon); } break; case 'exclude': $theTypes = BackendUtility::getExcludeFields(); foreach ($theTypes as $theTypeArrays) { list($theTable, $theFullField) = explode(':', $theTypeArrays[1]); // If the field comes from a FlexForm, the syntax is more complex $theFieldParts = explode(';', $theFullField); $theField = array_pop($theFieldParts); // Add header if not yet set for table: if (!array_key_exists($theTable, $items)) { $icon = IconUtility::mapRecordTypeToSpriteIconName($theTable, array()); $items[$theTable] = array($this->sL($GLOBALS['TCA'][$theTable]['ctrl']['title']), '--div--', $icon); } // Add help text $helpText = array(); $lang->loadSingleTableDescription($theTable); $helpTextArray = $GLOBALS['TCA_DESCR'][$theTable]['columns'][$theFullField]; if (!empty($helpTextArray['description'])) { $helpText['description'] = $helpTextArray['description']; } // Item configuration: $items[] = array(rtrim($lang->sl($GLOBALS['TCA'][$theTable]['columns'][$theField]['label']), ':') . ' (' . $theField . ')', $theTypeArrays[1], 'empty-empty', $helpText); } break; case 'explicitValues': $theTypes = BackendUtility::getExplicitAuthFieldValues(); // Icons: $icons = array('ALLOW' => 'status-status-permission-granted', 'DENY' => 'status-status-permission-denied'); // Traverse types: foreach ($theTypes as $tableFieldKey => $theTypeArrays) { if (is_array($theTypeArrays['items'])) { // Add header: $items[] = array($theTypeArrays['tableFieldLabel'], '--div--'); // Traverse options for this field: foreach ($theTypeArrays['items'] as $itemValue => $itemContent) { // Add item to be selected: $items[] = array('[' . $itemContent[2] . '] ' . $itemContent[1], $tableFieldKey . ':' . preg_replace('/[:|,]/', '', $itemValue) . ':' . $itemContent[0], $icons[$itemContent[0]]); } } } break; case 'languages': $items = array_merge($items, BackendUtility::getSystemLanguages()); break; case 'custom': // Initialize: $customOptions = $GLOBALS['TYPO3_CONF_VARS']['BE']['customPermOptions']; if (is_array($customOptions)) { foreach ($customOptions as $coKey => $coValue) { if (is_array($coValue['items'])) { // Add header: $items[] = array($lang->sl($coValue['header']), '--div--'); // Traverse items: foreach ($coValue['items'] as $itemKey => $itemCfg) { // Icon: if ($itemCfg[1]) { list($icon) = $this->getIcon($itemCfg[1]); } else { $icon = 'empty-empty'; } // Add help text $helpText = array(); if (!empty($itemCfg[2])) { $helpText['description'] = $lang->sl($itemCfg[2]); } // Add item to be selected: $items[] = array($lang->sl($itemCfg[0]), $coKey . ':' . preg_replace('/[:|,]/', '', $itemKey), $icon, $helpText); } } } } break; case 'modListGroup': case 'modListUser': $loadModules = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Module\\ModuleLoader'); $loadModules->load($GLOBALS['TBE_MODULES']); $modList = $fieldValue['config']['special'] == 'modListUser' ? $loadModules->modListUser : $loadModules->modListGroup; if (is_array($modList)) { foreach ($modList as $theMod) { // Icon: $icon = $lang->moduleLabels['tabs_images'][$theMod . '_tab']; if ($icon) { $icon = '../' . PathUtility::stripPathSitePrefix($icon); } // Add help text $helpText = array('title' => $lang->moduleLabels['labels'][$theMod . '_tablabel'], 'description' => $lang->moduleLabels['labels'][$theMod . '_tabdescr']); // Item configuration: $items[] = array($this->addSelectOptionsToItemArray_makeModuleData($theMod), $theMod, $icon, $helpText); } } break; } } // Return the items: return $items; }
/** * generate the folder structure for reST documentation */ protected function generateDocumentationFiles() { $this->mkdir_deep($this->extensionDirectory, 'Documentation.tmpl'); $docFiles = array(); $docFiles = GeneralUtility::getAllFilesAndFoldersInPath($docFiles, ExtensionManagementUtility::extPath('extension_builder') . 'Resources/Private/CodeTemplates/Extbase/Documentation.tmpl/', '', true, 5, '.*(rstt|ymlt)'); foreach ($docFiles as $docFile) { if (is_dir($docFile)) { $this->mkdir_deep($this->extensionDirectory, 'Documentation.tmpl/' . str_replace($this->codeTemplateRootPath . 'Documentation.tmpl/', '', $docFile)); } elseif (strpos($docFile, '.rstt') === false && strpos($docFile, '.ymlt') === false) { $this->upload_copy_move($docFile, str_replace(ExtensionManagementUtility::extPath('extension_builder') . 'Resources/Private/CodeTemplates/Extbase/', $this->extensionDirectory, $docFile)); } } $fileContents = $this->renderTemplate('Documentation.tmpl/Index.rstt', array('extension' => $this->extension)); $this->writeFile($this->extensionDirectory . 'Documentation.tmpl/Index.rst', $fileContents); $fileContents = $this->renderTemplate('Documentation.tmpl/Settings.ymlt', array('extension' => $this->extension)); $this->writeFile($this->extensionDirectory . 'Documentation.tmpl/Settings.yml', $fileContents); }
/** * @param array $exclude * @throws Exception */ public function patchPiwik($exclude = array()) { if (!is_writeable($this->getAbsInstallPath())) { throw new \Exception('Installation is invalid, ' . $this->getAbsInstallPath() . ' was not writeable for applying the patches'); } //recursive directory copy is not supported under windows ... so i implement is myself!!! $source = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('piwikintegration') . 'piwik_patches/'; $dest = $this->getAbsInstallPath() . 'piwik/'; $cmd = array(); $t = \TYPO3\CMS\Core\Utility\GeneralUtility::getAllFilesAndFoldersInPath(array(), $source, '', TRUE, 99); foreach ($t as $entry) { $shortEntry = str_replace($source, '', $entry); if ($shortEntry != '' && $shortEntry != '.') { if (!in_array($shortEntry, $exclude)) { if (is_dir($entry)) { $cmd['newfolder'][] = array('data' => basename($shortEntry), 'target' => dirname($dest . $shortEntry)); @mkdir($dest . $shortEntry); } elseif (is_file($entry)) { $cmd['copy'][] = array('data' => $entry, 'target' => $dest . $shortEntry); @copy($entry, $dest . $shortEntry); } } } } //store information about the last patch process $_EXTKEY = 'piwikintegration'; $EM_CONF = array(); @(include \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('piwikintegration') . 'ext_emconf.php'); $data = '<?php $piwikPatchVersion = "' . $EM_CONF['piwikintegration']['version'] . '"; ' . chr(63) . '>'; file_put_contents($this->getAbsInstallPath() . 'piwik/piwikintegration.php', $data); }
/** * Get all base file names in the given directory with the given file extension * Check also if the directory exists. If you scan the dir recursively you get * also the folder name. The filename is also "basename" only. * * @param string $dirPath * @param string $fileExtensions * @param bool $recursively * * @return array */ public static function getBaseFilesRecursivelyInDir($dirPath, $fileExtensions, $recursively = true) { if (!is_dir($dirPath)) { return []; } $recursively = $recursively ? 99 : 0; $files = GeneralUtility::getAllFilesAndFoldersInPath([], $dirPath, $fileExtensions, false, $recursively); foreach ($files as $key => $file) { $pathInfo = PathUtility::pathinfo($file); $files[$key] = $pathInfo['dirname'] . '/' . $pathInfo['filename']; } $files = GeneralUtility::removePrefixPathFromList($files, $dirPath); return array_values($files); }
/** * @return Form[][] */ public function getContentElementFormInstances() { $elements = array(); $allTemplatePaths = $this->getContentConfiguration(); $controllerName = 'Content'; foreach ($allTemplatePaths as $registeredExtensionKey => $templatePathSet) { $files = array(); $extensionKey = TRUE === isset($templatePathSet['extensionKey']) ? $templatePathSet['extensionKey'] : $registeredExtensionKey; $extensionKey = ExtensionNamingUtility::getExtensionKey($extensionKey); $templatePaths = new TemplatePaths($templatePathSet); $viewContext = new ViewContext(NULL, $extensionKey); $viewContext->setTemplatePaths($templatePaths); $viewContext->setSectionName('Configuration'); foreach ($templatePaths->getTemplateRootPaths() as $templateRootPath) { $files = GeneralUtility::getAllFilesAndFoldersInPath($files, $templateRootPath . '/' . $controllerName . '/', 'html'); if (0 < count($files)) { foreach ($files as $templateFilename) { $actionName = pathinfo($templateFilename, PATHINFO_FILENAME); $fileRelPath = $actionName . '.html'; $viewContext->setTemplatePathAndFilename($templateFilename); $form = $this->getFormFromTemplateFile($viewContext); if (TRUE === empty($form)) { $this->sendDisabledContentWarning($templateFilename); continue; } if (FALSE === $form->getEnabled()) { $this->sendDisabledContentWarning($templateFilename); continue; } $id = preg_replace('/[\\.\\/]/', '_', $registeredExtensionKey . '/' . $actionName . '.html'); $form->setOption('contentElementId', $registeredExtensionKey . ':' . $fileRelPath); $elements[$registeredExtensionKey][$id] = $form; } } } } return $elements; }
/** * Get all class names inside this namespace and return them as array. * This has to be done by iterating over class files for TYPO3 CMS * as the Extbase Reflection Service cannot return all implementations * of Fluid AbstractViewHelpers * * @param string $namespace * @return array Array of all class names inside a given namespace. */ protected function getClassNamesInNamespace($namespace) { $packageKey = $this->getPackageKeyFromNamespace($namespace); $viewHelperClassFiles = GeneralUtility::getAllFilesAndFoldersInPath(array(), $this->packageManager->getPackage($packageKey)->getPackagePath() . 'Classes/ViewHelpers/', 'php'); $affectedViewHelperClassNames = array(); foreach ($viewHelperClassFiles as $filePathAndFilename) { $potentialViewHelperClassName = $this->getClassNameFromNamespaceAndPath($namespace, $filePathAndFilename); if (is_subclass_of($potentialViewHelperClassName, 'TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\AbstractViewHelper')) { $classReflection = new \ReflectionClass($potentialViewHelperClassName); if ($classReflection->isAbstract() === TRUE) { continue; } $affectedViewHelperClassNames[] = $potentialViewHelperClassName; } } sort($affectedViewHelperClassNames); return $affectedViewHelperClassNames; }
/** * Include all files with matching Typoscript extensions in directory $dirPath. Contents of the files are * prepended to &$newstring, filename to &$includedFiles. * Order of the directory items to be processed: files first, then directories, both in alphabetical order. * Further include_typoscript tags in the contents of the files are processed recursively. * * @param string $dirPath Relative path to the directory to be included * @param int $cycle_counter Counter for detecting endless loops * @param bool $returnFiles When set, filenames of included files will be prepended to the array &$includedFiles * @param string &$newString The output string to which the content of the file will be prepended (referenced) * @param array &$includedFiles Array to which the filenames of included files will be prepended (referenced) * @param string $optionalProperties * @param string $parentFilenameOrPath The parent file (with absolute path) or path for relative includes * @static */ protected static function includeDirectory($dirPath, $cycle_counter = 1, $returnFiles = FALSE, &$newString = '', array &$includedFiles = array(), $optionalProperties = '', $parentFilenameOrPath = '') { // Extract the value of the property extensions="..." $matches = preg_split('#(?i)extensions\\s*=\\s*"([^"]*)"(\\s*|>)#', $optionalProperties, 2, PREG_SPLIT_DELIM_CAPTURE); if (count($matches) > 1) { $includedFileExtensions = $matches[1]; } else { $includedFileExtensions = ''; } // Resolve a possible relative paths if a parent file is given if ($parentFilenameOrPath !== '' && $dirPath[0] === '.') { $resolvedDirPath = PathUtility::getAbsolutePathOfRelativeReferencedFileOrPath($parentFilenameOrPath, $dirPath); } else { $resolvedDirPath = $dirPath; } $absDirPath = GeneralUtility::getFileAbsFileName($resolvedDirPath); if ($absDirPath) { $absDirPath = rtrim($absDirPath, '/') . '/'; $newString .= LF . '### <INCLUDE_TYPOSCRIPT: source="DIR:' . $dirPath . '"' . $optionalProperties . '> BEGIN:' . LF; // Get alphabetically sorted file index in array $fileIndex = GeneralUtility::getAllFilesAndFoldersInPath(array(), $absDirPath, $includedFileExtensions); // Prepend file contents to $newString $prefixLength = strlen(PATH_site); foreach ($fileIndex as $absFileRef) { $relFileRef = substr($absFileRef, $prefixLength); self::includeFile($relFileRef, $cycle_counter, $returnFiles, $newString, $includedFiles, '', $absDirPath); } $newString .= '### <INCLUDE_TYPOSCRIPT: source="DIR:' . $dirPath . '"' . $optionalProperties . '> END:' . LF . LF; } else { $newString .= self::typoscriptIncludeError('The path "' . $resolvedDirPath . '" is invalid.'); } }
/** * @param array $folders * @param string $format * @return array */ protected function resolveFilesInFolders(array $folders, $format) { $files = array(); foreach ($folders as $folder) { $files = array_merge($files, GeneralUtility::getAllFilesAndFoldersInPath(array(), $folder, $format)); } return array_values($files); }
/** * TCA config "fileFolder" evaluation. Add them to $items * * Used by TcaSelectItems and TcaSelectTreeItems data providers * * @param array $result Result array * @param string $fieldName Current handle field name * @param array $items Incoming items * @return array Modified item array */ protected function addItemsFromFolder(array $result, $fieldName, array $items) { if (empty($result['processedTca']['columns'][$fieldName]['config']['fileFolder']) || !is_string($result['processedTca']['columns'][$fieldName]['config']['fileFolder'])) { return $items; } $fileFolder = $result['processedTca']['columns'][$fieldName]['config']['fileFolder']; $fileFolder = GeneralUtility::getFileAbsFileName($fileFolder); $fileFolder = rtrim($fileFolder, '/') . '/'; if (@is_dir($fileFolder)) { $fileExtensionList = ''; if (!empty($result['processedTca']['columns'][$fieldName]['config']['fileFolder_extList']) && is_string($result['processedTca']['columns'][$fieldName]['config']['fileFolder_extList'])) { $fileExtensionList = $result['processedTca']['columns'][$fieldName]['config']['fileFolder_extList']; } $recursionLevels = isset($fieldValue['config']['fileFolder_recursions']) ? MathUtility::forceIntegerInRange($fieldValue['config']['fileFolder_recursions'], 0, 99) : 99; $fileArray = GeneralUtility::getAllFilesAndFoldersInPath([], $fileFolder, $fileExtensionList, 0, $recursionLevels); $fileArray = GeneralUtility::removePrefixPathFromList($fileArray, $fileFolder); foreach ($fileArray as $fileReference) { $fileInformation = pathinfo($fileReference); $icon = GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], strtolower($fileInformation['extension'])) ? '../' . PathUtility::stripPathSitePrefix($fileFolder) . $fileReference : ''; $items[] = [$fileReference, $fileReference, $icon]; } } return $items; }
/** * @param string $classPath * @return array */ protected function buildTreeFromClassPath($classPath) { $tree = array(); $classPathLength = strlen($classPath); $files = GeneralUtility::getAllFilesAndFoldersInPath(array(), $classPath, 'php'); foreach ($files as $index => $filePathAndFilename) { if (substr(pathinfo($filePathAndFilename, PATHINFO_FILENAME), 0, 8) === 'Abstract') { continue; } if (substr(pathinfo($filePathAndFilename, PATHINFO_FILENAME), -9) === 'Interface') { continue; } $identifier = substr($filePathAndFilename, $classPathLength, -4); $node =& $tree; $segments = explode('/', $identifier); $last = array_pop($segments); foreach ($segments as $segment) { if (!isset($node[$segment])) { $node[$segment] = array(); } $node =& $node[$segment]; } $node[$last] = $last; } return $this->sortTree($tree); }