File tree Expand file tree Collapse file tree
Resources/Private/Templates Expand file tree Collapse file tree Load diff This file was deleted.
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ /*
6+ * This file is part of the "codehighlight" extension for TYPO3 CMS.
7+ *
8+ * For the full copyright and license information, please read the
9+ * LICENSE.txt file that was distributed with this source code.
10+ */
11+
12+ namespace Brotkrueml \CodeHighlight \ViewHelpers \Format ;
13+
14+ use TYPO3Fluid \Fluid \Core \ViewHelper \AbstractViewHelper ;
15+
16+ /**
17+ * @internal
18+ */
19+ final class CropLinesViewHelper extends AbstractViewHelper
20+ {
21+ private const MAX_LINES = 20 ;
22+
23+ public function render (): string
24+ {
25+ $ stringToTruncate = (string ) $ this ->renderChildren ();
26+
27+ $ lines = \preg_split ('/\R/ ' , $ stringToTruncate );
28+ if ($ lines === false ) {
29+ return $ stringToTruncate ;
30+ }
31+
32+ $ slicedLines = \array_slice ($ lines , 0 , self ::MAX_LINES );
33+ $ output = \implode ("\r\n" , $ slicedLines );
34+ if (\count ($ lines ) !== \count ($ slicedLines )) {
35+ $ output .= "\r\n\r\n... " ;
36+ }
37+
38+ return $ output ;
39+ }
40+ }
Original file line number Diff line number Diff line change 88 */
99
1010use Brotkrueml \CodeHighlight \Extension ;
11- use Brotkrueml \CodeHighlight \Preview \ContentPreviewRenderer ;
1211use TYPO3 \CMS \Core \Utility \ExtensionManagementUtility ;
1312
1413defined ('TYPO3 ' ) || die ();
3534 );
3635
3736 $ GLOBALS ['TCA ' ]['tt_content ' ]['types ' ][$ contentType ] = [
38- 'previewRenderer ' => ContentPreviewRenderer::class,
3937 'columnsOverrides ' => [
4038 'bodytext ' => [
4139 'label ' => Extension::LANGUAGE_PATH_CONTENT_ELEMENT . ':codeSnippet ' ,
Original file line number Diff line number Diff line change 11@import "EXT:codehighlight/Configuration/TsConfig/Page/*.tsconfig"
2+
3+ mod.web_layout.tt_content.preview {
4+ tx_codehighlight_codesnippet = EXT:codehighlight/Resources/Private/Templates/Preview/CodeSnippetPreview.html
5+ }
Original file line number Diff line number Diff line change 1+ < html
2+ data-namespace-typo3-fluid ="true "
3+ xmlns:f ="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers "
4+ lang ="en "
5+ >
6+
7+ < f:if condition ="{record.bodytext} ">
8+ < f:then >
9+ < pre > < code > {record.bodytext -> codeHighlight:format.cropLines()}</ code > </ pre >
10+ </ f:then >
11+ < f:else >
12+ < br >
13+ < div class ="alert alert-warning ">
14+ < f:translate key ="LLL:EXT:codehighlight/Resources/Private/Language/ContentElement.xlf:codeSnippet.notDefined "/>
15+ </ div >
16+ </ f:else >
17+ </ f:if >
18+
19+ < f:if condition ="{record.pi_flexform.programmingLanguage} || {record.pi_flexform.filename} ">
20+ < div class ="t3-page-ce-footer " style ="margin-inline:-20px;margin-block-end:-20px; ">
21+ < div class ="t3-page-ce-info ">
22+ < f:if condition ="{record.pi_flexform.programmingLanguage} ">
23+ < strong > {record.pi_flexform.programmingLanguage.0 -> f:format.case()}</ strong >
24+ </ f:if >
25+ < f:if condition ="{record.pi_flexform.filename} ">
26+ {record.pi_flexform.filename}
27+ </ f:if >
28+ </ div >
29+ </ div >
30+ </ f:if >
31+
32+ </ html >
You can’t perform that action at this time.
0 commit comments