Initial commit
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\Compatibility6\ContentObject;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
/**
|
||||
* Contains CLEARGIF class object.
|
||||
*/
|
||||
class ClearGifContentObject extends \TYPO3\CMS\Frontend\ContentObject\AbstractContentObject
|
||||
{
|
||||
/**
|
||||
* Rendering the cObject, CLEARGIF
|
||||
*
|
||||
* @param array $conf Array of TypoScript properties
|
||||
* @return string Output
|
||||
*/
|
||||
public function render($conf = array())
|
||||
{
|
||||
$width = isset($conf['width.']) ? $this->cObj->stdWrap($conf['width'], $conf['width.']) : $conf['width'];
|
||||
if (!$width) {
|
||||
$width = 1;
|
||||
}
|
||||
$height = isset($conf['height.']) ? $this->cObj->stdWrap($conf['height'], $conf['height.']) : $conf['height'];
|
||||
if (!$height) {
|
||||
$height = 1;
|
||||
}
|
||||
$wrap = isset($conf['wrap.']) ? $this->cObj->stdWrap($conf['wrap'], $conf['wrap.']) : $conf['wrap'];
|
||||
if (!$wrap) {
|
||||
$wrap = '|<br />';
|
||||
}
|
||||
$theValue = $this->cObj->wrap('<span style="width: ' . $width . 'px; height: ' . $height . 'px;"></span>', $wrap);
|
||||
if (isset($conf['stdWrap.'])) {
|
||||
$theValue = $this->cObj->stdWrap($theValue, $conf['stdWrap.']);
|
||||
}
|
||||
return $theValue;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\Compatibility6\ContentObject;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
/**
|
||||
* Contains COLUMNS content object.
|
||||
*/
|
||||
class ColumnsContentObject extends \TYPO3\CMS\Frontend\ContentObject\AbstractContentObject
|
||||
{
|
||||
/**
|
||||
* Rendering the cObject, COLUMNS
|
||||
*
|
||||
* @param array $conf Array of TypoScript properties
|
||||
* @return string Output
|
||||
*/
|
||||
public function render($conf = array())
|
||||
{
|
||||
if (empty($conf) || !empty($conf['if.']) && !$this->cObj->checkIf($conf['if.'])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$content = '';
|
||||
|
||||
$tdRowCount = 0;
|
||||
$tableParams = isset($conf['tableParams.']) ? $this->cObj->stdWrap($conf['tableParams'], $conf['tableParams.']) : $conf['tableParams'];
|
||||
$tableParams = $tableParams ? ' ' . $tableParams : ' border="0" cellspacing="0" cellpadding="0"';
|
||||
$TDparams = isset($conf['TDParams.']) ? $this->cObj->stdWrap($conf['TDParams'], $conf['TDParams.']) : $conf['TDParams'];
|
||||
$TDparams = $TDparams ? ' ' . $TDparams : ' valign="top"';
|
||||
$rows = isset($conf['rows.']) ? $this->cObj->stdWrap($conf['rows'], $conf['rows.']) : $conf['rows'];
|
||||
$rows = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($rows, 2, 20);
|
||||
$totalWidth = isset($conf['totalWidth.']) ? (int)$this->cObj->stdWrap($conf['totalWidth'], $conf['totalWidth.']) : (int)$conf['totalWidth'];
|
||||
$totalGapWidth = 0;
|
||||
$gapData = array(
|
||||
'gapWidth' => isset($conf['gapWidth.']) ? $this->cObj->stdWrap($conf['gapWidth'], $conf['gapWidth.']) : $conf['gapWidth'],
|
||||
'gapBgCol' => isset($conf['gapBgCol.']) ? $this->cObj->stdWrap($conf['gapBgCol'], $conf['gapBgCol.']) : $conf['gapBgCol'],
|
||||
'gapLineThickness' => isset($conf['gapLineThickness.']) ? $this->cObj->stdWrap($conf['gapLineThickness'], $conf['gapLineThickness.']) : $conf['gapLineThickness'],
|
||||
'gapLineCol' => isset($conf['gapLineCol.']) ? $this->cObj->stdWrap($conf['gapLineCol'], $conf['gapLineCol.']) : $conf['gapLineCol']
|
||||
);
|
||||
$gapData = $GLOBALS['TSFE']->tmpl->splitConfArray($gapData, $rows - 1);
|
||||
foreach ($gapData as $val) {
|
||||
$totalGapWidth += (int)$val['gapWidth'];
|
||||
}
|
||||
if ($totalWidth) {
|
||||
$columnWidth = ceil(($totalWidth - $totalGapWidth) / $rows);
|
||||
$TDparams .= ' width="' . $columnWidth . '"';
|
||||
$tableParams .= ' width="' . $totalWidth . '"';
|
||||
} else {
|
||||
$TDparams .= ' width="' . floor(100 / $rows) . '%"';
|
||||
$tableParams .= ' width="100%"';
|
||||
}
|
||||
for ($a = 1; $a <= $rows; $a++) {
|
||||
$tdRowCount++;
|
||||
$content .= '<td' . $TDparams . '>';
|
||||
$content .= $this->cObj->cObjGetSingle($conf[$a], $conf[$a . '.'], $a);
|
||||
$content .= '</td>';
|
||||
if ($a < $rows) {
|
||||
$gapConf = $gapData[$a - 1];
|
||||
$gapWidth = (int)$gapConf['gapWidth'];
|
||||
if ($gapWidth) {
|
||||
$tdPar = $gapConf['gapBgCol'] ? ' bgcolor="' . $gapConf['gapBgCol'] . '"' : '';
|
||||
$gapLine = (int)$gapConf['gapLineThickness'];
|
||||
if ($gapLine) {
|
||||
$gapSurround = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(($gapWidth - $gapLine) / 2, 1, 1000);
|
||||
// right gap
|
||||
$content .= '<td' . $tdPar . '><span style="width: ' . $gapSurround . 'px; height: 1px;"></span></td>';
|
||||
$tdRowCount++;
|
||||
// line:
|
||||
$GtdPar = $gapConf['gapLineCol'] ? ' bgcolor="' . $gapConf['gapLineCol'] . '"' : ' bgcolor="black"';
|
||||
$content .= '<td' . $GtdPar . '><span style="width: ' . $gapLine . 'px; height: 1px;"></span></td>';
|
||||
$tdRowCount++;
|
||||
// left gap
|
||||
$content .= '<td' . $tdPar . '><span style="width: ' . $gapSurround . 'px; height: 1px;"></span></td>';
|
||||
$tdRowCount++;
|
||||
} else {
|
||||
$content .= '<td' . $tdPar . '><span style="width: ' . $gapWidth . 'px; height: 1px;"></span></td>';
|
||||
$tdRowCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$content = '<tr>' . $content . '</tr>';
|
||||
$content = '<table' . $tableParams . '>' . $content . '</table>';
|
||||
if ($conf['after'] || isset($conf['after.'])) {
|
||||
$content .= $this->cObj->cObjGetSingle($conf['after'], $conf['after.'], 'after');
|
||||
}
|
||||
if (isset($conf['stdWrap.'])) {
|
||||
$content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\Compatibility6\ContentObject;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
/**
|
||||
* Contains CTABLE content object.
|
||||
*/
|
||||
class ContentTableContentObject extends \TYPO3\CMS\Frontend\ContentObject\AbstractContentObject
|
||||
{
|
||||
/**
|
||||
* Rendering the cObject, CTABLE
|
||||
*
|
||||
* @param array $conf Array of TypoScript properties
|
||||
* @return string Output
|
||||
*/
|
||||
public function render($conf = array())
|
||||
{
|
||||
$controlTable = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(TableRenderer::class);
|
||||
$tableParams = isset($conf['tableParams.']) ? $this->cObj->stdWrap($conf['tableParams'], $conf['tableParams.']) : $conf['tableParams'];
|
||||
if ($tableParams) {
|
||||
$controlTable->tableParams = $tableParams;
|
||||
}
|
||||
// loads the pagecontent
|
||||
$conf['cWidth'] = isset($conf['cWidth.']) ? $this->cObj->stdWrap($conf['cWidth'], $conf['cWidth.']) : $conf['cWidth'];
|
||||
$controlTable->contentW = $conf['cWidth'];
|
||||
// loads the menues if any
|
||||
if (is_array($conf['c.'])) {
|
||||
$controlTable->content = $this->cObj->cObjGet($conf['c.'], 'c.');
|
||||
$contentTDParams = isset($conf['c.']['TDParams.']) ? $this->cObj->stdWrap($conf['c.']['TDParams'], $conf['c.']['TDParams.']) : $conf['c.']['TDParams'];
|
||||
$controlTable->contentTDparams = isset($contentTDParams) ? $contentTDParams : 'valign="top"';
|
||||
}
|
||||
if (is_array($conf['lm.'])) {
|
||||
$controlTable->lm = $this->cObj->cObjGet($conf['lm.'], 'lm.');
|
||||
$lmTDParams = isset($conf['lm.']['TDParams.']) ? $this->cObj->stdWrap($conf['lm.']['TDParams'], $conf['lm.']['TDParams.']) : $conf['lm.']['TDParams'];
|
||||
$controlTable->lmTDparams = isset($lmTDParams) ? $lmTDParams : 'valign="top"';
|
||||
}
|
||||
if (is_array($conf['tm.'])) {
|
||||
$controlTable->tm = $this->cObj->cObjGet($conf['tm.'], 'tm.');
|
||||
$tmTDParams = isset($conf['tm.']['TDParams.']) ? $this->cObj->stdWrap($conf['tm.']['TDParams'], $conf['tm.']['TDParams.']) : $conf['tm.']['TDParams'];
|
||||
$controlTable->tmTDparams = isset($tmTDParams) ? $tmTDParams : 'valign="top"';
|
||||
}
|
||||
if (is_array($conf['rm.'])) {
|
||||
$controlTable->rm = $this->cObj->cObjGet($conf['rm.'], 'rm.');
|
||||
$rmTDParams = isset($conf['rm.']['TDParams.']) ? $this->cObj->stdWrap($conf['rm.']['TDParams'], $conf['rm.']['TDParams.']) : $conf['rm.']['TDParams'];
|
||||
$controlTable->rmTDparams = isset($rmTDParams) ? $rmTDParams : 'valign="top"';
|
||||
}
|
||||
if (is_array($conf['bm.'])) {
|
||||
$controlTable->bm = $this->cObj->cObjGet($conf['bm.'], 'bm.');
|
||||
$bmTDParams = isset($conf['bm.']['TDParams.']) ? $this->cObj->stdWrap($conf['bm.']['TDParams'], $conf['bm.']['TDParams.']) : $conf['bm.']['TDParams'];
|
||||
$controlTable->bmTDparams = isset($bmTDParams) ? $bmTDParams : 'valign="top"';
|
||||
}
|
||||
$conf['offset'] = isset($conf['offset.']) ? $this->cObj->stdWrap($conf['offset'], $conf['offset.']) : $conf['offset'];
|
||||
$conf['cMargins'] = isset($conf['cMargins.']) ? $this->cObj->stdWrap($conf['cMargins'], $conf['cMargins.']) : $conf['cMargins'];
|
||||
$theValue = $controlTable->start($conf['offset'], $conf['cMargins']);
|
||||
if (isset($conf['stdWrap.'])) {
|
||||
$theValue = $this->cObj->stdWrap($theValue, $conf['stdWrap.']);
|
||||
}
|
||||
return $theValue;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,661 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\Compatibility6\ContentObject;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
/**
|
||||
* Contains FORM class object.
|
||||
*/
|
||||
class FormContentObject extends \TYPO3\CMS\Frontend\ContentObject\AbstractContentObject
|
||||
{
|
||||
/**
|
||||
* Rendering the cObject, FORM
|
||||
*
|
||||
* Note on $formData:
|
||||
* In the optional $formData array each entry represents a line in the ordinary setup.
|
||||
* In those entries each entry (0,1,2...) represents a space normally divided by the '|' line.
|
||||
*
|
||||
* $formData [] = array('Name:', 'name=input, 25 ', 'Default value....');
|
||||
* $formData [] = array('Email:', 'email=input, 25 ', 'Default value for email....');
|
||||
*
|
||||
* - corresponds to the $conf['data'] value being :
|
||||
* Name:|name=input, 25 |Default value....||Email:|email=input, 25 |Default value for email....
|
||||
*
|
||||
* If $formData is an array the value of $conf['data'] is ignored.
|
||||
*
|
||||
* @param array $conf Array of TypoScript properties
|
||||
* @param array $formData Alternative formdata overriding whatever comes from TypoScript
|
||||
* @return string Output
|
||||
*/
|
||||
public function render($conf = array(), $formData = '')
|
||||
{
|
||||
$content = '';
|
||||
if (is_array($formData)) {
|
||||
$dataArray = $formData;
|
||||
} else {
|
||||
$data = isset($conf['data.']) ? $this->cObj->stdWrap($conf['data'], $conf['data.']) : $conf['data'];
|
||||
// Clearing dataArr
|
||||
$dataArray = array();
|
||||
// Getting the original config
|
||||
if (trim($data)) {
|
||||
$data = str_replace(LF, '||', $data);
|
||||
$dataArray = explode('||', $data);
|
||||
}
|
||||
// Adding the new dataArray config form:
|
||||
if (is_array($conf['dataArray.'])) {
|
||||
// dataArray is supplied
|
||||
$sortedKeyArray = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($conf['dataArray.'], true);
|
||||
foreach ($sortedKeyArray as $theKey) {
|
||||
$singleKeyArray = $conf['dataArray.'][$theKey . '.'];
|
||||
if (is_array($singleKeyArray)) {
|
||||
$temp = array();
|
||||
$label = isset($singleKeyArray['label.']) ? $this->cObj->stdWrap($singleKeyArray['label'], $singleKeyArray['label.']) : $singleKeyArray['label'];
|
||||
list($temp[0]) = explode('|', $label);
|
||||
$type = isset($singleKeyArray['type.']) ? $this->cObj->stdWrap($singleKeyArray['type'], $singleKeyArray['type.']) : $singleKeyArray['type'];
|
||||
list($temp[1]) = explode('|', $type);
|
||||
$required = isset($singleKeyArray['required.']) ? $this->cObj->stdWrap($singleKeyArray['required'], $singleKeyArray['required.']) : $singleKeyArray['required'];
|
||||
if ($required) {
|
||||
$temp[1] = '*' . $temp[1];
|
||||
}
|
||||
$singleValue = isset($singleKeyArray['value.']) ? $this->cObj->stdWrap($singleKeyArray['value'], $singleKeyArray['value.']) : $singleKeyArray['value'];
|
||||
list($temp[2]) = explode('|', $singleValue);
|
||||
// If value array is set, then implode those values.
|
||||
if (is_array($singleKeyArray['valueArray.'])) {
|
||||
$temp_accumulated = array();
|
||||
foreach ($singleKeyArray['valueArray.'] as $singleKey => $singleKey_valueArray) {
|
||||
if (is_array($singleKey_valueArray) && (int)$singleKey . '.' === (string)$singleKey) {
|
||||
$temp_valueArray = array();
|
||||
$valueArrayLabel = isset($singleKey_valueArray['label.']) ? $this->cObj->stdWrap($singleKey_valueArray['label'], $singleKey_valueArray['label.']) : $singleKey_valueArray['label'];
|
||||
list($temp_valueArray[0]) = explode('=', $valueArrayLabel);
|
||||
$selected = isset($singleKey_valueArray['selected.']) ? $this->cObj->stdWrap($singleKey_valueArray['selected'], $singleKey_valueArray['selected.']) : $singleKey_valueArray['selected'];
|
||||
if ($selected) {
|
||||
$temp_valueArray[0] = '*' . $temp_valueArray[0];
|
||||
}
|
||||
$singleKeyValue = isset($singleKey_valueArray['value.']) ? $this->cObj->stdWrap($singleKey_valueArray['value'], $singleKey_valueArray['value.']) : $singleKey_valueArray['value'];
|
||||
list($temp_valueArray[1]) = explode(',', $singleKeyValue);
|
||||
}
|
||||
$temp_accumulated[] = implode('=', $temp_valueArray);
|
||||
}
|
||||
$temp[2] = implode(',', $temp_accumulated);
|
||||
}
|
||||
$specialEval = isset($singleKeyArray['specialEval.']) ? $this->cObj->stdWrap($singleKeyArray['specialEval'], $singleKeyArray['specialEval.']) : $singleKeyArray['specialEval'];
|
||||
list($temp[3]) = explode('|', $specialEval);
|
||||
// Adding the form entry to the dataArray
|
||||
$dataArray[] = implode('|', $temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$attachmentCounter = '';
|
||||
$hiddenfields = '';
|
||||
$fieldlist = array();
|
||||
$propertyOverride = array();
|
||||
$fieldname_hashArray = array();
|
||||
$counter = 0;
|
||||
$xhtmlStrict = GeneralUtility::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype);
|
||||
// Formname
|
||||
$formName = isset($conf['formName.']) ? $this->cObj->stdWrap($conf['formName'], $conf['formName.']) : $conf['formName'];
|
||||
$formName = $this->cleanFormName($formName);
|
||||
$formName = $GLOBALS['TSFE']->getUniqueId($formName);
|
||||
|
||||
$fieldPrefix = isset($conf['fieldPrefix.']) ? $this->cObj->stdWrap($conf['fieldPrefix'], $conf['fieldPrefix.']) : $conf['fieldPrefix'];
|
||||
if (isset($conf['fieldPrefix']) || isset($conf['fieldPrefix.'])) {
|
||||
if ($fieldPrefix) {
|
||||
$prefix = $this->cleanFormName($fieldPrefix);
|
||||
} else {
|
||||
$prefix = '';
|
||||
}
|
||||
} else {
|
||||
$prefix = $formName;
|
||||
}
|
||||
foreach ($dataArray as $dataValue) {
|
||||
$counter++;
|
||||
$confData = array();
|
||||
if (is_array($formData)) {
|
||||
$parts = $dataValue;
|
||||
// TRUE...
|
||||
$dataValue = 1;
|
||||
} else {
|
||||
$dataValue = trim($dataValue);
|
||||
$parts = explode('|', $dataValue);
|
||||
}
|
||||
if ($dataValue && strcspn($dataValue, '#/')) {
|
||||
// label:
|
||||
$confData['label'] = GeneralUtility::removeXSS(trim($parts[0]));
|
||||
// field:
|
||||
$fParts = explode(',', $parts[1]);
|
||||
$fParts[0] = trim($fParts[0]);
|
||||
if ($fParts[0][0] === '*') {
|
||||
$confData['required'] = 1;
|
||||
$fParts[0] = substr($fParts[0], 1);
|
||||
}
|
||||
$typeParts = explode('=', $fParts[0]);
|
||||
$confData['type'] = trim(strtolower(end($typeParts)));
|
||||
if (count($typeParts) === 1) {
|
||||
$confData['fieldname'] = $this->cleanFormName($parts[0]);
|
||||
if (strtolower(preg_replace('/[^[:alnum:]]/', '', $confData['fieldname'])) == 'email') {
|
||||
$confData['fieldname'] = 'email';
|
||||
}
|
||||
// Duplicate fieldnames resolved
|
||||
if (isset($fieldname_hashArray[md5($confData['fieldname'])])) {
|
||||
$confData['fieldname'] .= '_' . $counter;
|
||||
}
|
||||
$fieldname_hashArray[md5($confData['fieldname'])] = $confData['fieldname'];
|
||||
// Attachment names...
|
||||
if ($confData['type'] == 'file') {
|
||||
$confData['fieldname'] = 'attachment' . $attachmentCounter;
|
||||
$attachmentCounter = (int)$attachmentCounter + 1;
|
||||
}
|
||||
} else {
|
||||
$confData['fieldname'] = str_replace(' ', '_', trim($typeParts[0]));
|
||||
}
|
||||
$confData['fieldname'] = htmlspecialchars($confData['fieldname']);
|
||||
$fieldCode = '';
|
||||
$wrapFieldName = isset($conf['wrapFieldName']) ? $this->cObj->stdWrap($conf['wrapFieldName'], $conf['wrapFieldName.']) : $conf['wrapFieldName'];
|
||||
if ($wrapFieldName) {
|
||||
$confData['fieldname'] = $this->cObj->wrap($confData['fieldname'], $wrapFieldName);
|
||||
}
|
||||
// Set field name as current:
|
||||
$this->cObj->setCurrentVal($confData['fieldname']);
|
||||
// Additional parameters
|
||||
if (trim($confData['type'])) {
|
||||
if (isset($conf['params.'][$confData['type']])) {
|
||||
$addParams = isset($conf['params.'][$confData['type'] . '.']) ? trim($this->cObj->stdWrap($conf['params.'][$confData['type']], $conf['params.'][$confData['type'] . '.'])) : trim($conf['params.'][$confData['type']]);
|
||||
} else {
|
||||
$addParams = isset($conf['params.']) ? trim($this->cObj->stdWrap($conf['params'], $conf['params.'])) : trim($conf['params']);
|
||||
}
|
||||
if ((string)$addParams !== '') {
|
||||
$addParams = ' ' . $addParams;
|
||||
}
|
||||
} else {
|
||||
$addParams = '';
|
||||
}
|
||||
$dontMd5FieldNames = isset($conf['dontMd5FieldNames.']) ? $this->cObj->stdWrap($conf['dontMd5FieldNames'], $conf['dontMd5FieldNames.']) : $conf['dontMd5FieldNames'];
|
||||
if ($dontMd5FieldNames) {
|
||||
$fName = $confData['fieldname'];
|
||||
} else {
|
||||
$fName = md5($confData['fieldname']);
|
||||
}
|
||||
// Accessibility: Set id = fieldname attribute:
|
||||
$accessibility = isset($conf['accessibility.']) ? $this->cObj->stdWrap($conf['accessibility'], $conf['accessibility.']) : $conf['accessibility'];
|
||||
if ($accessibility || $xhtmlStrict) {
|
||||
$elementIdAttribute = ' id="' . $prefix . $fName . '"';
|
||||
} else {
|
||||
$elementIdAttribute = '';
|
||||
}
|
||||
// Create form field based on configuration/type:
|
||||
switch ($confData['type']) {
|
||||
case 'textarea':
|
||||
$cols = trim($fParts[1]) ? (int)$fParts[1] : 20;
|
||||
$compensateFieldWidth = isset($conf['compensateFieldWidth.']) ? $this->cObj->stdWrap($conf['compensateFieldWidth'], $conf['compensateFieldWidth.']) : $conf['compensateFieldWidth'];
|
||||
$compWidth = doubleval($compensateFieldWidth ? $compensateFieldWidth : $GLOBALS['TSFE']->compensateFieldWidth);
|
||||
$compWidth = $compWidth ? $compWidth : 1;
|
||||
$cols = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($cols * $compWidth, 1, 120);
|
||||
$rows = trim($fParts[2]) ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($fParts[2], 1, 30) : 5;
|
||||
$wrap = trim($fParts[3]);
|
||||
$noWrapAttr = isset($conf['noWrapAttr.']) ? $this->cObj->stdWrap($conf['noWrapAttr'], $conf['noWrapAttr.']) : $conf['noWrapAttr'];
|
||||
if ($noWrapAttr || $wrap === 'disabled') {
|
||||
$wrap = '';
|
||||
} else {
|
||||
$wrap = $wrap ? ' wrap="' . $wrap . '"' : ' wrap="virtual"';
|
||||
}
|
||||
$noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
|
||||
$default = $this->getFieldDefaultValue($noValueInsert, $confData['fieldname'], str_replace('\\n', LF, trim($parts[2])));
|
||||
$fieldCode = sprintf('<textarea name="%s"%s cols="%s" rows="%s"%s%s>%s</textarea>', $confData['fieldname'], $elementIdAttribute, $cols, $rows, $wrap, $addParams, htmlspecialchars($default));
|
||||
break;
|
||||
case 'input':
|
||||
|
||||
case 'password':
|
||||
$size = trim($fParts[1]) ? (int)$fParts[1] : 20;
|
||||
$compensateFieldWidth = isset($conf['compensateFieldWidth.']) ? $this->cObj->stdWrap($conf['compensateFieldWidth'], $conf['compensateFieldWidth.']) : $conf['compensateFieldWidth'];
|
||||
$compWidth = doubleval($compensateFieldWidth ? $compensateFieldWidth : $GLOBALS['TSFE']->compensateFieldWidth);
|
||||
$compWidth = $compWidth ? $compWidth : 1;
|
||||
$size = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($size * $compWidth, 1, 120);
|
||||
$noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
|
||||
$default = $this->getFieldDefaultValue($noValueInsert, $confData['fieldname'], trim($parts[2]));
|
||||
if ($confData['type'] == 'password') {
|
||||
$default = '';
|
||||
}
|
||||
$max = trim($fParts[2]) ? ' maxlength="' . \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($fParts[2], 1, 1000) . '"' : '';
|
||||
$theType = $confData['type'] == 'input' ? 'text' : 'password';
|
||||
$fieldCode = sprintf('<input type="%s" name="%s"%s size="%s"%s value="%s"%s />', $theType, $confData['fieldname'], $elementIdAttribute, $size, $max, htmlspecialchars($default), $addParams);
|
||||
break;
|
||||
case 'file':
|
||||
$size = trim($fParts[1]) ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($fParts[1], 1, 60) : 20;
|
||||
$fieldCode = sprintf('<input type="file" name="%s"%s size="%s"%s />', $confData['fieldname'], $elementIdAttribute, $size, $addParams);
|
||||
break;
|
||||
case 'check':
|
||||
// alternative default value:
|
||||
$noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
|
||||
$default = $this->getFieldDefaultValue($noValueInsert, $confData['fieldname'], trim($parts[2]));
|
||||
$checked = $default ? ' checked="checked"' : '';
|
||||
$fieldCode = sprintf('<input type="checkbox" value="%s" name="%s"%s%s%s />', 1, $confData['fieldname'], $elementIdAttribute, $checked, $addParams);
|
||||
break;
|
||||
case 'select':
|
||||
$option = '';
|
||||
$valueParts = explode(',', $parts[2]);
|
||||
// size
|
||||
if (strtolower(trim($fParts[1])) == 'auto') {
|
||||
$fParts[1] = count($valueParts);
|
||||
}
|
||||
// Auto size set here. Max 20
|
||||
$size = trim($fParts[1]) ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($fParts[1], 1, 20) : 1;
|
||||
// multiple
|
||||
$multiple = strtolower(trim($fParts[2])) == 'm' ? ' multiple="multiple"' : '';
|
||||
// Where the items will be
|
||||
$items = array();
|
||||
//RTF
|
||||
$defaults = array();
|
||||
$pCount = count($valueParts);
|
||||
for ($a = 0; $a < $pCount; $a++) {
|
||||
$valueParts[$a] = trim($valueParts[$a]);
|
||||
// Finding default value
|
||||
if ($valueParts[$a][0] === '*') {
|
||||
$sel = 'selected';
|
||||
$valueParts[$a] = substr($valueParts[$a], 1);
|
||||
} else {
|
||||
$sel = '';
|
||||
}
|
||||
// Get value/label
|
||||
$subParts = explode('=', $valueParts[$a]);
|
||||
// Sets the value
|
||||
$subParts[1] = isset($subParts[1]) ? trim($subParts[1]) : trim($subParts[0]);
|
||||
// Adds the value/label pair to the items-array
|
||||
$items[] = $subParts;
|
||||
if ($sel) {
|
||||
$defaults[] = $subParts[1];
|
||||
}
|
||||
}
|
||||
// alternative default value:
|
||||
$noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
|
||||
$default = $this->getFieldDefaultValue($noValueInsert, $confData['fieldname'], $defaults);
|
||||
if (!is_array($default)) {
|
||||
$defaults = array();
|
||||
$defaults[] = $default;
|
||||
} else {
|
||||
$defaults = $default;
|
||||
}
|
||||
// Create the select-box:
|
||||
$iCount = count($items);
|
||||
for ($a = 0; $a < $iCount; $a++) {
|
||||
$option .= '<option value="' . $items[$a][1] . '"' . (in_array($items[$a][1], $defaults) ? ' selected="selected"' : '') . '>' . trim($items[$a][0]) . '</option>';
|
||||
}
|
||||
if ($multiple) {
|
||||
// The fieldname must be prepended '[]' if multiple select. And the reason why it's prepended is, because the required-field list later must also have [] prepended.
|
||||
$confData['fieldname'] .= '[]';
|
||||
}
|
||||
$fieldCode = sprintf('<select name="%s"%s size="%s"%s%s>%s</select>', $confData['fieldname'], $elementIdAttribute, $size, $multiple, $addParams, $option);
|
||||
//RTF
|
||||
break;
|
||||
case 'radio':
|
||||
$option = '';
|
||||
$valueParts = explode(',', $parts[2]);
|
||||
// Where the items will be
|
||||
$items = array();
|
||||
$default = '';
|
||||
$pCount = count($valueParts);
|
||||
for ($a = 0; $a < $pCount; $a++) {
|
||||
$valueParts[$a] = trim($valueParts[$a]);
|
||||
if ($valueParts[$a][0] === '*') {
|
||||
$sel = 'checked';
|
||||
$valueParts[$a] = substr($valueParts[$a], 1);
|
||||
} else {
|
||||
$sel = '';
|
||||
}
|
||||
// Get value/label
|
||||
$subParts = explode('=', $valueParts[$a]);
|
||||
// Sets the value
|
||||
$subParts[1] = isset($subParts[1]) ? trim($subParts[1]) : trim($subParts[0]);
|
||||
// Adds the value/label pair to the items-array
|
||||
$items[] = $subParts;
|
||||
if ($sel) {
|
||||
$default = $subParts[1];
|
||||
}
|
||||
}
|
||||
// alternative default value:
|
||||
$noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
|
||||
$default = $this->getFieldDefaultValue($noValueInsert, $confData['fieldname'], $default);
|
||||
// Create the select-box:
|
||||
$iCount = count($items);
|
||||
for ($a = 0; $a < $iCount; $a++) {
|
||||
$optionParts = '';
|
||||
$radioId = $prefix . $fName . $this->cleanFormName($items[$a][0]);
|
||||
if ($accessibility) {
|
||||
$radioLabelIdAttribute = ' id="' . $radioId . '"';
|
||||
} else {
|
||||
$radioLabelIdAttribute = '';
|
||||
}
|
||||
$optionParts .= '<input type="radio" name="' . $confData['fieldname'] . '"' . $radioLabelIdAttribute . ' value="' . $items[$a][1] . '"' . ((string)$items[$a][1] === (string)$default ? ' checked="checked"' : '') . $addParams . ' />';
|
||||
if ($accessibility) {
|
||||
$label = isset($conf['radioWrap.']) ? $this->cObj->stdWrap(trim($items[$a][0]), $conf['radioWrap.']) : trim($items[$a][0]);
|
||||
$optionParts .= '<label for="' . $radioId . '">' . $label . '</label>';
|
||||
} else {
|
||||
$optionParts .= isset($conf['radioWrap.']) ? $this->cObj->stdWrap(trim($items[$a][0]), $conf['radioWrap.']) : trim($items[$a][0]);
|
||||
}
|
||||
$option .= isset($conf['radioInputWrap.']) ? $this->cObj->stdWrap($optionParts, $conf['radioInputWrap.']) : $optionParts;
|
||||
}
|
||||
if ($accessibility) {
|
||||
$accessibilityWrap = isset($conf['radioWrap.']['accessibilityWrap.']) ? $this->cObj->stdWrap($conf['radioWrap.']['accessibilityWrap'], $conf['radioWrap.']['accessibilityWrap.']) : $conf['radioWrap.']['accessibilityWrap'];
|
||||
if ($accessibilityWrap) {
|
||||
$search = array(
|
||||
'###RADIO_FIELD_ID###',
|
||||
'###RADIO_GROUP_LABEL###'
|
||||
);
|
||||
$replace = array(
|
||||
$elementIdAttribute,
|
||||
$confData['label']
|
||||
);
|
||||
$accessibilityWrap = str_replace($search, $replace, $accessibilityWrap);
|
||||
$option = $this->cObj->wrap($option, $accessibilityWrap);
|
||||
}
|
||||
}
|
||||
$fieldCode = $option;
|
||||
break;
|
||||
case 'hidden':
|
||||
$value = trim($parts[2]);
|
||||
// If this form includes an auto responder message, include a HMAC checksum field
|
||||
// in order to verify potential abuse of this feature.
|
||||
if ($value !== '') {
|
||||
if (GeneralUtility::inList($confData['fieldname'], 'auto_respond_msg')) {
|
||||
$hmacChecksum = GeneralUtility::hmac($value, 'content_form');
|
||||
$hiddenfields .= sprintf('<input type="hidden" name="auto_respond_checksum" id="%sauto_respond_checksum" value="%s" />', $prefix, $hmacChecksum);
|
||||
}
|
||||
if (GeneralUtility::inList('recipient_copy,recipient', $confData['fieldname']) && $GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) {
|
||||
break;
|
||||
}
|
||||
if (GeneralUtility::inList('recipient_copy,recipient', $confData['fieldname'])) {
|
||||
$value = \TYPO3\CMS\Compatibility6\Utility\FormUtility::codeString($value);
|
||||
}
|
||||
}
|
||||
$hiddenfields .= sprintf('<input type="hidden" name="%s"%s value="%s" />', $confData['fieldname'], $elementIdAttribute, htmlspecialchars($value));
|
||||
break;
|
||||
case 'property':
|
||||
if (GeneralUtility::inList('type,locationData,goodMess,badMess,emailMess', $confData['fieldname'])) {
|
||||
$value = trim($parts[2]);
|
||||
$propertyOverride[$confData['fieldname']] = $value;
|
||||
$conf[$confData['fieldname']] = $value;
|
||||
}
|
||||
break;
|
||||
case 'submit':
|
||||
$value = trim($parts[2]);
|
||||
if ($conf['image.']) {
|
||||
$this->cObj->data[$this->cObj->currentValKey] = $value;
|
||||
$image = $this->cObj->cObjGetSingle('IMG_RESOURCE', $conf['image.']);
|
||||
$params = $conf['image.']['params'] ? ' ' . $conf['image.']['params'] : '';
|
||||
$params .= $this->cObj->getAltParam($conf['image.'], false);
|
||||
$params .= $addParams;
|
||||
} else {
|
||||
$image = '';
|
||||
}
|
||||
if ($image) {
|
||||
$fieldCode = sprintf('<input type="image" name="%s"%s src="%s"%s />', $confData['fieldname'], $elementIdAttribute, $image, $params);
|
||||
} else {
|
||||
$fieldCode = sprintf('<input type="submit" name="%s"%s value="%s"%s />', $confData['fieldname'], $elementIdAttribute, htmlspecialchars($value, ENT_COMPAT, 'UTF-8', false), $addParams);
|
||||
}
|
||||
break;
|
||||
case 'reset':
|
||||
$value = trim($parts[2]);
|
||||
$fieldCode = sprintf('<input type="reset" name="%s"%s value="%s"%s />', $confData['fieldname'], $elementIdAttribute, htmlspecialchars($value, ENT_COMPAT, 'UTF-8', false), $addParams);
|
||||
break;
|
||||
case 'label':
|
||||
$fieldCode = nl2br(htmlspecialchars(trim($parts[2])));
|
||||
break;
|
||||
default:
|
||||
$confData['type'] = 'comment';
|
||||
$fieldCode = trim($parts[2]) . ' ';
|
||||
}
|
||||
if ($fieldCode) {
|
||||
// Checking for special evaluation modes:
|
||||
if (trim($parts[3]) !== '' && GeneralUtility::inList('textarea,input,password', $confData['type'])) {
|
||||
$modeParameters = GeneralUtility::trimExplode(':', $parts[3]);
|
||||
} else {
|
||||
$modeParameters = array();
|
||||
}
|
||||
// Adding evaluation based on settings:
|
||||
switch ((string)$modeParameters[0]) {
|
||||
case 'EREG':
|
||||
$fieldlist[] = '_EREG';
|
||||
$fieldlist[] = $modeParameters[1];
|
||||
$fieldlist[] = $modeParameters[2];
|
||||
$fieldlist[] = $confData['fieldname'];
|
||||
$fieldlist[] = $confData['label'];
|
||||
// Setting this so "required" layout is used.
|
||||
$confData['required'] = 1;
|
||||
break;
|
||||
case 'EMAIL':
|
||||
$fieldlist[] = '_EMAIL';
|
||||
$fieldlist[] = $confData['fieldname'];
|
||||
$fieldlist[] = $confData['label'];
|
||||
// Setting this so "required" layout is used.
|
||||
$confData['required'] = 1;
|
||||
break;
|
||||
default:
|
||||
if ($confData['required']) {
|
||||
$fieldlist[] = $confData['fieldname'];
|
||||
$fieldlist[] = $confData['label'];
|
||||
}
|
||||
}
|
||||
// Field:
|
||||
$fieldLabel = $confData['label'];
|
||||
if ($accessibility && trim($fieldLabel) && !preg_match('/^(label|hidden|comment)$/', $confData['type'])) {
|
||||
$fieldLabel = '<label for="' . $prefix . $fName . '">' . $fieldLabel . '</label>';
|
||||
}
|
||||
// Getting template code:
|
||||
if (isset($conf['fieldWrap.'])) {
|
||||
$fieldCode = $this->cObj->stdWrap($fieldCode, $conf['fieldWrap.']);
|
||||
}
|
||||
$labelCode = isset($conf['labelWrap.']) ? $this->cObj->stdWrap($fieldLabel, $conf['labelWrap.']) : $fieldLabel;
|
||||
$commentCode = isset($conf['commentWrap.']) ? $this->cObj->stdWrap($confData['label'], $conf['commentWrap.']) : $confData['label'];
|
||||
$result = $conf['layout'];
|
||||
$req = isset($conf['REQ.']) ? $this->cObj->stdWrap($conf['REQ'], $conf['REQ.']) : $conf['REQ'];
|
||||
if ($req && $confData['required']) {
|
||||
if (isset($conf['REQ.']['fieldWrap.'])) {
|
||||
$fieldCode = $this->cObj->stdWrap($fieldCode, $conf['REQ.']['fieldWrap.']);
|
||||
}
|
||||
if (isset($conf['REQ.']['labelWrap.'])) {
|
||||
$labelCode = $this->cObj->stdWrap($fieldLabel, $conf['REQ.']['labelWrap.']);
|
||||
}
|
||||
$reqLayout = isset($conf['REQ.']['layout.']) ? $this->cObj->stdWrap($conf['REQ.']['layout'], $conf['REQ.']['layout.']) : $conf['REQ.']['layout'];
|
||||
if ($reqLayout) {
|
||||
$result = $reqLayout;
|
||||
}
|
||||
}
|
||||
if ($confData['type'] == 'comment') {
|
||||
$commentLayout = isset($conf['COMMENT.']['layout.']) ? $this->cObj->stdWrap($conf['COMMENT.']['layout'], $conf['COMMENT.']['layout.']) : $conf['COMMENT.']['layout'];
|
||||
if ($commentLayout) {
|
||||
$result = $commentLayout;
|
||||
}
|
||||
}
|
||||
if ($confData['type'] == 'check') {
|
||||
$checkLayout = isset($conf['CHECK.']['layout.']) ? $this->cObj->stdWrap($conf['CHECK.']['layout'], $conf['CHECK.']['layout.']) : $conf['CHECK.']['layout'];
|
||||
if ($checkLayout) {
|
||||
$result = $checkLayout;
|
||||
}
|
||||
}
|
||||
if ($confData['type'] == 'radio') {
|
||||
$radioLayout = isset($conf['RADIO.']['layout.']) ? $this->cObj->stdWrap($conf['RADIO.']['layout'], $conf['RADIO.']['layout.']) : $conf['RADIO.']['layout'];
|
||||
if ($radioLayout) {
|
||||
$result = $radioLayout;
|
||||
}
|
||||
}
|
||||
if ($confData['type'] == 'label') {
|
||||
$labelLayout = isset($conf['LABEL.']['layout.']) ? $this->cObj->stdWrap($conf['LABEL.']['layout'], $conf['LABEL.']['layout.']) : $conf['LABEL.']['layout'];
|
||||
if ($labelLayout) {
|
||||
$result = $labelLayout;
|
||||
}
|
||||
}
|
||||
//RTF
|
||||
$content .= str_replace(
|
||||
array(
|
||||
'###FIELD###',
|
||||
'###LABEL###',
|
||||
'###COMMENT###'
|
||||
),
|
||||
array(
|
||||
$fieldCode,
|
||||
$labelCode,
|
||||
$commentCode
|
||||
),
|
||||
$result
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($conf['stdWrap.'])) {
|
||||
$content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
|
||||
}
|
||||
// Redirect (external: where to go afterwards. internal: where to submit to)
|
||||
$theRedirect = isset($conf['redirect.']) ? $this->cObj->stdWrap($conf['redirect'], $conf['redirect.']) : $conf['redirect'];
|
||||
// redirect should be set to the page to redirect to after an external script has been used. If internal scripts is used, and if no 'type' is set that dictates otherwise, redirect is used as the url to jump to as long as it's an integer (page)
|
||||
$target = isset($conf['target.']) ? $this->cObj->stdWrap($conf['target'], $conf['target.']) : $conf['target'];
|
||||
// redirect should be set to the page to redirect to after an external script has been used. If internal scripts is used, and if no 'type' is set that dictates otherwise, redirect is used as the url to jump to as long as it's an integer (page)
|
||||
$noCache = isset($conf['no_cache.']) ? $this->cObj->stdWrap($conf['no_cache'], $conf['no_cache.']) : $conf['no_cache'];
|
||||
// redirect should be set to the page to redirect to after an external script has been used. If internal scripts is used, and if no 'type' is set that dictates otherwise, redirect is used as the url to jump to as long as it's an integer (page)
|
||||
$page = $GLOBALS['TSFE']->page;
|
||||
// Internal: Just submit to current page
|
||||
if (!$theRedirect) {
|
||||
$LD = $GLOBALS['TSFE']->tmpl->linkData($page, $target, $noCache, 'index.php', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
|
||||
} elseif (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($theRedirect)) {
|
||||
// Internal: Submit to page with ID $theRedirect
|
||||
$page = $GLOBALS['TSFE']->sys_page->getPage_noCheck($theRedirect);
|
||||
$LD = $GLOBALS['TSFE']->tmpl->linkData($page, $target, $noCache, 'index.php', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
|
||||
} else {
|
||||
// External URL, redirect-hidden field is rendered!
|
||||
$LD = $GLOBALS['TSFE']->tmpl->linkData($page, $target, $noCache, '', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
|
||||
$LD['totalURL'] = $theRedirect;
|
||||
$hiddenfields .= '<input type="hidden" name="redirect" value="' . htmlspecialchars($LD['totalURL']) . '" />';
|
||||
}
|
||||
// Formtype (where to submit to!):
|
||||
if ($propertyOverride['type']) {
|
||||
$formtype = $propertyOverride['type'];
|
||||
} else {
|
||||
$formtype = isset($conf['type.']) ? $this->cObj->stdWrap($conf['type'], $conf['type.']) : $conf['type'];
|
||||
}
|
||||
// Submit to a specific page
|
||||
if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($formtype)) {
|
||||
$page = $GLOBALS['TSFE']->sys_page->getPage_noCheck($formtype);
|
||||
$LD_A = $GLOBALS['TSFE']->tmpl->linkData($page, $target, $noCache, '', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
|
||||
$action = $LD_A['totalURL'];
|
||||
} elseif ($formtype) {
|
||||
// Submit to external script
|
||||
$LD_A = $LD;
|
||||
$action = $formtype;
|
||||
} elseif (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($theRedirect)) {
|
||||
$LD_A = $LD;
|
||||
$action = $LD_A['totalURL'];
|
||||
} else {
|
||||
// Submit to "nothing" - which is current page
|
||||
$LD_A = $GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page, $target, $noCache, '', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
|
||||
$action = $LD_A['totalURL'];
|
||||
}
|
||||
// Recipient:
|
||||
$theEmail = isset($conf['recipient.']) ? $this->cObj->stdWrap($conf['recipient'], $conf['recipient.']) : $conf['recipient'];
|
||||
if ($theEmail && !$GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) {
|
||||
$theEmail = \TYPO3\CMS\Compatibility6\Utility\FormUtility::codeString($theEmail);
|
||||
$hiddenfields .= '<input type="hidden" name="recipient" value="' . htmlspecialchars($theEmail) . '" />';
|
||||
}
|
||||
// location data:
|
||||
$location = isset($conf['locationData.']) ? $this->cObj->stdWrap($conf['locationData'], $conf['locationData.']) : $conf['locationData'];
|
||||
if ($location) {
|
||||
if ($location == 'HTTP_POST_VARS' && isset($_POST['locationData'])) {
|
||||
$locationData = GeneralUtility::_POST('locationData');
|
||||
} else {
|
||||
// locationData is [the page id]:[tablename]:[uid of record]. Indicates on which page the record (from tablename with uid) is shown. Used to check access.
|
||||
if (isset($this->data['_LOCALIZED_UID'])) {
|
||||
$locationData = $GLOBALS['TSFE']->id . ':' . str_replace($this->data['uid'], $this->data['_LOCALIZED_UID'], $this->cObj->currentRecord);
|
||||
} else {
|
||||
$locationData = $GLOBALS['TSFE']->id . ':' . $this->cObj->currentRecord;
|
||||
}
|
||||
}
|
||||
$hiddenfields .= '<input type="hidden" name="locationData" value="' . htmlspecialchars($locationData) . '" />';
|
||||
}
|
||||
// Hidden fields:
|
||||
if (is_array($conf['hiddenFields.'])) {
|
||||
foreach ($conf['hiddenFields.'] as $hF_key => $hF_conf) {
|
||||
if (substr($hF_key, -1) != '.') {
|
||||
$hF_value = $this->cObj->cObjGetSingle($hF_conf, $conf['hiddenFields.'][$hF_key . '.'], 'hiddenfields');
|
||||
if ((string)$hF_value !== '' && GeneralUtility::inList('recipient_copy,recipient', $hF_key)) {
|
||||
if ($GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) {
|
||||
continue;
|
||||
}
|
||||
$hF_value = \TYPO3\CMS\Compatibility6\Utility\FormUtility::codeString($hF_value);
|
||||
}
|
||||
$hiddenfields .= '<input type="hidden" name="' . $hF_key . '" value="' . htmlspecialchars($hF_value) . '" />';
|
||||
}
|
||||
}
|
||||
}
|
||||
// Wrap all hidden fields in a div tag (see http://forge.typo3.org/issues/14491)
|
||||
$hiddenfields = isset($conf['hiddenFields.']['stdWrap.']) ? $this->cObj->stdWrap($hiddenfields, $conf['hiddenFields.']['stdWrap.']) : '<div style="display:none;">' . $hiddenfields . '</div>';
|
||||
if ($conf['REQ']) {
|
||||
$goodMess = isset($conf['goodMess.']) ? $this->cObj->stdWrap($conf['goodMess'], $conf['goodMess.']) : $conf['goodMess'];
|
||||
$badMess = isset($conf['badMess.']) ? $this->cObj->stdWrap($conf['badMess'], $conf['badMess.']) : $conf['badMess'];
|
||||
$emailMess = isset($conf['emailMess.']) ? $this->cObj->stdWrap($conf['emailMess'], $conf['emailMess.']) : $conf['emailMess'];
|
||||
$validateForm = ' onsubmit="return validateForm(' . GeneralUtility::quoteJSvalue($formName) . ',' . GeneralUtility::quoteJSvalue(implode(',', $fieldlist)) . ',' . GeneralUtility::quoteJSvalue($goodMess) . ',' . GeneralUtility::quoteJSvalue($badMess) . ',' . GeneralUtility::quoteJSvalue($emailMess) . ')"';
|
||||
$GLOBALS['TSFE']->additionalHeaderData['JSFormValidate'] = '<script type="text/javascript" src="' . GeneralUtility::createVersionNumberedFilename(($GLOBALS['TSFE']->absRefPrefix . 'typo3/sysext/compatibility6/Resources/Public/JavaScript/jsfunc.validateform.js')) . '"></script>';
|
||||
} else {
|
||||
$validateForm = '';
|
||||
}
|
||||
// Create form tag:
|
||||
$theTarget = $theRedirect ? $LD['target'] : $LD_A['target'];
|
||||
$method = isset($conf['method.']) ? $this->cObj->stdWrap($conf['method'], $conf['method.']) : $conf['method'];
|
||||
$content = array(
|
||||
'<form' . ' action="' . htmlspecialchars($action) . '"' . ' id="' . $formName . '"' . ($xhtmlStrict ? '' : ' name="' . $formName . '"') . ' enctype="multipart/form-data"' . ' method="' . ($method ? $method : 'post') . '"' . ($theTarget ? ' target="' . $theTarget . '"' : '') . $validateForm . '>',
|
||||
$hiddenfields . $content,
|
||||
'</form>'
|
||||
);
|
||||
$arrayReturnMode = isset($conf['arrayReturnMode.']) ? $this->cObj->stdWrap($conf['arrayReturnMode'], $conf['arrayReturnMode.']) : $conf['arrayReturnMode'];
|
||||
if ($arrayReturnMode) {
|
||||
$content['validateForm'] = $validateForm;
|
||||
$content['formname'] = $formName;
|
||||
return $content;
|
||||
} else {
|
||||
return implode('', $content);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a default value for a form field in the FORM cObject.
|
||||
* Page CANNOT be cached because that would include the inserted value for the current user.
|
||||
*
|
||||
* @param bool $noValueInsert If noValueInsert OR if the no_cache flag for this page is NOT set, the original default value is returned.
|
||||
* @param string $fieldName The POST var name to get default value for
|
||||
* @param string $defaultVal The current default value
|
||||
* @return string The default value, either from INPUT var or the current default, based on whether caching is enabled or not.
|
||||
*/
|
||||
protected function getFieldDefaultValue($noValueInsert, $fieldName, $defaultVal)
|
||||
{
|
||||
if (!$GLOBALS['TSFE']->no_cache || !isset($_POST[$fieldName]) && !isset($_GET[$fieldName]) || $noValueInsert) {
|
||||
return $defaultVal;
|
||||
} else {
|
||||
return GeneralUtility::_GP($fieldName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes forbidden characters and spaces from name/id attributes in the form tag and formfields
|
||||
*
|
||||
* @param string $name Input string
|
||||
* @return string the cleaned string
|
||||
*/
|
||||
protected function cleanFormName($name)
|
||||
{
|
||||
// Turn data[x][y] into data:x:y:
|
||||
$name = preg_replace('/\\[|\\]\\[?/', ':', trim($name));
|
||||
// Remove illegal chars like _
|
||||
return preg_replace('#[^:a-zA-Z0-9]#', '', $name);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\Compatibility6\ContentObject;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
/**
|
||||
* Contains HRULER content object.
|
||||
*/
|
||||
class HorizontalRulerContentObject extends \TYPO3\CMS\Frontend\ContentObject\AbstractContentObject
|
||||
{
|
||||
/**
|
||||
* Rendering the cObject, HRULER
|
||||
*
|
||||
* @param array $conf Array of TypoScript properties
|
||||
* @return string Output
|
||||
*/
|
||||
public function render($conf = array())
|
||||
{
|
||||
$lineThickness = isset($conf['lineThickness.']) ? $this->cObj->stdWrap($conf['lineThickness'], $conf['lineThickness.']) : $conf['lineThickness'];
|
||||
$lineThickness = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($lineThickness, 1, 50);
|
||||
$lineColor = isset($conf['lineColor.']) ? $this->cObj->stdWrap($conf['lineColor'], $conf['lineColor.']) : $conf['lineColor'];
|
||||
if (!$lineColor) {
|
||||
$lineColor = 'black';
|
||||
}
|
||||
$spaceBefore = isset($conf['spaceLeft.']) ? (int)$this->cObj->stdWrap($conf['spaceLeft'], $conf['spaceLeft.']) : (int)$conf['spaceLeft'];
|
||||
$spaceAfter = isset($conf['spaceRight.']) ? (int)$this->cObj->stdWrap($conf['spaceRight'], $conf['spaceRight.']) : (int)$conf['spaceRight'];
|
||||
$tableWidth = isset($conf['tableWidth.']) ? (int)$this->cObj->stdWrap($conf['tableWidth'], $conf['tableWidth.']) : (int)$conf['tableWidth'];
|
||||
if (!$tableWidth) {
|
||||
$tableWidth = '99%';
|
||||
}
|
||||
$theValue = '';
|
||||
$theValue .= '<table border="0" cellspacing="0" cellpadding="0"
|
||||
width="' . htmlspecialchars($tableWidth) . '"
|
||||
summary=""><tr>';
|
||||
if ($spaceBefore) {
|
||||
$theValue .= '<td width="1">
|
||||
<span style="width: ' . $spaceBefore . 'px; height: 1px;"></span>
|
||||
</td>';
|
||||
}
|
||||
$theValue .= '<td bgcolor="' . $lineColor . '">
|
||||
<span style="width: 1px; height: ' . $lineThickness . 'px;"></span>
|
||||
</td>';
|
||||
if ($spaceAfter) {
|
||||
$theValue .= '<td width="1">
|
||||
<span style="width: ' . $spaceAfter . 'px; height: 1px;"></span>
|
||||
</td>';
|
||||
}
|
||||
$theValue .= '</tr></table>';
|
||||
if (isset($conf['stdWrap.'])) {
|
||||
$theValue = $this->cObj->stdWrap($theValue, $conf['stdWrap.']);
|
||||
}
|
||||
return $theValue;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,513 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\Compatibility6\ContentObject;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Core\Resource\ResourceFactory;
|
||||
|
||||
/**
|
||||
* Contains IMGTEXT content object.
|
||||
*/
|
||||
class ImageTextContentObject extends \TYPO3\CMS\Frontend\ContentObject\AbstractContentObject
|
||||
{
|
||||
/**
|
||||
* @var ResourceFactory
|
||||
*/
|
||||
protected $fileFactory = null;
|
||||
|
||||
/**
|
||||
* Rendering the cObject, IMGTEXT
|
||||
* which is a text w/ image type that works with the image position through tables (pre-CSS styled content-time)
|
||||
*
|
||||
* @param array $conf Array of TypoScript properties
|
||||
* @return string Output
|
||||
*/
|
||||
public function render($conf = array())
|
||||
{
|
||||
$content = '';
|
||||
if (isset($conf['text.'])) {
|
||||
$text = $this->cObj->cObjGet($conf['text.'], 'text.');
|
||||
// this gets the surrounding content
|
||||
$content .= $this->cObj->stdWrap($text, $conf['text.']);
|
||||
}
|
||||
$imgList = isset($conf['imgList.']) ? trim($this->cObj->stdWrap($conf['imgList'], $conf['imgList.'])) : trim($conf['imgList']);
|
||||
if ($imgList) {
|
||||
$imgs = GeneralUtility::trimExplode(',', $imgList, true);
|
||||
$imgStart = isset($conf['imgStart.']) ? (int)$this->cObj->stdWrap($conf['imgStart'], $conf['imgStart.']) : (int)$conf['imgStart'];
|
||||
$imgCount = count($imgs) - $imgStart;
|
||||
$imgMax = isset($conf['imgMax.']) ? (int)$this->cObj->stdWrap($conf['imgMax'], $conf['imgMax.']) : (int)$conf['imgMax'];
|
||||
if ($imgMax) {
|
||||
// Reduces the number of images.
|
||||
$imgCount = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($imgCount, 0, $imgMax);
|
||||
}
|
||||
$imgPath = isset($conf['imgPath.']) ? $this->cObj->stdWrap($conf['imgPath'], $conf['imgPath.']) : $conf['imgPath'];
|
||||
// initialisation
|
||||
$caption = '';
|
||||
$captionArray = array();
|
||||
if (!$conf['captionSplit'] && !$conf['imageTextSplit'] && isset($conf['caption.'])) {
|
||||
$caption = $this->cObj->cObjGet($conf['caption.'], 'caption.');
|
||||
// Global caption, no splitting
|
||||
$caption = $this->cObj->stdWrap($caption, $conf['caption.']);
|
||||
}
|
||||
if ($conf['captionSplit'] && $conf['captionSplit.']['cObject']) {
|
||||
$legacyCaptionSplit = 1;
|
||||
$capSplit = isset($conf['captionSplit.']['token.']) ? $this->cObj->stdWrap($conf['captionSplit.']['token'], $conf['captionSplit.']['token.']) : $conf['captionSplit.']['token'];
|
||||
if (!$capSplit) {
|
||||
$capSplit = LF;
|
||||
}
|
||||
$captionArray = explode($capSplit, $this->cObj->cObjGetSingle($conf['captionSplit.']['cObject'], $conf['captionSplit.']['cObject.'], 'captionSplit.cObject'));
|
||||
foreach ($captionArray as $ca_key => $ca_val) {
|
||||
$captionArray[$ca_key] = isset($conf['captionSplit.']['stdWrap.']) ? $this->cObj->stdWrap(trim($captionArray[$ca_key]), $conf['captionSplit.']['stdWrap.']) : trim($captionArray[$ca_key]);
|
||||
}
|
||||
}
|
||||
$tablecode = '';
|
||||
$position = isset($conf['textPos.']) ? $this->cObj->stdWrap($conf['textPos'], $conf['textPos.']) : $conf['textPos'];
|
||||
$tmppos = $position & 7;
|
||||
$contentPosition = $position & 24;
|
||||
$align = $this->cObj->align[$tmppos];
|
||||
$cap = $caption ? 1 : 0;
|
||||
$txtMarg = isset($conf['textMargin.']) ? (int)$this->cObj->stdWrap($conf['textMargin'], $conf['textMargin.']) : (int)$conf['textMargin'];
|
||||
if (!$conf['textMargin_outOfText'] && $contentPosition < 16) {
|
||||
$txtMarg = 0;
|
||||
}
|
||||
$cols = isset($conf['cols.']) ? (int)$this->cObj->stdWrap($conf['cols'], $conf['cols.']) : (int)$conf['cols'];
|
||||
$rows = isset($conf['rows.']) ? (int)$this->cObj->stdWrap($conf['rows'], $conf['rows.']) : (int)$conf['rows'];
|
||||
$colspacing = isset($conf['colSpace.']) ? (int)$this->cObj->stdWrap($conf['colSpace'], $conf['colSpace.']) : (int)$conf['colSpace'];
|
||||
$rowspacing = isset($conf['rowSpace.']) ? (int)$this->cObj->stdWrap($conf['rowSpace'], $conf['rowSpace.']) : (int)$conf['rowSpace'];
|
||||
$border = isset($conf['border.']) ? (int)$this->cObj->stdWrap($conf['border'], $conf['border.']) : (int)$conf['border'];
|
||||
$border = $border ? 1 : 0;
|
||||
if ($border) {
|
||||
$borderColor = isset($conf['borderCol.']) ? $this->cObj->stdWrap($conf['borderCol'], $conf['borderCol.']) : $conf['borderCol'];
|
||||
if (!$borderColor) {
|
||||
$borderColor = 'black';
|
||||
}
|
||||
$borderThickness = isset($conf['borderThick.']) ? (int)$this->cObj->stdWrap($conf['borderThick'], $conf['borderThick.']) : (int)$conf['borderThick'];
|
||||
if (!$borderThickness) {
|
||||
$borderThickness = 'black';
|
||||
}
|
||||
}
|
||||
$caption_align = isset($conf['captionAlign.']) ? $this->cObj->stdWrap($conf['captionAlign'], $conf['captionAlign.']) : $conf['captionAlign'];
|
||||
if (!$caption_align) {
|
||||
$caption_align = $align;
|
||||
}
|
||||
// Generate cols
|
||||
$colCount = $cols > 1 ? $cols : 1;
|
||||
if ($colCount > $imgCount) {
|
||||
$colCount = $imgCount;
|
||||
}
|
||||
$rowCount = $colCount > 1 ? ceil($imgCount / $colCount) : $imgCount;
|
||||
// Generate rows
|
||||
if ($rows > 1) {
|
||||
$rowCount = $rows;
|
||||
if ($rowCount > $imgCount) {
|
||||
$rowCount = $imgCount;
|
||||
}
|
||||
$colCount = $rowCount > 1 ? ceil($imgCount / $rowCount) : $imgCount;
|
||||
}
|
||||
// Max Width
|
||||
$colRelations = isset($conf['colRelations.']) ? trim($this->cObj->stdWrap($conf['colRelations'], $conf['colRelations.'])) : trim($conf['colRelations']);
|
||||
$maxW = isset($conf['maxW.']) ? (int)$this->cObj->stdWrap($conf['maxW'], $conf['maxW.']) : (int)$conf['maxW'];
|
||||
$maxWInText = isset($conf['maxWInText.']) ? (int)$this->cObj->stdWrap($conf['maxWInText'], $conf['maxWInText.']) : (int)$conf['maxWInText'];
|
||||
// If maxWInText is not set, it's calculated to the 50 % of the max...
|
||||
if (!$maxWInText) {
|
||||
$maxWInText = round($maxW / 2);
|
||||
}
|
||||
// inText
|
||||
if ($maxWInText && $contentPosition >= 16) {
|
||||
$maxW = $maxWInText;
|
||||
}
|
||||
// If there is a max width and if colCount is greater than column
|
||||
if ($maxW && $colCount > 0) {
|
||||
$maxW = ceil(($maxW - $colspacing * ($colCount - 1) - $colCount * $border * $borderThickness * 2) / $colCount);
|
||||
}
|
||||
// Create the relation between rows
|
||||
$colMaxW = array();
|
||||
if ($colRelations) {
|
||||
$rel_parts = explode(':', $colRelations);
|
||||
$rel_total = 0;
|
||||
for ($a = 0; $a < $colCount; $a++) {
|
||||
$rel_parts[$a] = (int)$rel_parts[$a];
|
||||
$rel_total += $rel_parts[$a];
|
||||
}
|
||||
if ($rel_total) {
|
||||
for ($a = 0; $a < $colCount; $a++) {
|
||||
$colMaxW[$a] = round($maxW * $colCount / $rel_total * $rel_parts[$a]);
|
||||
}
|
||||
// The difference in size between the largest and smalles must be within a factor of ten.
|
||||
if (min($colMaxW) <= 0 || max($rel_parts) / min($rel_parts) > 10) {
|
||||
$colMaxW = array();
|
||||
}
|
||||
}
|
||||
}
|
||||
$image_compression = isset($conf['image_compression.']) ? (int)$this->cObj->stdWrap($conf['image_compression'], $conf['image_compression.']) : (int)$conf['image_compression'];
|
||||
$image_effects = isset($conf['image_effects.']) ? (int)$this->cObj->stdWrap($conf['image_effects'], $conf['image_effects.']) : (int)$conf['image_effects'];
|
||||
$image_frames = isset($conf['image_frames.']['key.']) ? (int)$this->cObj->stdWrap($conf['image_frames.']['key'], $conf['image_frames.']['key.']) : (int)$conf['image_frames.']['key'];
|
||||
// Fetches pictures
|
||||
$splitArr = array();
|
||||
$splitArr['imgObjNum'] = $conf['imgObjNum'];
|
||||
$splitArr = $GLOBALS['TSFE']->tmpl->splitConfArray($splitArr, $imgCount);
|
||||
// EqualHeight
|
||||
$equalHeight = isset($conf['equalH.']) ? (int)$this->cObj->stdWrap($conf['equalH'], $conf['equalH.']) : (int)$conf['equalH'];
|
||||
// Initiate gifbuilder object in order to get dimensions AND calculate the imageWidth's
|
||||
if ($equalHeight) {
|
||||
$gifCreator = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Imaging\GifBuilder::class);
|
||||
$gifCreator->init();
|
||||
$relations = array();
|
||||
$relations_cols = array();
|
||||
$totalMaxW = $maxW * $colCount;
|
||||
for ($a = 0; $a < $imgCount; $a++) {
|
||||
$imgKey = $a + $imgStart;
|
||||
$imgInfo = $gifCreator->getImageDimensions($imgPath . $imgs[$imgKey]);
|
||||
// relationship between the original height and the wished height
|
||||
$relations[$a] = $imgInfo[1] / $equalHeight;
|
||||
// if relations is zero, then the addition of this value is omitted as
|
||||
// the image is not expected to display because of some error.
|
||||
if ($relations[$a]) {
|
||||
// Counts the total width of the row with the new height taken into consideration.
|
||||
$relations_cols[floor($a / $colCount)] += $imgInfo[0] / $relations[$a];
|
||||
}
|
||||
}
|
||||
}
|
||||
// Contains the width of every image row
|
||||
$imageRowsFinalWidths = array();
|
||||
$imageRowsMaxHeights = array();
|
||||
$imgsTag = array();
|
||||
$origImages = array();
|
||||
for ($a = 0; $a < $imgCount; $a++) {
|
||||
$GLOBALS['TSFE']->register['IMAGE_NUM'] = $a;
|
||||
$GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $a;
|
||||
$imgKey = $a + $imgStart;
|
||||
if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($imgs[$imgKey])) {
|
||||
$this->setCurrentFileInContentObjectRenderer(intval($imgs[$imgKey]));
|
||||
}
|
||||
$totalImagePath = $imgPath . $imgs[$imgKey];
|
||||
$this->cObj->data[$this->cObj->currentValKey] = $totalImagePath;
|
||||
$imgObjNum = (int)$splitArr[$a]['imgObjNum'];
|
||||
$imgConf = $conf[$imgObjNum . '.'];
|
||||
if ($equalHeight) {
|
||||
$scale = 1;
|
||||
if ($totalMaxW) {
|
||||
$rowTotalMaxW = $relations_cols[floor($a / $colCount)];
|
||||
if ($rowTotalMaxW > $totalMaxW) {
|
||||
$scale = $rowTotalMaxW / $totalMaxW;
|
||||
}
|
||||
}
|
||||
// Transfer info to the imageObject. Please note, that
|
||||
$imgConf['file.']['height'] = round($equalHeight / $scale);
|
||||
unset($imgConf['file.']['width'], $imgConf['file.']['maxW'], $imgConf['file.']['maxH'], $imgConf['file.']['minW'], $imgConf['file.']['minH'], $imgConf['file.']['width.'], $imgConf['file.']['maxW.'], $imgConf['file.']['maxH.'], $imgConf['file.']['minW.'], $imgConf['file.']['minH.']);
|
||||
// Setting this to zero, so that it doesn't disturb
|
||||
$maxW = 0;
|
||||
}
|
||||
if ($maxW) {
|
||||
if (!empty($colMaxW)) {
|
||||
$imgConf['file.']['maxW'] = $colMaxW[$a % $colCount];
|
||||
} else {
|
||||
$imgConf['file.']['maxW'] = $maxW;
|
||||
}
|
||||
}
|
||||
// Image Object supplied:
|
||||
if (is_array($imgConf)) {
|
||||
if ($this->cObj->image_effects[$image_effects]) {
|
||||
$imgConf['file.']['params'] .= ' ' . $this->cObj->image_effects[$image_effects];
|
||||
}
|
||||
if ($image_frames) {
|
||||
if (is_array($conf['image_frames.'][$image_frames . '.'])) {
|
||||
$imgConf['file.']['m.'] = $conf['image_frames.'][$image_frames . '.'];
|
||||
}
|
||||
}
|
||||
if ($image_compression && $imgConf['file'] != 'GIFBUILDER') {
|
||||
if ($image_compression == 1) {
|
||||
$tempImport = $imgConf['file.']['import'];
|
||||
$tempImport_dot = $imgConf['file.']['import.'];
|
||||
unset($imgConf['file.']);
|
||||
$imgConf['file.']['import'] = $tempImport;
|
||||
$imgConf['file.']['import.'] = $tempImport_dot;
|
||||
} elseif (isset($this->cObj->image_compression[$image_compression])) {
|
||||
$imgConf['file.']['params'] .= ' ' . $this->cObj->image_compression[$image_compression]['params'];
|
||||
$imgConf['file.']['ext'] = $this->cObj->image_compression[$image_compression]['ext'];
|
||||
unset($imgConf['file.']['ext.']);
|
||||
}
|
||||
}
|
||||
// "alt", "title" and "longdesc" attributes:
|
||||
if ($imgConf['altText'] === '' && !is_array($imgConf['altText.'])) {
|
||||
$imgConf['altText'] = $conf['altText'];
|
||||
$imgConf['altText.'] = $conf['altText.'];
|
||||
}
|
||||
if ($imgConf['titleText'] === '' && !is_array($imgConf['titleText.'])) {
|
||||
$imgConf['titleText'] = $conf['titleText'];
|
||||
$imgConf['titleText.'] = $conf['titleText.'];
|
||||
}
|
||||
if ($imgConf['longdescURL'] === '' && !is_array($imgConf['longdescURL.'])) {
|
||||
$imgConf['longdescURL'] = $conf['longdescURL'];
|
||||
$imgConf['longdescURL.'] = $conf['longdescURL.'];
|
||||
}
|
||||
} else {
|
||||
$imgConf = array(
|
||||
'altText' => $conf['altText'],
|
||||
'titleText' => $conf['titleText'],
|
||||
'longdescURL' => $conf['longdescURL'],
|
||||
'file' => $totalImagePath
|
||||
);
|
||||
}
|
||||
$imgsTag[$imgKey] = $this->cObj->cObjGetSingle('IMAGE', $imgConf);
|
||||
// Store the original filepath
|
||||
$origImages[$imgKey] = $GLOBALS['TSFE']->lastImageInfo;
|
||||
$imageRowsFinalWidths[floor($a / $colCount)] += $GLOBALS['TSFE']->lastImageInfo[0];
|
||||
if ($GLOBALS['TSFE']->lastImageInfo[1] > $imageRowsMaxHeights[floor($a / $colCount)]) {
|
||||
$imageRowsMaxHeights[floor($a / $colCount)] = $GLOBALS['TSFE']->lastImageInfo[1];
|
||||
}
|
||||
}
|
||||
// Calculating the tableWidth:
|
||||
// TableWidth problems: It creates problems if the pictures are NOT as wide as the tableWidth.
|
||||
$tableWidth = max($imageRowsFinalWidths) + $colspacing * ($colCount - 1) + $colCount * $border * $borderThickness * 2;
|
||||
// Make table for pictures
|
||||
$index = ($imgIndex = $imgStart);
|
||||
$noRows = isset($conf['noRows.']) ? $this->cObj->stdWrap($conf['noRows'], $conf['noRows.']) : $conf['noRows'];
|
||||
$noCols = isset($conf['noCols.']) ? $this->cObj->stdWrap($conf['noCols'], $conf['noCols.']) : $conf['noCols'];
|
||||
if ($noRows) {
|
||||
$noCols = 0;
|
||||
}
|
||||
// noRows overrides noCols. They cannot exist at the same time.
|
||||
if ($equalHeight) {
|
||||
$noCols = 1;
|
||||
$noRows = 0;
|
||||
}
|
||||
$rowCount_temp = 1;
|
||||
$colCount_temp = $colCount;
|
||||
if ($noRows) {
|
||||
$rowCount_temp = $rowCount;
|
||||
$rowCount = 1;
|
||||
}
|
||||
if ($noCols) {
|
||||
$colCount = 1;
|
||||
}
|
||||
// col- and rowspans calculated
|
||||
$colspan = $colspacing ? $colCount * 2 - 1 : $colCount;
|
||||
$rowspan = ($rowspacing ? $rowCount * 2 - 1 : $rowCount) + $cap;
|
||||
// Edit icons:
|
||||
if (!is_array($conf['editIcons.'])) {
|
||||
$conf['editIcons.'] = array();
|
||||
}
|
||||
$editIconsHTML = $conf['editIcons'] && $GLOBALS['TSFE']->beUserLogin ? $this->cObj->editIcons('', $conf['editIcons'], $conf['editIcons.']) : '';
|
||||
// Strech out table:
|
||||
$tablecode = '';
|
||||
$flag = 0;
|
||||
$noStretchAndMarginCells = isset($conf['noStretchAndMarginCells.']) ? $this->cObj->stdWrap($conf['noStretchAndMarginCells'], $conf['noStretchAndMarginCells.']) : $conf['noStretchAndMarginCells'];
|
||||
if ($noStretchAndMarginCells != 1) {
|
||||
$tablecode .= '<tr>';
|
||||
if ($txtMarg && $align == 'right') {
|
||||
// If right aligned, the textborder is added on the right side
|
||||
$tablecode .= '<td rowspan="' . ($rowspan + 1) . '" valign="top"><span style="width: ' . $txtMarg . 'px; height: 1px;"></span>' . ($editIconsHTML ? '<br />' . $editIconsHTML : '') . '</td>';
|
||||
$editIconsHTML = '';
|
||||
$flag = 1;
|
||||
}
|
||||
$tablecode .= '<td colspan="' . $colspan . '"><span style="width: ' . $tableWidth . 'px; height: 1px;"></span></td>';
|
||||
if ($txtMarg && $align == 'left') {
|
||||
// If left aligned, the textborder is added on the left side
|
||||
$tablecode .= '<td rowspan="' . ($rowspan + 1) . '" valign="top"><span style="width: ' . $txtMarg . 'px; height: 1px;"></span>' . ($editIconsHTML ? '<br />' . $editIconsHTML : '') . '</td>';
|
||||
$editIconsHTML = '';
|
||||
$flag = 1;
|
||||
}
|
||||
if ($flag) {
|
||||
$tableWidth += $txtMarg + 1;
|
||||
}
|
||||
$tablecode .= '</tr>';
|
||||
}
|
||||
// draw table
|
||||
// Looping through rows. If 'noRows' is set, this is '1 time', but $rowCount_temp will hold the actual number of rows!
|
||||
for ($c = 0; $c < $rowCount; $c++) {
|
||||
// If this is NOT the first time in the loop AND if space is required, a row-spacer is added. In case of "noRows" rowspacing is done further down.
|
||||
if ($c && $rowspacing) {
|
||||
$tablecode .= '<tr><td colspan="' . $colspan . '"><span style="width: 1px; height: ' . $rowspacing . 'px;"></span></td></tr>';
|
||||
}
|
||||
// starting row
|
||||
$tablecode .= '<tr>';
|
||||
// Looping through the columns
|
||||
for ($b = 0; $b < $colCount_temp; $b++) {
|
||||
// If this is NOT the first iteration AND if column space is required. In case of "noCols", the space is done without a separate cell.
|
||||
if ($b && $colspacing) {
|
||||
if (!$noCols) {
|
||||
$tablecode .= '<td><span style="width: ' . $colspacing . 'px; height: 1px;"></span></td>';
|
||||
} else {
|
||||
$colSpacer = '<span style="width: ' . ($border ? $colspacing - 6 : $colspacing) . 'px; height: ' . ($imageRowsMaxHeights[$c] + ($border ? $borderThickness * 2 : 0)) . 'px;"></span>';
|
||||
$colSpacer = '<td valign="top">' . $colSpacer . '</td>';
|
||||
// added 160301, needed for the new "noCols"-table...
|
||||
$tablecode .= $colSpacer;
|
||||
}
|
||||
}
|
||||
if (!$noCols || $noCols && !$b) {
|
||||
// starting the cell. If "noCols" this cell will hold all images in the row, otherwise only a single image.
|
||||
$tablecode .= '<td valign="top">';
|
||||
if ($noCols) {
|
||||
$tablecode .= '<table width="' . $imageRowsFinalWidths[$c] . '" border="0" cellpadding="0" cellspacing="0"><tr>';
|
||||
}
|
||||
}
|
||||
// Looping through the rows IF "noRows" is set. "noRows" means that the rows of images is not rendered
|
||||
// by physical table rows but images are all in one column and spaced apart with clear-gifs. This loop is
|
||||
// only one time if "noRows" is not set.
|
||||
for ($a = 0; $a < $rowCount_temp; $a++) {
|
||||
// register previous imgIndex
|
||||
$GLOBALS['TSFE']->register['IMAGE_NUM'] = $imgIndex;
|
||||
$imgIndex = $index + $a * $colCount_temp;
|
||||
$GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $imgIndex;
|
||||
if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($imgs[$imgIndex])) {
|
||||
$this->setCurrentFileInContentObjectRenderer(intval($imgs[$imgIndex]));
|
||||
}
|
||||
if ($imgsTag[$imgIndex]) {
|
||||
// Puts distance between the images IF "noRows" is set and this is the first iteration of the loop
|
||||
if ($rowspacing && $noRows && $a) {
|
||||
$tablecode .= '<span style="width: 1px; height: ' . $rowspacing . 'px;"></span><br />';
|
||||
}
|
||||
if ($legacyCaptionSplit) {
|
||||
$thisCaption = $captionArray[$imgIndex];
|
||||
} elseif (($conf['captionSplit'] || $conf['imageTextSplit']) && isset($conf['caption.'])) {
|
||||
$thisCaption = $this->cObj->cObjGet($conf['caption.'], 'caption.');
|
||||
$thisCaption = $this->cObj->stdWrap($thisCaption, $conf['caption.']);
|
||||
}
|
||||
$imageHTML = $imgsTag[$imgIndex] . '<br />';
|
||||
// this is necessary if the tablerows are supposed to space properly together! "noRows" is excluded because else the images "layer" together.
|
||||
$Talign = !trim($thisCaption) && !$noRows ? ' align="left"' : '';
|
||||
if ($border) {
|
||||
$imageHTML = '<table border="0" cellpadding="' . $borderThickness . '" cellspacing="0" bgcolor="' . $borderColor . '"' . $Talign . '><tr><td>' . $imageHTML . '</td></tr></table>';
|
||||
}
|
||||
$imageHTML .= $editIconsHTML;
|
||||
$editIconsHTML = '';
|
||||
// Adds caption.
|
||||
$imageHTML .= $thisCaption;
|
||||
if ($noCols) {
|
||||
$imageHTML = '<td valign="top">' . $imageHTML . '</td>';
|
||||
}
|
||||
// If noCols, put in table cell.
|
||||
$tablecode .= $imageHTML;
|
||||
}
|
||||
}
|
||||
$index++;
|
||||
if (!$noCols || $noCols && $b + 1 == $colCount_temp) {
|
||||
if ($noCols) {
|
||||
$tablecode .= '</tr></table>';
|
||||
}
|
||||
// In case of "noCols" we must finish the table that surrounds the images in the row.
|
||||
$tablecode .= '</td>';
|
||||
}
|
||||
}
|
||||
// ending row
|
||||
$tablecode .= '</tr>';
|
||||
}
|
||||
if ($c) {
|
||||
switch ($contentPosition) {
|
||||
case '0':
|
||||
|
||||
case '8':
|
||||
// below
|
||||
switch ($align) {
|
||||
case 'center':
|
||||
$table_align = 'margin-left: auto; margin-right: auto';
|
||||
break;
|
||||
case 'right':
|
||||
$table_align = 'margin-left: auto; margin-right: 0px';
|
||||
break;
|
||||
default:
|
||||
// Most of all: left
|
||||
$table_align = 'margin-left: 0px; margin-right: auto';
|
||||
}
|
||||
$table_align = 'style="' . $table_align . '"';
|
||||
break;
|
||||
case '16':
|
||||
// in text
|
||||
$table_align = 'align="' . $align . '"';
|
||||
break;
|
||||
default:
|
||||
$table_align = '';
|
||||
}
|
||||
// Table-tag is inserted
|
||||
$tablecode = '<table' . ($tableWidth ? ' width="' . $tableWidth . '"' : '') . ' border="0" cellspacing="0" cellpadding="0" ' . $table_align . ' class="imgtext-table">' . $tablecode;
|
||||
// If this value is not long since reset.
|
||||
if ($editIconsHTML) {
|
||||
$tablecode .= '<tr><td colspan="' . $colspan . '">' . $editIconsHTML . '</td></tr>';
|
||||
$editIconsHTML = '';
|
||||
}
|
||||
if ($cap) {
|
||||
$tablecode .= '<tr><td colspan="' . $colspan . '" align="' . $caption_align . '">' . $caption . '</td></tr>';
|
||||
}
|
||||
$tablecode .= '</table>';
|
||||
if (isset($conf['tableStdWrap.'])) {
|
||||
$tablecode = $this->cObj->stdWrap($tablecode, $conf['tableStdWrap.']);
|
||||
}
|
||||
}
|
||||
$spaceBelowAbove = isset($conf['spaceBelowAbove.']) ? (int)$this->cObj->stdWrap($conf['spaceBelowAbove'], $conf['spaceBelowAbove.']) : (int)$conf['spaceBelowAbove'];
|
||||
switch ($contentPosition) {
|
||||
case '0':
|
||||
// above
|
||||
$output = '<div style="text-align:' . $align . ';">' . $tablecode . '</div>' . $this->cObj->wrapSpace($content, ($spaceBelowAbove . '|0'));
|
||||
break;
|
||||
case '8':
|
||||
// below
|
||||
$output = $this->cObj->wrapSpace($content, ('0|' . $spaceBelowAbove)) . '<div style="text-align:' . $align . ';">' . $tablecode . '</div>';
|
||||
break;
|
||||
case '16':
|
||||
// in text
|
||||
$output = $tablecode . $content;
|
||||
break;
|
||||
case '24':
|
||||
// in text, no wrap
|
||||
$theResult = '';
|
||||
$theResult .= '<table border="0" cellspacing="0" cellpadding="0" class="imgtext-nowrap"><tr>';
|
||||
if ($align == 'right') {
|
||||
$theResult .= '<td valign="top">' . $content . '</td><td valign="top">' . $tablecode . '</td>';
|
||||
} else {
|
||||
$theResult .= '<td valign="top">' . $tablecode . '</td><td valign="top">' . $content . '</td>';
|
||||
}
|
||||
$theResult .= '</tr></table>';
|
||||
$output = $theResult;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$output = $content;
|
||||
}
|
||||
if (isset($conf['stdWrap.'])) {
|
||||
$output = $this->cObj->stdWrap($output, $conf['stdWrap.']);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the file reference object and sets it in the
|
||||
* currentFile property of the ContentObjectRenderer.
|
||||
*
|
||||
* This makes the file data available during image rendering.
|
||||
*
|
||||
* @param int $fileUid The UID of the file reference that should be loaded.
|
||||
* @return void
|
||||
*/
|
||||
protected function setCurrentFileInContentObjectRenderer($fileUid)
|
||||
{
|
||||
$imageFile = $this->getFileFactory()->getFileReferenceObject($fileUid);
|
||||
$this->cObj->setCurrentFile($imageFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the file factory.
|
||||
*
|
||||
* @return ResourceFactory
|
||||
*/
|
||||
protected function getFileFactory()
|
||||
{
|
||||
if ($this->fileFactory === null) {
|
||||
$this->fileFactory = GeneralUtility::makeInstance(ResourceFactory::class);
|
||||
}
|
||||
|
||||
return $this->fileFactory;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\Compatibility6\ContentObject;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
/**
|
||||
* Rendering of tables for offset
|
||||
*/
|
||||
class OffsetTableContentObject extends \TYPO3\CMS\Frontend\ContentObject\AbstractContentObject
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $tableParams = 'border="0" cellspacing="0" cellpadding="0"';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $default_tableParams = 'border="0" cellspacing="0" cellpadding="0"';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $tdParams = ' width="99%" valign="top"';
|
||||
|
||||
/**
|
||||
* Override default constructor to make it possible to instantiate this
|
||||
* class for rendering an offset table not in content object context
|
||||
*
|
||||
* @param \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj
|
||||
*/
|
||||
public function __construct(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj = null)
|
||||
{
|
||||
if (!is_null($cObj)) {
|
||||
$this->cObj = $cObj;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rendering the cObject, OTABLE
|
||||
*
|
||||
* @param array $conf Array of TypoScript properties
|
||||
* @return string Output
|
||||
*/
|
||||
public function render($conf = array())
|
||||
{
|
||||
$tableParams = isset($conf['tableParams.']) ? $this->cObj->stdWrap($conf['tableParams'], $conf['tableParams.']) : $conf['tableParams'];
|
||||
if ($tableParams) {
|
||||
$this->tableParams = $tableParams;
|
||||
}
|
||||
$offset = isset($conf['offset.']) ? $this->cObj->stdWrap($conf['offset'], $conf['offset.']) : $conf['offset'];
|
||||
$content = $this->start($this->cObj->cObjGet($conf), $offset);
|
||||
if (isset($conf['stdWrap.'])) {
|
||||
$content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapping the input content string in a table which will space it out from top/left/right/bottom
|
||||
*
|
||||
* @param string $content The HTML content string
|
||||
* @param string $offset List of offset parameters; x,y,r,b,w,h
|
||||
* @return string The HTML content string being wrapped in a <table> offsetting the content as the $offset parameters defined
|
||||
*/
|
||||
public function start($content, $offset)
|
||||
{
|
||||
$valPairs = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $offset . ',,,,,');
|
||||
if ($valPairs[0] || $valPairs[1] || $valPairs[2] || $valPairs[3] || $valPairs[4] || $valPairs[5]) {
|
||||
// If width is defined AND there has been no change to the default table params,
|
||||
// then extend them to a tablewidth of 1
|
||||
if ($valPairs[4] && $this->default_tableParams == $this->tableParams) {
|
||||
$this->tableParams .= ' width="1"';
|
||||
}
|
||||
// Init:
|
||||
$this->begin = LF . '<table ' . $this->tableParams . '>';
|
||||
$this->end = '</table>';
|
||||
$rows = array();
|
||||
$widthImg = '';
|
||||
$heightImg = '';
|
||||
// If width is required, set so bottom column will display for sure
|
||||
if ($valPairs[4]) {
|
||||
if (!$valPairs[3]) {
|
||||
$valPairs[3] = 1;
|
||||
}
|
||||
$widthImg = '<span style="width: ' . $valPairs[4] . 'px; height: 1px;"></span>';
|
||||
}
|
||||
// If height is required, set so right column will display for sure
|
||||
if ($valPairs[5]) {
|
||||
if (!$valPairs[2]) {
|
||||
$valPairs[2] = 1;
|
||||
}
|
||||
$valPairs[2] = 1;
|
||||
$heightImg = '<span style="width: 1px; height: ' . $valPairs[5] . 'px;"></span>';
|
||||
}
|
||||
// First row:
|
||||
// top
|
||||
if ($valPairs[1]) {
|
||||
$rows[1] .= '<tr>';
|
||||
$rows[1] .= '<td><span style="width: ' . ($valPairs[0] ?: 1) . 'px; height: ' . $valPairs[1] . 'px;"></span></td>';
|
||||
if ($valPairs[0]) {
|
||||
$rows[1] .= '<td></td>';
|
||||
}
|
||||
if ($valPairs[2]) {
|
||||
$rows[1] .= '<td></td>';
|
||||
}
|
||||
$rows[1] .= '</tr>';
|
||||
}
|
||||
// Middle row:
|
||||
$rows[2] .= '<tr>';
|
||||
if ($valPairs[0]) {
|
||||
$rows[2] .= $valPairs[1] ? '<td></td>' : '<td><span style="width: ' . $valPairs[0] . 'px; height: 1px;"></span></td>';
|
||||
}
|
||||
$rows[2] .= '<td' . $this->tdParams . '>' . $content . '</td>';
|
||||
if ($valPairs[2]) {
|
||||
$rows[2] .= $valPairs[3] ? '<td>' . $heightImg . '</td>' : '<td><span style="width: ' . $valPairs[2] . 'px; height: ' . ($valPairs[5] ?: 1) . 'px;"></span></td>';
|
||||
}
|
||||
$rows[2] .= '</tr>';
|
||||
// Bottom row:
|
||||
if ($valPairs[3]) {
|
||||
$rows[3] .= '<tr>';
|
||||
if ($valPairs[0]) {
|
||||
$rows[3] .= '<td></td>';
|
||||
}
|
||||
if ($valPairs[2]) {
|
||||
$rows[3] .= '<td>' . $widthImg . '</td>';
|
||||
}
|
||||
$rows[3] .= '<td><span style="width: ' . ($valPairs[2] ?: ($valPairs[4] ?: 1)) . 'px; height: ' . $valPairs[3] . 'px;"></span></td>';
|
||||
$rows[3] .= '</tr>';
|
||||
}
|
||||
return $this->begin . implode('', $rows) . $this->end;
|
||||
} else {
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,661 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\Compatibility6\ContentObject;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
||||
|
||||
/**
|
||||
* Search class used for the content object SEARCHRESULT
|
||||
* and searching in database tables, typ. "pages" and "tt_content"
|
||||
* Used to generate search queries for TypoScript.
|
||||
* The class is included from "TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer"
|
||||
* based on whether there has been detected content in the GPvar "sword"
|
||||
*/
|
||||
class SearchResultContentObject extends \TYPO3\CMS\Frontend\ContentObject\AbstractContentObject
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $tables = array();
|
||||
|
||||
/**
|
||||
* Alternatively 'PRIMARY_KEY'; sorting by primary key
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $group_by = 'PRIMARY_KEY';
|
||||
|
||||
/**
|
||||
* Standard SQL-operator between words
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $default_operator = 'AND';
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $operator_translate_table_caseinsensitive = true;
|
||||
|
||||
/**
|
||||
* case-sensitive. Defines the words, which will be operators between words
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $operator_translate_table = array(
|
||||
array('+', 'AND'),
|
||||
array('|', 'AND'),
|
||||
array('-', 'AND NOT'),
|
||||
// english
|
||||
array('and', 'AND'),
|
||||
array('or', 'OR'),
|
||||
array('not', 'AND NOT')
|
||||
);
|
||||
|
||||
/**
|
||||
* Contains the search-words and operators
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $sword_array;
|
||||
|
||||
/**
|
||||
* Contains the query parts after processing.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $queryParts;
|
||||
|
||||
/**
|
||||
* This is set with the foreign table that 'pages' are connected to.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $fTable;
|
||||
|
||||
/**
|
||||
* How many rows to offset from the beginning
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $res_offset = 0;
|
||||
|
||||
/**
|
||||
* How many results to show (0 = no limit)
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $res_shows = 20;
|
||||
|
||||
/**
|
||||
* Intern: How many results, there was last time (with the exact same searchstring.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $res_count;
|
||||
|
||||
/**
|
||||
* List of pageIds.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $pageIdList = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $listOfSearchFields = '';
|
||||
|
||||
/**
|
||||
* Override default constructor to make it possible to instantiate this
|
||||
* class for indexed_search
|
||||
*
|
||||
* @param \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj
|
||||
*/
|
||||
public function __construct(ContentObjectRenderer $cObj = null)
|
||||
{
|
||||
if (!is_null($cObj)) {
|
||||
$this->cObj = $cObj;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rendering the cObject, SEARCHRESULT
|
||||
*
|
||||
* @param array $conf Array of TypoScript properties
|
||||
* @return string Output
|
||||
*/
|
||||
public function render($conf = array())
|
||||
{
|
||||
if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('sword') && \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('scols')) {
|
||||
$this->register_and_explode_search_string(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('sword'));
|
||||
$this->register_tables_and_columns(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('scols'), $conf['allowedCols']);
|
||||
// Depth
|
||||
$depth = 100;
|
||||
// The startId is found
|
||||
$theStartId = 0;
|
||||
if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('stype'))) {
|
||||
$temp_theStartId = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('stype');
|
||||
$rootLine = $GLOBALS['TSFE']->sys_page->getRootLine($temp_theStartId);
|
||||
// The page MUST have a rootline with the Level0-page of the current site inside!!
|
||||
foreach ($rootLine as $val) {
|
||||
if ($val['uid'] == $GLOBALS['TSFE']->tmpl->rootLine[0]['uid']) {
|
||||
$theStartId = $temp_theStartId;
|
||||
}
|
||||
}
|
||||
} elseif (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('stype')) {
|
||||
if (substr(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('stype'), 0, 1) == 'L') {
|
||||
$pointer = (int)substr(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('stype'), 1);
|
||||
$theRootLine = $GLOBALS['TSFE']->tmpl->rootLine;
|
||||
// location Data:
|
||||
$locDat_arr = explode(':', \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('locationData'));
|
||||
$pId = (int)$locDat_arr[0];
|
||||
if ($pId) {
|
||||
$altRootLine = $GLOBALS['TSFE']->sys_page->getRootLine($pId);
|
||||
ksort($altRootLine);
|
||||
if (!empty($altRootLine)) {
|
||||
// Check if the rootline has the real Level0 in it!!
|
||||
$hitRoot = 0;
|
||||
$theNewRoot = array();
|
||||
foreach ($altRootLine as $val) {
|
||||
if ($hitRoot || $val['uid'] == $GLOBALS['TSFE']->tmpl->rootLine[0]['uid']) {
|
||||
$hitRoot = 1;
|
||||
$theNewRoot[] = $val;
|
||||
}
|
||||
}
|
||||
if ($hitRoot) {
|
||||
// Override the real rootline if any thing
|
||||
$theRootLine = $theNewRoot;
|
||||
}
|
||||
}
|
||||
}
|
||||
$key = $this->cObj->getKey($pointer, $theRootLine);
|
||||
$theStartId = $theRootLine[$key]['uid'];
|
||||
}
|
||||
}
|
||||
if (!$theStartId) {
|
||||
// If not set, we use current page
|
||||
$theStartId = $GLOBALS['TSFE']->id;
|
||||
}
|
||||
// Generate page-tree
|
||||
$this->pageIdList .= $this->cObj->getTreeList(-1 * $theStartId, $depth);
|
||||
$endClause = 'pages.uid IN (' . $this->pageIdList . ')
|
||||
AND pages.doktype in (' . $GLOBALS['TYPO3_CONF_VARS']['FE']['content_doktypes'] . ($conf['addExtUrlsAndShortCuts'] ? ',3,4' : '') . ')
|
||||
AND pages.no_search=0' . $this->cObj->enableFields($this->fTable) . $this->cObj->enableFields('pages');
|
||||
if ($conf['languageField.'][$this->fTable]) {
|
||||
// (using sys_language_uid which is the ACTUAL language of the page.
|
||||
// sys_language_content is only for selecting DISPLAY content!)
|
||||
$endClause .= ' AND ' . $this->fTable . '.' . $conf['languageField.'][$this->fTable] . ' = ' . (int)$GLOBALS['TSFE']->sys_language_uid;
|
||||
}
|
||||
// Build query
|
||||
$this->build_search_query($endClause);
|
||||
// Count...
|
||||
if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('scount'))) {
|
||||
$this->res_count = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('scount');
|
||||
} else {
|
||||
$this->count_query();
|
||||
}
|
||||
// Range
|
||||
$spointer = (int)\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('spointer');
|
||||
$range = isset($conf['range.']) ? $this->cObj->stdWrap($conf['range'], $conf['range.']) : $conf['range'];
|
||||
if ($range) {
|
||||
$theRange = (int)$range;
|
||||
} else {
|
||||
$theRange = 20;
|
||||
}
|
||||
// Order By:
|
||||
$noOrderBy = isset($conf['noOrderBy.']) ? $this->cObj->stdWrap($conf['noOrderBy'], $conf['noOrderBy.']) : $conf['noOrderBy'];
|
||||
if (!$noOrderBy) {
|
||||
$this->queryParts['ORDERBY'] = 'pages.lastUpdated, pages.tstamp';
|
||||
}
|
||||
$this->queryParts['LIMIT'] = $spointer . ',' . $theRange;
|
||||
// Search...
|
||||
$this->execute_query();
|
||||
if ($GLOBALS['TYPO3_DB']->sql_num_rows($this->result)) {
|
||||
$GLOBALS['TSFE']->register['SWORD_PARAMS'] = $this->get_searchwords();
|
||||
$total = $this->res_count;
|
||||
$rangeLow = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($spointer + 1, 1, $total);
|
||||
$rangeHigh = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($spointer + $theRange, 1, $total);
|
||||
// prev/next url:
|
||||
$target = isset($conf['target.']) ? $this->cObj->stdWrap($conf['target'], $conf['target.']) : $conf['target'];
|
||||
$LD = $GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page, $target, 1, '', '', $this->cObj->getClosestMPvalueForPage($GLOBALS['TSFE']->page['uid']));
|
||||
$targetPart = $LD['target'] ? ' target="' . htmlspecialchars($LD['target']) . '"' : '';
|
||||
$urlParams = $this->cObj->URLqMark($LD['totalURL'], '&sword=' . rawurlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('sword')) . '&scols=' . rawurlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('scols')) . '&stype=' . rawurlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('stype')) . '&scount=' . $total);
|
||||
// substitution:
|
||||
$result = str_replace(
|
||||
array(
|
||||
'###RANGELOW###',
|
||||
'###RANGEHIGH###',
|
||||
'###TOTAL###'
|
||||
),
|
||||
array(
|
||||
$rangeLow,
|
||||
$rangeHigh,
|
||||
$total
|
||||
),
|
||||
$this->cObj->cObjGetSingle($conf['layout'], $conf['layout.'], 'layout')
|
||||
);
|
||||
if ($rangeHigh < $total) {
|
||||
$next = $this->cObj->cObjGetSingle($conf['next'], $conf['next.'], 'next');
|
||||
$next = '<a href="' . htmlspecialchars(($urlParams . '&spointer=' . ($spointer + $theRange))) . '"' . $targetPart . $GLOBALS['TSFE']->ATagParams . '>' . $next . '</a>';
|
||||
} else {
|
||||
$next = '';
|
||||
}
|
||||
$result = str_replace('###NEXT###', $next, $result);
|
||||
if ($rangeLow > 1) {
|
||||
$prev = $this->cObj->cObjGetSingle($conf['prev'], $conf['prev.'], 'prev');
|
||||
$prev = '<a href="' . htmlspecialchars(($urlParams . '&spointer=' . ($spointer - $theRange))) . '"' . $targetPart . $GLOBALS['TSFE']->ATagParams . '>' . $prev . '</a>';
|
||||
} else {
|
||||
$prev = '';
|
||||
}
|
||||
$result = str_replace('###PREV###', $prev, $result);
|
||||
// Searching result
|
||||
$theValue = $this->cObj->cObjGetSingle($conf['resultObj'], $conf['resultObj.'], 'resultObj');
|
||||
/** @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj */
|
||||
$cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
|
||||
$cObj->setParent($this->cObj->data, $this->cObj->currentRecord);
|
||||
$renderCode = '';
|
||||
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($this->result)) {
|
||||
// versionOL() here? This is search result displays, is that possible to preview anyway?
|
||||
// Or are records selected here already future versions?
|
||||
$cObj->start($row);
|
||||
$renderCode .= $cObj->cObjGetSingle($conf['renderObj'], $conf['renderObj.'], 'renderObj');
|
||||
}
|
||||
$renderWrap = isset($conf['renderWrap.']) ? $this->cObj->stdWrap($conf['renderWrap'], $conf['renderWrap.']) : $conf['renderWrap'];
|
||||
$theValue .= $this->cObj->wrap($renderCode, $renderWrap);
|
||||
$theValue = str_replace('###RESULT###', $theValue, $result);
|
||||
} else {
|
||||
$theValue = $this->cObj->cObjGetSingle($conf['noResultObj'], $conf['noResultObj.'], 'noResultObj');
|
||||
}
|
||||
$GLOBALS['TT']->setTSlogMessage('Search in fields: ' . $this->listOfSearchFields);
|
||||
// Wrapping
|
||||
$content = $theValue;
|
||||
$wrap = isset($conf['wrap.']) ? $this->cObj->stdWrap($conf['wrap'], $conf['wrap.']) : $conf['wrap'];
|
||||
if ($wrap) {
|
||||
$content = $this->cObj->wrap($content, $wrap);
|
||||
}
|
||||
if (isset($conf['stdWrap.'])) {
|
||||
$content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
|
||||
}
|
||||
// Returning, do not cache the result of the search
|
||||
$GLOBALS['TSFE']->set_no_cache('Search result page');
|
||||
return $content;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the $this->tables-array.
|
||||
* The 'pages'-table is ALWAYS included as the search is page-based. Apart from this there may be one and only one table, joined with the pages-table. This table is the first table mentioned in the requested-list. If any more tables are set here, they are ignored.
|
||||
*
|
||||
* @param string $requestedCols is a list (-) of columns that we want to search. This could be input from the search-form (see TypoScript documentation)
|
||||
* @param string $allowedCols $allowedCols: is the list of columns, that MAY be searched. All allowed cols are set as result-fields. All requested cols MUST be in the allowed-fields list.
|
||||
* @return void
|
||||
*/
|
||||
public function register_tables_and_columns($requestedCols, $allowedCols)
|
||||
{
|
||||
$rCols = $this->explodeCols($requestedCols);
|
||||
$aCols = $this->explodeCols($allowedCols);
|
||||
foreach ($rCols as $k => $v) {
|
||||
$rCols[$k] = trim($v);
|
||||
if (in_array($rCols[$k], $aCols)) {
|
||||
$parts = explode('.', $rCols[$k]);
|
||||
$this->tables[$parts[0]]['searchfields'][] = $parts[1];
|
||||
}
|
||||
}
|
||||
$this->tables['pages']['primary_key'] = 'uid';
|
||||
$this->tables['pages']['resultfields'][] = 'uid';
|
||||
unset($this->tables['pages']['fkey']);
|
||||
foreach ($aCols as $k => $v) {
|
||||
$aCols[$k] = trim($v);
|
||||
$parts = explode('.', $aCols[$k]);
|
||||
$this->tables[$parts[0]]['resultfields'][] = $parts[1] . ' AS ' . str_replace('.', '_', $aCols[$k]);
|
||||
$this->tables[$parts[0]]['fkey'] = 'pid';
|
||||
}
|
||||
$this->fTable = '';
|
||||
foreach ($this->tables as $t => $v) {
|
||||
if ($t != 'pages') {
|
||||
if (!$this->fTable) {
|
||||
$this->fTable = $t;
|
||||
} else {
|
||||
unset($this->tables[$t]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function that can convert the syntax for entering which tables/fields the search should be conducted in.
|
||||
*
|
||||
* @param string $in This is the code-line defining the tables/fields to search. Syntax: '[table1].[field1]-[field2]-[field3] : [table2].[field1]-[field2]'
|
||||
* @return array An array where the values is "[table].[field]" strings to search
|
||||
* @see register_tables_and_columns()
|
||||
*/
|
||||
public function explodeCols($in)
|
||||
{
|
||||
$theArray = explode(':', $in);
|
||||
$out = array();
|
||||
foreach ($theArray as $val) {
|
||||
$val = trim($val);
|
||||
$parts = explode('.', $val);
|
||||
if ($parts[0] && $parts[1]) {
|
||||
$subparts = explode('-', $parts[1]);
|
||||
foreach ($subparts as $piece) {
|
||||
$piece = trim($piece);
|
||||
if ($piece) {
|
||||
$out[] = $parts[0] . '.' . $piece;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a search-string (WITHOUT SLASHES or else it'll be a little sppooky , NOW REMEMBER to unslash!!)
|
||||
* Sets up $this->sword_array op with operators.
|
||||
* This function uses $this->operator_translate_table as well as $this->default_operator
|
||||
*
|
||||
* @param string $sword The input search-word string.
|
||||
* @return void
|
||||
*/
|
||||
public function register_and_explode_search_string($sword)
|
||||
{
|
||||
$sword = trim($sword);
|
||||
if ($sword) {
|
||||
$components = $this->split($sword);
|
||||
// the searchword is stored here during the loop
|
||||
$s_sword = '';
|
||||
if (is_array($components)) {
|
||||
$i = 0;
|
||||
$lastoper = '';
|
||||
foreach ($components as $key => $val) {
|
||||
$operator = $this->get_operator($val);
|
||||
if ($operator) {
|
||||
$lastoper = $operator;
|
||||
} elseif (strlen($val) > 1) {
|
||||
// A searchword MUST be at least two characters long!
|
||||
$this->sword_array[$i]['sword'] = $val;
|
||||
$this->sword_array[$i]['oper'] = $lastoper ?: $this->default_operator;
|
||||
$lastoper = '';
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to split a search-word line up into elements to search for. This function will detect boolean words like AND and OR, + and -, and even find sentences encapsulated in ""
|
||||
* This function could be re-written to be more clean and effective - yet it's not that important.
|
||||
*
|
||||
* @param string $origSword The raw sword string from outside
|
||||
* @param string $specchars Special chars which are used as operators (+- is default)
|
||||
* @param string $delchars Special chars which are deleted if the append the searchword (+-., is default)
|
||||
* @return mixed Returns an ARRAY if there were search words, otherwise the return value may be unset.
|
||||
*/
|
||||
public function split($origSword, $specchars = '+-', $delchars = '+.,-')
|
||||
{
|
||||
$sword = $origSword;
|
||||
$specs = '[' . preg_quote($specchars, '/') . ']';
|
||||
// As long as $sword is TRUE (that means $sword MUST be reduced little by little until its empty inside the loop!)
|
||||
while ($sword) {
|
||||
// There was a double-quote and we will then look for the ending quote.
|
||||
if (preg_match('/^"/', $sword)) {
|
||||
// Removes first double-quote
|
||||
$sword = preg_replace('/^"/', '', $sword);
|
||||
// Removes everything till next double-quote
|
||||
preg_match('/^[^"]*/', $sword, $reg);
|
||||
// reg[0] is the value, should not be trimmed
|
||||
$value[] = $reg[0];
|
||||
$sword = preg_replace('/^' . preg_quote($reg[0], '/') . '/', '', $sword);
|
||||
// Removes last double-quote
|
||||
$sword = trim(preg_replace('/^"/', '', $sword));
|
||||
} elseif (preg_match('/^' . $specs . '/', $sword, $reg)) {
|
||||
$value[] = $reg[0];
|
||||
// Removes = sign
|
||||
$sword = trim(preg_replace('/^' . $specs . '/', '', $sword));
|
||||
} elseif (preg_match('/[\\+\\-]/', $sword)) {
|
||||
// Check if $sword contains + or -
|
||||
// + and - shall only be interpreted as $specchars when there's whitespace before it
|
||||
// otherwise it's included in the searchword (e.g. "know-how")
|
||||
// explode $sword to single words
|
||||
$a_sword = explode(' ', $sword);
|
||||
// get first word
|
||||
$word = array_shift($a_sword);
|
||||
// Delete $delchars at end of string
|
||||
$word = rtrim($word, $delchars);
|
||||
// add searchword to values
|
||||
$value[] = $word;
|
||||
// re-build $sword
|
||||
$sword = implode(' ', $a_sword);
|
||||
} else {
|
||||
// There are no double-quotes around the value. Looking for next (space) or special char.
|
||||
preg_match('/^[^ ' . preg_quote($specchars, '/') . ']*/', $sword, $reg);
|
||||
// Delete $delchars at end of string
|
||||
$word = rtrim(trim($reg[0]), $delchars);
|
||||
$value[] = $word;
|
||||
$sword = trim(preg_replace('/^' . preg_quote($reg[0], '/') . '/', '', $sword));
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* This creates the search-query.
|
||||
* In TypoScript this is used for searching only records not hidden, start/endtimed and fe_grouped! (enable-fields, see tt_content)
|
||||
* Sets $this->queryParts
|
||||
*
|
||||
* @param string $endClause Some extra conditions that the search must match.
|
||||
* @return bool Returns TRUE no matter what - sweet isn't it!
|
||||
* @access private
|
||||
* @see \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::SEARCHRESULT()
|
||||
*/
|
||||
public function build_search_query($endClause)
|
||||
{
|
||||
if (is_array($this->tables)) {
|
||||
$tables = $this->tables;
|
||||
$primary_table = '';
|
||||
// Primary key table is found.
|
||||
foreach ($tables as $key => $val) {
|
||||
if ($tables[$key]['primary_key']) {
|
||||
$primary_table = $key;
|
||||
}
|
||||
}
|
||||
if ($primary_table) {
|
||||
// Initialize query parts:
|
||||
$this->queryParts = array(
|
||||
'SELECT' => '',
|
||||
'FROM' => '',
|
||||
'WHERE' => '',
|
||||
'GROUPBY' => '',
|
||||
'ORDERBY' => '',
|
||||
'LIMIT' => ''
|
||||
);
|
||||
// Find tables / field names to select:
|
||||
$fieldArray = array();
|
||||
$tableArray = array();
|
||||
foreach ($tables as $key => $val) {
|
||||
$tableArray[] = $key;
|
||||
$resultfields = $tables[$key]['resultfields'];
|
||||
if (is_array($resultfields)) {
|
||||
foreach ($resultfields as $key2 => $val2) {
|
||||
$fieldArray[] = $key . '.' . $val2;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->queryParts['SELECT'] = implode(',', $fieldArray);
|
||||
$this->queryParts['FROM'] = implode(',', $tableArray);
|
||||
// Set join WHERE parts:
|
||||
$whereArray = array();
|
||||
$primary_table_and_key = $primary_table . '.' . $tables[$primary_table]['primary_key'];
|
||||
$primKeys = array();
|
||||
foreach ($tables as $key => $val) {
|
||||
$fkey = $tables[$key]['fkey'];
|
||||
if ($fkey) {
|
||||
$primKeys[] = $key . '.' . $fkey . '=' . $primary_table_and_key;
|
||||
}
|
||||
}
|
||||
if (!empty($primKeys)) {
|
||||
$whereArray[] = '(' . implode(' OR ', $primKeys) . ')';
|
||||
}
|
||||
// Additional where clause:
|
||||
if (trim($endClause)) {
|
||||
$whereArray[] = trim($endClause);
|
||||
}
|
||||
// Add search word where clause:
|
||||
$query_part = $this->build_search_query_for_searchwords();
|
||||
if (!$query_part) {
|
||||
$query_part = '(0!=0)';
|
||||
}
|
||||
$whereArray[] = '(' . $query_part . ')';
|
||||
// Implode where clauses:
|
||||
$this->queryParts['WHERE'] = implode(' AND ', $whereArray);
|
||||
// Group by settings:
|
||||
if ($this->group_by) {
|
||||
if ($this->group_by == 'PRIMARY_KEY') {
|
||||
$this->queryParts['GROUPBY'] = $primary_table_and_key;
|
||||
} else {
|
||||
$this->queryParts['GROUPBY'] = $this->group_by;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the part of the SQL-sentence, that searches for the search-words ($this->sword_array)
|
||||
*
|
||||
* @return string Part of where class limiting result to the those having the search word.
|
||||
* @access private
|
||||
*/
|
||||
public function build_search_query_for_searchwords()
|
||||
{
|
||||
if (is_array($this->sword_array)) {
|
||||
$main_query_part = array();
|
||||
foreach ($this->sword_array as $key => $val) {
|
||||
$s_sword = $this->sword_array[$key]['sword'];
|
||||
// Get subQueryPart
|
||||
$sub_query_part = array();
|
||||
$this->listOfSearchFields = '';
|
||||
foreach ($this->tables as $key3 => $val3) {
|
||||
$searchfields = $this->tables[$key3]['searchfields'];
|
||||
if (is_array($searchfields)) {
|
||||
foreach ($searchfields as $key2 => $val2) {
|
||||
$this->listOfSearchFields .= $key3 . '.' . $val2 . ',';
|
||||
$sub_query_part[] = $key3 . '.' . $val2 . ' LIKE \'%' . $GLOBALS['TYPO3_DB']->quoteStr($s_sword, $key3) . '%\'';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($sub_query_part)) {
|
||||
$main_query_part[] = $this->sword_array[$key]['oper'];
|
||||
$main_query_part[] = '(' . implode(' OR ', $sub_query_part) . ')';
|
||||
}
|
||||
}
|
||||
if (!empty($main_query_part)) {
|
||||
// Remove first part anyways.
|
||||
unset($main_query_part[0]);
|
||||
return implode(' ', $main_query_part);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This returns an SQL search-operator (eg. AND, OR, NOT) translated from the current localized set of operators (eg. in danish OG, ELLER, IKKE).
|
||||
*
|
||||
* @param string $operator The possible operator to find in the internal operator array.
|
||||
* @return string If found, the SQL operator for the localized input operator.
|
||||
* @access private
|
||||
*/
|
||||
public function get_operator($operator)
|
||||
{
|
||||
$operator = trim($operator);
|
||||
$op_array = $this->operator_translate_table;
|
||||
if ($this->operator_translate_table_caseinsensitive) {
|
||||
// case-conversion is charset insensitive, but it doesn't spoil
|
||||
// anything if input string AND operator table is already converted
|
||||
$operator = strtolower($operator);
|
||||
}
|
||||
foreach ($op_array as $key => $val) {
|
||||
$item = $op_array[$key][0];
|
||||
if ($this->operator_translate_table_caseinsensitive) {
|
||||
// See note above.
|
||||
$item = strtolower($item);
|
||||
}
|
||||
if ($operator == $item) {
|
||||
return $op_array[$key][1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts the results and sets the result in $this->res_count
|
||||
*
|
||||
* @return bool TRUE, if $this->query was found
|
||||
*/
|
||||
public function count_query()
|
||||
{
|
||||
if (is_array($this->queryParts)) {
|
||||
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($this->queryParts['SELECT'], $this->queryParts['FROM'], $this->queryParts['WHERE'], $this->queryParts['GROUPBY']);
|
||||
$this->res_count = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the search, sets result pointer in $this->result
|
||||
*
|
||||
* @return bool TRUE, if $this->query was set and query performed
|
||||
*/
|
||||
public function execute_query()
|
||||
{
|
||||
if (is_array($this->queryParts)) {
|
||||
$this->result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($this->queryParts);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns URL-parameters with the current search words.
|
||||
* Used when linking to result pages so that search words can be highlighted.
|
||||
*
|
||||
* @return string URL-parameters with the searchwords
|
||||
*/
|
||||
public function get_searchwords()
|
||||
{
|
||||
$SWORD_PARAMS = '';
|
||||
if (is_array($this->sword_array)) {
|
||||
foreach ($this->sword_array as $key => $val) {
|
||||
$SWORD_PARAMS .= '&sword_list[]=' . rawurlencode($val['sword']);
|
||||
}
|
||||
}
|
||||
return $SWORD_PARAMS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with the search words in
|
||||
*
|
||||
* @return array IF the internal sword_array contained search words it will return these, otherwise "void
|
||||
*/
|
||||
public function get_searchwordsArray()
|
||||
{
|
||||
if (is_array($this->sword_array)) {
|
||||
foreach ($this->sword_array as $key => $val) {
|
||||
$swords[] = $val['sword'];
|
||||
}
|
||||
}
|
||||
return $swords;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\Compatibility6\ContentObject;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
/**
|
||||
* Rendering of tables for content positioning
|
||||
*
|
||||
* @see ContentObjectRenderer::CTABLE()
|
||||
*/
|
||||
class TableRenderer
|
||||
{
|
||||
/**
|
||||
* offset, x
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $offX = 0;
|
||||
|
||||
/**
|
||||
* offset, y
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $offY = 0;
|
||||
|
||||
/**
|
||||
* top menu
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $tm = '';
|
||||
|
||||
/**
|
||||
* left menu
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $lm = '';
|
||||
|
||||
/**
|
||||
* right menu
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $rm = '';
|
||||
|
||||
/**
|
||||
* bottom menu
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $bm = '';
|
||||
|
||||
/**
|
||||
* content
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $content = '';
|
||||
|
||||
/**
|
||||
* top menu TDparams
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $tmTDparams = 'valign="top"';
|
||||
|
||||
/**
|
||||
* left menu TDparams
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $lmTDparams = 'valign="top"';
|
||||
|
||||
/**
|
||||
* right menu TDparams
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $rmTDparams = 'valign="top"';
|
||||
|
||||
/**
|
||||
* bottom menu TDparams
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $bmTDparams = 'valign="top"';
|
||||
|
||||
/**
|
||||
* content TDparams
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $contentTDparams = 'valign="top"';
|
||||
|
||||
/**
|
||||
* content margin, left
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $cMl = 1;
|
||||
|
||||
/**
|
||||
* content margin, right
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $cMr = 1;
|
||||
|
||||
/**
|
||||
* content margin, top
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $cMt = 0;
|
||||
|
||||
/**
|
||||
* content margin, bottom
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $cMb = 1;
|
||||
|
||||
/**
|
||||
* Places a little gif-spacer in the bottom of the content frame
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $contentW = 0;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $tableParams = 'border="0" cellspacing="0" cellpadding="0"';
|
||||
|
||||
/**
|
||||
* Wrapping internal vars ->tm, ->lm, ->rm, ->bm and ->content in a table where each content part is stored in a cell.
|
||||
* The two arguments to this function defines some offsets and margins to use in the arrangement of the content in the table.
|
||||
*
|
||||
* @param string $offset List of offset parameters; x,y
|
||||
* @param string $cMargins List of margin parameters; left, top, right, bottom
|
||||
* @return string The content strings wrapped in a <table> as the parameters defined
|
||||
* @see \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::CTABLE()
|
||||
*/
|
||||
public function start($offset, $cMargins)
|
||||
{
|
||||
$offArr = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $offset);
|
||||
$cMargArr = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $cMargins);
|
||||
$cols = 0;
|
||||
$rows = 0;
|
||||
if ($this->lm) {
|
||||
$cols++;
|
||||
}
|
||||
if ($this->rm) {
|
||||
$cols++;
|
||||
}
|
||||
if ($cMargArr[0]) {
|
||||
$cols++;
|
||||
}
|
||||
if ($cMargArr[2]) {
|
||||
$cols++;
|
||||
}
|
||||
if ($cMargArr[1] || $cMargArr[3] || $this->tm || $this->bm || $this->content || $this->contentW) {
|
||||
$cols++;
|
||||
}
|
||||
if ($cMargArr[1]) {
|
||||
$rows++;
|
||||
}
|
||||
if ($cMargArr[3]) {
|
||||
$rows++;
|
||||
}
|
||||
if ($this->tm) {
|
||||
$rows++;
|
||||
}
|
||||
if ($this->bm) {
|
||||
$rows++;
|
||||
}
|
||||
if ($this->content) {
|
||||
$rows++;
|
||||
}
|
||||
if ($this->contentW) {
|
||||
$rows++;
|
||||
}
|
||||
if (!$rows && $cols) {
|
||||
// If there are no rows in the middle but still som columns...
|
||||
$rows = 1;
|
||||
}
|
||||
if ($rows && $cols) {
|
||||
$res = LF . '<table ' . $this->tableParams . '>';
|
||||
// Top offset:
|
||||
if ($offArr[1]) {
|
||||
$xoff = $offArr[0] ? 1 : 0;
|
||||
if ($cols + $xoff > 1) {
|
||||
$colspan = ' colspan="' . ($cols + $xoff) . '"';
|
||||
}
|
||||
$res .= '<tr><td' . $colspan . '><span style="width: 1px; height: ' . $offArr[1] . 'px;"></span></td></tr>';
|
||||
}
|
||||
// The rows:
|
||||
if ($rows > 1) {
|
||||
$rowspan = ' rowspan="' . $rows . '"';
|
||||
}
|
||||
$res .= '<tr>';
|
||||
if ($offArr[0]) {
|
||||
$res .= '<td' . $rowspan . '><span style="width: ' . $offArr[0] . 'px; height: 1px;"></span></td>';
|
||||
}
|
||||
if ($this->lm) {
|
||||
$res .= '<td' . $rowspan . ' ' . $this->lmTDparams . '>' . $this->lm . '</td>';
|
||||
}
|
||||
if ($cMargArr[0]) {
|
||||
$res .= '<td' . $rowspan . '><span style="width: ' . $cMargArr[0] . 'px; height: 1px;"></span></td>';
|
||||
}
|
||||
// Content...
|
||||
$middle = array();
|
||||
if ($this->tm) {
|
||||
$middle[] = '<td ' . $this->tmTDparams . '>' . $this->tm . '</td>';
|
||||
}
|
||||
if ($cMargArr[1]) {
|
||||
$middle[] = '<td><span style="width: 1px; height: ' . $cMargArr[1] . 'px;"></span></td>';
|
||||
}
|
||||
if ($this->content) {
|
||||
$middle[] = '<td ' . $this->contentTDparams . '>' . $this->content . '</td>';
|
||||
}
|
||||
if ($cMargArr[3]) {
|
||||
$middle[] = '<td><span style="width: 1px; height: ' . $cMargArr[3] . 'px;"></span></td>';
|
||||
}
|
||||
if ($this->bm) {
|
||||
$middle[] = '<td ' . $this->bmTDparams . '>' . $this->bm . '</td>';
|
||||
}
|
||||
if ($this->contentW) {
|
||||
$middle[] = '<td><span style="width: ' . $this->contentW . 'px; height: 1px;"></span></td>';
|
||||
}
|
||||
if (isset($middle[0])) {
|
||||
$res .= $middle[0];
|
||||
}
|
||||
// Left of content
|
||||
if ($cMargArr[2]) {
|
||||
$res .= '<td' . $rowspan . '><span style="width: ' . $cMargArr[2] . 'px; height: 1px;"></span></td>';
|
||||
}
|
||||
if ($this->rm) {
|
||||
$res .= '<td' . $rowspan . ' ' . $this->rmTDparams . '>' . $this->rm . '</td>';
|
||||
}
|
||||
$res .= '</tr>';
|
||||
// More than the two rows
|
||||
$mCount = count($middle);
|
||||
for ($a = 1; $a < $mCount; $a++) {
|
||||
$res .= '<tr>' . $middle[$a] . '</tr>';
|
||||
}
|
||||
$res .= '</table>';
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user