1 | <?php |
||
17 | abstract class AbstractRendering implements RenderingInterface |
||
18 | { |
||
19 | |||
20 | /** |
||
21 | * Content object |
||
22 | * |
||
23 | * @var ContentObjectRenderer |
||
24 | */ |
||
25 | protected $contentObject; |
||
26 | |||
27 | /** |
||
28 | * Configuration |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | protected $configuration; |
||
33 | |||
34 | /** |
||
35 | * Set the content object and configuration |
||
36 | * Call the renderInternal after preparation |
||
37 | * |
||
38 | * @param ContentObjectRenderer $contentObject |
||
39 | * @param array $configuration |
||
40 | * |
||
41 | * @return array |
||
42 | */ |
||
43 | public function render($contentObject, $configuration) |
||
49 | |||
50 | /** |
||
51 | * Parsing the bodytext field content, removing typical entities and <br /> tags. |
||
52 | * |
||
53 | * @param string $str : Field content from "bodytext" or other text field |
||
54 | * @param string $altConf : Altername conf name (especially when bodyext field in other table then tt_content) |
||
55 | * |
||
56 | * @return string Processed content |
||
57 | */ |
||
58 | public function parseBody($str, $altConf = 'bodytext') |
||
59 | { |
||
60 | if ($this->configuration[$altConf . '.']['doubleLF']) { |
||
61 | $str = preg_replace("/\n/", "\n\n", $str); |
||
62 | } |
||
63 | // Regular parsing: |
||
64 | $str = preg_replace('/<br\s*\/?>/i', chr(10), $str); |
||
65 | $str = $this->contentObject->stdWrap($str, $this->configuration[$altConf . '.']['stdWrap.']); |
||
66 | |||
67 | // Then all a-tags: |
||
68 | $aConf = array(); |
||
69 | $aConf['parseFunc.']['tags.']['a'] = 'USER'; |
||
70 | // check direct mail usage @todo |
||
71 | $aConf['parseFunc.']['tags.']['a.']['userFunc'] = 'FRUIT\\Ink\\PlainRenderer->atagToHttp'; |
||
72 | $aConf['parseFunc.']['tags.']['a.']['siteUrl'] = 'http://www.google.de'; |
||
73 | $str = $this->contentObject->stdWrap($str, $aConf); |
||
74 | $str = str_replace(' ', ' ', htmlspecialchars_decode($str)); |
||
75 | |||
76 | if ($this->configuration[$altConf . '.']['header']) { |
||
77 | $str = $this->configuration[$altConf . '.']['header'] . LF . $str; |
||
78 | } |
||
79 | |||
80 | return chr(10) . $str; |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * Function used to wrap the bodytext field content (or image caption) into lines of a max length of |
||
85 | * |
||
86 | * @param string $str : The content to break |
||
87 | * |
||
88 | * @return string Processed value. |
||
89 | * @see main_plaintext(), breakLines() |
||
90 | */ |
||
91 | public function breakContent($str) |
||
100 | |||
101 | /** |
||
102 | * Returns a typolink URL based on input. |
||
103 | * |
||
104 | * @param string $ll : Parameter to typolink |
||
105 | * |
||
106 | * @return string The URL returned from $this->cObj->getTypoLink_URL(); - possibly it prefixed with the URL of the site if not present already |
||
107 | */ |
||
108 | public function getLink($ll) |
||
112 | |||
113 | /** |
||
114 | * Breaking lines into fixed length lines, using GeneralUtility::breakLinesForEmail() |
||
115 | * |
||
116 | * @param string $str : The string to break |
||
117 | * @param string $implChar : Line break character |
||
118 | * @param integer $charWidth : Length of lines, default is $this->charWidth |
||
119 | * |
||
120 | * @return string Processed string |
||
121 | */ |
||
122 | public function breakLines($str, $implChar = LF, $charWidth = false) |
||
127 | } |
||
128 |