Utility

extRelPath()

What does it do?

Get the relative path to the extension directory.

Sample

TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
        $extKey
        , 'Pi1'
        , 'LLL:EXT:browser/Configuration/ExtTables/7.6/locallang_db.xml:tt_content.list_type_pi1'
        , Netzmacher\Refresh\Compatibility\Core\Utility\ExtensionManagementUtility::extRelPath( $extKey ) . 'ext_icon.svg'
);

Refresh

You can refresh your extension by find and replace.

// Code from TYPO3 6.2 to 8.7
$extPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath( $extKey );
// Code from TYPO3 6.2 to 9.x
$extPath = Netzmacher\Refresh\Compatibility\Core\Utility\ExtensionManagementUtility::extRelPath( $extKey );

Move “\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath” to “Netzmacher\Refresh\Compatibility\Core\Utility\ExtensionManagementUtility::extRelPath”

png_to_gif_by_imagemagick()

What does it do?

This function converts a png file to gif

Header

/**
 * Converts a png file to gif.
 * This converts a png file to gif IF the FLAG $GLOBALS['TYPO3_CONF_VARS']['FE']['png_to_gif'] is set TRUE.
 *
 * @param string $theFile The filename with path
 * @return string New filename
 */
public static function png_to_gif_by_imagemagick( $theFile )

Sample

$imageInfo[ 3 ] = \Netzmacher\Refresh\Compatibility\Core\Utility\GeneralUtility::png_to_gif_by_imagemagick( $imageInfo[ 3 ] );

Refresh

You can refresh your extension by find and replace.

// Code from TYPO3 6.2 to 7.6
$imageInfo[3] = \TYPO3\CMS\Core\Utility\GeneralUtility::png_to_gif_by_imagemagick($imageInfo[3]);
// Code from TYPO3 6.2 to 9.x
$imageInfo[ 3 ] = \Netzmacher\Refresh\Compatibility\Core\Utility\GeneralUtility::png_to_gif_by_imagemagick( $imageInfo[ 3 ] );

Move “\TYPO3\CMS\Core\Utility\GeneralUtility::png_to_gif_by_imagemagick” to “\Netzmacher\Refresh\Compatibility\Core\Utility\GeneralUtility::png_to_gif_by_imagemagick”

slashJS()

What does it do?

This function is used to escape any ‘ -characters when transferring text to JavaScript!

Header

/**
 * This function is used to escape any ' -characters when transferring text to JavaScript!
 *
 * @param string $string String to escape
 * @param boolean $extended If set, also backslashes are escaped.
 * @param string $char The character to escape, default is ' (single-quote)
 * @return string Processed input string
 */
public static function slashJS( $string, $extended = FALSE, $char = '\'' )

Sample

$promptJSS = $this->pObj->pi_getLL( 'error_views_single_noview' );
$promptJSS = \Netzmacher\Refresh\Compatibility\Core\Utility\GeneralUtility::slashJS( $promptJSS, false, "'" );

Refresh

You can refresh your extension by find and replace.

// Code from TYPO3 6.2 to 7.6
$promptJSS = \TYPO3\CMS\Core\Utility\GeneralUtility::slashJS( $promptJSS, false, "'" );
// Code from TYPO3 6.2 to 9.x
$promptJSS = \Netzmacher\Refresh\Compatibility\Core\Utility\GeneralUtility::slashJS( $promptJSS, false, "'" );

Move “\TYPO3\CMS\Core\Utility\GeneralUtility::slashJS” to “\Netzmacher\Refresh\Compatibility\Core\Utility\GeneralUtility::slashJS”