Created
November 21, 2023 15:25
-
-
Save rr-it/223d32f8b3abe8800a599178a535b8c8 to your computer and use it in GitHub Desktop.
TYPO3: BE: display soft-hyphens and non-breaking spaces in input fields
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Subject: [PATCH] BE: display soft-hyphens and non-breaking spaces in input fields | |
--- | |
Index: Classes/Evaluation/SoftHyphenEvaluation.php | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
diff --git a/Classes/Evaluation/SoftHyphenEvaluation.php b/Classes/Evaluation/SoftHyphenEvaluation.php | |
new file mode 100644 | |
--- /dev/null (revision 32a965144cb14c8ddd93b9b47204c018ac2aa496) | |
+++ b/Classes/Evaluation/SoftHyphenEvaluation.php (revision 32a965144cb14c8ddd93b9b47204c018ac2aa496) | |
@@ -0,0 +1,55 @@ | |
+<?php | |
+ | |
+namespace RRafalskiIt\RritLibs\Evaluation; | |
+ | |
+/** | |
+ * Class for field value validation/evaluation to be used in 'eval' of TCA | |
+ */ | |
+class SoftHyphenEvaluation | |
+{ | |
+ | |
+ /** | |
+ * JavaScript code for client side validation/evaluation | |
+ * Replace soft-hyphen and soft-hyphen placeholders by placeholder character. | |
+ * | |
+ * @return string JavaScript code for client side validation/evaluation | |
+ */ | |
+ public function returnFieldJS() | |
+ { | |
+ return 'return value.replace(/(\u00AD|­|­|&x(00)?AD;|\(-\))/gi,"\uE9AD");'; | |
+ } | |
+ | |
+ /** | |
+ * Server-side validation/evaluation on saving the record: | |
+ * Replace placeholder by soft-hyphen. | |
+ * | |
+ * @param string $value The field value to be evaluated | |
+ * @param string $is_in The "is_in" value of the field configuration from TCA | |
+ * @param bool $set Boolean defining if the value is written to the database or not. | |
+ * @return string Evaluated field value | |
+ */ | |
+ public function evaluateFieldValue($value, $is_in, &$set) | |
+ { | |
+ if (!is_string($value)) { | |
+ return $value; | |
+ } | |
+ | |
+ return mb_ereg_replace('\x{E9AD}', "\u{00AD}", $value); | |
+ } | |
+ | |
+ /** | |
+ * Server-side validation/evaluation on opening the record: | |
+ * Replace soft-hyphen by placeholder. | |
+ * | |
+ * @param array $parameters Array with key 'value' containing the field value from the database | |
+ * @return string Evaluated field value | |
+ */ | |
+ public function deevaluateFieldValue(array $parameters) | |
+ { | |
+ if (!is_string($parameters['value'])) { | |
+ return $parameters['value']; | |
+ } | |
+ | |
+ return mb_ereg_replace('\x{00AD}', "\u{E9AD}", $parameters['value']); | |
+ } | |
+} | |
Index: Configuration/TCA/Overrides/pages.php | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
diff --git a/Configuration/TCA/Overrides/pages.php b/Configuration/TCA/Overrides/pages.php | |
new file mode 100644 | |
--- /dev/null (revision 32a965144cb14c8ddd93b9b47204c018ac2aa496) | |
+++ b/Configuration/TCA/Overrides/pages.php (revision 32a965144cb14c8ddd93b9b47204c018ac2aa496) | |
@@ -0,0 +1,8 @@ | |
+<?php | |
+defined('TYPO3_MODE') or die(); | |
+ | |
+/** Make soft-hypen visible in BE */ | |
+foreach (['title', 'nav_title', 'subtitle'] as $field) { | |
+ $tempEval = $GLOBALS['TCA']['pages']['columns'][$field]['config']['eval'] ?? ''; | |
+ $GLOBALS['TCA']['pages']['columns'][$field]['config']['eval'] = ($tempEval ? $tempEval . ',' : '') . 'RRafalskiIt\\RritLibs\\Evaluation\\SoftHyphenEvaluation'; | |
+} | |
Index: Configuration/TCA/Overrides/tt_content.php | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php | |
new file mode 100644 | |
--- /dev/null (revision 32a965144cb14c8ddd93b9b47204c018ac2aa496) | |
+++ b/Configuration/TCA/Overrides/tt_content.php (revision 32a965144cb14c8ddd93b9b47204c018ac2aa496) | |
@@ -0,0 +1,8 @@ | |
+<?php | |
+defined('TYPO3_MODE') or die(); | |
+ | |
+/** Make soft-hypen visible in BE */ | |
+foreach (['header', 'subheader'] as $field) { | |
+ $tempEval = $GLOBALS['TCA']['tt_content']['columns'][$field]['config']['eval'] ?? ''; | |
+ $GLOBALS['TCA']['tt_content']['columns'][$field]['config']['eval'] = ($tempEval ? $tempEval . ',' : '') . 'RRafalskiIt\\RritLibs\\Evaluation\\SoftHyphenEvaluation'; | |
+} | |
Index: Resources/Private/Assets/IcoMoon/DashJoinerSpace.json | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
diff --git a/Resources/Private/Assets/IcoMoon/DashJoinerSpace.json b/Resources/Private/Assets/IcoMoon/DashJoinerSpace.json | |
new file mode 100644 | |
--- /dev/null (revision 32a965144cb14c8ddd93b9b47204c018ac2aa496) | |
+++ b/Resources/Private/Assets/IcoMoon/DashJoinerSpace.json (revision 32a965144cb14c8ddd93b9b47204c018ac2aa496) | |
@@ -0,0 +1,155 @@ | |
+{ | |
+ "metadata": { | |
+ "name": "DashJoinerSpace", | |
+ "lastOpened": 0, | |
+ "created": 1700492440342 | |
+ }, | |
+ "iconSets": [ | |
+ { | |
+ "selection": [ | |
+ { | |
+ "order": 10, | |
+ "id": 0, | |
+ "name": "xAD, 173, shy", | |
+ "prevSize": 32, | |
+ "code": 59821, | |
+ "tempChar": "" | |
+ } | |
+ ], | |
+ "id": 3, | |
+ "metadata": { | |
+ "name": "Dash" | |
+ }, | |
+ "height": 1024, | |
+ "prevSize": 32, | |
+ "icons": [ | |
+ { | |
+ "id": 0, | |
+ "paths": [ | |
+ "M210.645 618.025v51.2h218.72v-51.2z", | |
+ "M509.783 423.259l-31.999 32.052c49.592 49.515 77.617 117.396 77.619 188.317 0.002 70.923-28.011 138.799-77.602 188.317l31.999 32.035c58.19-58.106 90.888-137.522 90.886-220.37-0.003-82.846-32.712-162.25-90.904-220.352z", | |
+ "M130.217 423.259c-58.192 58.102-90.901 137.506-90.904 220.352-0.002 82.848 32.713 162.264 90.904 220.37l31.999-32.035c-49.59-49.518-77.621-117.394-77.619-188.317 0.003-70.921 28.028-138.802 77.619-188.317z" | |
+ ], | |
+ "attrs": [ | |
+ {}, | |
+ {}, | |
+ {} | |
+ ], | |
+ "grid": 16, | |
+ "tags": [ | |
+ "soft hyphen", | |
+ "SHY" | |
+ ], | |
+ "width": 640, | |
+ "defaultCode": 173, | |
+ "isMulticolor": false, | |
+ "isMulticolor2": false | |
+ } | |
+ ], | |
+ "colorThemes": [] | |
+ }, | |
+ { | |
+ "selection": [], | |
+ "id": 2, | |
+ "metadata": { | |
+ "name": "Joiner", | |
+ "importSize": { | |
+ "width": 200, | |
+ "height": 200 | |
+ } | |
+ }, | |
+ "height": 1024, | |
+ "prevSize": 32, | |
+ "icons": [], | |
+ "invisible": false, | |
+ "colorThemes": [] | |
+ }, | |
+ { | |
+ "selection": [ | |
+ { | |
+ "order": 8, | |
+ "id": 0, | |
+ "name": "xA0, 160, nbsp", | |
+ "prevSize": 32, | |
+ "code": 160, | |
+ "tempChar": "" | |
+ } | |
+ ], | |
+ "id": 0, | |
+ "metadata": { | |
+ "name": "Space", | |
+ "importSize": { | |
+ "width": 200, | |
+ "height": 200 | |
+ } | |
+ }, | |
+ "height": 1024, | |
+ "prevSize": 32, | |
+ "icons": [ | |
+ { | |
+ "id": 0, | |
+ "paths": [ | |
+ "M155.343 1042.101h201.6v-151.2h123.9v51h-73.5v151.2h-302.4v-151.2h-73.8v-51h124.2z" | |
+ ], | |
+ "attrs": [ | |
+ {} | |
+ ], | |
+ "grid": 16, | |
+ "tags": [ | |
+ "non-breaking space", | |
+ "no-break space", | |
+ "NBSP" | |
+ ], | |
+ "width": 512, | |
+ "isMulticolor": false, | |
+ "isMulticolor2": false | |
+ } | |
+ ], | |
+ "invisible": false, | |
+ "colorThemes": [] | |
+ } | |
+ ], | |
+ "uid": -1, | |
+ "preferences": { | |
+ "showGlyphs": true, | |
+ "showCodes": true, | |
+ "showQuickUse": true, | |
+ "showQuickUse2": true, | |
+ "showSVGs": true, | |
+ "fontPref": { | |
+ "prefix": "djs-", | |
+ "metadata": { | |
+ "fontFamily": "DashJoinerSpace", | |
+ "majorVersion": 1, | |
+ "minorVersion": 0 | |
+ }, | |
+ "metrics": { | |
+ "emSize": 1024, | |
+ "baseline": 6.25, | |
+ "whitespace": 50 | |
+ }, | |
+ "embed": false, | |
+ "noie8": true, | |
+ "ie7": false, | |
+ "showSelector": true, | |
+ "showMetrics": false, | |
+ "showMetadata": false, | |
+ "showVersion": false | |
+ }, | |
+ "imagePref": { | |
+ "prefix": "djs-", | |
+ "png": true, | |
+ "useClassSelector": true, | |
+ "color": 0, | |
+ "bgColor": 16777215, | |
+ "name": "DashJoinerSpace", | |
+ "classSelector": ".djs-icon", | |
+ "height": 32, | |
+ "columns": 16, | |
+ "margin": 16 | |
+ }, | |
+ "historySize": 50, | |
+ "gridSize": 16, | |
+ "showGrid": true | |
+ } | |
+} | |
\ No newline at end of file | |
Index: Resources/Public/Backend/Fonts/DashJoinerSpace/DashJoinerSpace.svg | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
diff --git a/Resources/Public/Backend/Fonts/DashJoinerSpace/DashJoinerSpace.svg b/Resources/Public/Backend/Fonts/DashJoinerSpace/DashJoinerSpace.svg | |
new file mode 100644 | |
--- /dev/null (revision 32a965144cb14c8ddd93b9b47204c018ac2aa496) | |
+++ b/Resources/Public/Backend/Fonts/DashJoinerSpace/DashJoinerSpace.svg (revision 32a965144cb14c8ddd93b9b47204c018ac2aa496) | |
@@ -0,0 +1,12 @@ | |
+<?xml version="1.0" standalone="no"?> | |
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" > | |
+<svg xmlns="http://www.w3.org/2000/svg"> | |
+<metadata>Generated by IcoMoon</metadata> | |
+<defs> | |
+<font id="DashJoinerSpace" horiz-adv-x="1024"> | |
+<font-face units-per-em="1024" ascent="960" descent="-64" /> | |
+<missing-glyph horiz-adv-x="1024" /> | |
+<glyph unicode=" " horiz-adv-x="512" d="" /> | |
+<glyph unicode=" " glyph-name="xA0, 160, nbsp" horiz-adv-x="512" d="M155.343-82.101h201.6v151.2h123.9v-51h-73.5v-151.2h-302.4v151.2h-73.8v51h124.2z" /> | |
+<glyph unicode="" glyph-name="xAD, 173, shy" horiz-adv-x="640" d="M210.645 341.975v-51.2h218.72v51.2zM509.783 536.741l-31.999-32.052c49.592-49.515 77.617-117.396 77.619-188.317 0.002-70.923-28.011-138.799-77.602-188.317l31.999-32.035c58.19 58.106 90.888 137.522 90.886 220.37-0.003 82.846-32.712 162.25-90.904 220.352zM130.217 536.741c-58.192-58.102-90.901-137.506-90.904-220.352-0.002-82.848 32.713-162.264 90.904-220.37l31.999 32.035c-49.59 49.518-77.621 117.394-77.619 188.317 0.003 70.921 28.028 138.802 77.619 188.317z" /> | |
+</font></defs></svg> | |
\ No newline at end of file | |
Index: Resources/Public/Backend/Styles/Fix/FontVisibleDashJoinerSpace.css | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
diff --git a/Resources/Public/Backend/Styles/Fix/FontVisibleDashJoinerSpace.css b/Resources/Public/Backend/Styles/Fix/FontVisibleDashJoinerSpace.css | |
new file mode 100644 | |
--- /dev/null (revision 32a965144cb14c8ddd93b9b47204c018ac2aa496) | |
+++ b/Resources/Public/Backend/Styles/Fix/FontVisibleDashJoinerSpace.css (revision 32a965144cb14c8ddd93b9b47204c018ac2aa496) | |
@@ -0,0 +1,32 @@ | |
+@font-face { | |
+ font-family: 'DJSSoftHyphenPlaceholder'; | |
+ src: url('../../../../../../../../typo3conf/ext/rrit_libs/Resources/Public/Backend/Fonts/DashJoinerSpace/DashJoinerSpace.ttf?51tizs') format('truetype'), | |
+ url('../../../../../../../../typo3conf/ext/rrit_libs/Resources/Public/Backend/Fonts/DashJoinerSpace/DashJoinerSpace.woff?51tizs') format('woff'), | |
+ url('../../../../../../../../typo3conf/ext/rrit_libs/Resources/Public/Backend/Fonts/DashJoinerSpace/DashJoinerSpace.svg?51tizs#DashJoinerSpace') format('svg'); | |
+ unicode-range: U+E9AD; | |
+ font-weight: normal; | |
+ font-style: normal; | |
+} | |
+ | |
+@font-face { | |
+ font-family: 'DJSNonBreakingSpace'; | |
+ src: url('../../../../../../../../typo3conf/ext/rrit_libs/Resources/Public/Backend/Fonts/DashJoinerSpace/DashJoinerSpace.ttf?51tizs') format('truetype'), | |
+ url('../../../../../../../../typo3conf/ext/rrit_libs/Resources/Public/Backend/Fonts/DashJoinerSpace/DashJoinerSpace.woff?51tizs') format('woff'), | |
+ url('../../../../../../../../typo3conf/ext/rrit_libs/Resources/Public/Backend/Fonts/DashJoinerSpace/DashJoinerSpace.svg?51tizs#DashJoinerSpace') format('svg'); | |
+ unicode-range: U+00A0; | |
+ font-weight: normal; | |
+ font-style: normal; | |
+} | |
+ | |
+h1, | |
+body { | |
+ /* Always display hyphen-placeholder for visible soft-hyphens e.g. on active line-break inside word. */ | |
+ font-family: 'DJSSoftHyphenPlaceholder', Verdana, Arial, Helvetica, sans-serif; | |
+ hyphenate-character: '\e9ad'; | |
+} | |
+ | |
+input:not([type]), | |
+input[type="text"], | |
+textarea { | |
+ font-family: 'DJSSoftHyphenPlaceholder', 'DJSNonBreakingSpace', Verdana, Arial, Helvetica, sans-serif; | |
+} | |
Index: ext_localconf.php | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
diff --git a/ext_localconf.php b/ext_localconf.php | |
--- a/ext_localconf.php (revision 13a356eb523582778b3c86826ea894fbe0a23834) | |
+++ b/ext_localconf.php (revision 32a965144cb14c8ddd93b9b47204c018ac2aa496) | |
@@ -15,3 +15,6 @@ | |
// RTE ckeditor | |
//$GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['rrit_libs'] = 'EXT:rrit_libs/Configuration/RTE/RritLibs.yaml'; | |
+ | |
+// Make SoftHyphenEvaluation available in 'eval' of TCA | |
+$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals']['RRafalskiIt\\RritLibs\\Evaluation\\SoftHyphenEvaluation'] = ''; | |
Index: ext_tables.php | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
diff --git a/ext_tables.php b/ext_tables.php | |
new file mode 100644 | |
--- /dev/null (revision 32a965144cb14c8ddd93b9b47204c018ac2aa496) | |
+++ b/ext_tables.php (revision 32a965144cb14c8ddd93b9b47204c018ac2aa496) | |
@@ -0,0 +1,10 @@ | |
+<?php | |
+defined('TYPO3_MODE') or die(); | |
+ | |
+// Register as a skin | |
+$GLOBALS['TBE_STYLES']['skins']['rrit_libs'] = [ | |
+ 'name' => 'RRIT Libs Fix', | |
+ 'stylesheetDirectories' => [ | |
+ 'css' => 'EXT:rrit_libs/Resources/Public/Backend/Styles/Fix/' | |
+ ] | |
+]; | |
diff --git a/Resources/Public/Backend/Fonts/DashJoinerSpace/DashJoinerSpace.ttf b/Resources/Public/Backend/Fonts/DashJoinerSpace/DashJoinerSpace.ttf | |
new file mode 100644 | |
index 0000000000000000000000000000000000000000..2ea98f513a19de62c8380ff9c3e30b4a9c2a4301 | |
GIT binary patch | |
literal 1276 | |
zc$}3~&ubGw6#iy+leVd}MVr(grEF=Vg~ph6n?zCC9!jBs`Xhy6L8+T$-4v2+*rd?X | |
z9*TGnFZNbM1rHuPSp5eS0*ZoE5%nZqil9Ufg4m;7-|kLq?Lq9o%zWSX-kW*v%_d*~ | |
z8nFZskuwv=`kPxl0x6GaUP|ZHVztVW0Ba|HL03yf+FOXv(O$3T<}d&Fa{CVPCE{<g | |
znwsfed>#OVv&3Ur61<1R7sRg-@6P7Sb3WS>!UJ0N=Zv(9WsDMkM!YGn&K2Q97xDMR | |
z<${{mreD22K>R1&@wsS}%9JM!>7#9jDD<*rc*uTJSR>_zyR&alSOfkZV#^Kz!$5Ua | |
ztXLHcixr!JZL`X56rb&6b9d44YKP=R>_I&Q!i@ayR#&ZGmc^rMj9H(oOyE3^+Zv24 | |
z7Mg99G5}>jeUG1DuI>M|1-4FFBhaQq6@Qn%GujnZZoOPgY`#q_CRdb|6~)fnst8l$ | |
zCt|N%**?D#jn{QBf2+5yZIDF=4j<`kA{J<ihl$1F?>?N9gFQV#xi=E&-MnhA4rh~! | |
z@>C9{V$oDk4w-{PW+-G14Vod+qOnxa?IF#R`n`?m=2IJJl$>(cuMB_R+N}jA8#vvo | |
z^#jgZ!1WiVcJvGIO52D~n@e2qp%oqIN0z^%7oG06^5=%_qX`fB`HbG6_VNPiaGzt5 | |
z^wS(mgr9Kip<W;5*h~5X$37gySNoNv22wi6;$ngBdc?6v`bCZ<!fPCR5WsPcy`*2~ | |
z*oOfoji{w;!k8&&=0s6VYZ!rw5|x>Nff*E_!NdfLq^6-wYG!H1D9C-`2qqm<iJS~_ | |
zlhKDTBD*?mSI$XIpUtTzk|gVxMUG^1S0{`bg|e(`<gAvpjGUU6$I`~QVHCpjA7R%} | |
grYdxbapP3t8ZxA%Fi-0konc^{rtKT%zubR}-)s=rAOHXW | |
diff --git a/Resources/Public/Backend/Fonts/DashJoinerSpace/DashJoinerSpace.woff b/Resources/Public/Backend/Fonts/DashJoinerSpace/DashJoinerSpace.woff | |
new file mode 100644 | |
index 0000000000000000000000000000000000000000..06aeed0da1821e279e85b308971227f8a2ee44e2 | |
GIT binary patch | |
literal 1352 | |
zc$}3}-Ahwp9R8h;O`V}qZuTK^L|1}qO^@4(LcNfYgOVmlLSbjyX%n`caW+ZO3yH3} | |
z$vcS*y6B=C>n{ifML}3Zb=92&#p)smgf7a{^Pcn0kA%n<p7(v8=l#83zu!4G#$quN | |
z2+eh#8rdlSa`fIdHh!v~NT>(B#?ajA5>t7t2rmnLg`rv%5*e+;yywvM94(pL+;w<s | |
z;BOgzd|A1l)wMK{xB?wv=w5i?%ff{B0lJ&PeN1|p&6j84{e(Wu;8`Tf87ag`EznIi | |
zmME6jW^t~hKs)eIS3%3`@P={rXNIZQZ;lj=QW@{<*@~0UOJc9EL@u0jS7f)m<BY;L | |
zQiX=U5@8>^t6~4@s#LKmG%Qt^+Lc4aS;f(gIcJpYsCJU=6$g+h5nMq0gX*gF+p_rT | |
zni8x}R@!%&uiI_{W-MxEE^a`$fk+fRBRF&a@68MA@bDG1sbSUI<?Rf2h1Gkn7UG-l | |
z;tPpob$MB3H@7O{B;q7G$X<5HtA?X>9fG&jUDq}!ga?kF=xl=WwMBzak?8x6mlS_b | |
zk6-Bxg?cw{vEJ6ggsMJM{K-f-=~n{g;E)*zm_vhR0A4tf^gB5O&SoBNOf{d|phnq# | |
z?)uH)@7tp_Z{LRO?A7u?b}h(>7bo|8(QbK%5NlZEhKE|IgZe4U>*%IVyJEC;!p_!2 | |
zkNN%rYEY}ZNOkmxa|!-M&SmhYoV$?glbpNZ&vWjfqx6+kS#E&Sff<L3IO_@L68x*2 | |
z%iwFAyU0hUId{Xq&AEpL1bIX&W#h(lK{v;XT1ux8(x`-I#>t>*Dv(YljZ+bBiu4KH | |
zEKM5)r7sww345x9AOm3v^-+*Q``T?^!3jMxlhaH}z|PPN<zSop+975X%1TB@uvXU7 | |
uN^(vaO&J#qqY$K+{f07Lk--{god&H_8eWp-(2rsdgDwCpHpu_nf3!cj^xKgD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment