*
* The TYPO3 project - inspiring people to share!
*/
+
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
/**
* Microdata Schema extension for htmlArea RTE
*
// Parse configured schemas
if (is_array($this->thisConfig['schema.']) && is_array($this->thisConfig['schema.']['sources.'])) {
foreach ($this->thisConfig['schema.']['sources.'] as $source) {
- $fileName = $this->htmlAreaRTE->getFullFileName($source);
- $absolutePath = $fileName ? \TYPO3\CMS\Core\Utility\GeneralUtility::resolveBackPath(PATH_site . ($this->htmlAreaRTE->is_FE() || $this->htmlAreaRTE->isFrontendEditActive() ? '' : TYPO3_mainDir) . $fileName) : '';
+ $fileName = trim($source);
+ $absolutePath = GeneralUtility::getFileAbsFileName($fileName);
// Fallback to default schema file if configured file does not exists or is of zero size
if (!$fileName || !file_exists($absolutePath) || !filesize($absolutePath)) {
- $fileName = $this->htmlAreaRTE->getFullFileName('EXT:' . $this->ID . '/extensions/MicrodataSchema/res/schemaOrgAll.rdf');
+ $fileName = 'EXT:' . $this->ID . '/extensions/MicrodataSchema/res/schemaOrgAll.rdf';
}
- $rdf = \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($fileName);
+ $fileName = $this->htmlAreaRTE->getFullFileName($fileName);
+ $rdf = GeneralUtility::getUrl($fileName);
if ($rdf) {
$this->parseSchema($rdf, $schema);
}
$contentCssFiles = array();
if (count($contentCss)) {
foreach ($contentCss as $contentCssKey => $contentCssfile) {
- $fileName = trim($contentCssfile) ? $this->getFullFileName($contentCssfile) : '';
- $backPathResolvedFileName = $fileName ? GeneralUtility::resolveBackPath(($this->is_FE() || $this->isFrontendEditActive() ? '' : TYPO3_mainDir) . $fileName) : '';
- $absolutePath = $fileName ? GeneralUtility::getFileAbsFileName($backPathResolvedFileName) : '';
+ $fileName = trim($contentCssfile);
+ $absolutePath = GeneralUtility::getFileAbsFileName($fileName);
if (file_exists($absolutePath) && filesize($absolutePath)) {
- $contentCssFiles[$contentCssKey] = $fileName;
+ $contentCssFiles[$contentCssKey] = $this->getFullFileName($fileName);
}
}
}
return GeneralUtility::quoteJSvalue($str);
}
+ /**
+ * Make a file name relative to the PATH_site or to the PATH_typo3
+ *
+ * @param string $filename: a file name of the form EXT:.... or relative to the PATH_site
+ * @return string the file name relative to the PATH_site if in frontend or relative to the PATH_typo3 if in backend
+ */
public function getFullFileName($filename) {
if (substr($filename, 0, 4) == 'EXT:') {
// extension
if ((string)$extKey !== '' && \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($extKey) && (string)$local !== '') {
$newFilename = ($this->is_FE() || $this->isFrontendEditActive() ? \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath($extKey) : $this->backPath . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($extKey)) . $local;
}
- } elseif ($filename[0] !== '/') {
- $newFilename = ($this->is_FE() || $this->isFrontendEditActive() ? '' : $this->backPath . '../') . $filename;
} else {
- $newFilename = ($this->is_FE() || $this->isFrontendEditActive() ? '' : $this->backPath . '../') . substr($filename, 1);
+ $path = ($this->is_FE() || $this->isFrontendEditActive() ? '' : $this->backPath . '../');
+ $newFilename = $path . ($filename[0] === '/' ? substr($filename, 1) : $filename);
}
return GeneralUtility::resolveBackPath($newFilename);
}