[BUGIFX] RTEmagic upgrade wizard: missing attributes 19/22019/3
authorFrancois Suter <francois@typo3.org>
Sat, 6 Jul 2013 14:32:56 +0000 (16:32 +0200)
committerMarkus Klein <klein.t3@mfc-linz.at>
Sat, 13 Jul 2013 18:32:29 +0000 (20:32 +0200)
When the RTE creates a magic images it uses data-* attributes
to keep a reference to the original FAL record. The upgrade
wizard migrates the images, creates the sys_file entries but
does not add the data-* attributes.

Resolves: #49733
Releases: 6.1, 6.2
Change-Id: Ib483355336d1331892920ada847850a61c35a3af
Reviewed-on: https://review.typo3.org/22019
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Stefan Neufeind
Reviewed-by: Markus Klein
Tested-by: Markus Klein
typo3/sysext/install/Classes/Updates/RteMagicImagesUpdateWizard.php

index b2fd7e5..a906fe0 100644 (file)
@@ -172,8 +172,17 @@ class RteMagicImagesUpdateWizard extends \TYPO3\CMS\Install\Updates\AbstractUpda
                                $targetFieldName = $refRecord['field'];
                                $targetRecord = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('uid, ' . $targetFieldName, $refRecord['tablename'], 'uid=' . intval($refRecord['recuid']));
                                if ($targetRecord) {
-                                       // replace the old filename with the new one, and update the according record
-                                       $targetRecord[$targetFieldName] = str_replace($sourceFileName, $fileadminDirectory . $targetFileName, $targetRecord[$targetFieldName]);
+                                       // Replace the old filename with the new one, and add data-* attributes used by the RTE
+                                       $searchString = 'src="' . $sourceFileName . '"';
+                                       $replacementString = 'src="' . $fileadminDirectory . $targetFileName . '"';
+                                       $replacementString .= ' data-htmlarea-file-uid="' . $file->getUid() . '"';
+                                       $replacementString .= ' data-htmlarea-file-table="sys_file"';
+                                       $targetRecord[$targetFieldName] = str_replace(
+                                               $searchString,
+                                               $replacementString,
+                                               $targetRecord[$targetFieldName]
+                                       );
+                                       // Update the record
                                        $GLOBALS['TYPO3_DB']->exec_UPDATEquery(
                                                $refRecord['tablename'],
                                                'uid=' . intval($refRecord['recuid']),
@@ -181,7 +190,7 @@ class RteMagicImagesUpdateWizard extends \TYPO3\CMS\Install\Updates\AbstractUpda
                                        );
                                        $queries[] = str_replace(LF, ' ', $GLOBALS['TYPO3_DB']->debug_lastBuiltQuery);
 
-                                       // finally, update the sys_refindex table as well
+                                       // Finally, update the sys_refindex table as well
                                        $GLOBALS['TYPO3_DB']->exec_UPDATEquery(
                                                'sys_refindex',
                                                'hash=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($refRecord['hash'], 'sys_refindex'),
@@ -220,4 +229,4 @@ class RteMagicImagesUpdateWizard extends \TYPO3\CMS\Install\Updates\AbstractUpda
 }
 
 
-?>
\ No newline at end of file
+?>