Skip to content

Commit

Permalink
[TASK] add Realurl replace characters xclass (#159)
Browse files Browse the repository at this point in the history
* [TASK] include realurl xclass from t3kit_extension_tools

* [TASK] PSR-2 code standard fixes
  • Loading branch information
pixelmatseriks authored and dmh committed Apr 20, 2017
1 parent 72eefb1 commit 051b365
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 2 deletions.
76 changes: 76 additions & 0 deletions Classes/Xclass/Realurl/Utility.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php


namespace T3kit\themeT3kit\Xclass\Realurl;

use T3kit\themeT3kit\Utility\HelperUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* Class Utility
* @package T3kit\themeT3kit\Xclass\Realurl\Utility
*/
class Utility extends \DmitryDulepov\Realurl\Utility
{
/**
* Array of replacement characters
*
* @var array
*/
protected static $replacements = [
'ä' => 'a',
'å' => 'a',
'ö' => 'o',
'Å' => 'a',
'Ä' => 'a',
'Ö' => 'o'
];

/**
* Xclass standard Reaurl utility to remove some specials characters
*
* @param string $processedTitle
* @param string $spaceCharacter
* @param bool $strToLower
* @return string
*/
public function convertToSafeString($processedTitle, $spaceCharacter = '-', $strToLower = true)
{
$processedTitle = str_replace(
array_keys($this->getFinalCharsReplacements()),
$this->getFinalCharsReplacements(),
$processedTitle
);

return parent::convertToSafeString($processedTitle, $spaceCharacter, $strToLower);
}

/**
* Check in extension configuration for additional replacements
*
* @return array|null
*/
protected function getFinalCharsReplacements()
{
static $finalReplacements = null;

if ($finalReplacements === null) {
$t3kitExtToolConf = HelperUtility::getExtConf();
$additionalChars = [];

if (!empty($t3kitExtToolConf['additionalCharacters'])) {

$charsSet = GeneralUtility::trimExplode(',', $t3kitExtToolConf['additionalCharacters']);

foreach ($charsSet as $charSet) {
list($find, $replace) = GeneralUtility::trimExplode('=>', $charSet, true);
$additionalChars[$find] = $replace;
}
}

$finalReplacements = array_merge(self::$replacements, $additionalChars);
}

return $finalReplacements;
}
}
8 changes: 6 additions & 2 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@
*/

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem']['imageTextLink']
= \T3kit\themeT3kit\Hooks\ImageTextLinkPreviewRenderer::class;
= \T3kit\themeT3kit\Hooks\ImageTextLinkPreviewRenderer::class;

$GLOBALS['TYPO3_CONF_VARS']['SYS']['fluid']['namespaces']['t3kit'][] = 'T3kit\\themeT3kit\\ViewHelpers';


$GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['t3kit_default'] = 'EXT:theme_t3kit/Resources/Private/Extensions/RTE/Default.yaml';
$GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['t3kit_default']
= 'EXT:theme_t3kit/Resources/Private/Extensions/RTE/Default.yaml';

$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\DmitryDulepov\Realurl\Utility::class]['className']
= \T3kit\themeT3kit\Xclass\Realurl\Utility::class;

0 comments on commit 051b365

Please sign in to comment.