[BUGFIX] Quickedit mode: RTE has no user CSS 21/33821/2
authorStanislas Rolland <typo3@sjbr.ca>
Wed, 5 Nov 2014 14:42:00 +0000 (09:42 -0500)
committerStanislas Rolland <typo3@sjbr.ca>
Wed, 5 Nov 2014 14:43:03 +0000 (15:43 +0100)
A similar issue arises with configured microdata schema.
This is a follow-up to change https://review.typo3.org/#/c/33568/

Releases: master, 6.2
Resolves: #56408
Change-Id: Ic8122d7a40372f1da85b31d1bd3a7677f2c14a2b
Reviewed-on: http://review.typo3.org/33821
Reviewed-by: Stanislas Rolland <typo3@sjbr.ca>
Tested-by: Stanislas Rolland <typo3@sjbr.ca>
typo3/sysext/rtehtmlarea/Classes/Extension/MicroDataSchema.php
typo3/sysext/rtehtmlarea/Classes/RteHtmlAreaBase.php

index f0e2db9..5bac0ed 100644 (file)
@@ -13,6 +13,9 @@ namespace TYPO3\CMS\Rtehtmlarea\Extension;
  *
  * The TYPO3 project - inspiring people to share!
  */
+
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
 /**
  * Microdata Schema extension for htmlArea RTE
  *
@@ -65,13 +68,14 @@ class MicroDataSchema extends \TYPO3\CMS\Rtehtmlarea\RteHtmlAreaApi {
                // 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);
                                }
index 4139b30..efa783a 100644 (file)
@@ -526,11 +526,10 @@ class RteHtmlAreaBase extends \TYPO3\CMS\Backend\Rte\AbstractRte {
                $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);
                                }
                        }
                }
@@ -1320,6 +1319,12 @@ class RteHtmlAreaBase extends \TYPO3\CMS\Backend\Rte\AbstractRte {
                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
@@ -1328,10 +1333,9 @@ class RteHtmlAreaBase extends \TYPO3\CMS\Backend\Rte\AbstractRte {
                        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);
        }