2 namespace TYPO3\CMS\CssStyledContent\Controller;
68 if ($hookObj = $this->
hookRequest(
'render_bullets')) {
69 return $hookObj->render_bullets($content,
$conf);
72 $field = isset(
$conf[
'field']) && trim(
$conf[
'field']) ? trim(
$conf[
'field']) :
'bodytext';
73 $content = trim($this->cObj->data[$field]);
74 if ($content ===
'') {
79 foreach ($lines as &$val) {
80 $val =
'<li>' . $this->cObj->stdWrap($val,
$conf[
'innerStdWrap.']) .
'</li>';
84 $type = (int)$this->cObj->data[
'layout'];
87 <ul class="csc-bulletlist csc-bulletlist-' . $type .
'">' . implode(
'', $lines) .
'
104 if ($hookObj = $this->
hookRequest(
'render_table')) {
105 return $hookObj->render_table($content,
$conf);
110 $field = isset(
$conf[
'field']) && trim(
$conf[
'field']) ? trim(
$conf[
'field']) :
'bodytext';
111 $content = trim($this->cObj->data[$field]);
112 if ($content ===
'') {
116 $caption = trim(htmlspecialchars($this->
pi_getFFvalue($this->cObj->data[
'pi_flexform'],
'acctables_caption')));
117 $useTfoot = trim($this->
pi_getFFvalue($this->cObj->data[
'pi_flexform'],
'acctables_tfoot'));
118 $headerPos = $this->
pi_getFFvalue($this->cObj->data[
'pi_flexform'],
'acctables_headerpos');
119 $noStyles = $this->
pi_getFFvalue($this->cObj->data[
'pi_flexform'],
'acctables_nostyles');
120 $tableClass = $this->
pi_getFFvalue($this->cObj->data[
'pi_flexform'],
'acctables_tableclass');
121 $delimiter = trim($this->
pi_getFFvalue($this->cObj->data[
'pi_flexform'],
'tableparsing_delimiter',
's_parsing'));
123 $delimiter = chr((
int)$delimiter);
127 $quotedInput = trim($this->
pi_getFFvalue($this->cObj->data[
'pi_flexform'],
'tableparsing_quote',
's_parsing'));
129 $quotedInput = chr((
int)$quotedInput);
134 $headerScope = $headerPos ==
'top' ?
'col' :
'row';
135 $headerIdPrefix = $headerScope . $this->cObj->data[
'uid'] .
'-';
140 $cols = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(
141 $this->cObj->data[
'cols'] ? $this->cObj->data[
'cols'] : count(str_getcsv(current($rows), $delimiter, $quotedInput)),
146 $rCount = count($rows);
147 foreach ($rows as $k => $v) {
148 $cells = str_getcsv($v, $delimiter, $quotedInput);
150 for ($a = 0; $a < $cols; $a++) {
151 if (trim($cells[$a]) ===
'') {
152 $cells[$a] =
' ';
154 $cellAttribs = $noStyles ?
'' : ($a > 0 && $cols - 1 == $a ?
' class="td-last td-' . $a .
'"' :
' class="td-' . $a .
'"');
155 if ($headerPos ==
'top' && !$k || $headerPos ==
'left' && !$a) {
156 $scope =
' scope="' . $headerScope .
'"';
157 $scope .=
' id="' . $headerIdPrefix . ($headerScope ==
'col' ? $a : $k) .
'"';
159 <th' . $cellAttribs . $scope .
'>' . $this->cObj->stdWrap($cells[$a],
$conf[
'innerStdWrap.']) .
'</th>';
161 if (empty($headerPos)) {
162 $accessibleHeader =
'';
164 $accessibleHeader =
' headers="' . $headerIdPrefix . ($headerScope ==
'col' ? $a : $k) .
'"';
167 <td' . $cellAttribs . $accessibleHeader .
'>' . $this->cObj->stdWrap($cells[$a],
$conf[
'innerStdWrap.']) .
'</td>';
171 $oddEven = $k % 2 ?
'tr-odd' :
'tr-even';
172 $rowAttribs = $k > 0 && $rCount - 1 == $k ?
' class="' . $oddEven .
' tr-last"' :
' class="' . $oddEven .
' tr-' . $k .
'"';
175 <tr' . $rowAttribs .
'>' . implode(
'', $newCells) .
'
182 <caption>' . $caption .
'</caption>';
184 if ($headerPos ==
'top' && $rows[0]) {
185 $tableContents .=
'<thead>' . $rows[0] .
'
192 <tfoot>' . $rows[($rCount - 1)] .
'</tfoot>';
193 unset($rows[$rCount - 1]);
196 $tmpTable = implode(
'', $rows);
198 $tmpTable =
'<tbody>' . $tmpTable .
'</tbody>';
200 $tableContents .= $tmpTable;
202 $type = (int)$this->cObj->data[
'layout'];
204 $tableTagParams = $this->getTableAttributes(
$conf, $type);
206 $tableTagParams[
'class'] =
'contenttable contenttable-' . $type . ($tableClass ?
' ' . $tableClass :
'') . $tableTagParams[
'class'];
208 $tableTagParams[
'class'] = $tableClass;
231 if ($hookObj = $this->
hookRequest(
'render_uploads')) {
232 return $hookObj->render_uploads($content,
$conf);
238 $type = (int)$this->cObj->data[
'layout'];
240 $filePathConf = $this->cObj->stdWrap(
$conf[
'filePath'],
$conf[
'filePath.']);
242 $fileList = $this->cObj->filelist($filePathConf);
243 list($path) = explode(
'|', $filePathConf);
246 $field = trim(
$conf[
'field']) ?:
'media';
247 $fileList = $this->cObj->data[$field];
248 $path =
'uploads/media/';
250 is_array(
$GLOBALS[
'TCA'][
'tt_content'][
'columns'][$field]) &&
251 !empty(
$GLOBALS[
'TCA'][
'tt_content'][
'columns'][$field][
'config'][
'uploadfolder'])
254 $path =
$GLOBALS[
'TCA'][
'tt_content'][
'columns'][$field][
'config'][
'uploadfolder'] .
'/';
261 if (!empty($fileArray)) {
269 if ($this->cObj->data[
'target']) {
270 $conf[
'linkProc.'][
'target'] = $this->cObj->data[
'target'];
271 unset(
$conf[
'linkProc.'][
'target.']);
274 $conf[
'linkProc.'][
'path.'][
'current'] = 1;
275 if (
$conf[
'linkProc.'][
'combinedLink']) {
276 $conf[
'linkProc.'][
'icon'] = $type > 0 ? 1 : 0;
279 $conf[
'linkProc.'][
'icon'] = 1;
281 $conf[
'linkProc.'][
'icon.'][
'wrap'] =
' | //**//';
283 $conf[
'linkProc.'][
'icon_link'] = 1;
285 $conf[
'linkProc.'][
'icon_image_ext_list'] = $type == 2 || $type == 3 ?
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'imagefile_ext'] :
'';
287 if (
$conf[
'labelStdWrap.']) {
288 $conf[
'linkProc.'][
'labelStdWrap.'] =
$conf[
'labelStdWrap.'];
290 if (
$conf[
'useSpacesInLinkText'] ||
$conf[
'stripFileExtensionFromLinkText']) {
291 $conf[
'linkProc.'][
'removePrependedNumbers'] = 0;
294 $filesData = array();
295 foreach ($fileArray as $key => $fileName) {
297 if (@is_file($absPath)) {
298 $fI = pathinfo($fileName);
299 $filesData[$key] = array();
300 $currentPath = $path;
303 $fileName = substr($fileName, 6);
305 $filesData[$key][
'filename'] = $fileName;
306 $filesData[$key][
'path'] = $currentPath;
307 $filesData[$key][
'filesize'] = filesize($absPath);
308 $filesData[$key][
'fileextension'] = strtolower($fI[
'extension']);
309 $filesData[$key][
'description'] = trim($descriptions[$key]);
310 $filesData[$key][
'titletext'] = trim($titles[$key]);
311 $filesData[$key][
'alttext'] = trim($altTexts[$key]);
312 $conf[
'linkProc.'][
'title'] = trim($titles[$key]);
313 if (isset($altTexts[$key]) && !empty($altTexts[$key])) {
314 $altText = trim($altTexts[$key]);
316 $altText = sprintf($this->
pi_getLL(
'uploads.icon'), $fileName);
318 $conf[
'linkProc.'][
'altText'] = (
$conf[
'linkProc.'][
'iconCObject.'][
'altText'] = $altText);
319 $this->cObj->setCurrentVal($currentPath);
320 $this->frontendController->register[
'ICON_REL_PATH'] = $currentPath . $fileName;
321 $this->frontendController->register[
'filename'] = $filesData[$key][
'filename'];
322 $this->frontendController->register[
'path'] = $filesData[$key][
'path'];
323 $this->frontendController->register[
'fileSize'] = $filesData[$key][
'filesize'];
324 $this->frontendController->register[
'fileExtension'] = $filesData[$key][
'fileextension'];
325 $this->frontendController->register[
'description'] = $filesData[$key][
'description'];
326 $this->frontendController->register[
'titleText'] = $filesData[$key][
'titletext'];
327 $this->frontendController->register[
'altText'] = $filesData[$key][
'alttext'];
330 explode(
'//**//', $this->cObj->filelink($fileName,
$conf[
'linkProc.'])),
332 $conf[
'useSpacesInLinkText'],
333 $conf[
'stripFileExtensionFromLinkText']
338 $splitConf = $this->frontendController->tmpl->splitConfArray(
$conf, count($filesData));
340 $outputEntries = array();
341 foreach ($filesData as $key => $fileData) {
342 $this->frontendController->register[
'linkedIcon'] = $fileData[
'linkedFilenameParts'][0];
343 $this->frontendController->register[
'linkedLabel'] = $fileData[
'linkedFilenameParts'][1];
344 $this->frontendController->register[
'filename'] = $fileData[
'filename'];
345 $this->frontendController->register[
'path'] = $fileData[
'path'];
346 $this->frontendController->register[
'description'] = $fileData[
'description'];
347 $this->frontendController->register[
'fileSize'] = $fileData[
'filesize'];
348 $this->frontendController->register[
'fileExtension'] = $fileData[
'fileextension'];
349 $this->frontendController->register[
'titleText'] = $fileData[
'titletext'];
350 $this->frontendController->register[
'altText'] = $fileData[
'alttext'];
351 $outputEntries[] = $this->cObj->cObjGetSingle($splitConf[$key][
'itemRendering'], $splitConf[$key][
'itemRendering.']);
353 if (isset(
$conf[
'outerWrap'])) {
355 $outerWrap = $this->cObj->stdWrap(
$conf[
'outerWrap'],
$conf[
'outerWrap.']);
359 $tableTagParams[
'class'] =
'csc-uploads csc-uploads-' . $type;
363 $out = $this->cObj->wrap(implode(
'', $outputEntries), $outerWrap);
382 $relations = array();
383 $equalRelations = array_fill(0, $colCount, 1);
384 $colRelationsTypoScript = trim($this->cObj->stdWrap(
$conf[
'colRelations'],
$conf[
'colRelations.']));
385 if ($colRelationsTypoScript) {
387 $relationParts = explode(
':', $colRelationsTypoScript);
389 if (count($relationParts) >= $colCount) {
391 for ($a = 0; $a < $colCount; $a++) {
392 $currentRelationValue = (int)$relationParts[$a];
393 if ($currentRelationValue >= 1) {
394 $out[$a] = $currentRelationValue;
396 GeneralUtility::devLog(
'colRelations used with a value smaller than 1 therefore colRelations setting is ignored.', $this->extKey, 2);
401 if (max($out) / min($out) <= 10) {
405 'The difference in size between the largest and smallest colRelation was not within' .
406 ' a factor of ten therefore colRelations setting is ignored..',
413 return $relations ?: $equalRelations;
426 $columnWidths = array();
429 $accumDesiredWidth = 0;
430 $relUnitCount = array_sum($colRelations);
431 for ($a = 0; $a < $colCount; $a++) {
433 $availableWidth = $netW - $accumWidth;
435 $desiredWidth = $netW / $relUnitCount * $colRelations[$a];
437 $accumDesiredWidth += $desiredWidth;
440 $suggestedWidth = round($accumDesiredWidth - $accumWidth);
442 $finalImgWidth = (int)min($availableWidth, $suggestedWidth);
443 $accumWidth += $finalImgWidth;
444 $columnWidths[$a] = $finalImgWidth;
446 return $columnWidths;
456 public function render_textpic($content,
$conf)
459 if (method_exists($this,
'hookRequest') && ($hookObj = $this->
hookRequest(
'render_textpic'))) {
460 return $hookObj->render_textpic($content,
$conf);
462 $renderMethod = $this->cObj->stdWrap(
$conf[
'renderMethod'],
$conf[
'renderMethod.']);
464 if (!$renderMethod || $renderMethod ==
'table') {
465 return $this->cObj->cObjGetSingle(
'IMGTEXT',
$conf);
467 $restoreRegisters =
false;
468 if (isset(
$conf[
'preRenderRegisters.'])) {
469 $restoreRegisters =
true;
470 $this->cObj->cObjGetSingle(
'LOAD_REGISTER',
$conf[
'preRenderRegisters.']);
473 if (is_array(
$conf[
'rendering.'][$renderMethod .
'.'])) {
474 $conf = array_replace_recursive(
$conf,
$conf[
'rendering.'][$renderMethod .
'.']);
477 if (is_array(
$conf[
'text.'])) {
478 $content = $this->cObj->stdWrap($this->cObj->cObjGet(
$conf[
'text.'],
'text.'),
$conf[
'text.']);
480 $imgList = trim($this->cObj->stdWrap(
$conf[
'imgList'],
$conf[
'imgList.']));
483 if ($restoreRegisters) {
484 $this->cObj->cObjGetSingle(
'RESTORE_REGISTER', array());
491 if ($restoreRegisters) {
492 $this->cObj->cObjGetSingle(
'RESTORE_REGISTER', array());
496 $imgStart = (int)$this->cObj->stdWrap(
$conf[
'imgStart'],
$conf[
'imgStart.']);
497 $imgCount = count($imgs) - $imgStart;
498 $imgMax = (int)$this->cObj->stdWrap(
$conf[
'imgMax'],
$conf[
'imgMax.']);
502 $imgPath = $this->cObj->stdWrap(
$conf[
'imgPath'],
$conf[
'imgPath.']);
504 $renderGlobalCaption = !
$conf[
'captionSplit'] && !
$conf[
'imageTextSplit'] && is_array(
$conf[
'caption.']);
505 if ($imgCount == 1) {
507 $renderGlobalCaption =
false;
509 $imgListContainsReferenceUids = (bool)(isset(
$conf[
'imgListContainsReferenceUids.'])
510 ? $this->cObj->stdWrap(
$conf[
'imgListContainsReferenceUids'],
$conf[
'imgListContainsReferenceUids.'])
511 :
$conf[
'imgListContainsReferenceUids']);
513 $this->frontendController->register[
'imageCount'] = $imgCount;
514 $this->frontendController->register[
'renderGlobalCaption'] = $renderGlobalCaption;
515 $fallbackRenderMethod =
'';
516 if (
$conf[
'fallbackRendering']) {
517 $fallbackRenderMethod = $this->cObj->cObjGetSingle(
$conf[
'fallbackRendering'],
$conf[
'fallbackRendering.']);
519 if ($fallbackRenderMethod && is_array(
$conf[
'rendering.'][$fallbackRenderMethod .
'.'])) {
520 $conf = array_replace_recursive(
$conf,
$conf[
'rendering.'][$fallbackRenderMethod .
'.']);
523 $accessibilityMode =
false;
524 if (strpos(strtolower($renderMethod),
'caption') || strpos(strtolower($fallbackRenderMethod),
'caption')) {
525 $accessibilityMode =
true;
529 if ($renderGlobalCaption) {
530 $globalCaption = $this->cObj->stdWrap($this->cObj->cObjGet(
$conf[
'caption.'],
'caption.'),
$conf[
'caption.']);
533 $position = $this->cObj->stdWrap(
$conf[
'textPos'],
$conf[
'textPos.']);
535 $imagePosition = $position & 7;
537 $contentPosition = $position & 24;
538 $textMargin = (int)$this->cObj->stdWrap(
$conf[
'textMargin'],
$conf[
'textMargin.']);
539 if (!
$conf[
'textMargin_outOfText'] && $contentPosition < 16) {
542 $colspacing = (int)$this->cObj->stdWrap(
$conf[
'colSpace'],
$conf[
'colSpace.']);
543 $border = (int)$this->cObj->stdWrap(
$conf[
'border'],
$conf[
'border.']) ? 1 : 0;
544 $borderThickness = (int)$this->cObj->stdWrap(
$conf[
'borderThick'],
$conf[
'borderThick.']);
545 $borderThickness = $borderThickness ?: 1;
546 $borderSpace =
$conf[
'borderSpace'] && $border ? (int)
$conf[
'borderSpace'] : 0;
548 $cols = (int)$this->cObj->stdWrap(
$conf[
'cols'],
$conf[
'cols.']);
549 $colCount = $cols > 1 ? $cols : 1;
550 if ($colCount > $imgCount) {
551 $colCount = $imgCount;
553 $rowCount = ceil($imgCount / $colCount);
555 $rows = (int)$this->cObj->stdWrap(
$conf[
'rows'],
$conf[
'rows.']);
558 if ($rowCount > $imgCount) {
559 $rowCount = $imgCount;
561 $colCount = $rowCount > 1 ? ceil($imgCount / $rowCount) : $imgCount;
564 $maxW = (int)$this->cObj->stdWrap(
$conf[
'maxW'],
$conf[
'maxW.']);
565 $maxWInText = (int)$this->cObj->stdWrap(
$conf[
'maxWInText'],
$conf[
'maxWInText.']);
566 $fiftyPercentWidthInText = round($maxW / 100 * 50);
568 if ($contentPosition >= 16) {
571 $maxW = $fiftyPercentWidthInText;
577 $netW = $maxW - $colspacing * ($colCount - 1) - $colCount * $border * ($borderThickness + $borderSpace) * 2;
580 $image_compression = (int)$this->cObj->stdWrap(
$conf[
'image_compression'],
$conf[
'image_compression.']);
581 $image_effects = (int)$this->cObj->stdWrap(
$conf[
'image_effects'],
$conf[
'image_effects.']);
582 $image_frames = (int)$this->cObj->stdWrap(
$conf[
'image_frames.'][
'key'],
$conf[
'image_frames.'][
'key.']);
584 $equalHeight = (int)$this->cObj->stdWrap(
$conf[
'equalH'],
$conf[
'equalH.']);
586 $relations_cols = array();
588 $imgWidths = array();
589 for ($a = 0; $a < $imgCount; $a++) {
590 $imgKey = $a + $imgStart;
594 if ($imgListContainsReferenceUids) {
595 $file = $this->
getResourceFactory()->getFileReferenceObject((
int)$imgs[$imgKey])->getOriginalFile();
600 $file = $this->
getResourceFactory()->getFileObjectFromCombinedIdentifier($imgPath . $imgs[$imgKey]);
604 $rel = $file->getProperty(
'height') / $equalHeight;
607 $imgWidths[$a] = $file->getProperty(
'width') / $rel;
609 $relations_cols[(int)floor($a / $colCount)] += $imgWidths[$a];
615 $splitArr[
'imgObjNum'] =
$conf[
'imgObjNum'];
616 $splitArr = $this->frontendController->tmpl->splitConfArray($splitArr, $imgCount);
618 $imageRowsFinalWidths = array();
621 $origImages = array();
623 for ($a = 0; $a < $imgCount; $a++) {
624 $imgKey = $a + $imgStart;
627 $totalImagePath = (int)$imgs[$imgKey];
630 $totalImagePath = $imgPath . $imgs[$imgKey];
633 $this->frontendController->register[
'IMAGE_NUM'] = $imgKey;
634 $this->frontendController->register[
'IMAGE_NUM_CURRENT'] = $imgKey;
635 $this->frontendController->register[
'ORIG_FILENAME'] = $totalImagePath;
636 $this->cObj->data[$this->cObj->currentValKey] = $totalImagePath;
637 $imgObjNum = (int)$splitArr[$a][
'imgObjNum'];
638 $imgConf =
$conf[$imgObjNum .
'.'];
640 if ($a % $colCount == 0) {
645 $accumDesiredWidth = 0;
646 $rowTotalMaxW = $relations_cols[$rowIdx];
647 if ($rowTotalMaxW > $netW && $netW > 0) {
648 $scale = $rowTotalMaxW / $netW;
652 $desiredHeight = $equalHeight / $scale;
656 $availableWidth = $netW - $accumWidth;
658 $desiredWidth = $imgWidths[$a] / $scale;
660 $accumDesiredWidth += $desiredWidth;
663 $suggestedWidth = round($accumDesiredWidth - $accumWidth);
665 $finalImgWidth = (int)min($availableWidth, $suggestedWidth);
666 $accumWidth += $finalImgWidth;
667 $imgConf[
'file.'][
'width'] = $finalImgWidth;
668 $imgConf[
'file.'][
'height'] = round($desiredHeight);
670 unset($imgConf[
'file.'][
'maxW']);
671 unset($imgConf[
'file.'][
'maxH']);
672 unset($imgConf[
'file.'][
'minW']);
673 unset($imgConf[
'file.'][
'minH']);
674 unset($imgConf[
'file.'][
'width.']);
675 unset($imgConf[
'file.'][
'maxW.']);
676 unset($imgConf[
'file.'][
'maxH.']);
677 unset($imgConf[
'file.'][
'minW.']);
678 unset($imgConf[
'file.'][
'minH.']);
680 $imgConf[
'file.'][
'maxW'] = $columnWidths[$a % $colCount];
682 $titleInLink = $this->cObj->stdWrap($imgConf[
'titleInLink'], $imgConf[
'titleInLink.']);
683 $titleInLinkAndImg = $this->cObj->stdWrap($imgConf[
'titleInLinkAndImg'], $imgConf[
'titleInLinkAndImg.']);
684 $oldATagParms = $this->frontendController->ATagParams;
687 $titleText = trim($this->cObj->stdWrap($imgConf[
'titleText'], $imgConf[
'titleText.']));
690 $this->frontendController->ATagParams .=
' title="' . htmlspecialchars($titleText) .
'"';
697 $customRendering =
'';
698 if (isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'css_styled_content'][
'pi1_hooks'][
'render_singleMediaElement'])
699 && is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'css_styled_content'][
'pi1_hooks'][
'render_singleMediaElement'])) {
700 $hookParameters = array(
701 'file' => $totalImagePath,
702 'imageConfiguration' => $imgConf
705 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'css_styled_content'][
'pi1_hooks'][
'render_singleMediaElement'] as $reference) {
706 $customRendering = \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($reference, $hookParameters, $this);
708 if (!empty($customRendering)) {
714 if (!empty($customRendering)) {
715 $imgsTag[$imgKey] = $customRendering;
716 }
elseif ($imgConf || $imgConf[
'file']) {
717 if ($this->cObj->image_effects[$image_effects]) {
718 $imgConf[
'file.'][
'params'] .=
' ' . $this->cObj->image_effects[$image_effects];
721 if (is_array(
$conf[
'image_frames.'][$image_frames .
'.'])) {
722 $imgConf[
'file.'][
'm.'] =
$conf[
'image_frames.'][$image_frames .
'.'];
725 if ($image_compression && $imgConf[
'file'] !=
'GIFBUILDER') {
726 if ($image_compression == 1) {
727 $tempImport = $imgConf[
'file.'][
'import'];
728 $tempImport_dot = $imgConf[
'file.'][
'import.'];
729 $tempTreatIdAsReference = $imgConf[
'file.'][
'treatIdAsReference'];
730 unset($imgConf[
'file.']);
731 $imgConf[
'file.'][
'import'] = $tempImport;
732 $imgConf[
'file.'][
'import.'] = $tempImport_dot;
733 $imgConf[
'file.'][
'treatIdAsReference'] = $tempTreatIdAsReference;
734 }
elseif (isset($this->cObj->image_compression[$image_compression])) {
735 $imgConf[
'file.'][
'params'] .=
' ' . $this->cObj->image_compression[$image_compression][
'params'];
736 $imgConf[
'file.'][
'ext'] = $this->cObj->image_compression[$image_compression][
'ext'];
737 unset($imgConf[
'file.'][
'ext.']);
740 if ($titleInLink && !$titleInLinkAndImg) {
742 $link = $this->cObj->imageLinkWrap(
'', $this->cObj->getCurrentFile() ?: $totalImagePath, $imgConf[
'imageLinkWrap.']);
745 unset($imgConf[
'titleText']);
746 unset($imgConf[
'titleText.']);
747 $imgConf[
'emptyTitleHandling'] =
'removeAttr';
750 $imgsTag[$imgKey] = $this->cObj->cObjGetSingle(
'IMAGE', $imgConf);
753 $imgsTag[$imgKey] = $this->cObj->cObjGetSingle(
'IMAGE', array(
'file' => $totalImagePath));
756 $this->frontendController->ATagParams = $oldATagParms;
758 $origImages[$imgKey] = $this->frontendController->lastImageInfo;
759 if ($this->frontendController->lastImageInfo[0] == 0) {
760 $imageRowsFinalWidths[(int)floor($a / $colCount)] += $this->cObj->data[
'imagewidth'];
762 $imageRowsFinalWidths[(int)floor($a / $colCount)] += $this->frontendController->lastImageInfo[0];
766 $imageBlockWidth = max($imageRowsFinalWidths) + $colspacing * ($colCount - 1) + $colCount * $border * ($borderSpace + $borderThickness) * 2;
767 $this->frontendController->register[
'rowwidth'] = $imageBlockWidth;
768 $this->frontendController->register[
'rowWidthPlusTextMargin'] = $imageBlockWidth + $textMargin;
771 $noRows = $this->cObj->stdWrap(
$conf[
'noRows'],
$conf[
'noRows.']);
772 $noCols = $this->cObj->stdWrap(
$conf[
'noCols'],
$conf[
'noCols.']);
782 if (!is_array(
$conf[
'editIcons.'])) {
783 $conf[
'editIcons.'] = array();
785 $editIconsHTML =
$conf[
'editIcons'] && $this->frontendController->beUserLogin ? $this->cObj->editIcons(
'',
$conf[
'editIcons'],
$conf[
'editIcons.']) :
'';
789 $imageWrapCols = $colCount;
792 $separateRows = $this->cObj->stdWrap(
$conf[
'separateRows'],
$conf[
'separateRows.']);
796 if ($rowCount == 1) {
799 if ($accessibilityMode) {
800 $imagesInColumns = round($imgCount / ($rowCount * $colCount), 0, PHP_ROUND_HALF_UP);
802 $addClassesCol =
$conf[
'addClassesCol'];
803 if (isset(
$conf[
'addClassesCol.'])) {
804 $addClassesCol = $this->cObj->stdWrap($addClassesCol,
$conf[
'addClassesCol.']);
806 $addClassesColConf = $this->frontendController->tmpl->splitConfArray(array(
'addClassesCol' => $addClassesCol), $colCount);
808 $addClassesImage =
$conf[
'addClassesImage'];
809 if (isset(
$conf[
'addClassesImage.'])) {
810 $addClassesImage = $this->cObj->stdWrap($addClassesImage,
$conf[
'addClassesImage.']);
812 $addClassesImageConf = $this->frontendController->tmpl->splitConfArray(array(
'addClassesImage' => $addClassesImage), $imagesInColumns);
816 $classCaptionAlign = array(
817 'center' =>
'csc-textpic-caption-c',
818 'right' =>
'csc-textpic-caption-r',
819 'left' =>
'csc-textpic-caption-l'
821 $captionAlign = $this->cObj->stdWrap(
$conf[
'captionAlign'],
$conf[
'captionAlign.']);
823 for ($rowCounter = 1; $rowCounter <= $rowCount; $rowCounter++) {
824 $rowColumns = array();
826 for ($columnCounter = 1; $columnCounter <= $colCount; $columnCounter++) {
827 $columnImages = array();
829 for ($imagesCounter = 1; $imagesCounter <= $imagesInColumns; $imagesCounter++) {
831 $splitCaption = null;
832 $imageMarkers = ($captionMarkers = array());
835 $imageKey = $currentImage + $imgStart;
837 $this->frontendController->register[
'IMAGE_NUM_CURRENT'] = $imageKey;
838 $this->cObj->data[$this->cObj->currentValKey] = $origImages[$imageKey][
'origFile'];
841 }
elseif (!isset($imgs[$imageKey])) {
844 $this->cObj->setCurrentFile(null);
847 if (isset($imgsTag[$imageKey])) {
848 $image = $this->cObj->stdWrap($imgsTag[$imageKey],
$conf[
'imgTagStdWrap.']);
850 if ($editIconsHTML) {
851 $image .= $this->cObj->stdWrap($editIconsHTML,
$conf[
'editIconsStdWrap.']);
854 $single = $this->cObj->stdWrap($image,
$conf[
'singleStdWrap.']);
856 if (!$renderGlobalCaption) {
857 $imageMarkers[
'caption'] = $this->cObj->stdWrap($this->cObj->cObjGet(
$conf[
'caption.'],
'caption.'),
$conf[
'caption.']);
859 $captionMarkers[
'classes'] =
' ' . $classCaptionAlign[$captionAlign];
861 $imageMarkers[
'caption'] = $this->cObj->substituteMarkerArray($imageMarkers[
'caption'], $captionMarkers,
'###|###', 1, 1);
863 if ($addClassesImageConf[$imagesCounter - 1][
'addClassesImage']) {
864 $imageMarkers[
'classes'] =
' ' . $addClassesImageConf[($imagesCounter - 1)][
'addClassesImage'];
867 $columnImages[] = $this->cObj->substituteMarkerArray($single, $imageMarkers,
'###|###', 1, 1);
870 $rowColumn = $this->cObj->stdWrap(implode(LF, $columnImages),
$conf[
'columnStdWrap.']);
872 $columnMarkers = array();
873 if ($addClassesColConf[$columnCounter - 1][
'addClassesCol']) {
874 $columnMarkers[
'classes'] =
' ' . $addClassesColConf[($columnCounter - 1)][
'addClassesCol'];
876 $rowColumns[] = $this->cObj->substituteMarkerArray($rowColumn, $columnMarkers,
'###|###', 1, 1);
879 $rowConfiguration =
$conf[
'noRowsStdWrap.'];
880 }
elseif ($rowCounter == $rowCount) {
881 $rowConfiguration =
$conf[
'lastRowStdWrap.'];
883 $rowConfiguration =
$conf[
'rowStdWrap.'];
885 $row = $this->cObj->stdWrap(implode(LF, $rowColumns), $rowConfiguration);
887 $rowMarkers = array();
888 $rows[] = $this->cObj->substituteMarkerArray($row, $rowMarkers,
'###|###', 1, 1);
890 $images = $this->cObj->stdWrap(implode(LF, $rows),
$conf[
'allStdWrap.']);
892 $allMarkers = array();
895 if ($globalCaption) {
896 $allMarkers[
'caption'] = $globalCaption;
898 $classes[] = $classCaptionAlign[$captionAlign];
902 $noWrapMargin = (int)(($maxWInText ? $maxWInText : $fiftyPercentWidthInText) + (int)$this->cObj->stdWrap(
$conf[
'textMargin'],
$conf[
'textMargin.']));
903 $this->
addPageStyle(
'.csc-textpic-intext-right-nowrap .csc-textpic-text',
'margin-right: ' . $noWrapMargin .
'px;');
904 $this->
addPageStyle(
'.csc-textpic-intext-left-nowrap .csc-textpic-text',
'margin-left: ' . $noWrapMargin .
'px;');
906 if ($contentPosition == 24 && $maxW != $imageBlockWidth) {
907 $noWrapMargin = $imageBlockWidth + $textMargin;
909 if ($imagePosition == 1) {
910 $this->
addPageStyle(
'.csc-textpic-intext-right-nowrap-' . $noWrapMargin .
' .csc-textpic-text',
'margin-right: ' . $noWrapMargin .
'px;');
911 $classes[] =
'csc-textpic-intext-right-nowrap-' . $noWrapMargin;
912 }
elseif ($imagePosition == 2) {
913 $this->
addPageStyle(
'.csc-textpic-intext-left-nowrap-' . $noWrapMargin .
' .csc-textpic-text',
'margin-left: ' . $noWrapMargin .
'px;');
914 $classes[] =
'csc-textpic-intext-left-nowrap-' . $noWrapMargin;
919 $classes[] =
$conf[
'borderClass'] ?:
'csc-textpic-border';
923 $classes[] =
'csc-textpic-equalheight';
925 $addClasses = $this->cObj->stdWrap(
$conf[
'addClasses'],
$conf[
'addClasses.']);
927 $classes[] = $addClasses;
930 $class =
' ' . implode(
' ', $classes);
933 $images = $this->cObj->substituteMarkerArray($images, $allMarkers,
'###|###', 1, 1);
936 $addClassesImage =
$conf[
'addClassesImage'];
937 if (isset(
$conf[
'addClassesImage.'])) {
938 $addClassesImage = $this->cObj->stdWrap($addClassesImage,
$conf[
'addClassesImage.']);
940 $addClassesImageConf = $this->frontendController->tmpl->splitConfArray(array(
'addClassesImage' => $addClassesImage), $colCount);
943 for ($c = 0; $c < $imageWrapCols; $c++) {
944 $tmpColspacing = $colspacing;
945 if ($c == $imageWrapCols - 1 && $imagePosition == 2 || $c == 0 && ($imagePosition == 1 || $imagePosition == 0)) {
952 $imgsTagCount = count($imgsTag);
953 for ($i = $c; $i < $imgsTagCount; $i = $i + $imageWrapCols) {
954 $imgKey = $i + $imgStart;
955 $colPos = $i % $colCount;
956 if ($separateRows && $colPos == 0) {
960 if ($origImages[$imgKey][0] == 0) {
961 $imageSpace = $this->cObj->data[
'imagewidth'] + $border * ($borderSpace + $borderThickness) * 2;
963 $imageSpace = $origImages[$imgKey][0] + $border * ($borderSpace + $borderThickness) * 2;
965 $this->frontendController->register[
'IMAGE_NUM'] = $imgKey;
966 $this->frontendController->register[
'IMAGE_NUM_CURRENT'] = $imgKey;
967 $this->frontendController->register[
'ORIG_FILENAME'] = $origImages[$imgKey][
'origFile'];
968 $this->frontendController->register[
'imagewidth'] = $origImages[$imgKey][0];
969 $this->frontendController->register[
'imagespace'] = $imageSpace;
970 $this->frontendController->register[
'imageheight'] = $origImages[$imgKey][1];
974 if ($imageSpace > $maxImageSpace) {
975 $maxImageSpace = $imageSpace;
978 $thisImage .= $this->cObj->stdWrap($imgsTag[$imgKey],
$conf[
'imgTagStdWrap.']);
979 if (!$renderGlobalCaption) {
980 $thisImage .= $this->cObj->stdWrap($this->cObj->cObjGet(
$conf[
'caption.'],
'caption.'),
$conf[
'caption.']);
982 if ($editIconsHTML) {
983 $thisImage .= $this->cObj->stdWrap($editIconsHTML,
$conf[
'editIconsStdWrap.']);
985 $thisImage = $this->cObj->stdWrap($thisImage,
$conf[
'oneImageStdWrap.']);
987 if ($addClassesImageConf[$colPos][
'addClassesImage']) {
988 $classes =
' ' . $addClassesImageConf[$colPos][
'addClassesImage'];
990 $thisImage = str_replace(
'###CLASSES###', $classes, $thisImage);
992 $thisRow .= $thisImage;
994 $allRows .= $thisImage;
996 $this->frontendController->register[
'columnwidth'] = $maxImageSpace + $tmpColspacing;
998 if ($separateRows && $i + 1 === count($imgsTag)) {
1000 $allRows .= $this->cObj->stdWrap(
1002 is_array(
$conf[
'imageLastRowStdWrap.']) ?
$conf[
'imageLastRowStdWrap.'] :
$conf[
'imageRowStdWrap.']
1004 }
elseif ($separateRows && $colPos == $colCount - 1) {
1005 $allRows .= $this->cObj->stdWrap($thisRow,
$conf[
'imageRowStdWrap.']);
1008 if ($separateRows) {
1009 $thisImages .= $allRows;
1011 $thisImages .= $this->cObj->stdWrap($allRows,
$conf[
'noRowsStdWrap.']);
1015 $images .= $this->cObj->stdWrap($thisImages,
$conf[
'imageColumnStdWrap.']);
1017 $images .= $thisImages;
1021 if ($globalCaption) {
1022 $images .= $globalCaption;
1026 $classCaptionAlign = array(
1027 'center' =>
'csc-textpic-caption-c',
1028 'right' =>
'csc-textpic-caption-r',
1029 'left' =>
'csc-textpic-caption-l'
1031 $captionAlign = $this->cObj->stdWrap(
$conf[
'captionAlign'],
$conf[
'captionAlign.']);
1032 if ($captionAlign) {
1033 $captionClass = $classCaptionAlign[$captionAlign];
1037 $borderClass =
$conf[
'borderClass'] ?:
'csc-textpic-border';
1041 $class .= $borderClass ?
' ' . $borderClass :
'';
1042 $class .= $captionClass ?
' ' . $captionClass :
'';
1043 $class .= $equalHeight ?
' csc-textpic-equalheight' :
'';
1044 $addClasses = $this->cObj->stdWrap(
$conf[
'addClasses'],
$conf[
'addClasses.']);
1045 $class .= $addClasses ?
' ' . $addClasses :
'';
1048 if ($position == 0 || $position == 8) {
1050 $imgWrapWidth = $imageBlockWidth;
1052 if ($rowCount > 1) {
1054 $imgWrapWidth = $imageBlockWidth;
1056 if ($globalCaption) {
1058 $imgWrapWidth = $imageBlockWidth;
1061 $this->frontendController->register[
'totalwidth'] = $imgWrapWidth;
1062 if ($imgWrapWidth) {
1063 $images = $this->cObj->stdWrap($images,
$conf[
'imageStdWrap.']);
1065 $images = $this->cObj->stdWrap($images,
$conf[
'imageStdWrapNoWidth.']);
1069 $output = str_replace(
1080 $this->cObj->cObjGetSingle(
$conf[
'layout'],
$conf[
'layout.'])
1083 if ($restoreRegisters) {
1084 $this->cObj->cObjGetSingle(
'RESTORE_REGISTER', array());
1102 $resourceFactory = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance();
1103 if ($treatAsReference) {
1104 $imageFile = $resourceFactory->getFileReferenceObject($fileUid);
1106 $imageFile = $resourceFactory->getFileObject($fileUid);
1108 $this->cObj->setCurrentFile($imageFile);
1128 if (method_exists($this,
'hookRequest') && ($hookObject = $this->
hookRequest(
'renderSpace'))) {
1129 return $hookObject->renderSpace($content, $configuration);
1131 if (isset($configuration[
'space']) && in_array($configuration[
'space'], array(
'before',
'after'))) {
1132 $constant = (int)$configuration[
'constant'];
1133 if ($configuration[
'space'] ===
'before') {
1134 $value = $constant + $this->cObj->data[
'spaceBefore'];
1135 $declaration =
'margin-top: ' . $value .
'px !important;';
1137 $value = $constant + $this->cObj->data[
'spaceAfter'];
1138 $declaration =
'margin-bottom: ' . $value .
'px !important;';
1140 if (!empty($value)) {
1141 if ($configuration[
'classStdWrap.']) {
1142 $className = $this->cObj->stdWrap($value, $configuration[
'classStdWrap.']);
1144 $className = $value;
1146 $selector =
'.' . trim($className);
1170 protected function beautifyFileLink(array $links, $fileName, $useSpaces =
false, $cutFileExtension =
false)
1173 $linkText = $fileName;
1175 $linkText = str_replace(
'_',
' ', $linkText);
1177 if ($cutFileExtension) {
1178 $pos = strrpos($linkText,
'.');
1179 $linkText = substr($linkText, 0, $pos);
1181 $links[1] = str_replace(
'>' . $fileName .
'<',
'>' . htmlspecialchars($linkText) .
'<', $links[1]);
1195 $tableTagParams_conf =
$conf[
'tableParams_' . $type .
'.'];
1196 $border = $this->cObj->data[
'table_border'] ? (int)$this->cObj->data[
'table_border'] : $tableTagParams_conf[
'border'];
1197 $cellSpacing = $this->cObj->data[
'table_cellspacing'] ? (
int)$this->cObj->data[
'table_cellspacing'] : $tableTagParams_conf[
'cellspacing'];
1198 $cellPadding = $this->cObj->data[
'table_cellpadding'] ? (int)$this->cObj->data[
'table_cellpadding'] : $tableTagParams_conf[
'cellpadding'];
1199 $summary = trim(htmlspecialchars($this->
pi_getFFvalue($this->cObj->data[
'pi_flexform'],
'acctables_summary')));
1201 $tableTagParams = ($classes = array());
1203 if ($this->frontendController->config[
'config'][
'doctype'] !==
'html5') {
1204 $tableTagParams[
'border'] = $border;
1205 $tableTagParams[
'cellspacing'] = $cellSpacing;
1206 $tableTagParams[
'cellpadding'] = $cellPadding;
1208 $tableTagParams[
'summary'] = $summary;
1213 $borderClass =
'contenttable-border-' . $border;
1214 $borderDeclaration =
'border-width: ' . $border .
'px; border-style: solid;';
1215 $this->
addPageStyle(
'.' . $borderClass, $borderDeclaration);
1216 $classes[] = $borderClass;
1220 $tableTagParams[
'border'] = 1;
1222 $cellSpacingClass =
'contenttable-cellspacing-' . $cellSpacing;
1223 $cellSpacingDeclaration =
'border-spacing: ' . $cellSpacing .
'px;';
1224 $this->
addPageStyle(
'.' . $cellSpacingClass, $cellSpacingDeclaration);
1225 $classes[] = $cellSpacingClass;
1229 $cellPaddingClass =
'contenttable-cellpadding-' . $cellPadding;
1230 $cellSpacingSelector =
'.' . $cellPaddingClass .
' td, .' . $cellPaddingClass .
' th';
1231 $cellPaddingDeclaration =
'padding: ' . $cellPadding .
'px;';
1232 $this->
addPageStyle($cellSpacingSelector, $cellPaddingDeclaration);
1233 $classes[] = $cellPaddingClass;
1237 if (isset(
$conf[
'color.'][$this->cObj->data[
'table_bgColor']]) && !empty(
$conf[
'color.'][$this->cObj->data[
'table_bgColor']])) {
1238 $classes[] =
'contenttable-color-' . $this->cObj->data[
'table_bgColor'];
1240 if (!empty($classes)) {
1241 $tableTagParams[
'class'] =
' ' . implode(
' ', $classes);
1244 return $tableTagParams;
1260 if (!isset($this->frontendController->tmpl->setup[
'plugin.'][
'tx_cssstyledcontent.'][
'_CSS_PAGE_STYLE'])) {
1261 $this->frontendController->tmpl->setup[
'plugin.'][
'tx_cssstyledcontent.'][
'_CSS_PAGE_STYLE'] = array();
1263 if (!isset($this->frontendController->tmpl->setup[
'plugin.'][
'tx_cssstyledcontent.'][
'_CSS_PAGE_STYLE'][$selector])) {
1264 $this->frontendController->tmpl->setup[
'plugin.'][
'tx_cssstyledcontent.'][
'_CSS_PAGE_STYLE'][$selector] = TAB . $selector .
' { ' . $declaration .
' }';
1277 if (
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'css_styled_content'][
'pi1_hooks'][$functionName]) {
1279 if (method_exists($hookObj, $functionName)) {
1280 $hookObj->pObj = $this;
1293 return \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance();