[BUGFIX] Quickedit mode: RTE has no user CSS 23/33823/3
authorStanislas Rolland <typo3@sjbr.ca>
Wed, 5 Nov 2014 15:12:20 +0000 (10:12 -0500)
committerStanislas Rolland <typo3@sjbr.ca>
Wed, 5 Nov 2014 15:24:15 +0000 (16:24 +0100)
A similar issue arises with configured microdata schema.
This is a follow-up to change https://review.typo3.org/#/c/33569/

Releases: master, 6.2
Resolves: #56408
Change-Id: Ic8122d7a40372f1da85b31d1bd3a7677f2c14a2b
Reviewed-on: http://review.typo3.org/33823
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 cad43fd..be97487 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 6c11438..db78efe 100644 (file)
@@ -526,15 +526,12 @@ class RteHtmlAreaBase extends \TYPO3\CMS\Backend\Rte\AbstractRte {
        protected function getContentCssFileName() {
                // Get stylesheet file name from Page TSConfig if any
                $fileName = trim($this->thisConfig['contentCSS']);
-               if ($fileName) {
-                       $fileName = $this->getFullFileName($fileName);
-               }
-               $backPathResolvedFileName = $fileName ? GeneralUtility::resolveBackPath(($this->is_FE() || $this->isFrontendEditActive() ? '' : TYPO3_mainDir) . $fileName) : '';
-               $absolutePath = $fileName ? GeneralUtility::getFileAbsFileName($backPathResolvedFileName) : '';
+               $absolutePath = GeneralUtility::getFileAbsFileName($fileName);
                // Fallback to default content css file if configured file does not exists or is of zero size
                if (!$fileName || !file_exists($absolutePath) || !filesize($absolutePath)) {
-                       $fileName = $this->getFullFileName('EXT:' . $this->ID . '/res/contentcss/default.css');
+                       $fileName = 'EXT:' . $this->ID . '/res/contentcss/default.css';
                }
+               $fileName = $this->getFullFileName($fileName);
                return $fileName;
        }
 
@@ -1287,6 +1284,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
@@ -1295,10 +1298,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);
        }