Ejemplo n.º 1
0
    /**
     * Draws the RTE as a form field or whatever is needed (inserts JavaApplet, creates iframe, renders ....)
     * Default is to output the transformed content in a plain textarea field. This mode is great for debugging transformations!
     *
     * @param object $pObj Reference to parent object, which is an instance of the TCEforms.
     * @param string $table The table name
     * @param string $field The field name
     * @param array $row The current row from which field is being rendered
     * @param array $PA Array of standard content for rendering form fields from TCEforms. See TCEforms for details on this. Includes for instance the value and the form field name, java script actions and more.
     * @param array $specConf "special" configuration - what is found at position 4 in the types configuration of a field from record, parsed into an array.
     * @param array $thisConfig Configuration for RTEs; A mix between TSconfig and otherwise. Contains configuration for display, which buttons are enabled, additional transformation information etc.
     * @param string $RTEtypeVal Record "type" field value.
     * @param string $RTErelPath Relative path for images/links in RTE; this is used when the RTE edits content from static files where the path of such media has to be transformed forth and back!
     * @param integer $thePidValue PID value of record (true parent page id)
     * @return string HTML code for RTE!
     * @todo Define visibility
     */
    public function drawRTE(&$pObj, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue)
    {
        // Transform value:
        $value = $this->transformContent('rte', $PA['itemFormElValue'], $table, $field, $row, $specConf, $thisConfig, $RTErelPath, $thePidValue);
        // Create item:
        $item = '
			' . $this->triggerField($PA['itemFormElName']) . '
			<textarea name="' . htmlspecialchars($PA['itemFormElName']) . '"' . $pObj->formWidthText('48', 'off') . ' rows="20" wrap="off" style="background-color: #99eebb;">' . GeneralUtility::formatForTextarea($value) . '</textarea>';
        // Return form item:
        return $item;
    }
Ejemplo n.º 2
0
 /**
  * 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->cObj->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->cObj->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->cObj->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->cObj->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, GeneralUtility::formatForTextarea($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->cObj->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->cObj->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->cObj->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->cObj->getFieldDefaultValue($noValueInsert, $confData['fieldname'], $default);
                     // Create the select-box:
                     $iCount = count($items);
                     for ($a = 0; $a < $iCount; $a++) {
                         $optionParts = '';
                         $radioId = $prefix . $fName . $this->cObj->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 (strlen($value) && 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 (strlen($value) && GeneralUtility::inList('recipient_copy,recipient', $confData['fieldname']) && $GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) {
                         break;
                     }
                     if (strlen($value) && GeneralUtility::inList('recipient_copy,recipient', $confData['fieldname'])) {
                         $value = $GLOBALS['TSFE']->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->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]) . '&nbsp;';
             }
             if ($fieldCode) {
                 // Checking for special evaluation modes:
                 if (GeneralUtility::inList('textarea,input,password', $confData['type']) && strlen(trim($parts[3]))) {
                     $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 = $GLOBALS['TSFE']->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 (strlen($hF_value) && GeneralUtility::inList('recipient_copy,recipient', $hF_key)) {
                     if ($GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) {
                         continue;
                     }
                     $hF_value = $GLOBALS['TSFE']->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/frontend/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="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '"' . ' 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);
     }
 }
Ejemplo n.º 3
0
    /**
     * Generation of TCEform elements of the type "text"
     * This will render a <textarea> OR RTE area form field, possibly with various control/validation features
     *
     * @param string $table The table name of the record
     * @param string $field The field name which this element is supposed to edit
     * @param array $row The record data array where the value(s) for the field can be found
     * @param array $PA An array with additional configuration options.
     * @return string The HTML code for the TCEform field
     * @todo Define visibility
     */
    public function getSingleField_typeText($table, $field, $row, &$PA)
    {
        // Init config:
        $config = $PA['fieldConf']['config'];
        $evalList = GeneralUtility::trimExplode(',', $config['eval'], TRUE);
        if ($this->renderReadonly || $config['readOnly']) {
            return $this->getSingleField_typeNone_render($config, $PA['itemFormElValue']);
        }
        // Setting columns number:
        $cols = MathUtility::forceIntegerInRange($config['cols'] ? $config['cols'] : 30, 5, $this->maxTextareaWidth);
        // Setting number of rows:
        $origRows = $rows = MathUtility::forceIntegerInRange($config['rows'] ? $config['rows'] : 5, 1, 20);
        if (strlen($PA['itemFormElValue']) > $this->charsPerRow * 2) {
            $cols = $this->maxTextareaWidth;
            $rows = MathUtility::forceIntegerInRange(round(strlen($PA['itemFormElValue']) / $this->charsPerRow), count(explode(LF, $PA['itemFormElValue'])), 20);
            if ($rows < $origRows) {
                $rows = $origRows;
            }
        }
        if (in_array('required', $evalList)) {
            $this->requiredFields[$table . '_' . $row['uid'] . '_' . $field] = $PA['itemFormElName'];
        }
        // Init RTE vars:
        // Set TRUE, if the RTE is loaded; If not a normal textarea is shown.
        $RTEwasLoaded = 0;
        // Set TRUE, if the RTE would have been loaded if it wasn't for the disable-RTE flag in the bottom of the page...
        $RTEwouldHaveBeenLoaded = 0;
        // "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. Traditionally, this is where RTE configuration has been found.
        $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
        // Setting up the altItem form field, which is a hidden field containing the value
        $altItem = '<input type="hidden" name="' . htmlspecialchars($PA['itemFormElName']) . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
        $item = '';
        // If RTE is generally enabled (TYPO3_CONF_VARS and user settings)
        if ($this->RTEenabled) {
            $p = BackendUtility::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
            // If the field is configured for RTE and if any flag-field is not set to disable it.
            if (isset($specConf['richtext']) && (!$p['flag'] || !$row[$p['flag']])) {
                BackendUtility::fixVersioningPid($table, $row);
                list($tscPID, $thePidValue) = $this->getTSCpid($table, $row['uid'], $row['pid']);
                // If the pid-value is not negative (that is, a pid could NOT be fetched)
                if ($thePidValue >= 0) {
                    $RTEsetup = $this->getBackendUserAuthentication()->getTSConfig('RTE', BackendUtility::getPagesTSconfig($tscPID));
                    $RTEtypeVal = BackendUtility::getTCAtypeValue($table, $row);
                    $thisConfig = BackendUtility::RTEsetup($RTEsetup['properties'], $table, $field, $RTEtypeVal);
                    if (!$thisConfig['disabled']) {
                        if (!$this->disableRTE) {
                            $this->RTEcounter++;
                            // Find alternative relative path for RTE images/links:
                            $eFile = RteHtmlParser::evalWriteFile($specConf['static_write'], $row);
                            $RTErelPath = is_array($eFile) ? dirname($eFile['relEditFile']) : '';
                            // Get RTE object, draw form and set flag:
                            $RTEobj = BackendUtility::RTEgetObj();
                            $item = $RTEobj->drawRTE($this, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue);
                            // Wizard:
                            $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf, 1);
                            $RTEwasLoaded = 1;
                        } else {
                            $RTEwouldHaveBeenLoaded = 1;
                            $this->commentMessages[] = $PA['itemFormElName'] . ': RTE is disabled by the on-page RTE-flag (probably you can enable it by the check-box in the bottom of this page!)';
                        }
                    } else {
                        $this->commentMessages[] = $PA['itemFormElName'] . ': RTE is disabled by the Page TSconfig, "RTE"-key (eg. by RTE.default.disabled=0 or such)';
                    }
                } else {
                    $this->commentMessages[] = $PA['itemFormElName'] . ': PID value could NOT be fetched. Rare error, normally with new records.';
                }
            } else {
                if (!isset($specConf['richtext'])) {
                    $this->commentMessages[] = $PA['itemFormElName'] . ': RTE was not configured for this field in TCA-types';
                }
                if (!(!$p['flag'] || !$row[$p['flag']])) {
                    $this->commentMessages[] = $PA['itemFormElName'] . ': Field-flag (' . $PA['flag'] . ') has been set to disable RTE!';
                }
            }
        }
        // Display ordinary field if RTE was not loaded.
        if (!$RTEwasLoaded) {
            // Show message, if no RTE (field can only be edited with RTE!)
            if ($specConf['rte_only']) {
                $item = '<p><em>' . htmlspecialchars($this->getLL('l_noRTEfound')) . '</em></p>';
            } else {
                if ($specConf['nowrap']) {
                    $wrap = 'off';
                } else {
                    $wrap = $config['wrap'] ?: 'virtual';
                }
                $classes = array();
                if ($specConf['fixed-font']) {
                    $classes[] = 'fixed-font';
                }
                if ($specConf['enable-tab']) {
                    $classes[] = 'enable-tab';
                }
                $formWidthText = $this->formWidthText($cols, $wrap);
                // Extract class attributes from $formWidthText (otherwise it would be added twice to the output)
                $res = array();
                if (preg_match('/ class="(.+?)"/', $formWidthText, $res)) {
                    $formWidthText = str_replace(' class="' . $res[1] . '"', '', $formWidthText);
                    $classes = array_merge($classes, explode(' ', $res[1]));
                }
                if (count($classes)) {
                    $class = ' class="tceforms-textarea ' . implode(' ', $classes) . '"';
                } else {
                    $class = 'tceforms-textarea';
                }
                $evalList = GeneralUtility::trimExplode(',', $config['eval'], TRUE);
                foreach ($evalList as $func) {
                    switch ($func) {
                        case 'required':
                            $this->registerRequiredProperty('field', $table . '_' . $row['uid'] . '_' . $field, $PA['itemFormElName']);
                            break;
                        default:
                            // Pair hook to the one in \TYPO3\CMS\Core\DataHandling\DataHandler::checkValue_input_Eval()
                            // and \TYPO3\CMS\Core\DataHandling\DataHandler::checkValue_text_Eval()
                            $evalObj = GeneralUtility::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
                            if (is_object($evalObj) && method_exists($evalObj, 'deevaluateFieldValue')) {
                                $_params = array('value' => $PA['itemFormElValue']);
                                $PA['itemFormElValue'] = $evalObj->deevaluateFieldValue($_params);
                            }
                    }
                }
                $iOnChange = implode('', $PA['fieldChangeFunc']);
                $item .= '
							<textarea ' . 'id="' . uniqid('tceforms-textarea-') . '" ' . 'name="' . $PA['itemFormElName'] . '"' . $formWidthText . $class . ' ' . 'rows="' . $rows . '" ' . 'wrap="' . $wrap . '" ' . 'onchange="' . htmlspecialchars($iOnChange) . '"' . $this->getPlaceholderAttribute($table, $field, $config, $row) . $PA['onFocus'] . '>' . GeneralUtility::formatForTextarea($PA['itemFormElValue']) . '</textarea>';
                $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf, $RTEwouldHaveBeenLoaded);
            }
        }
        // Return field HTML:
        return $item;
    }
Ejemplo n.º 4
0
 /**
  * [Describe function...]
  *
  * @param string $mQ
  * @param pointer $res
  * @param string $table
  * @return string
  * @todo Define visibility
  */
 public function getQueryResultCode($mQ, $res, $table)
 {
     $out = '';
     $cPR = array();
     switch ($mQ) {
         case 'count':
             $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
             $cPR['header'] = 'Count';
             $cPR['content'] = '<BR><strong>' . $row[0] . '</strong> records selected.';
             break;
         case 'all':
             $rowArr = array();
             while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                 $rowArr[] = $this->resultRowDisplay($row, $GLOBALS['TCA'][$table], $table);
                 $lrow = $row;
             }
             if (is_array($this->hookArray['beforeResultTable'])) {
                 foreach ($this->hookArray['beforeResultTable'] as $_funcRef) {
                     $out .= GeneralUtility::callUserFunction($_funcRef, $GLOBALS['SOBE']->MOD_SETTINGS, $this);
                 }
             }
             if (count($rowArr)) {
                 $out .= '<table border="0" cellpadding="2" cellspacing="1" width="100%">' . $this->resultRowTitles($lrow, $GLOBALS['TCA'][$table], $table) . implode(LF, $rowArr) . '</table>';
             }
             if (!$out) {
                 $out = '<em>No rows selected!</em>';
             }
             $cPR['header'] = 'Result';
             $cPR['content'] = $out;
             break;
         case 'csv':
             $rowArr = array();
             $first = 1;
             while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                 if ($first) {
                     $rowArr[] = $this->csvValues(array_keys($row), ',', '');
                     $first = 0;
                 }
                 $rowArr[] = $this->csvValues($row, ',', '"', $GLOBALS['TCA'][$table], $table);
             }
             if (count($rowArr)) {
                 $out .= '<textarea name="whatever" rows="20" wrap="off"' . $GLOBALS['SOBE']->doc->formWidthText($this->formW, '', 'off') . ' class="fixed-font">' . GeneralUtility::formatForTextarea(implode(LF, $rowArr)) . '</textarea>';
                 if (!$this->noDownloadB) {
                     $out .= '<BR><input type="submit" name="download_file" value="Click to download file" onClick="window.location.href=\'' . $this->downloadScript . '\';">';
                 }
                 // Downloads file:
                 if (GeneralUtility::_GP('download_file')) {
                     $filename = 'TYPO3_' . $table . '_export_' . date('dmy-Hi') . '.csv';
                     $mimeType = 'application/octet-stream';
                     header('Content-Type: ' . $mimeType);
                     header('Content-Disposition: attachment; filename=' . $filename);
                     echo implode(CRLF, $rowArr);
                     die;
                 }
             }
             if (!$out) {
                 $out = '<em>No rows selected!</em>';
             }
             $cPR['header'] = 'Result';
             $cPR['content'] = $out;
             break;
         case 'explain':
         default:
             while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                 $out .= '<br />' . \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($row);
             }
             $cPR['header'] = 'Explain SQL query';
             $cPR['content'] = $out;
     }
     return $cPR;
 }
 /**
  * The main processing method if this class
  *
  * @return string Information of the template status or the taken actions as HTML string
  * @todo Define visibility
  */
 public function main()
 {
     global $BACK_PATH;
     global $tmpl, $tplRow, $theConstants;
     $this->pObj->MOD_MENU['includeTypoScriptFileContent'] = TRUE;
     $edit = $this->pObj->edit;
     $e = $this->pObj->e;
     \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA('sys_template');
     // Checking for more than one template an if, set a menu...
     $manyTemplatesMenu = $this->pObj->templateMenu();
     $template_uid = 0;
     if ($manyTemplatesMenu) {
         $template_uid = $this->pObj->MOD_SETTINGS['templatesOnPage'];
     }
     // Initialize
     $existTemplate = $this->initialize_editor($this->pObj->id, $template_uid);
     if ($existTemplate) {
         $saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid'];
     }
     // Create extension template
     $newId = $this->pObj->createTemplate($this->pObj->id, $saveId);
     if ($newId) {
         // Switch to new template
         $urlParameters = array('id' => $this->pObj->id, 'SET[templatesOnPage]' => $newId);
         $aHref = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_ts', $urlParameters);
         \TYPO3\CMS\Core\Utility\HttpUtility::redirect($aHref);
     }
     if ($existTemplate) {
         // Update template ?
         $POST = \TYPO3\CMS\Core\Utility\GeneralUtility::_POST();
         if ($POST['submit'] || \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($POST['submit_x']) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($POST['submit_y']) || $POST['saveclose'] || \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($POST['saveclose_x']) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($POST['saveclose_y'])) {
             // Set the data to be saved
             $recData = array();
             $alternativeFileName = array();
             $tmp_upload_name = '';
             // Set this to blank
             $tmp_newresource_name = '';
             if (is_array($POST['data'])) {
                 foreach ($POST['data'] as $field => $val) {
                     switch ($field) {
                         case 'constants':
                         case 'config':
                         case 'title':
                         case 'sitetitle':
                         case 'description':
                             $recData['sys_template'][$saveId][$field] = $val;
                             break;
                     }
                 }
             }
             if (count($recData)) {
                 $recData['sys_template'][$saveId] = $this->processTemplateRowBeforeSaving($recData['sys_template'][$saveId]);
                 // Create new  tce-object
                 $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
                 $tce->stripslashes_values = 0;
                 $tce->alternativeFileName = $alternativeFileName;
                 // Initialize
                 $tce->start($recData, array());
                 // Saved the stuff
                 $tce->process_datamap();
                 // Clear the cache (note: currently only admin-users can clear the cache in tce_main.php)
                 $tce->clear_cacheCmd('all');
                 // tce were processed successfully
                 $this->tce_processed = TRUE;
                 // re-read the template ...
                 $this->initialize_editor($this->pObj->id, $template_uid);
             }
             // If files has been edited:
             if (is_array($edit)) {
                 if ($edit['filename'] && $tplRow['resources'] && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($tplRow['resources'], $edit['filename'])) {
                     // Check if there are resources, and that the file is in the resourcelist.
                     $path = PATH_site . $GLOBALS['TCA']['sys_template']['columns']['resources']['config']['uploadfolder'] . '/' . $edit['filename'];
                     $fI = \TYPO3\CMS\Core\Utility\GeneralUtility::split_fileref($edit['filename']);
                     if (@is_file($path) && \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($path) && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->pObj->textExtensions, $fI['fileext'])) {
                         // checks that have already been done.. Just to make sure
                         // @TODO: Check if the hardcorded value already has a config member, otherwise create one
                         // Checks that have already been done.. Just to make sure
                         if (filesize($path) < 30720) {
                             \TYPO3\CMS\Core\Utility\GeneralUtility::writeFile($path, $edit['file']);
                             $theOutput .= $this->pObj->doc->spacer(10);
                             $theOutput .= $this->pObj->doc->section('<font color=red>' . $GLOBALS['LANG']->getLL('fileChanged') . '</font>', sprintf($GLOBALS['LANG']->getLL('resourceUpdated'), $edit['filename']), 0, 0, 0, 1);
                             // Clear cache - the file has probably affected the template setup
                             // @TODO: Check if the edited file really had something to do with cached data and prevent this clearing if possible!
                             /** @var $tce \TYPO3\CMS\Core\DataHandling\DataHandler */
                             $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
                             $tce->stripslashes_values = 0;
                             $tce->start(array(), array());
                             $tce->clear_cacheCmd('all');
                         }
                     }
                 }
             }
         }
         // Hook	post updating template/TCE processing
         if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook'])) {
             $postTCEProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook'];
             if (is_array($postTCEProcessingHook)) {
                 $hookParameters = array('POST' => $POST, 'tce' => $tce);
                 foreach ($postTCEProcessingHook as $hookFunction) {
                     \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this);
                 }
             }
         }
         $content = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('sys_template', $tplRow) . '<strong>' . htmlspecialchars($tplRow['title']) . '</strong>' . htmlspecialchars(trim($tplRow['sitetitle']) ? ' (' . $tplRow['sitetitle'] . ')' : '');
         $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('templateInformation'), $content, 0, 1);
         if ($manyTemplatesMenu) {
             $theOutput .= $this->pObj->doc->section('', $manyTemplatesMenu);
         }
         $theOutput .= $this->pObj->doc->spacer(10);
         $numberOfRows = 35;
         // If abort pressed, nothing should be edited:
         if ($POST['abort'] || \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($POST['abort_x']) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($POST['abort_y']) || $POST['saveclose'] || \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($POST['saveclose_x']) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($POST['saveclose_y'])) {
             unset($e);
         }
         if ($e['title']) {
             $outCode = '<input type="Text" name="data[title]" value="' . htmlspecialchars($tplRow['title']) . '"' . $this->pObj->doc->formWidth() . '>';
             $outCode .= '<input type="Hidden" name="e[title]" value="1">';
             $theOutput .= $this->pObj->doc->spacer(15);
             $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('title'), $outCode, TRUE);
         }
         if ($e['sitetitle']) {
             $outCode = '<input type="Text" name="data[sitetitle]" value="' . htmlspecialchars($tplRow['sitetitle']) . '"' . $this->pObj->doc->formWidth() . '>';
             $outCode .= '<input type="Hidden" name="e[sitetitle]" value="1">';
             $theOutput .= $this->pObj->doc->spacer(15);
             $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('sitetitle'), $outCode, TRUE);
         }
         if ($e['description']) {
             $outCode = '<textarea name="data[description]" rows="5" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, '', '') . '>' . \TYPO3\CMS\Core\Utility\GeneralUtility::formatForTextarea($tplRow['description']) . '</textarea>';
             $outCode .= '<input type="Hidden" name="e[description]" value="1">';
             $theOutput .= $this->pObj->doc->spacer(15);
             $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('description'), $outCode, TRUE);
         }
         if ($e['constants']) {
             $outCode = '<textarea name="data[constants]" rows="' . $numberOfRows . '" wrap="off" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, 'width:98%;height:70%', 'off') . ' class="fixed-font">' . \TYPO3\CMS\Core\Utility\GeneralUtility::formatForTextarea($tplRow['constants']) . '</textarea>';
             $outCode .= '<input type="Hidden" name="e[constants]" value="1">';
             // Display "Include TypoScript file content?" checkbox
             $outCode .= \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->pObj->id, 'SET[includeTypoScriptFileContent]', $this->pObj->MOD_SETTINGS['includeTypoScriptFileContent'], '', '&e[constants]=1', 'id="checkIncludeTypoScriptFileContent"');
             $outCode .= '<label for="checkIncludeTypoScriptFileContent">' . $GLOBALS['LANG']->getLL('includeTypoScriptFileContent') . '</label><br />';
             $theOutput .= $this->pObj->doc->spacer(15);
             $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('constants'), '', TRUE);
             $theOutput .= $this->pObj->doc->sectionEnd() . $outCode;
         }
         if ($e['file']) {
             $path = PATH_site . $GLOBALS['TCA']['sys_template']['columns']['resources']['config']['uploadfolder'] . '/' . $e[file];
             $fI = \TYPO3\CMS\Core\Utility\GeneralUtility::split_fileref($e[file]);
             if (@is_file($path) && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->pObj->textExtensions, $fI['fileext'])) {
                 if (filesize($path) < $GLOBALS['TCA']['sys_template']['columns']['resources']['config']['max_size'] * 1024) {
                     $fileContent = \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($path);
                     $outCode = $GLOBALS['LANG']->getLL('file') . ' <strong>' . $e[file] . '</strong><BR>';
                     $outCode .= '<textarea name="edit[file]" rows="' . $numberOfRows . '" wrap="off" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, 'width:98%;height:70%', 'off') . ' class="fixed-font">' . \TYPO3\CMS\Core\Utility\GeneralUtility::formatForTextarea($fileContent) . '</textarea>';
                     $outCode .= '<input type="Hidden" name="edit[filename]" value="' . $e[file] . '">';
                     $outCode .= '<input type="Hidden" name="e[file]" value="' . htmlspecialchars($e[file]) . '">';
                     $theOutput .= $this->pObj->doc->spacer(15);
                     $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('editResource'), '');
                     $theOutput .= $this->pObj->doc->sectionEnd() . $outCode;
                 } else {
                     $theOutput .= $this->pObj->doc->spacer(15);
                     $fileToBig = sprintf($GLOBALS['LANG']->getLL('filesizeExceeded'), $GLOBALS['TCA']['sys_template']['columns']['resources']['config']['max_size']);
                     $filesizeNotAllowed = sprintf($GLOBALS['LANG']->getLL('notAllowed'), $GLOBALS['TCA']['sys_template']['columns']['resources']['config']['max_size']);
                     $theOutput .= $this->pObj->doc->section('<font color=red>' . $fileToBig . '</font>', $filesizeNotAllowed, 0, 0, 0, 1);
                 }
             }
         }
         if ($e['config']) {
             $outCode = '<textarea name="data[config]" rows="' . $numberOfRows . '" wrap="off" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, 'width:98%;height:70%', 'off') . ' class="fixed-font">' . \TYPO3\CMS\Core\Utility\GeneralUtility::formatForTextarea($tplRow['config']) . '</textarea>';
             $outCode .= '<input type="Hidden" name="e[config]" value="1">';
             // Display "Include TypoScript file content?" checkbox
             $outCode .= \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->pObj->id, 'SET[includeTypoScriptFileContent]', $this->pObj->MOD_SETTINGS['includeTypoScriptFileContent'], '', '&e[config]=1', 'id="checkIncludeTypoScriptFileContent"');
             $outCode .= '<label for="checkIncludeTypoScriptFileContent">' . $GLOBALS['LANG']->getLL('includeTypoScriptFileContent') . '</label><br />';
             if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('tsconfig_help')) {
                 $url = $BACK_PATH . 'wizard_tsconfig.php?mode=tsref';
                 $params = array('formName' => 'editForm', 'itemName' => 'data[config]');
                 $outCode .= '<a href="#" onClick="vHWin=window.open(\'' . $url . \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl('', array('P' => $params)) . '\',\'popUp' . $md5ID . '\',\'height=500,width=780,status=0,menubar=0,scrollbars=1\');vHWin.focus();return false;">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-system-typoscript-documentation-open', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:tsRef', TRUE))) . '</a>';
             }
             $theOutput .= $this->pObj->doc->spacer(15);
             $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('setup'), '', TRUE);
             $theOutput .= $this->pObj->doc->sectionEnd() . $outCode;
         }
         // Processing:
         $outCode = '';
         $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('title'), htmlspecialchars($tplRow['title']), 'title');
         $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('sitetitle'), htmlspecialchars($tplRow['sitetitle']), 'sitetitle');
         $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('description'), nl2br(htmlspecialchars($tplRow['description'])), 'description');
         $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('constants'), sprintf($GLOBALS['LANG']->getLL('editToView'), trim($tplRow[constants]) ? count(explode(LF, $tplRow[constants])) : 0), 'constants');
         $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('setup'), sprintf($GLOBALS['LANG']->getLL('editToView'), trim($tplRow[config]) ? count(explode(LF, $tplRow[config])) : 0), 'config');
         $outCode = '<table class="t3-table-info">' . $outCode . '</table>';
         // Edit all icon:
         $outCode .= '<br /><a href="#" onClick="' . \TYPO3\CMS\Backend\Utility\BackendUtility::editOnClick(rawurlencode('&createExtension=0') . '&amp;edit[sys_template][' . $tplRow['uid'] . ']=edit', $BACK_PATH, '') . '"><strong>' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-open', array('title' => $GLOBALS['LANG']->getLL('editTemplateRecord'))) . $GLOBALS['LANG']->getLL('editTemplateRecord') . '</strong></a>';
         $theOutput .= $this->pObj->doc->section('', $outCode);
         // hook	after compiling the output
         if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook'])) {
             $postOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook'];
             if (is_array($postOutputProcessingHook)) {
                 $hookParameters = array('theOutput' => &$theOutput, 'POST' => $POST, 'e' => $e, 'tplRow' => $tplRow, 'numberOfRows' => $numberOfRows);
                 foreach ($postOutputProcessingHook as $hookFunction) {
                     \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this);
                 }
             }
         }
     } else {
         $theOutput .= $this->pObj->noTemplate(1);
     }
     return $theOutput;
 }
 /**
  * The main processing method if this class
  *
  * @return string Information of the template status or the taken actions as HTML string
  */
 public function main()
 {
     $lang = $this->getLanguageService();
     $lang->includeLLFile('EXT:tstemplate/Resources/Private/Language/locallang_info.xlf');
     $this->pObj->MOD_MENU['includeTypoScriptFileContent'] = TRUE;
     $e = $this->pObj->e;
     // Checking for more than one template an if, set a menu...
     $manyTemplatesMenu = $this->pObj->templateMenu();
     $template_uid = 0;
     if ($manyTemplatesMenu) {
         $template_uid = $this->pObj->MOD_SETTINGS['templatesOnPage'];
     }
     // Initialize
     $existTemplate = $this->initialize_editor($this->pObj->id, $template_uid);
     $tplRow = $GLOBALS['tplRow'];
     $saveId = 0;
     if ($existTemplate) {
         $saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid'];
     }
     // Create extension template
     $newId = $this->pObj->createTemplate($this->pObj->id, $saveId);
     if ($newId) {
         // Switch to new template
         $urlParameters = array('id' => $this->pObj->id, 'SET[templatesOnPage]' => $newId);
         $aHref = BackendUtility::getModuleUrl('web_ts', $urlParameters);
         HttpUtility::redirect($aHref);
     }
     $tce = NULL;
     $theOutput = '';
     if ($existTemplate) {
         // Update template ?
         $POST = GeneralUtility::_POST();
         if ($POST['submit'] || MathUtility::canBeInterpretedAsInteger($POST['submit_x']) && MathUtility::canBeInterpretedAsInteger($POST['submit_y']) || $POST['saveclose'] || MathUtility::canBeInterpretedAsInteger($POST['saveclose_x']) && MathUtility::canBeInterpretedAsInteger($POST['saveclose_y'])) {
             // Set the data to be saved
             $recData = array();
             $alternativeFileName = array();
             if (is_array($POST['data'])) {
                 foreach ($POST['data'] as $field => $val) {
                     switch ($field) {
                         case 'constants':
                         case 'config':
                             $recData['sys_template'][$saveId][$field] = $val;
                             break;
                     }
                 }
             }
             if (!empty($recData)) {
                 $recData['sys_template'][$saveId] = $this->processTemplateRowBeforeSaving($recData['sys_template'][$saveId]);
                 // Create new  tce-object
                 $tce = GeneralUtility::makeInstance(DataHandler::class);
                 $tce->stripslashes_values = FALSE;
                 $tce->alternativeFileName = $alternativeFileName;
                 // Initialize
                 $tce->start($recData, array());
                 // Saved the stuff
                 $tce->process_datamap();
                 // Clear the cache (note: currently only admin-users can clear the cache in tce_main.php)
                 $tce->clear_cacheCmd('all');
                 // tce were processed successfully
                 $this->tce_processed = TRUE;
                 // re-read the template ...
                 $this->initialize_editor($this->pObj->id, $template_uid);
                 $tplRow = $GLOBALS['tplRow'];
                 // reload template menu
                 $manyTemplatesMenu = $this->pObj->templateMenu();
             }
         }
         // Hook post updating template/TCE processing
         if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook'])) {
             $postTCEProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook'];
             if (is_array($postTCEProcessingHook)) {
                 $hookParameters = array('POST' => $POST, 'tce' => $tce);
                 foreach ($postTCEProcessingHook as $hookFunction) {
                     GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this);
                 }
             }
         }
         $content = '<a href="#" class="t3-js-clickmenutrigger" data-table="sys_template" data-uid="' . $tplRow['uid'] . '" data-listframe="1">' . IconUtility::getSpriteIconForRecord('sys_template', $tplRow) . '</a><strong>' . htmlspecialchars($tplRow['title']) . '</strong>' . htmlspecialchars(trim($tplRow['sitetitle']) ? ' (' . $tplRow['sitetitle'] . ')' : '');
         $theOutput .= $this->pObj->doc->section($lang->getLL('templateInformation'), $content, 0, 1);
         if ($manyTemplatesMenu) {
             $theOutput .= $this->pObj->doc->section('', $manyTemplatesMenu);
         }
         $theOutput .= $this->pObj->doc->spacer(10);
         $numberOfRows = 35;
         // If abort pressed, nothing should be edited:
         if ($POST['saveclose'] || MathUtility::canBeInterpretedAsInteger($POST['saveclose_x']) && MathUtility::canBeInterpretedAsInteger($POST['saveclose_y'])) {
             unset($e);
         }
         if (isset($e['constants'])) {
             $outCode = '<textarea name="data[constants]" rows="' . $numberOfRows . '" wrap="off" class="text-monospace enable-tab"' . $this->pObj->doc->formWidth(48, TRUE, 'width:98%;height:70%') . ' class="text-monospace">' . GeneralUtility::formatForTextarea($tplRow['constants']) . '</textarea>';
             $outCode .= '<input type="hidden" name="e[constants]" value="1">';
             // Display "Include TypoScript file content?" checkbox
             $outCode .= '<div class="checkbox"><label for="checkIncludeTypoScriptFileContent">' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[includeTypoScriptFileContent]', $this->pObj->MOD_SETTINGS['includeTypoScriptFileContent'], '', '&e[constants]=1', 'id="checkIncludeTypoScriptFileContent"');
             $outCode .= $lang->getLL('includeTypoScriptFileContent') . '</label></div><br />';
             $theOutput .= $this->pObj->doc->spacer(15);
             $theOutput .= $this->pObj->doc->section($lang->getLL('constants'), '', TRUE);
             $theOutput .= $this->pObj->doc->sectionEnd() . $outCode;
         }
         if (isset($e['config'])) {
             $outCode = '<textarea name="data[config]" rows="' . $numberOfRows . '" wrap="off" class="text-monospace enable-tab"' . $this->pObj->doc->formWidth(48, TRUE, 'width:98%;height:70%') . ' class="text-monospace">' . GeneralUtility::formatForTextarea($tplRow['config']) . '</textarea>';
             $outCode .= '<input type="hidden" name="e[config]" value="1">';
             // Display "Include TypoScript file content?" checkbox
             $outCode .= '<div class="checkbox"><label for="checkIncludeTypoScriptFileContent">' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[includeTypoScriptFileContent]', $this->pObj->MOD_SETTINGS['includeTypoScriptFileContent'], '', '&e[config]=1', 'id="checkIncludeTypoScriptFileContent"');
             $outCode .= $lang->getLL('includeTypoScriptFileContent') . '</label></div><br />';
             $theOutput .= $this->pObj->doc->spacer(15);
             $theOutput .= $this->pObj->doc->section($lang->getLL('setup'), '', TRUE);
             $theOutput .= $this->pObj->doc->sectionEnd() . $outCode;
         }
         // Processing:
         $outCode = '';
         $outCode .= $this->tableRow($lang->getLL('title'), htmlspecialchars($tplRow['title']), 'title', $tplRow['uid']);
         $outCode .= $this->tableRow($lang->getLL('sitetitle'), htmlspecialchars($tplRow['sitetitle']), 'sitetitle', $tplRow['uid']);
         $outCode .= $this->tableRow($lang->getLL('description'), nl2br(htmlspecialchars($tplRow['description'])), 'description', $tplRow['uid']);
         $outCode .= $this->tableRow($lang->getLL('constants'), sprintf($lang->getLL('editToView'), trim($tplRow['constants']) ? count(explode(LF, $tplRow['constants'])) : 0), 'constants', $tplRow['uid']);
         $outCode .= $this->tableRow($lang->getLL('setup'), sprintf($lang->getLL('editToView'), trim($tplRow['config']) ? count(explode(LF, $tplRow['config'])) : 0), 'config', $tplRow['uid']);
         $outCode = '<div class="table-fit"><table class="table table-striped table-hover">' . $outCode . '</table></div>';
         // Edit all icon:
         $editOnClick = BackendUtility::editOnClick('&createExtension=0&edit[sys_template][' . $tplRow['uid'] . ']=edit');
         $icon = IconUtility::getSpriteIcon('actions-document-open', array('title' => $lang->getLL('editTemplateRecord'))) . $lang->getLL('editTemplateRecord');
         $outCode .= '<br /><a href="#" onclick="' . htmlspecialchars($editOnClick) . '"><strong>' . $icon . '</strong></a>';
         $theOutput .= $this->pObj->doc->section('', $outCode);
         // hook	after compiling the output
         if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook'])) {
             $postOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook'];
             if (is_array($postOutputProcessingHook)) {
                 $hookParameters = array('theOutput' => &$theOutput, 'POST' => $POST, 'e' => $e, 'tplRow' => $tplRow, 'numberOfRows' => $numberOfRows);
                 foreach ($postOutputProcessingHook as $hookFunction) {
                     GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this);
                 }
             }
         }
     } else {
         $theOutput .= $this->pObj->noTemplate(1);
     }
     return $theOutput;
 }
Ejemplo n.º 7
0
    /**
     * Creates the HTML for the Table Wizard:
     *
     * @param array $cfgArr Table config array
     * @param array $row Current parent record array
     * @return string HTML for the table wizard
     * @access private
     * @todo Define visibility
     */
    public function getTableHTML($cfgArr, $row)
    {
        // Traverse the rows:
        $tRows = array();
        $k = 0;
        foreach ($cfgArr as $cellArr) {
            if (is_array($cellArr)) {
                // Initialize:
                $cells = array();
                $a = 0;
                // Traverse the columns:
                foreach ($cellArr as $cellContent) {
                    if ($this->inputStyle) {
                        $cells[] = '<input type="text"' . $this->doc->formWidth(20) . ' name="TABLE[c][' . ($k + 1) * 2 . '][' . ($a + 1) * 2 . ']" value="' . htmlspecialchars($cellContent) . '" />';
                    } else {
                        $cellContent = preg_replace('/<br[ ]?[\\/]?>/i', LF, $cellContent);
                        $cells[] = '<textarea ' . $this->doc->formWidth(20) . ' rows="5" name="TABLE[c][' . ($k + 1) * 2 . '][' . ($a + 1) * 2 . ']">' . \TYPO3\CMS\Core\Utility\GeneralUtility::formatForTextarea($cellContent) . '</textarea>';
                    }
                    // Increment counter:
                    $a++;
                }
                // CTRL panel for a table row (move up/down/around):
                $onClick = 'document.wizardForm.action+=\'#ANC_' . (($k + 1) * 2 - 2) . '\';';
                $onClick = ' onclick="' . htmlspecialchars($onClick) . '"';
                $ctrl = '';
                $brTag = $this->inputStyle ? '' : '<br />';
                if ($k != 0) {
                    $ctrl .= '<input type="image" name="TABLE[row_up][' . ($k + 1) * 2 . ']"' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->doc->backPath, 'gfx/pil2up.gif', '') . $onClick . ' title="' . $GLOBALS['LANG']->getLL('table_up', 1) . '" />' . $brTag;
                } else {
                    $ctrl .= '<input type="image" name="TABLE[row_bottom][' . ($k + 1) * 2 . ']"' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->doc->backPath, 'gfx/turn_up.gif', '') . $onClick . ' title="' . $GLOBALS['LANG']->getLL('table_bottom', 1) . '" />' . $brTag;
                }
                $ctrl .= '<input type="image" name="TABLE[row_remove][' . ($k + 1) * 2 . ']"' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->doc->backPath, 'gfx/garbage.gif', '') . $onClick . ' title="' . $GLOBALS['LANG']->getLL('table_removeRow', 1) . '" />' . $brTag;
                // FIXME what is $tLines? See wizard_forms.php for the same.
                if ($k + 1 != count($tLines)) {
                    $ctrl .= '<input type="image" name="TABLE[row_down][' . ($k + 1) * 2 . ']"' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->doc->backPath, 'gfx/pil2down.gif', '') . $onClick . ' title="' . $GLOBALS['LANG']->getLL('table_down', 1) . '" />' . $brTag;
                } else {
                    $ctrl .= '<input type="image" name="TABLE[row_top][' . ($k + 1) * 2 . ']"' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->doc->backPath, 'gfx/turn_down.gif', '') . $onClick . ' title="' . $GLOBALS['LANG']->getLL('table_top', 1) . '" />' . $brTag;
                }
                $ctrl .= '<input type="image" name="TABLE[row_add][' . ($k + 1) * 2 . ']"' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->doc->backPath, 'gfx/add.gif', '') . $onClick . ' title="' . $GLOBALS['LANG']->getLL('table_addRow', 1) . '" />' . $brTag;
                $tRows[] = '
					<tr class="bgColor4">
						<td class="bgColor5"><a name="ANC_' . ($k + 1) * 2 . '"></a><span class="c-wizButtonsV">' . $ctrl . '</span></td>
						<td>' . implode('</td>
						<td>', $cells) . '</td>
					</tr>';
                // Increment counter:
                $k++;
            }
        }
        // CTRL panel for a table column (move left/right/around/delete)
        $cells = array();
        $cells[] = '';
        // Finding first row:
        $firstRow = reset($cfgArr);
        if (is_array($firstRow)) {
            // Init:
            $a = 0;
            $cols = count($firstRow);
            // Traverse first row:
            foreach ($firstRow as $temp) {
                $ctrl = '';
                if ($a != 0) {
                    $ctrl .= '<input type="image" name="TABLE[col_left][' . ($a + 1) * 2 . ']"' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->doc->backPath, 'gfx/pil2left.gif', '') . ' title="' . $GLOBALS['LANG']->getLL('table_left', 1) . '" />';
                } else {
                    $ctrl .= '<input type="image" name="TABLE[col_end][' . ($a + 1) * 2 . ']"' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->doc->backPath, 'gfx/turn_left.gif', '') . ' title="' . $GLOBALS['LANG']->getLL('table_end', 1) . '" />';
                }
                $ctrl .= '<input type="image" name="TABLE[col_remove][' . ($a + 1) * 2 . ']"' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->doc->backPath, 'gfx/garbage.gif', '') . ' title="' . $GLOBALS['LANG']->getLL('table_removeColumn', 1) . '" />';
                if ($a + 1 != $cols) {
                    $ctrl .= '<input type="image" name="TABLE[col_right][' . ($a + 1) * 2 . ']"' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->doc->backPath, 'gfx/pil2right.gif', '') . ' title="' . $GLOBALS['LANG']->getLL('table_right', 1) . '" />';
                } else {
                    $ctrl .= '<input type="image" name="TABLE[col_start][' . ($a + 1) * 2 . ']"' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->doc->backPath, 'gfx/turn_right.gif', '') . ' title="' . $GLOBALS['LANG']->getLL('table_start', 1) . '" />';
                }
                $ctrl .= '<input type="image" name="TABLE[col_add][' . ($a + 1) * 2 . ']"' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->doc->backPath, 'gfx/add.gif', '') . ' title="' . $GLOBALS['LANG']->getLL('table_addColumn', 1) . '" />';
                $cells[] = '<span class="c-wizButtonsH">' . $ctrl . '</span>';
                // Incr. counter:
                $a++;
            }
            $tRows[] = '
				<tr class="bgColor5">
					<td align="center">' . implode('</td>
					<td align="center">', $cells) . '</td>
				</tr>';
        }
        $content = '';
        // Implode all table rows into a string, wrapped in table tags.
        $content .= '


			<!--
				Table wizard
			-->
			<table border="0" cellpadding="0" cellspacing="1" id="typo3-tablewizard">
				' . implode('', $tRows) . '
			</table>';
        // Input type checkbox:
        $content .= '

			<!--
				Input mode check box:
			-->
			<div id="c-inputMode">
				' . '<input type="hidden" name="TABLE[textFields]" value="0" />' . '<input type="checkbox" name="TABLE[textFields]" id="textFields" value="1"' . ($this->inputStyle ? ' checked="checked"' : '') . ' /> <label for="textFields">' . $GLOBALS['LANG']->getLL('table_smallFields') . '</label>
			</div>

			<br /><br />
			';
        // Return content:
        return $content;
    }
Ejemplo n.º 8
0
    /**
     * Outputs system information
     *
     * @return void
     * @todo Define visibility
     */
    public function phpinformation()
    {
        $headCode = 'PHP information';
        $sVar = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('_ARRAY');
        $sVar['CONST: PHP_OS'] = PHP_OS;
        $sVar['CONST: TYPO3_OS'] = TYPO3_OS;
        $sVar['CONST: PATH_thisScript'] = PATH_thisScript;
        $sVar['CONST: php_sapi_name()'] = PHP_SAPI;
        $sVar['OTHER: TYPO3_VERSION'] = TYPO3_version;
        $sVar['OTHER: PHP_VERSION'] = phpversion();
        $sVar['imagecreatefromgif()'] = function_exists('imagecreatefromgif');
        $sVar['imagecreatefrompng()'] = function_exists('imagecreatefrompng');
        $sVar['imagecreatefromjpeg()'] = function_exists('imagecreatefromjpeg');
        $sVar['imagegif()'] = function_exists('imagegif');
        $sVar['imagepng()'] = function_exists('imagepng');
        $sVar['imagejpeg()'] = function_exists('imagejpeg');
        $sVar['imagettftext()'] = function_exists('imagettftext');
        $sVar['OTHER: IMAGE_TYPES'] = function_exists('imagetypes') ? imagetypes() : 0;
        $sVar['OTHER: memory_limit'] = ini_get('memory_limit');
        $gE_keys = explode(',', 'SERVER_PORT,SERVER_SOFTWARE,GATEWAY_INTERFACE,SCRIPT_NAME,PATH_TRANSLATED');
        foreach ($gE_keys as $k) {
            $sVar['SERVER: ' . $k] = $_SERVER[$k];
        }
        $gE_keys = explode(',', 'image_processing,gdlib,gdlib_png,im,im_path,im_path_lzw,im_version_5,im_negate_mask,im_imvMaskState,im_combine_filename');
        foreach ($gE_keys as $k) {
            $sVar['T3CV_GFX: ' . $k] = $GLOBALS['TYPO3_CONF_VARS']['GFX'][$k];
        }
        $debugInfo = array('### DEBUG SYSTEM INFORMATION - START ###');
        foreach ($sVar as $kkk => $vvv) {
            $debugInfo[] = str_pad(substr($kkk, 0, 20), 20) . ': ' . $vvv;
        }
        $debugInfo[] = '### DEBUG SYSTEM INFORMATION - END ###';
        // Get the template file
        $templateFile = @file_get_contents(PATH_site . $this->templateFilePath . 'PhpInformation.html');
        // Get the template part from the file
        $template = \TYPO3\CMS\Core\Html\HtmlParser::getSubpart($templateFile, '###TEMPLATE###');
        // Define the markers content
        $markers = array('explanation' => 'Please copy/paste the information from this text field into an email or bug-report as "Debug System Information" whenever you wish to get support or report problems. This information helps others to check if your system has some obvious misconfiguration and you\'ll get your help faster!', 'debugInfo' => \TYPO3\CMS\Core\Utility\GeneralUtility::formatForTextarea(implode(LF, $debugInfo)));
        // Fill the markers
        $content = \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray($template, $markers, '###|###', TRUE, FALSE);
        // Add the content to the message array
        $this->message($headCode, 'DEBUG information', $content);
        // Start with various server information
        $getEnvArray = array();
        $gE_keys = explode(',', 'QUERY_STRING,HTTP_ACCEPT,HTTP_ACCEPT_ENCODING,HTTP_ACCEPT_LANGUAGE,HTTP_CONNECTION,HTTP_COOKIE,HTTP_HOST,HTTP_USER_AGENT,REMOTE_ADDR,REMOTE_HOST,REMOTE_PORT,SERVER_ADDR,SERVER_ADMIN,SERVER_NAME,SERVER_PORT,SERVER_SIGNATURE,SERVER_SOFTWARE,GATEWAY_INTERFACE,SERVER_PROTOCOL,REQUEST_METHOD,SCRIPT_NAME,PATH_TRANSLATED,HTTP_REFERER,PATH_INFO');
        foreach ($gE_keys as $k) {
            $getEnvArray[$k] = getenv($k);
        }
        $this->message($headCode, 'TYPO3\\CMS\\Core\\Utility\\GeneralUtility::getIndpEnv()', $this->viewArray(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('_ARRAY')));
        $this->message($headCode, 'getenv()', $this->viewArray($getEnvArray));
        $this->message($headCode, '_ENV', $this->viewArray($_ENV));
        $this->message($headCode, '_SERVER', $this->viewArray($_SERVER));
        $this->message($headCode, '_COOKIE', $this->viewArray($_COOKIE));
        $this->message($headCode, '_GET', $this->viewArray($_GET));
        // Start with the phpinfo() part
        ob_start();
        phpinfo();
        $contents = explode('<body>', ob_get_contents());
        ob_end_clean();
        $contents = explode('</body>', $contents[1]);
        // Do code cleaning: phpinfo() is not XHTML1.1 compliant
        $phpinfo = str_replace('<font', '<span', $contents[0]);
        $phpinfo = str_replace('</font', '</span', $phpinfo);
        $phpinfo = str_replace('<img border="0"', '<img', $phpinfo);
        $phpinfo = str_replace('<a name=', '<a id=', $phpinfo);
        // Add phpinfo() to the message array
        $this->message($headCode, 'phpinfo()', '
			<div class="phpinfo">
				' . $phpinfo . '
			</div>
		');
        // Output the page
        $this->output($this->outputWrapper($this->printAll()));
    }
Ejemplo n.º 9
0
    /**
     * Creates the HTML for the Table Wizard:
     *
     * @param array $configuration Table config array
     * @return string HTML for the table wizard
     * @internal
     */
    public function getTableHTML($configuration)
    {
        // Traverse the rows:
        $tRows = array();
        $k = 0;
        $countLines = count($configuration);
        foreach ($configuration as $cellArr) {
            if (is_array($cellArr)) {
                // Initialize:
                $cells = array();
                $a = 0;
                // Traverse the columns:
                foreach ($cellArr as $cellContent) {
                    if ($this->inputStyle) {
                        $cells[] = '<input class="form-control" type="text"' . $this->doc->formWidth(20) . ' name="TABLE[c][' . ($k + 1) * 2 . '][' . ($a + 1) * 2 . ']" value="' . htmlspecialchars($cellContent) . '" />';
                    } else {
                        $cellContent = preg_replace('/<br[ ]?[\\/]?>/i', LF, $cellContent);
                        $cells[] = '<textarea class="form-control" ' . $this->doc->formWidth(20) . ' rows="6" name="TABLE[c][' . ($k + 1) * 2 . '][' . ($a + 1) * 2 . ']">' . GeneralUtility::formatForTextarea($cellContent) . '</textarea>';
                    }
                    // Increment counter:
                    $a++;
                }
                // CTRL panel for a table row (move up/down/around):
                $onClick = 'document.wizardForm.action+=' . GeneralUtility::quoteJSvalue('#ANC_' . (($k + 1) * 2 - 2)) . ';';
                $onClick = ' onclick="' . htmlspecialchars($onClick) . '"';
                $ctrl = '';
                if ($k !== 0) {
                    $ctrl .= '<button class="btn btn-default" name="TABLE[row_up][' . ($k + 1) * 2 . ']" title="' . $this->getLanguageService()->getLL('table_up', TRUE) . '"' . $onClick . '><span class="t3-icon fa fa-fw fa-angle-up"></span></button>';
                } else {
                    $ctrl .= '<button class="btn btn-default" name="TABLE[row_bottom][' . ($k + 1) * 2 . ']" title="' . $this->getLanguageService()->getLL('table_bottom', TRUE) . '"' . $onClick . '><span class="t3-icon fa fa-fw fa-angle-double-down"></span></button>';
                }
                if ($k + 1 !== $countLines) {
                    $ctrl .= '<button class="btn btn-default" name="TABLE[row_down][' . ($k + 1) * 2 . ']" title="' . $this->getLanguageService()->getLL('table_down', TRUE) . '"' . $onClick . '><span class="t3-icon fa fa-fw fa-angle-down"></span></button>';
                } else {
                    $ctrl .= '<button class="btn btn-default" name="TABLE[row_top][' . ($k + 1) * 2 . ']" title="' . $this->getLanguageService()->getLL('table_top', TRUE) . '"' . $onClick . '><span class="t3-icon fa fa-fw fa-angle-double-up"></span></button>';
                }
                $ctrl .= '<button class="btn btn-default" name="TABLE[row_remove][' . ($k + 1) * 2 . ']" title="' . $this->getLanguageService()->getLL('table_removeRow', TRUE) . '"' . $onClick . '><span class="t3-icon fa fa-fw fa-trash"></span></button>';
                $ctrl .= '<button class="btn btn-default" name="TABLE[row_add][' . ($k + 1) * 2 . ']" title="' . $this->getLanguageService()->getLL('table_addRow', TRUE) . '"' . $onClick . '><span class="t3-icon fa fa-fw fa-plus"></span></button>';
                $tRows[] = '
					<tr>
						<td>
							<a name="ANC_' . ($k + 1) * 2 . '"></a>
							<span class="btn-group' . ($this->inputStyle ? '' : '-vertical') . '">' . $ctrl . '</span>
						</td>
						<td>' . implode('</td>
						<td>', $cells) . '</td>
					</tr>';
                // Increment counter:
                $k++;
            }
        }
        // CTRL panel for a table column (move left/right/around/delete)
        $cells = array();
        $cells[] = '';
        // Finding first row:
        $firstRow = reset($configuration);
        if (is_array($firstRow)) {
            $cols = count($firstRow);
            for ($a = 1; $a <= $cols; $a++) {
                $b = $a * 2;
                $ctrl = '';
                if ($a !== 1) {
                    $ctrl .= '<button class="btn btn-default" name="TABLE[col_left][' . $b . ']" title="' . $this->getLanguageService()->getLL('table_left', TRUE) . '"><span class="t3-icon fa fa-fw fa-angle-left"></span></button>';
                } else {
                    $ctrl .= '<button class="btn btn-default" name="TABLE[col_end][' . $b . ']" title="' . $this->getLanguageService()->getLL('table_end', TRUE) . '"><span class="t3-icon fa fa-fw fa-angle-double-right"></span></button>';
                }
                if ($a != $cols) {
                    $ctrl .= '<button class="btn btn-default" name="TABLE[col_right][' . $b . ']" title="' . $this->getLanguageService()->getLL('table_right', TRUE) . '"><span class="t3-icon fa fa-fw fa-angle-right"></span></button>';
                } else {
                    $ctrl .= '<button class="btn btn-default" name="TABLE[col_start][' . $b . ']" title="' . $this->getLanguageService()->getLL('table_start', TRUE) . '"><span class="t3-icon fa fa-fw fa-angle-double-left"></span></button>';
                }
                $ctrl .= '<button class="btn btn-default" name="TABLE[col_remove][' . $b . ']" title="' . $this->getLanguageService()->getLL('table_removeColumn', TRUE) . '"><span class="t3-icon fa fa-fw fa-trash"></span></button>';
                $ctrl .= '<button class="btn btn-default" name="TABLE[col_add][' . $b . ']" title="' . $this->getLanguageService()->getLL('table_addColumn', TRUE) . '"><span class="t3-icon fa fa-fw fa-plus"></span></button>';
                $cells[] = '<span class="btn-group">' . $ctrl . '</span>';
            }
            $tRows[] = '
				<tfoot>
					<tr>
						<td>' . implode('</td>
						<td>', $cells) . '</td>
					</tr>
				</tfoot>';
        }
        $content = '';
        // Implode all table rows into a string, wrapped in table tags.
        $content .= '

			<!-- Table wizard -->
			<div class="table-fit table-fit-inline-block">
				<table id="typo3-tablewizard" class="table table-center">
					' . implode('', $tRows) . '
				</table>
			</div>';
        // Input type checkbox:
        $content .= '

			<!-- Input mode check box: -->
			<div class="checkbox">
				<input type="hidden" name="TABLE[textFields]" value="0" />
				<label for="textFields">
					<input type="checkbox" name="TABLE[textFields]" id="textFields" value="1"' . ($this->inputStyle ? ' checked="checked"' : '') . ' />
					' . $this->getLanguageService()->getLL('table_smallFields') . '
				</label>
			</div>';
        return $content;
    }
Ejemplo n.º 10
0
 /**
  * get statistics from DB and compile them.
  *
  * @param	array		$row: DB record
  * @return	string		statistics of a mail
  */
 function cmd_stats($row)
 {
     if (GeneralUtility::_GP("recalcCache")) {
         $this->makeStatTempTableContent($row);
     }
     $thisurl = 'index.php?id=' . $this->id . '&sys_dmail_uid=' . $row['uid'] . '&CMD=' . $this->CMD . '&recalcCache=1';
     $output = $this->directMail_compactView($row);
     // *****************************
     // Mail responses, general:
     // *****************************
     $mailingId = intval($row['uid']);
     $queryArray = array('response_type,count(*) as counter', 'sys_dmail_maillog', 'mid=' . $mailingId, 'response_type');
     $table = $this->getQueryRows($queryArray, 'response_type');
     // Plaintext/HTML
     $res = $GLOBALS["TYPO3_DB"]->exec_SELECTquery('html_sent,count(*) as counter', 'sys_dmail_maillog', 'mid=' . $mailingId . ' AND response_type=0', 'html_sent');
     $text_html = array();
     while ($row2 = $GLOBALS["TYPO3_DB"]->sql_fetch_assoc($res)) {
         // 0:No mail; 1:HTML; 2:TEXT; 3:HTML+TEXT
         $text_html[$row2['html_sent']] = $row2['counter'];
     }
     $GLOBALS["TYPO3_DB"]->sql_free_result($res);
     // Unique responses, html
     $res = $GLOBALS["TYPO3_DB"]->exec_SELECTquery('count(*) as counter', 'sys_dmail_maillog', 'mid=' . $mailingId . ' AND response_type=1', 'rid,rtbl', 'counter');
     $unique_html_responses = $GLOBALS["TYPO3_DB"]->sql_num_rows($res);
     $GLOBALS["TYPO3_DB"]->sql_free_result($res);
     // Unique responses, Plain
     $res = $GLOBALS["TYPO3_DB"]->exec_SELECTquery('count(*) as counter', 'sys_dmail_maillog', 'mid=' . $mailingId . ' AND response_type=2', 'rid,rtbl', 'counter');
     $unique_plain_responses = $GLOBALS["TYPO3_DB"]->sql_num_rows($res);
     $GLOBALS["TYPO3_DB"]->sql_free_result($res);
     // Unique responses, pings
     $res = $GLOBALS["TYPO3_DB"]->exec_SELECTquery('count(*) as counter', 'sys_dmail_maillog', 'mid=' . $mailingId . ' AND response_type=-1', 'rid,rtbl', 'counter');
     $unique_ping_responses = $GLOBALS["TYPO3_DB"]->sql_num_rows($res);
     $GLOBALS["TYPO3_DB"]->sql_free_result($res);
     $tblLines = array();
     $tblLines[] = array('', $GLOBALS["LANG"]->getLL('stats_total'), $GLOBALS["LANG"]->getLL('stats_HTML'), $GLOBALS["LANG"]->getLL('stats_plaintext'));
     $sent_total = intval($text_html['1'] + $text_html['2'] + $text_html['3']);
     $sent_html = intval($text_html['1'] + $text_html['3']);
     $sent_plain = intval($text_html['2']);
     $tblLines[] = array($GLOBALS["LANG"]->getLL('stats_mails_sent'), $sent_total, $sent_html, $sent_plain);
     $tblLines[] = array($GLOBALS["LANG"]->getLL('stats_mails_returned'), $this->showWithPercent($table['-127']['counter'], $sent_total));
     $tblLines[] = array($GLOBALS["LANG"]->getLL('stats_HTML_mails_viewed'), '', $this->showWithPercent($unique_ping_responses, $sent_html));
     $tblLines[] = array($GLOBALS["LANG"]->getLL('stats_unique_responses'), $this->showWithPercent($unique_html_responses + $unique_plain_responses, $sent_total), $this->showWithPercent($unique_html_responses, $sent_html), $this->showWithPercent($unique_plain_responses, $sent_plain ? $sent_plain : $sent_html));
     $output .= '<br /><h2>' . $GLOBALS["LANG"]->getLL('stats_general_information') . '</h2>';
     $output .= DirectMailUtility::formatTable($tblLines, array('nowrap', 'nowrap align="right"', 'nowrap align="right"', 'nowrap align="right"'), 1, array(), 'cellspacing="0" cellpadding="3" class="stats-table"');
     // ******************
     // Links:
     // ******************
     // initialize $urlCounter
     $urlCounter = array('total' => array(), 'plain' => array(), 'html' => array());
     // Most popular links, html:
     $queryArray = array('url_id,count(*) as counter', 'sys_dmail_maillog', 'mid=' . intval($row['uid']) . ' AND response_type=1', 'url_id', 'counter');
     $htmlUrlsTable = $this->getQueryRows($queryArray, 'url_id');
     // Most popular links, plain:
     $queryArray = array('url_id,count(*) as counter', 'sys_dmail_maillog', 'mid=' . intval($row['uid']) . ' AND response_type=2', 'url_id', 'counter');
     $plainUrlsTable = $this->getQueryRows($queryArray, 'url_id');
     // Find urls:
     $temp_unpackedMail = unserialize(base64_decode($row['mailContent']));
     // this array will include a unique list of all URLs that are used in the mailing
     $urlArr = array();
     $urlMd5Map = array();
     if (is_array($temp_unpackedMail['html']['hrefs'])) {
         foreach ($temp_unpackedMail['html']['hrefs'] as $k => $v) {
             $urlArr[$k] = html_entity_decode($v['absRef']);
             // convert &amp; of query params back
             $urlMd5Map[md5($v['absRef'])] = $k;
         }
     }
     if (is_array($temp_unpackedMail['plain']['link_ids'])) {
         foreach ($temp_unpackedMail['plain']['link_ids'] as $k => $v) {
             $urlArr[intval(-$k)] = $v;
         }
     }
     // Traverse plain urls:
     $plainUrlsTable_mapped = array();
     foreach ($plainUrlsTable as $id => $c) {
         $url = $urlArr[intval($id)];
         if (isset($urlMd5Map[md5($url)])) {
             $plainUrlsTable_mapped[$urlMd5Map[md5($url)]] = $c;
         } else {
             $plainUrlsTable_mapped[$id] = $c;
         }
     }
     $urlCounter['total'] = array();
     // Traverse html urls:
     $urlCounter['html'] = array();
     if (count($htmlUrlsTable) > 0) {
         foreach ($htmlUrlsTable as $id => $c) {
             $urlCounter['html'][$id]['counter'] = $urlCounter['total'][$id]['counter'] = $c['counter'];
         }
     }
     // Traverse plain urls:
     $urlCounter['plain'] = array();
     foreach ($plainUrlsTable_mapped as $id => $c) {
         // Look up plain url in html urls
         $htmlLinkFound = FALSE;
         foreach ($urlCounter['html'] as $htmlId => $htmlLink) {
             if ($urlArr[$id] == $urlArr[$htmlId]) {
                 $urlCounter['html'][$htmlId]['plainId'] = $id;
                 $urlCounter['html'][$htmlId]['plainCounter'] = $c['counter'];
                 $urlCounter['total'][$htmlId]['counter'] = $urlCounter['total'][$htmlId]['counter'] + $c['counter'];
                 $htmlLinkFound = TRUE;
                 break;
             }
         }
         if (!$htmlLinkFound) {
             $urlCounter['plain'][$id]['counter'] = $c['counter'];
             $urlCounter['total'][$id]['counter'] = $urlCounter['total'][$id]['counter'] + $c['counter'];
         }
     }
     $tblLines = array();
     $tblLines[] = array('', $GLOBALS["LANG"]->getLL('stats_total'), $GLOBALS["LANG"]->getLL('stats_HTML'), $GLOBALS["LANG"]->getLL('stats_plaintext'));
     $tblLines[] = array($GLOBALS["LANG"]->getLL('stats_total_responses'), $table['1']['counter'] + $table['2']['counter'], $table['1']['counter'] ? $table['1']['counter'] : '0', $table['2']['counter'] ? $table['2']['counter'] : '0');
     $tblLines[] = array($GLOBALS["LANG"]->getLL('stats_unique_responses'), $this->showWithPercent($unique_html_responses + $unique_plain_responses, $sent_total), $this->showWithPercent($unique_html_responses, $sent_html), $this->showWithPercent($unique_plain_responses, $sent_plain ? $sent_plain : $sent_html));
     $tblLines[] = array($GLOBALS["LANG"]->getLL('stats_links_clicked_per_respondent'), $unique_html_responses + $unique_plain_responses ? number_format(($table['1']['counter'] + $table['2']['counter']) / ($unique_html_responses + $unique_plain_responses), 2) : '-', $unique_html_responses ? number_format($table['1']['counter'] / $unique_html_responses, 2) : '-', $unique_plain_responses ? number_format($table['2']['counter'] / $unique_plain_responses, 2) : '-');
     $output .= '<br /><h2>' . $GLOBALS["LANG"]->getLL('stats_response') . '</h2>';
     $output .= DirectMailUtility::formatTable($tblLines, array('nowrap', 'nowrap align="right"', 'nowrap align="right"', 'nowrap align="right"'), 1, array(0, 0, 0, 0), 'cellspacing="0" cellpadding="3" class="stats-table"');
     arsort($urlCounter['total']);
     arsort($urlCounter['html']);
     arsort($urlCounter['plain']);
     reset($urlCounter['total']);
     $tblLines = array();
     $tblLines[] = array('', $GLOBALS["LANG"]->getLL('stats_HTML_link_nr'), $GLOBALS["LANG"]->getLL('stats_plaintext_link_nr'), $GLOBALS["LANG"]->getLL('stats_total'), $GLOBALS["LANG"]->getLL('stats_HTML'), $GLOBALS["LANG"]->getLL('stats_plaintext'), '');
     // HTML mails
     if (intval($row['sendOptions']) & 0x2) {
         $HTMLContent = $temp_unpackedMail['html']['content'];
         $HTMLlinks = array();
         if (is_array($temp_unpackedMail['html']['hrefs'])) {
             foreach ($temp_unpackedMail['html']['hrefs'] as $jumpurlId => $data) {
                 $HTMLlinks[$jumpurlId] = array('url' => $data['ref'], 'label' => '');
             }
         }
         // get body
         if (strstr($HTMLContent, '<BODY')) {
             $tmp = explode('<BODY', $HTMLContent);
         } else {
             $tmp = explode('<body', $HTMLContent);
         }
         $bodyPart = explode('<', $tmp[1]);
         // load all <a href="*" parts into $tempHref array, in a 2-dimensional array
         // where the lower level of the array contains two values, the URL and the unique ID (see $urlArr)
         foreach ($bodyPart as $k => $str) {
             if (preg_match('/a.href/', $str)) {
                 $tagAttr = GeneralUtility::get_tag_attributes($bodyPart[$k]);
                 if (strpos($str, '>') === strlen($str) - 1) {
                     if ($tagAttr['href'][0] != '#') {
                         list(, $jumpurlId) = explode('jumpurl=', $tagAttr['href']);
                         $url = $HTMLlinks[$jumpurlId]['url'];
                         // Use the link title if it exists - otherwise use the URL
                         if (strlen($tagAttr['title'])) {
                             $label = $GLOBALS["LANG"]->getLL('stats_img_link') . '<span title="' . $tagAttr['title'] . '">' . GeneralUtility::fixed_lgd_cs(substr($url, 7), 40) . '</span>';
                         } else {
                             $label = $GLOBALS["LANG"]->getLL('stats_img_link') . '<span title="' . $url . '">' . GeneralUtility::fixed_lgd_cs(substr($url, 7), 40) . '</span>';
                         }
                         $HTMLlinks[$jumpurlId]['label'] = $label;
                     }
                 } else {
                     if ($tagAttr['href'][0] != '#') {
                         list($url, $jumpurlId) = explode('jumpurl=', $tagAttr['href']);
                         $wordPos = strpos($str, '>');
                         $label = substr($str, $wordPos + 1);
                         $HTMLlinks[$jumpurlId]['label'] = $label;
                     }
                 }
             }
         }
     }
     foreach ($urlCounter['total'] as $id => $hits) {
         // $id is the jumpurl ID
         $origId = $id;
         $id = abs(intval($id));
         $url = $HTMLlinks[$id]['url'] ? $HTMLlinks[$id]['url'] : $urlArr[$origId];
         // a link to this host?
         $uParts = @parse_url($url);
         $urlstr = $this->getUrlStr($uParts);
         $label = $this->getLinkLabel($url, $urlstr, FALSE, $HTMLlinks[$id]['label']);
         $img = '<a href="' . $urlstr . '" target="_blank"><img ' . IconUtility::skinImg($GLOBALS["BACK_PATH"], 'gfx/zoom.gif', 'width="12" height="12"') . ' title="' . htmlspecialchars($label) . '" /></a>';
         if (isset($urlCounter['html'][$id]['plainId'])) {
             $tblLines[] = array($label, $id, $urlCounter['html'][$id]['plainId'], $urlCounter['total'][$origId]['counter'], $urlCounter['html'][$id]['counter'], $urlCounter['html'][$id]['plainCounter'], $img);
         } else {
             $html = empty($urlCounter['html'][$id]['counter']) ? 0 : 1;
             $tblLines[] = array($label, $html ? $id : '-', $html ? '-' : $id, $html ? $urlCounter['html'][$id]['counter'] : $urlCounter['plain'][$origId]['counter'], $urlCounter['html'][$id]['counter'], $urlCounter['plain'][$origId]['counter'], $img);
         }
     }
     // go through all links that were not clicked yet and that have a label
     $clickedLinks = array_keys($urlCounter['total']);
     foreach ($urlArr as $id => $link) {
         if (!in_array($id, $clickedLinks) && isset($HTMLlinks['id'])) {
             // a link to this host?
             $uParts = @parse_url($link);
             $urlstr = $this->getUrlStr($uParts);
             $label = $HTMLlinks[$id]['label'] . ' (' . ($urlstr ? $urlstr : '/') . ')';
             $img = '<a href="' . htmlspecialchars($link) . '" target="_blank"><img ' . IconUtility::skinImg($GLOBALS["BACK_PATH"], 'gfx/zoom.gif', 'width="12" height="12"') . ' title="' . htmlspecialchars($link) . '" /></a>';
             $tblLines[] = array($label, $html ? $id : '-', $html ? '-' : abs($id), $html ? $urlCounter['html'][$id]['counter'] : $urlCounter['plain'][$id]['counter'], $urlCounter['html'][$id]['counter'], $urlCounter['plain'][$id]['counter'], $img);
         }
     }
     if ($urlCounter['total']) {
         $output .= '<br /><h2>' . $GLOBALS["LANG"]->getLL('stats_response_link') . '</h2>';
         $output .= DirectMailUtility::formatTable($tblLines, array('nowrap', 'nowrap width="100"', 'nowrap width="100"', 'nowrap align="right"', 'nowrap align="right"', 'nowrap align="right"', 'nowrap align="right"'), 1, array(1, 0, 0, 0, 0, 0, 1), ' cellspacing="0" cellpadding="3"  class="stats-table"');
     }
     // ******************
     // Returned mails
     // ******************
     //The icons:
     $listIcons = '<img ' . IconUtility::skinImg($GLOBALS["BACK_PATH"], 'gfx/list.gif', 'width="12" height="12" alt=""') . ' />';
     $csvIcons = '<img ' . IconUtility::skinImg($GLOBALS["BACK_PATH"], 'gfx/csv.gif', 'width="27" height="12" alt=""') . ' />';
     if (ExtensionManagementUtility::isLoaded('tt_address')) {
         $iconPath = ExtensionManagementUtility::extRelPath('tt_address') . 'ext_icon__h.gif';
         $iconParam = 'width="18" height="16"';
     } else {
         $iconPath = 'gfx/button_hide.gif';
         $iconParam = 'width="11" height="10"';
     }
     $hideIcons = '<img ' . IconUtility::skinImg($GLOBALS["BACK_PATH"], $iconPath, $iconParam . ' alt=""') . ' />';
     //icons mails returned
     $iconsMailReturned[] = '<a href="' . $thisurl . '&returnList=1" class="bubble">' . $listIcons . '<span class="help">' . $GLOBALS["LANG"]->getLL('stats_list_returned') . '</span></a>';
     $iconsMailReturned[] = '<a href="' . $thisurl . '&returnDisable=1" class="bubble">' . $hideIcons . '<span class="help">' . $GLOBALS["LANG"]->getLL('stats_disable_returned') . '</span></a>';
     $iconsMailReturned[] = '<a href="' . $thisurl . '&returnCSV=1" class="bubble">' . $csvIcons . '<span class="help">' . $GLOBALS["LANG"]->getLL('stats_CSV_returned') . '</span></a>';
     //icons unknown recip
     $iconsUnknownRecip[] = '<a href="' . $thisurl . '&unknownList=1" class="bubble">' . $listIcons . '<span class="help">' . $GLOBALS["LANG"]->getLL('stats_list_returned_unknown_recipient') . '</span></a>';
     $iconsUnknownRecip[] = '<a href="' . $thisurl . '&unknownDisable=1" class="bubble">' . $hideIcons . '<span class="help">' . $GLOBALS["LANG"]->getLL('stats_disable_returned_unknown_recipient') . '</span></a>';
     $iconsUnknownRecip[] = '<a href="' . $thisurl . '&unknownCSV=1" class="bubble">' . $csvIcons . '<span class="help">' . $GLOBALS["LANG"]->getLL('stats_CSV_returned_unknown_recipient') . '</span></a>';
     //icons mailbox full
     $iconsMailbox[] = '<a href="' . $thisurl . '&fullList=1" class="bubble">' . $listIcons . '<span class="help">' . $GLOBALS["LANG"]->getLL('stats_list_returned_mailbox_full') . '</span></a>';
     $iconsMailbox[] = '<a href="' . $thisurl . '&fullDisable=1" class="bubble">' . $hideIcons . '<span class="help">' . $GLOBALS["LANG"]->getLL('stats_disable_returned_mailbox_full') . '</span></a>';
     $iconsMailbox[] = '<a href="' . $thisurl . '&fullCSV=1" class="bubble">' . $csvIcons . '<span class="help">' . $GLOBALS["LANG"]->getLL('stats_CSV_returned_mailbox_full') . '</span></a>';
     //icons bad host
     $iconsBadhost[] = '<a href="' . $thisurl . '&badHostList=1" class="bubble">' . $listIcons . '<span class="help">' . $GLOBALS["LANG"]->getLL('stats_list_returned_bad_host') . '</span></a>';
     $iconsBadhost[] = '<a href="' . $thisurl . '&badHostDisable=1" class="bubble">' . $hideIcons . '<span class="help">' . $GLOBALS["LANG"]->getLL('stats_disable_returned_bad_host') . '</span></a>';
     $iconsBadhost[] = '<a href="' . $thisurl . '&badHostCSV=1" class="bubble">' . $csvIcons . '<span class="help">' . $GLOBALS["LANG"]->getLL('stats_CSV_returned_bad_host') . '</span></a>';
     //icons bad header
     $iconsBadheader[] = '<a href="' . $thisurl . '&badHeaderList=1" class="bubble">' . $listIcons . '<span class="help">' . $GLOBALS["LANG"]->getLL('stats_list_returned_bad_header') . '</span></a>';
     $iconsBadheader[] = '<a href="' . $thisurl . '&badHeaderDisable=1" class="bubble">' . $hideIcons . '<span class="help">' . $GLOBALS["LANG"]->getLL('stats_disable_returned_bad_header') . '</span></a>';
     $iconsBadheader[] = '<a href="' . $thisurl . '&badHeaderCSV=1" class="bubble">' . $csvIcons . '<span class="help">' . $GLOBALS["LANG"]->getLL('stats_CSV_returned_bad_header') . '</span></a>';
     //icons unknown reasons
     //TODO: link to show all reason
     $iconsUnknownReason[] = '<a href="' . $thisurl . '&reasonUnknownList=1" class="bubble">' . $listIcons . '<span class="help">' . $GLOBALS["LANG"]->getLL('stats_list_returned_reason_unknown') . '</span></a>';
     $iconsUnknownReason[] = '<a href="' . $thisurl . '&reasonUnknownDisable=1" class="bubble">' . $hideIcons . '<span class="help">' . $GLOBALS["LANG"]->getLL('stats_disable_returned_reason_unknown') . '</span></a>';
     $iconsUnknownReason[] = '<a href="' . $thisurl . '&reasonUnknownCSV=1" class="bubble">' . $csvIcons . '<span class="help">' . $GLOBALS["LANG"]->getLL('stats_CSV_returned_reason_unknown') . '</span></a>';
     //Table with Icon
     $queryArray = array('count(*) as counter,return_code', 'sys_dmail_maillog', 'mid=' . intval($row['uid']) . ' AND response_type=-127', 'return_code');
     $table_ret = $this->getQueryRows($queryArray, 'return_code');
     $tblLines = array();
     $tblLines[] = array('', $GLOBALS["LANG"]->getLL('stats_count'), '');
     $tblLines[] = array($GLOBALS["LANG"]->getLL('stats_total_mails_returned'), $table['-127']['counter'] ? number_format(intval($table['-127']['counter'])) : '0', implode('&nbsp;&nbsp;', $iconsMailReturned));
     $tblLines[] = array($GLOBALS["LANG"]->getLL('stats_recipient_unknown'), $this->showWithPercent($table_ret['550']['counter'] + $table_ret['553']['counter'], $table['-127']['counter']), implode('&nbsp;&nbsp;', $iconsUnknownRecip));
     $tblLines[] = array($GLOBALS["LANG"]->getLL('stats_mailbox_full'), $this->showWithPercent($table_ret['551']['counter'], $table['-127']['counter']), implode('&nbsp;&nbsp;', $iconsMailbox));
     $tblLines[] = array($GLOBALS["LANG"]->getLL('stats_bad_host'), $this->showWithPercent($table_ret['552']['counter'], $table['-127']['counter']), implode('&nbsp;&nbsp;', $iconsBadhost));
     $tblLines[] = array($GLOBALS["LANG"]->getLL('stats_error_in_header'), $this->showWithPercent($table_ret['554']['counter'], $table['-127']['counter']), implode('&nbsp;&nbsp;', $iconsBadheader));
     $tblLines[] = array($GLOBALS["LANG"]->getLL('stats_reason_unkown'), $this->showWithPercent($table_ret['-1']['counter'], $table['-127']['counter']), implode('&nbsp;&nbsp;', $iconsUnknownReason));
     $output .= '<br /><h2>' . $GLOBALS["LANG"]->getLL('stats_mails_returned') . '</h2>';
     $output .= DirectMailUtility::formatTable($tblLines, array('nowrap', 'nowrap align="right"', ''), 1, array(0, 0, 1), 'cellspacing="0" cellpadding="3" class="stats-table"');
     //Find all returned mail
     if (GeneralUtility::_GP('returnList') || GeneralUtility::_GP('returnDisable') || GeneralUtility::_GP('returnCSV')) {
         $res = $GLOBALS["TYPO3_DB"]->exec_SELECTquery('rid,rtbl,email', 'sys_dmail_maillog', 'mid=' . intval($row['uid']) . ' AND response_type=-127');
         $idLists = array();
         while ($rrow = $GLOBALS["TYPO3_DB"]->sql_fetch_assoc($res)) {
             switch ($rrow['rtbl']) {
                 case 't':
                     $idLists['tt_address'][] = $rrow['rid'];
                     break;
                 case 'f':
                     $idLists['fe_users'][] = $rrow['rid'];
                     break;
                 case 'P':
                     $idLists['PLAINLIST'][] = $rrow['email'];
                     break;
                 default:
                     $idLists[$rrow['rtbl']][] = $rrow['rid'];
                     break;
             }
         }
         if (GeneralUtility::_GP('returnList')) {
             if (is_array($idLists['tt_address'])) {
                 $output .= '<br />' . $GLOBALS["LANG"]->getLL('stats_emails') . '<br />' . DirectMailUtility::getRecordList(DirectMailUtility::fetchRecordsListValues($idLists['tt_address'], 'tt_address'), 'tt_address', $this->id, 1, $this->sys_dmail_uid);
             }
             if (is_array($idLists['fe_users'])) {
                 $output .= '<br />' . $GLOBALS["LANG"]->getLL('stats_website_users') . DirectMailUtility::getRecordList(DirectMailUtility::fetchRecordsListValues($idLists['fe_users'], 'fe_users'), 'fe_users', $this->id, 1, $this->sys_dmail_uid);
             }
             if (is_array($idLists['PLAINLIST'])) {
                 $output .= '<br />' . $GLOBALS["LANG"]->getLL('stats_plainlist');
                 $output .= '<ul><li>' . join('</li><li>', $idLists['PLAINLIST']) . '</li></ul>';
             }
         }
         if (GeneralUtility::_GP('returnDisable')) {
             if (is_array($idLists['tt_address'])) {
                 $c = $this->disableRecipients(DirectMailUtility::fetchRecordsListValues($idLists['tt_address'], 'tt_address'), 'tt_address');
                 $output .= '<br />' . $c . ' ' . $GLOBALS["LANG"]->getLL('stats_emails_disabled');
             }
             if (is_array($idLists['fe_users'])) {
                 $c = $this->disableRecipients(DirectMailUtility::fetchRecordsListValues($idLists['fe_users'], 'fe_users'), 'fe_users');
                 $output .= '<br />' . $c . ' ' . $GLOBALS["LANG"]->getLL('stats_website_users_disabled');
             }
         }
         if (GeneralUtility::_GP('returnCSV')) {
             $emails = array();
             if (is_array($idLists['tt_address'])) {
                 $arr = DirectMailUtility::fetchRecordsListValues($idLists['tt_address'], 'tt_address');
                 foreach ($arr as $v) {
                     $emails[] = $v['email'];
                 }
             }
             if (is_array($idLists['fe_users'])) {
                 $arr = DirectMailUtility::fetchRecordsListValues($idLists['fe_users'], 'fe_users');
                 foreach ($arr as $v) {
                     $emails[] = $v['email'];
                 }
             }
             if (is_array($idLists['PLAINLIST'])) {
                 $emails = array_merge($emails, $idLists['PLAINLIST']);
             }
             $output .= '<br />' . $GLOBALS["LANG"]->getLL('stats_emails_returned_list') . '<br />';
             $output .= '<textarea' . $GLOBALS["TBE_TEMPLATE"]->formWidthText() . ' rows="6" name="nothing">' . GeneralUtility::formatForTextarea(implode(LF, $emails)) . '</textarea>';
         }
     }
     //Find Unknown Recipient
     if (GeneralUtility::_GP('unknownList') || GeneralUtility::_GP('unknownDisable') || GeneralUtility::_GP('unknownCSV')) {
         $res = $GLOBALS["TYPO3_DB"]->exec_SELECTquery('rid,rtbl,email', 'sys_dmail_maillog', 'mid=' . intval($row['uid']) . ' AND response_type=-127' . ' AND (return_code=550 OR return_code=553)');
         $idLists = array();
         while ($rrow = $GLOBALS["TYPO3_DB"]->sql_fetch_assoc($res)) {
             switch ($rrow['rtbl']) {
                 case 't':
                     $idLists['tt_address'][] = $rrow['rid'];
                     break;
                 case 'f':
                     $idLists['fe_users'][] = $rrow['rid'];
                     break;
                 case 'P':
                     $idLists['PLAINLIST'][] = $rrow['email'];
                     break;
                 default:
                     $idLists[$rrow['rtbl']][] = $rrow['rid'];
                     break;
             }
         }
         if (GeneralUtility::_GP('unknownList')) {
             if (is_array($idLists['tt_address'])) {
                 $output .= '<br />' . $GLOBALS["LANG"]->getLL('stats_emails') . '<br />' . DirectMailUtility::getRecordList(DirectMailUtility::fetchRecordsListValues($idLists['tt_address'], 'tt_address'), 'tt_address', $this->id, 1, $this->sys_dmail_uid);
             }
             if (is_array($idLists['fe_users'])) {
                 $output .= '<br />' . $GLOBALS["LANG"]->getLL('stats_website_users') . DirectMailUtility::getRecordList(DirectMailUtility::fetchRecordsListValues($idLists['fe_users'], 'fe_users'), 'fe_users', $this->id, 1, $this->sys_dmail_uid);
             }
             if (is_array($idLists['PLAINLIST'])) {
                 $output .= '<br />' . $GLOBALS["LANG"]->getLL('stats_plainlist');
                 $output .= '<ul><li>' . join('</li><li>', $idLists['PLAINLIST']) . '</li></ul>';
             }
         }
         if (GeneralUtility::_GP('unknownDisable')) {
             if (is_array($idLists['tt_address'])) {
                 $c = $this->disableRecipients(DirectMailUtility::fetchRecordsListValues($idLists['tt_address'], 'tt_address'), 'tt_address');
                 $output .= '<br />' . $c . ' ' . $GLOBALS["LANG"]->getLL('stats_emails_disabled');
             }
             if (is_array($idLists['fe_users'])) {
                 $c = $this->disableRecipients(DirectMailUtility::fetchRecordsListValues($idLists['fe_users'], 'fe_users'), 'fe_users');
                 $output .= '<br />' . $c . ' ' . $GLOBALS["LANG"]->getLL('stats_website_users_disabled');
             }
         }
         if (GeneralUtility::_GP('unknownCSV')) {
             $emails = array();
             if (is_array($idLists['tt_address'])) {
                 $arr = DirectMailUtility::fetchRecordsListValues($idLists['tt_address'], 'tt_address');
                 foreach ($arr as $v) {
                     $emails[] = $v['email'];
                 }
             }
             if (is_array($idLists['fe_users'])) {
                 $arr = DirectMailUtility::fetchRecordsListValues($idLists['fe_users'], 'fe_users');
                 foreach ($arr as $v) {
                     $emails[] = $v['email'];
                 }
             }
             if (is_array($idLists['PLAINLIST'])) {
                 $emails = array_merge($emails, $idLists['PLAINLIST']);
             }
             $output .= '<br />' . $GLOBALS["LANG"]->getLL('stats_emails_returned_unknown_recipient_list') . '<br />';
             $output .= '<textarea' . $GLOBALS["TBE_TEMPLATE"]->formWidthText() . ' rows="6" name="nothing">' . GeneralUtility::formatForTextarea(implode(LF, $emails)) . '</textarea>';
         }
     }
     //Mailbox Full
     if (GeneralUtility::_GP('fullList') || GeneralUtility::_GP('fullDisable') || GeneralUtility::_GP('fullCSV')) {
         $res = $GLOBALS["TYPO3_DB"]->exec_SELECTquery('rid,rtbl,email', 'sys_dmail_maillog', 'mid=' . intval($row['uid']) . ' AND response_type=-127' . ' AND return_code=551');
         $idLists = array();
         while ($rrow = $GLOBALS["TYPO3_DB"]->sql_fetch_assoc($res)) {
             switch ($rrow['rtbl']) {
                 case 't':
                     $idLists['tt_address'][] = $rrow['rid'];
                     break;
                 case 'f':
                     $idLists['fe_users'][] = $rrow['rid'];
                     break;
                 case 'P':
                     $idLists['PLAINLIST'][] = $rrow['email'];
                     break;
                 default:
                     $idLists[$rrow['rtbl']][] = $rrow['rid'];
                     break;
             }
         }
         if (GeneralUtility::_GP('fullList')) {
             if (is_array($idLists['tt_address'])) {
                 $output .= '<br />' . $GLOBALS["LANG"]->getLL('stats_emails') . '<br />' . DirectMailUtility::getRecordList(DirectMailUtility::fetchRecordsListValues($idLists['tt_address'], 'tt_address'), 'tt_address', $this->id, 1, $this->sys_dmail_uid);
             }
             if (is_array($idLists['fe_users'])) {
                 $output .= '<br />' . $GLOBALS["LANG"]->getLL('stats_website_users') . DirectMailUtility::getRecordList(DirectMailUtility::fetchRecordsListValues($idLists['fe_users'], 'fe_users'), 'fe_users', $this->id, 1, $this->sys_dmail_uid);
             }
             if (is_array($idLists['PLAINLIST'])) {
                 $output .= '<br />' . $GLOBALS["LANG"]->getLL('stats_plainlist');
                 $output .= '<ul><li>' . join('</li><li>', $idLists['PLAINLIST']) . '</li></ul>';
             }
         }
         if (GeneralUtility::_GP('fullDisable')) {
             if (is_array($idLists['tt_address'])) {
                 $c = $this->disableRecipients(DirectMailUtility::fetchRecordsListValues($idLists['tt_address'], 'tt_address'), 'tt_address');
                 $output .= '<br />' . $c . ' ' . $GLOBALS["LANG"]->getLL('stats_emails_disabled');
             }
             if (is_array($idLists['fe_users'])) {
                 $c = $this->disableRecipients(DirectMailUtility::fetchRecordsListValues($idLists['fe_users'], 'fe_users'), 'fe_users');
                 $output .= '<br />' . $c . ' ' . $GLOBALS["LANG"]->getLL('stats_website_users_disabled');
             }
         }
         if (GeneralUtility::_GP('fullCSV')) {
             $emails = array();
             if (is_array($idLists['tt_address'])) {
                 $arr = DirectMailUtility::fetchRecordsListValues($idLists['tt_address'], 'tt_address');
                 foreach ($arr as $v) {
                     $emails[] = $v['email'];
                 }
             }
             if (is_array($idLists['fe_users'])) {
                 $arr = DirectMailUtility::fetchRecordsListValues($idLists['fe_users'], 'fe_users');
                 foreach ($arr as $v) {
                     $emails[] = $v['email'];
                 }
             }
             if (is_array($idLists['PLAINLIST'])) {
                 $emails = array_merge($emails, $idLists['PLAINLIST']);
             }
             $output .= '<br />' . $GLOBALS["LANG"]->getLL('stats_emails_returned_mailbox_full_list') . '<br />';
             $output .= '<textarea' . $GLOBALS["TBE_TEMPLATE"]->formWidthText() . ' rows="6" name="nothing">' . GeneralUtility::formatForTextarea(implode(LF, $emails)) . '</textarea>';
         }
     }
     //find Bad Host
     if (GeneralUtility::_GP('badHostList') || GeneralUtility::_GP('badHostDisable') || GeneralUtility::_GP('badHostCSV')) {
         $res = $GLOBALS["TYPO3_DB"]->exec_SELECTquery('rid,rtbl,email', 'sys_dmail_maillog', 'mid=' . intval($row['uid']) . ' AND response_type=-127' . ' AND return_code=552');
         $idLists = array();
         while ($rrow = $GLOBALS["TYPO3_DB"]->sql_fetch_assoc($res)) {
             switch ($rrow['rtbl']) {
                 case 't':
                     $idLists['tt_address'][] = $rrow['rid'];
                     break;
                 case 'f':
                     $idLists['fe_users'][] = $rrow['rid'];
                     break;
                 case 'P':
                     $idLists['PLAINLIST'][] = $rrow['email'];
                     break;
                 default:
                     $idLists[$rrow['rtbl']][] = $rrow['rid'];
                     break;
             }
         }
         if (GeneralUtility::_GP('badHostList')) {
             if (is_array($idLists['tt_address'])) {
                 $output .= '<br />' . $GLOBALS["LANG"]->getLL('stats_emails') . '<br />' . DirectMailUtility::getRecordList(DirectMailUtility::fetchRecordsListValues($idLists['tt_address'], 'tt_address'), 'tt_address', $this->id, 1, $this->sys_dmail_uid);
             }
             if (is_array($idLists['fe_users'])) {
                 $output .= '<br />' . $GLOBALS["LANG"]->getLL('stats_website_users') . DirectMailUtility::getRecordList(DirectMailUtility::fetchRecordsListValues($idLists['fe_users'], 'fe_users'), 'fe_users', $this->id, 1, $this->sys_dmail_uid);
             }
             if (is_array($idLists['PLAINLIST'])) {
                 $output .= '<br />' . $GLOBALS["LANG"]->getLL('stats_plainlist');
                 $output .= '<ul><li>' . join('</li><li>', $idLists['PLAINLIST']) . '</li></ul>';
             }
         }
         if (GeneralUtility::_GP('badHostDisable')) {
             if (is_array($idLists['tt_address'])) {
                 $c = $this->disableRecipients(DirectMailUtility::fetchRecordsListValues($idLists['tt_address'], 'tt_address'), 'tt_address');
                 $output .= '<br />' . $c . ' ' . $GLOBALS["LANG"]->getLL('stats_emails_disabled');
             }
             if (is_array($idLists['fe_users'])) {
                 $c = $this->disableRecipients(DirectMailUtility::fetchRecordsListValues($idLists['fe_users'], 'fe_users'), 'fe_users');
                 $output .= '<br />' . $c . ' ' . $GLOBALS["LANG"]->getLL('stats_website_users_disabled');
             }
         }
         if (GeneralUtility::_GP('badHostCSV')) {
             $emails = array();
             if (is_array($idLists['tt_address'])) {
                 $arr = DirectMailUtility::fetchRecordsListValues($idLists['tt_address'], 'tt_address');
                 foreach ($arr as $v) {
                     $emails[] = $v['email'];
                 }
             }
             if (is_array($idLists['fe_users'])) {
                 $arr = DirectMailUtility::fetchRecordsListValues($idLists['fe_users'], 'fe_users');
                 foreach ($arr as $v) {
                     $emails[] = $v['email'];
                 }
             }
             if (is_array($idLists['PLAINLIST'])) {
                 $emails = array_merge($emails, $idLists['PLAINLIST']);
             }
             $output .= '<br />' . $GLOBALS["LANG"]->getLL('stats_emails_returned_bad_host_list') . '<br />';
             $output .= '<textarea' . $GLOBALS["TBE_TEMPLATE"]->formWidthText() . ' rows="6" name="nothing">' . GeneralUtility::formatForTextarea(implode(LF, $emails)) . '</textarea>';
         }
     }
     //find Bad Header
     if (GeneralUtility::_GP('badHeaderList') || GeneralUtility::_GP('badHeaderDisable') || GeneralUtility::_GP('badHeaderCSV')) {
         $res = $GLOBALS["TYPO3_DB"]->exec_SELECTquery('rid,rtbl,email', 'sys_dmail_maillog', 'mid=' . intval($row['uid']) . ' AND response_type=-127' . ' AND return_code=554');
         $idLists = array();
         while ($rrow = $GLOBALS["TYPO3_DB"]->sql_fetch_assoc($res)) {
             switch ($rrow['rtbl']) {
                 case 't':
                     $idLists['tt_address'][] = $rrow['rid'];
                     break;
                 case 'f':
                     $idLists['fe_users'][] = $rrow['rid'];
                     break;
                 case 'P':
                     $idLists['PLAINLIST'][] = $rrow['email'];
                     break;
                 default:
                     $idLists[$rrow['rtbl']][] = $rrow['rid'];
                     break;
             }
         }
         if (GeneralUtility::_GP('badHeaderList')) {
             if (is_array($idLists['tt_address'])) {
                 $output .= '<br />' . $GLOBALS["LANG"]->getLL('stats_emails') . '<br />' . DirectMailUtility::getRecordList(DirectMailUtility::fetchRecordsListValues($idLists['tt_address'], 'tt_address'), 'tt_address', $this->id, 1, $this->sys_dmail_uid);
             }
             if (is_array($idLists['fe_users'])) {
                 $output .= '<br />' . $GLOBALS["LANG"]->getLL('stats_website_users') . DirectMailUtility::getRecordList(DirectMailUtility::fetchRecordsListValues($idLists['fe_users'], 'fe_users'), 'fe_users', $this->id, 1, $this->sys_dmail_uid);
             }
             if (is_array($idLists['PLAINLIST'])) {
                 $output .= '<br />' . $GLOBALS["LANG"]->getLL('stats_plainlist');
                 $output .= '<ul><li>' . join('</li><li>', $idLists['PLAINLIST']) . '</li></ul>';
             }
         }
         if (GeneralUtility::_GP('badHeaderDisable')) {
             if (is_array($idLists['tt_address'])) {
                 $c = $this->disableRecipients(DirectMailUtility::fetchRecordsListValues($idLists['tt_address'], 'tt_address'), 'tt_address');
                 $output .= '<br />' . $c . ' ' . $GLOBALS["LANG"]->getLL('stats_emails_disabled');
             }
             if (is_array($idLists['fe_users'])) {
                 $c = $this->disableRecipients(DirectMailUtility::fetchRecordsListValues($idLists['fe_users'], 'fe_users'), 'fe_users');
                 $output .= '<br />' . $c . ' ' . $GLOBALS["LANG"]->getLL('stats_website_users_disabled');
             }
         }
         if (GeneralUtility::_GP('badHeaderCSV')) {
             $emails = array();
             if (is_array($idLists['tt_address'])) {
                 $arr = DirectMailUtility::fetchRecordsListValues($idLists['tt_address'], 'tt_address');
                 foreach ($arr as $v) {
                     $emails[] = $v['email'];
                 }
             }
             if (is_array($idLists['fe_users'])) {
                 $arr = DirectMailUtility::fetchRecordsListValues($idLists['fe_users'], 'fe_users');
                 foreach ($arr as $v) {
                     $emails[] = $v['email'];
                 }
             }
             if (is_array($idLists['PLAINLIST'])) {
                 $emails = array_merge($emails, $idLists['PLAINLIST']);
             }
             $output .= '<br />' . $GLOBALS["LANG"]->getLL('stats_emails_returned_bad_header_list') . '<br />';
             $output .= '<textarea' . $GLOBALS["TBE_TEMPLATE"]->formWidthText() . ' rows="6" name="nothing">' . GeneralUtility::formatForTextarea(implode(LF, $emails)) . '</textarea>';
         }
     }
     //find Unknown Reasons
     //TODO: list all reason
     if (GeneralUtility::_GP('reasonUnknownList') || GeneralUtility::_GP('reasonUnknownDisable') || GeneralUtility::_GP('reasonUnknownCSV')) {
         $res = $GLOBALS["TYPO3_DB"]->exec_SELECTquery('rid,rtbl,email', 'sys_dmail_maillog', 'mid=' . intval($row['uid']) . ' AND response_type=-127' . ' AND return_code=-1');
         $idLists = array();
         while ($rrow = $GLOBALS["TYPO3_DB"]->sql_fetch_assoc($res)) {
             switch ($rrow['rtbl']) {
                 case 't':
                     $idLists['tt_address'][] = $rrow['rid'];
                     break;
                 case 'f':
                     $idLists['fe_users'][] = $rrow['rid'];
                     break;
                 case 'P':
                     $idLists['PLAINLIST'][] = $rrow['email'];
                     break;
                 default:
                     $idLists[$rrow['rtbl']][] = $rrow['rid'];
                     break;
             }
         }
         if (GeneralUtility::_GP('reasonUnknownList')) {
             if (is_array($idLists['tt_address'])) {
                 $output .= '<br />' . $GLOBALS["LANG"]->getLL('stats_emails') . '<br />' . DirectMailUtility::getRecordList(DirectMailUtility::fetchRecordsListValues($idLists['tt_address'], 'tt_address'), 'tt_address', $this->id, 1, $this->sys_dmail_uid);
             }
             if (is_array($idLists['fe_users'])) {
                 $output .= '<br />' . $GLOBALS["LANG"]->getLL('stats_website_users') . DirectMailUtility::getRecordList(DirectMailUtility::fetchRecordsListValues($idLists['fe_users'], 'fe_users'), 'fe_users', $this->id, 1, $this->sys_dmail_uid);
             }
             if (is_array($idLists['PLAINLIST'])) {
                 $output .= '<br />' . $GLOBALS["LANG"]->getLL('stats_plainlist');
                 $output .= '<ul><li>' . join('</li><li>', $idLists['PLAINLIST']) . '</li></ul>';
             }
         }
         if (GeneralUtility::_GP('reasonUnknownDisable')) {
             if (is_array($idLists['tt_address'])) {
                 $c = $this->disableRecipients(DirectMailUtility::fetchRecordsListValues($idLists['tt_address'], 'tt_address'), 'tt_address');
                 $output .= '<br />' . $c . ' ' . $GLOBALS["LANG"]->getLL('stats_emails_disabled');
             }
             if (is_array($idLists['fe_users'])) {
                 $c = $this->disableRecipients(DirectMailUtility::fetchRecordsListValues($idLists['fe_users'], 'fe_users'), 'fe_users');
                 $output .= '<br />' . $c . ' ' . $GLOBALS["LANG"]->getLL('stats_website_users_disabled');
             }
         }
         if (GeneralUtility::_GP('reasonUnknownCSV')) {
             $emails = array();
             if (is_array($idLists['tt_address'])) {
                 $arr = DirectMailUtility::fetchRecordsListValues($idLists['tt_address'], 'tt_address');
                 foreach ($arr as $v) {
                     $emails[] = $v['email'];
                 }
             }
             if (is_array($idLists['fe_users'])) {
                 $arr = DirectMailUtility::fetchRecordsListValues($idLists['fe_users'], 'fe_users');
                 foreach ($arr as $v) {
                     $emails[] = $v['email'];
                 }
             }
             if (is_array($idLists['PLAINLIST'])) {
                 $emails = array_merge($emails, $idLists['PLAINLIST']);
             }
             $output .= '<br />' . $GLOBALS["LANG"]->getLL('stats_emails_returned_reason_unknown_list') . '<br />';
             $output .= '<textarea' . $GLOBALS["TBE_TEMPLATE"]->formWidthText() . ' rows="6" name="nothing">' . GeneralUtility::formatForTextarea(implode(LF, $emails)) . '</textarea>';
         }
     }
     /**
      * Hook for cmd_stats_postProcess
      * insert a link to open extended importer
      */
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['direct_mail']['mod4']['cmd_stats'])) {
         $hookObjectsArr = array();
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['direct_mail']['mod4']['cmd_stats'] as $classRef) {
             $hookObjectsArr[] =& GeneralUtility::getUserObj($classRef);
         }
         $this->output = $output;
         // assigned $output to class property to make it acesssible inside hook
         $output = '';
         // and clear the former $output to collect hoot return code there
         foreach ($hookObjectsArr as $hookObj) {
             if (method_exists($hookObj, 'cmd_stats_postProcess')) {
                 $output .= $hookObj->cmd_stats_postProcess($row, $this);
             }
         }
     }
     $this->noView = 1;
     // put all the stats tables in a section
     $theOutput = $this->doc->section($GLOBALS["LANG"]->getLL('stats_direct_mail'), $output, 1, 1, 0, TRUE);
     $theOutput .= $this->doc->spacer(20);
     $link = '<p><a style="text-decoration: underline;" href="' . $thisurl . '">' . $GLOBALS["LANG"]->getLL('stats_recalculate_stats') . '</a></p>';
     $theOutput .= $this->doc->section($GLOBALS["LANG"]->getLL('stats_recalculate_cached_data'), $link, 1, 1, 0, TRUE);
     return $theOutput;
 }
Ejemplo n.º 11
0
    /**
     * import CSV-Data in step-by-step mode
     *
     * @return	string		HTML form
     */
    function cmd_displayImport()
    {
        $step = GeneralUtility::_GP('importStep');
        $defaultConf = array('remove_existing' => 0, 'first_fieldname' => 0, 'valid_email' => 0, 'remove_dublette' => 0, 'update_unique' => 0);
        if (GeneralUtility::_GP('CSV_IMPORT')) {
            $importerConfig = GeneralUtility::_GP('CSV_IMPORT');
            if ($step['next'] == 'mapping') {
                $this->indata = GeneralUtility::array_merge($defaultConf, $importerConfig);
            } else {
                $this->indata = $importerConfig;
            }
        }
        if (empty($this->indata)) {
            $this->indata = array();
        }
        if (empty($this->params)) {
            $this->params = array();
        }
        // merge it with inData, but inData has priority.
        $this->indata = GeneralUtility::array_merge($this->params, $this->indata);
        $currentFileInfo = BasicFileUtility::getTotalFileInfo($this->indata['newFile']);
        $currentFileName = $currentFileInfo['file'];
        $currentFileSize = GeneralUtility::formatSize($currentFileInfo['size']);
        $currentFileMessage = $currentFileName . ' (' . $currentFileSize . ')';
        if (empty($this->indata['csv']) && !empty($_FILES['upload_1']['name'])) {
            $this->indata['newFile'] = $this->checkUpload();
            // TYPO3 6.0 returns an object...
            if (is_object($this->indata['newFile'][0])) {
                $storageConfig = $this->indata['newFile'][0]->getStorage()->getConfiguration();
                $this->indata['newFile'] = $storageConfig['basePath'] . ltrim($this->indata['newFile'][0]->getIdentifier(), '/');
            }
        } elseif (!empty($this->indata['csv']) && empty($_FILES['upload_1']['name'])) {
            if ((strpos($currentFileInfo['file'], 'import') === false ? 0 : 1) && $currentFileInfo['realFileext'] === 'txt') {
                //do nothing
            } else {
                unset($this->indata['newFile']);
            }
        }
        if ($this->indata['back']) {
            $stepCurrent = $step['back'];
        } elseif ($this->indata['next']) {
            $stepCurrent = $step['next'];
        } elseif ($this->indata['update']) {
            $stepCurrent = 'mapping';
        }
        if (strlen($this->indata['csv']) > 0) {
            $this->indata['mode'] = 'csv';
            $this->indata['newFile'] = $this->writeTempFile();
        } elseif (!empty($this->indata['newFile'])) {
            $this->indata['mode'] = 'file';
        } else {
            unset($stepCurrent);
        }
        //check if "email" is mapped
        if ($stepCurrent === 'import') {
            $map = $this->indata['map'];
            $error = array();
            //check noMap
            $newMap = GeneralUtility::removeArrayEntryByValue(array_unique($map), 'noMap');
            if (empty($newMap)) {
                $error[] = 'noMap';
            } elseif (!GeneralUtility::inArray($map, 'email')) {
                $error[] = 'email';
            }
            if ($error) {
                $stepCurrent = 'mapping';
            }
        }
        $out = "";
        switch ($stepCurrent) {
            case 'conf':
                //get list of sysfolder
                //TODO: maybe only subtree von this->id??
                $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,title', 'pages', 'doktype = 254 AND ' . $GLOBALS['BE_USER']->getPagePermsClause(3) . BackendUtility::deleteClause('pages') . BackendUtility::BEenableFields('pages'), '', 'uid');
                $optStorage = array();
                while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                    if (BackendUtility::readPageAccess($row['uid'], $GLOBALS['BE_USER']->getPagePermsClause(1))) {
                        $optStorage[] = array($row['uid'], $row['title'] . ' [uid:' . $row['uid'] . ']');
                    }
                }
                $GLOBALS['TYPO3_DB']->sql_free_result($res);
                $optDelimiter = array(array('comma', $GLOBALS['LANG']->getLL('mailgroup_import_separator_comma')), array('semicolon', $GLOBALS['LANG']->getLL('mailgroup_import_separator_semicolon')), array('colon', $GLOBALS['LANG']->getLL('mailgroup_import_separator_colon')), array('tab', $GLOBALS['LANG']->getLL('mailgroup_import_separator_tab')));
                $optEncap = array(array('doubleQuote', ' " '), array('singleQuote', " ' "));
                //TODO: make it variable?
                $optUnique = array(array('email', 'email'), array('name', 'name'));
                $this->params['inputDisable'] == 1 ? $disableInput = 'disabled="disabled"' : ($disableInput = '');
                //show configuration
                $out = '<hr /><h3>' . $GLOBALS['LANG']->getLL('mailgroup_import_header_conf') . '</h3>';
                $tblLines = array();
                $tblLines[] = array($GLOBALS['LANG']->getLL('mailgroup_import_storage'), $this->makeDropdown('CSV_IMPORT[storage]', $optStorage, $this->indata['storage']));
                $tblLines[] = array($GLOBALS['LANG']->getLL('mailgroup_import_remove_existing'), '<input type="checkbox" name="CSV_IMPORT[remove_existing]" value="1"' . (!$this->indata['remove_existing'] ? '' : ' checked="checked"') . ' ' . $disableInput . '/> ');
                $tblLines[] = array($GLOBALS['LANG']->getLL('mailgroup_import_first_fieldnames'), '<input type="checkbox" name="CSV_IMPORT[first_fieldname]" value="1"' . (!$this->indata['first_fieldname'] ? '' : ' checked="checked"') . ' ' . $disableInput . '/> ');
                $tblLines[] = array($GLOBALS['LANG']->getLL('mailgroup_import_separator'), $this->makeDropdown('CSV_IMPORT[delimiter]', $optDelimiter, $this->indata['delimiter'], $disableInput));
                $tblLines[] = array($GLOBALS['LANG']->getLL('mailgroup_import_encapsulation'), $this->makeDropdown('CSV_IMPORT[encapsulation]', $optEncap, $this->indata['encapsulation'], $disableInput));
                $tblLines[] = array($GLOBALS['LANG']->getLL('mailgroup_import_csv_validemail-description'), '<input type="checkbox" name="CSV_IMPORT[valid_email]" value="1"' . (!$this->indata['valid_email'] ? '' : ' checked="checked"') . ' ' . $disableInput . '/> ');
                $tblLines[] = array($GLOBALS['LANG']->getLL('mailgroup_import_csv_dublette-description'), '<input type="checkbox" name="CSV_IMPORT[remove_dublette]" value="1"' . (!$this->indata['remove_dublette'] ? '' : ' checked="checked"') . ' ' . $disableInput . '/> ');
                $tblLines[] = array($GLOBALS['LANG']->getLL('mailgroup_import_update_unique'), '<input type="checkbox" name="CSV_IMPORT[update_unique]" value="1"' . (!$this->indata['update_unique'] ? '' : ' checked="checked"') . ' ' . $disableInput . '/>');
                $tblLines[] = array($GLOBALS['LANG']->getLL('mailgroup_import_record_unique'), $this->makeDropdown('CSV_IMPORT[record_unique]', $optUnique, $this->indata['record_unique'], $disableInput));
                $out .= $this->formatTable($tblLines, array('width=300', 'nowrap'), 0, array(0, 1));
                $out .= '<br /><br />';
                $out .= '<input type="submit" name="CSV_IMPORT[back]" value="' . $GLOBALS['LANG']->getLL('mailgroup_import_back') . '" />
						<input type="submit" name="CSV_IMPORT[next]" value="' . $GLOBALS['LANG']->getLL('mailgroup_import_next') . '" />' . $this->makeHidden(array('CMD' => 'displayImport', 'importStep[next]' => 'mapping', 'importStep[back]' => 'upload', 'CSV_IMPORT[newFile]' => $this->indata['newFile']));
                break;
            case 'mapping':
                //show charset selector
                $cs = array_unique(array_values($GLOBALS['LANG']->csConvObj->synonyms));
                $charSets = array();
                foreach ($cs as $charset) {
                    $charSets[] = array($charset, $charset);
                }
                if (!isset($this->indata['charset'])) {
                    $this->indata['charset'] = 'iso-8859-1';
                }
                $out .= '<hr /><h3>' . $GLOBALS['LANG']->getLL('mailgroup_import_mapping_charset') . '</h3>';
                $tblLines = array();
                $tblLines[] = array($GLOBALS['LANG']->getLL('mailgroup_import_mapping_charset_choose'), $this->makeDropdown('CSV_IMPORT[charset]', $charSets, $this->indata['charset']));
                $out .= $this->formatTable($tblLines, array('nowrap', 'nowrap'), 0, array(1, 1), 'border="0" cellpadding="0" cellspacing="0" class="typo3-dblist"');
                $out .= '<input type="submit" name="CSV_IMPORT[update]" value="' . $GLOBALS['LANG']->getLL('mailgroup_import_update') . '"/>';
                unset($tblLines);
                //show mapping form
                $out .= '<hr /><h3>' . $GLOBALS['LANG']->getLL('mailgroup_import_mapping_conf') . '</h3>';
                if ($this->indata['first_fieldname']) {
                    //read csv
                    $csvData = $this->readExampleCSV(4);
                    $csv_firstRow = $csvData[0];
                    $csvData = array_slice($csvData, 1);
                } else {
                    //read csv
                    $csvData = $this->readExampleCSV(3);
                    $fieldsAmount = count($csvData[0]);
                    $csv_firstRow = array();
                    for ($i = 0; $i < $fieldsAmount; $i++) {
                        $csv_firstRow[] = 'field_' . $i;
                    }
                }
                //read tt_address TCA
                $no_map = array('image');
                $tt_address_fields = array_keys($GLOBALS['TCA']['tt_address']['columns']);
                foreach ($no_map as $v) {
                    $tt_address_fields = GeneralUtility::removeArrayEntryByValue($tt_address_fields, $v);
                }
                $mapFields = array();
                foreach ($tt_address_fields as $map) {
                    $mapFields[] = array($map, str_replace(':', '', $GLOBALS['LANG']->sL($GLOBALS['TCA']['tt_address']['columns'][$map]['label'])));
                }
                //add 'no value'
                array_unshift($mapFields, array('noMap', $GLOBALS['LANG']->getLL('mailgroup_import_mapping_mapTo')));
                $mapFields[] = array('cats', $GLOBALS['LANG']->getLL('mailgroup_import_mapping_categories'));
                reset($csv_firstRow);
                reset($csvData);
                $tblLines = array();
                $tblLines[] = array($GLOBALS['LANG']->getLL('mailgroup_import_mapping_number'), $GLOBALS['LANG']->getLL('mailgroup_import_mapping_description'), $GLOBALS['LANG']->getLL('mailgroup_import_mapping_mapping'), $GLOBALS['LANG']->getLL('mailgroup_import_mapping_value'));
                for ($i = 0; $i < count($csv_firstRow); $i++) {
                    //example CSV
                    $exampleLines = array();
                    for ($j = 0; $j < count($csvData); $j++) {
                        $exampleLines[] = array($csvData[$j][$i]);
                    }
                    $tblLines[] = array($i + 1, $csv_firstRow[$i], $this->makeDropdown('CSV_IMPORT[map][' . $i . ']', $mapFields, $this->indata['map'][$i]), $this->formatTable($exampleLines, array('nowrap'), 0, array(0), 'border="0" cellpadding="0" cellspacing="0" class="typo3-dblist" style="width:100%; border:0px; margin:0px;"'));
                }
                if ($error) {
                    $out .= '<h3>' . $GLOBALS['LANG']->getLL('mailgroup_import_mapping_error') . '</h3>';
                    $out .= $GLOBALS['LANG']->getLL('mailgroup_import_mapping_error_detail') . '<br /><ul>';
                    foreach ($error as $errorDetail) {
                        $out .= '<li>' . $GLOBALS['LANG']->getLL('mailgroup_import_mapping_error_' . $errorDetail) . '</li>';
                    }
                    $out .= '</ul>';
                }
                //additional options
                $tblLinesAdd = array();
                //header
                $tblLinesAdd[] = array($GLOBALS['LANG']->getLL('mailgroup_import_mapping_all_html'), '<input type="checkbox" name="CSV_IMPORT[all_html]" value="1"' . (!$this->indata['all_html'] ? '' : ' checked="checked"') . '/> ');
                //get categories
                $temp = BackendUtility::getModTSconfig($this->parent->id, 'TCEFORM.sys_dmail_group.select_categories.PAGE_TSCONFIG_IDLIST');
                if (is_numeric($temp['value'])) {
                    $rowCat = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_dmail_category', 'pid IN (' . $temp['value'] . ')' . BackendUtility::deleteClause('sys_dmail_category') . BackendUtility::BEenableFields('sys_dmail_category'));
                    if (!empty($rowCat)) {
                        $tblLinesAdd[] = array($GLOBALS['LANG']->getLL('mailgroup_import_mapping_cats'), '');
                        if ($this->indata['update_unique']) {
                            $tblLinesAdd[] = array($GLOBALS['LANG']->getLL('mailgroup_import_mapping_cats_add'), '<input type="checkbox" name="CSV_IMPORT[add_cat]" value="1"' . ($this->indata['add_cat'] ? ' checked="checked"' : '') . '/> ');
                        }
                        foreach ($rowCat as $k => $v) {
                            $tblLinesAdd[] = array('&nbsp;&nbsp;&nbsp;' . htmlspecialchars($v['category']), '<input type="checkbox" name="CSV_IMPORT[cat][' . $k . ']" value="' . $v['uid'] . '"' . ($this->indata['cat'][$k] != $v['uid'] ? '' : ' checked="checked"') . '/> ');
                        }
                    }
                }
                $out .= $this->formatTable($tblLines, array('nowrap', 'nowrap', 'nowrap', 'nowrap'), 1, array(0, 0, 1, 1), 'border="0" cellpadding="0" cellspacing="0" class="typo3-dblist"');
                $out .= '<br /><br />';
                //additional options
                $out .= '<hr /><h3>' . $GLOBALS['LANG']->getLL('mailgroup_import_mapping_conf_add') . '</h3>';
                $out .= $this->formatTable($tblLinesAdd, array('nowrap', 'nowrap'), 0, array(1, 1), 'border="0" cellpadding="0" cellspacing="0" class="typo3-dblist"');
                $out .= '<br /><br />';
                $out .= '<input type="submit" name="CSV_IMPORT[back]" value="' . $GLOBALS['LANG']->getLL('mailgroup_import_back') . '"/>
						<input type="submit" name="CSV_IMPORT[next]" value="' . $GLOBALS['LANG']->getLL('mailgroup_import_next') . '"/>' . $this->makeHidden(array('CMD' => 'displayImport', 'importStep[next]' => 'import', 'importStep[back]' => 'conf', 'CSV_IMPORT[newFile]' => $this->indata['newFile'], 'CSV_IMPORT[storage]' => $this->indata['storage'], 'CSV_IMPORT[remove_existing]' => $this->indata['remove_existing'], 'CSV_IMPORT[first_fieldname]' => $this->indata['first_fieldname'], 'CSV_IMPORT[delimiter]' => $this->indata['delimiter'], 'CSV_IMPORT[encapsulation]' => $this->indata['encapsulation'], 'CSV_IMPORT[valid_email]' => $this->indata['valid_email'], 'CSV_IMPORT[remove_dublette]' => $this->indata['remove_dublette'], 'CSV_IMPORT[update_unique]' => $this->indata['update_unique'], 'CSV_IMPORT[record_unique]' => $this->indata['record_unique']));
                break;
            case 'import':
                //show import messages
                $out .= '<hr /><h3>' . $GLOBALS['LANG']->getLL('mailgroup_import_ready_import') . '</h3>';
                $out .= $GLOBALS['LANG']->getLL('mailgroup_import_ready_import_label') . '<br /><br />';
                $out .= '<input type="submit" name="CSV_IMPORT[back]" value="' . $GLOBALS['LANG']->getLL('mailgroup_import_back') . '" />
						<input type="submit" name="CSV_IMPORT[next]" value="' . $GLOBALS['LANG']->getLL('mailgroup_import_import') . '" />' . $this->makeHidden(array('CMD' => 'displayImport', 'importStep[next]' => 'startImport', 'importStep[back]' => 'mapping', 'CSV_IMPORT[newFile]' => $this->indata['newFile'], 'CSV_IMPORT[storage]' => $this->indata['storage'], 'CSV_IMPORT[remove_existing]' => $this->indata['remove_existing'], 'CSV_IMPORT[first_fieldname]' => $this->indata['first_fieldname'], 'CSV_IMPORT[delimiter]' => $this->indata['delimiter'], 'CSV_IMPORT[encapsulation]' => $this->indata['encapsulation'], 'CSV_IMPORT[valid_email]' => $this->indata['valid_email'], 'CSV_IMPORT[remove_dublette]' => $this->indata['remove_dublette'], 'CSV_IMPORT[update_unique]' => $this->indata['update_unique'], 'CSV_IMPORT[record_unique]' => $this->indata['record_unique'], 'CSV_IMPORT[all_html]' => $this->indata['all_html'], 'CSV_IMPORT[add_cat]' => $this->indata['add_cat'], 'CSV_IMPORT[charset]' => $this->indata['charset']));
                $hiddenMapped = array();
                foreach ($this->indata['map'] as $fieldNr => $fieldMapped) {
                    $hiddenMapped[] = $this->makeHidden('CSV_IMPORT[map][' . $fieldNr . ']', $fieldMapped);
                }
                if (is_array($this->indata['cat'])) {
                    foreach ($this->indata['cat'] as $k => $catUID) {
                        $hiddenMapped[] = $this->makeHidden('CSV_IMPORT[cat][' . $k . ']', $catUID);
                    }
                }
                $out .= implode('', $hiddenMapped);
                break;
            case 'startImport':
                //starting import & show errors
                //read csv
                if ($this->indata['first_fieldname']) {
                    //read csv
                    $csvData = $this->readCSV();
                    $csvData = array_slice($csvData, 1);
                } else {
                    //read csv
                    $csvData = $this->readCSV();
                }
                //show not imported record and reasons,
                $result = $this->doImport($csvData);
                $out = '<hr /><h3>' . $GLOBALS['LANG']->getLL('mailgroup_import_done') . '</h3>';
                $defaultOrder = array('new', 'update', 'invalid_email', 'double');
                if (!empty($this->params['resultOrder'])) {
                    $resultOrder = GeneralUtility::trimExplode(',', $this->params['resultOrder']);
                } else {
                    $resultOrder = array();
                }
                $diffOrder = array_diff($defaultOrder, $resultOrder);
                $endOrder = array_merge($resultOrder, $diffOrder);
                foreach ($endOrder as $order) {
                    $tblLines = array();
                    $tblLines[] = array($GLOBALS['LANG']->getLL('mailgroup_import_report_' . $order));
                    if (is_array($result[$order])) {
                        foreach ($result[$order] as $k => $v) {
                            $mapKeys = array_keys($v);
                            $tblLines[] = array($k + 1, $v[$mapKeys[0]], $v['email']);
                        }
                    }
                    $out .= $this->formatTable($tblLines, array('nowrap', 'first' => 'colspan="3"'), 1, array(1));
                }
                //back button
                $out .= $this->makeHidden(array('CMD' => 'displayImport', 'importStep[back]' => 'import', 'CSV_IMPORT[newFile]' => $this->indata['newFile'], 'CSV_IMPORT[storage]' => $this->indata['storage'], 'CSV_IMPORT[remove_existing]' => $this->indata['remove_existing'], 'CSV_IMPORT[first_fieldname]' => $this->indata['first_fieldname'], 'CSV_IMPORT[delimiter]' => $this->indata['delimiter'], 'CSV_IMPORT[encapsulation]' => $this->indata['encapsulation'], 'CSV_IMPORT[valid_email]' => $this->indata['valid_email'], 'CSV_IMPORT[remove_dublette]' => $this->indata['remove_dublette'], 'CSV_IMPORT[update_unique]' => $this->indata['update_unique'], 'CSV_IMPORT[record_unique]' => $this->indata['record_unique'], 'CSV_IMPORT[all_html]' => $this->indata['all_html'], 'CSV_IMPORT[charset]' => $this->indata['charset']));
                $hiddenMapped = array();
                foreach ($this->indata['map'] as $fieldNr => $fieldMapped) {
                    $hiddenMapped[] = $this->makeHidden('CSV_IMPORT[map][' . $fieldNr . ']', $fieldMapped);
                }
                if (is_array($this->indata['cat'])) {
                    foreach ($this->indata['cat'] as $k => $catUID) {
                        $hiddenMapped[] = $this->makeHidden('CSV_IMPORT[cat][' . $k . ']', $catUID);
                    }
                }
                $out .= implode('', $hiddenMapped);
                break;
            case 'upload':
            default:
                //show upload file form
                $out = '<hr /><h3>' . $GLOBALS['LANG']->getLL('mailgroup_import_header_upload') . '</h3>';
                $tempDir = $this->userTempFolder();
                $tblLines[] = $GLOBALS['LANG']->getLL('mailgroup_import_upload_file') . '<input type="file" name="upload_1" size="30" />';
                if ($this->indata['mode'] == 'file' && !((strpos($currentFileInfo['file'], 'import') === false ? 0 : 1) && $currentFileInfo['realFileext'] === 'txt')) {
                    $tblLines[] = $GLOBALS['LANG']->getLL('mailgroup_import_current_file') . '<b>' . $currentFileMessage . '</b>';
                }
                if ((strpos($currentFileInfo['file'], 'import') === false ? 0 : 1) && $currentFileInfo['realFileext'] === 'txt') {
                    $handleCSV = fopen($this->indata['newFile'], 'r');
                    $this->indata['csv'] = fread($handleCSV, filesize($this->indata['newFile']));
                    fclose($handleCSV);
                }
                $tblLines[] = '';
                $tblLines[] = '<b>' . $GLOBALS['LANG']->getLL('mailgroup_import_or') . '</b>';
                $tblLines[] = '';
                $tblLines[] = $GLOBALS['LANG']->getLL('mailgroup_import_paste_csv');
                $tblLines[] = '<textarea name="CSV_IMPORT[csv]" rows="25" wrap="off"' . $this->parent->doc->formWidthText(48, '', 'off') . '>' . GeneralUtility::formatForTextarea($this->indata['csv']) . '</textarea>';
                $tblLines[] = '<input type="submit" name="CSV_IMPORT[next]" value="' . $GLOBALS['LANG']->getLL('mailgroup_import_next') . '" />';
                $out .= implode('<br />', $tblLines);
                $out .= '<input type="hidden" name="CMD" value="displayImport" />
						<input type="hidden" name="importStep[next]" value="conf" />
						<input type="hidden" name="file[upload][1][target]" value="' . htmlspecialchars($tempDir) . '" ' . ($_POST['importNow'] ? 'disabled' : '') . '/>
						<input type="hidden" name="file[upload][1][data]" value="1" />
						<input type="hidden" name="CSV_IMPORT[newFile]" value ="' . $this->indata['newFile'] . '">';
                break;
        }
        $theOutput = $this->parent->doc->section($GLOBALS['LANG']->getLL('mailgroup_import') . BackendUtility::cshItem($this->cshTable, 'mailgroup_import', $GLOBALS['BACK_PATH']), $out, 1, 1, 0, TRUE);
        /**
         *  Hook for cmd_displayImport
         *  use it to manipulate the steps in the import process
         */
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['direct_mail/mod3/class.tx_directmail_recipient_list.php']['cmd_displayImport'])) {
            $hookObjectsArr = array();
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['direct_mail/mod3/class.tx_directmail_recipient_list.php']['cmd_displayImport'] as $classRef) {
                $hookObjectsArr[] =& GeneralUtility::getUserObj($classRef);
            }
        }
        if (is_array($hookObjectsArr)) {
            foreach ($hookObjectsArr as $hookObj) {
                if (method_exists($hookObj, 'cmd_displayImport')) {
                    $theOutput = '';
                    $theOutput = $hookObj->cmd_displayImport($this);
                }
            }
        }
        return $theOutput;
    }
Ejemplo n.º 12
0
    /**
     * Create configuration form
     *
     * @param array $inData Form configurat data
     * @param array $row Table row accumulation variable. This is filled with table rows.
     * @return void Sets content in $this->content
     * @todo Define visibility
     */
    public function makeSaveForm($inData, &$row)
    {
        // Presets:
        $row[] = '
			<tr class="tableheader bgColor5">
				<td colspan="2">' . $this->lang->getLL('makesavefo_presets', TRUE) . '</td>
			</tr>';
        $opt = array('');
        $where = '(public>0 OR user_uid=' . (int) $this->getBackendUser()->user['uid'] . ')' . ($inData['pagetree']['id'] ? ' AND (item_uid=' . (int) $inData['pagetree']['id'] . ' OR item_uid=0)' : '');
        $presets = $this->getDatabaseConnection()->exec_SELECTgetRows('*', 'tx_impexp_presets', $where);
        if (is_array($presets)) {
            foreach ($presets as $presetCfg) {
                $opt[$presetCfg['uid']] = $presetCfg['title'] . ' [' . $presetCfg['uid'] . ']' . ($presetCfg['public'] ? ' [Public]' : '') . ($presetCfg['user_uid'] === $this->getBackendUser()->user['uid'] ? ' [Own]' : '');
            }
        }
        $row[] = '
				<tr class="bgColor4">
					<td><strong>' . $this->lang->getLL('makesavefo_presets', TRUE) . '</strong>' . BackendUtility::cshItem('xMOD_tx_impexp', 'presets', $GLOBALS['BACK_PATH'], '') . '</td>
					<td>
						' . $this->lang->getLL('makesavefo_selectPreset', TRUE) . '<br/>
						' . $this->renderSelectBox('preset[select]', '', $opt) . '
						<br/>
						<input type="submit" value="' . $this->lang->getLL('makesavefo_load', TRUE) . '" name="preset[load]" />
						<input type="submit" value="' . $this->lang->getLL('makesavefo_save', TRUE) . '" name="preset[save]" onclick="return confirm(\'' . $this->lang->getLL('makesavefo_areYouSure', TRUE) . '\');" />
						<input type="submit" value="' . $this->lang->getLL('makesavefo_delete', TRUE) . '" name="preset[delete]" onclick="return confirm(\'' . $this->lang->getLL('makesavefo_areYouSure', TRUE) . '\');" />
						<input type="submit" value="' . $this->lang->getLL('makesavefo_merge', TRUE) . '" name="preset[merge]" onclick="return confirm(\'' . $this->lang->getLL('makesavefo_areYouSure', TRUE) . '\');" />
						<br/>
						' . $this->lang->getLL('makesavefo_titleOfNewPreset', TRUE) . '
						<input type="text" name="tx_impexp[preset][title]" value="' . htmlspecialchars($inData['preset']['title']) . '"' . $this->doc->formWidth(30) . ' /><br/>
						<label for="checkPresetPublic">' . $this->lang->getLL('makesavefo_public', TRUE) . '</label>
						<input type="checkbox" name="tx_impexp[preset][public]" id="checkPresetPublic" value="1"' . ($inData['preset']['public'] ? ' checked="checked"' : '') . ' /><br/>
					</td>
				</tr>';
        // Output options:
        $row[] = '
			<tr class="tableheader bgColor5">
				<td colspan="2">' . $this->lang->getLL('makesavefo_outputOptions', TRUE) . '</td>
			</tr>';
        // Meta data:
        $thumbnailFiles = array();
        foreach ($this->getThumbnailFiles() as $thumbnailFile) {
            $thumbnailFiles[$thumbnailFile->getCombinedIdentifier()] = $thumbnailFile->getName();
        }
        if (!empty($thumbnailFiles)) {
            array_unshift($thumbnailFiles, '');
        }
        $thumbnail = NULL;
        if (!empty($inData['meta']['thumbnail'])) {
            $thumbnail = $this->getFile($inData['meta']['thumbnail']);
        }
        $saveFolder = $this->getDefaultImportExportFolder();
        $row[] = '
				<tr class="bgColor4">
					<td><strong>' . $this->lang->getLL('makesavefo_metaData', TRUE) . '</strong>' . BackendUtility::cshItem('xMOD_tx_impexp', 'metadata', $GLOBALS['BACK_PATH'], '') . '</td>
					<td>
							' . $this->lang->getLL('makesavefo_title', TRUE) . ' <br/>
							<input type="text" name="tx_impexp[meta][title]" value="' . htmlspecialchars($inData['meta']['title']) . '"' . $this->doc->formWidth(30) . ' /><br/>
							' . $this->lang->getLL('makesavefo_description', TRUE) . ' <br/>
							<input type="text" name="tx_impexp[meta][description]" value="' . htmlspecialchars($inData['meta']['description']) . '"' . $this->doc->formWidth(30) . ' /><br/>
							' . $this->lang->getLL('makesavefo_notes', TRUE) . ' <br/>
							<textarea name="tx_impexp[meta][notes]"' . $this->doc->formWidth(30, 1) . '>' . GeneralUtility::formatForTextarea($inData['meta']['notes']) . '</textarea><br/>
							' . (!empty($thumbnailFiles) ? '
							' . $this->lang->getLL('makesavefo_thumbnail', TRUE) . '<br/>
							' . $this->renderSelectBox('tx_impexp[meta][thumbnail]', $inData['meta']['thumbnail'], $thumbnailFiles) : '') . '<br/>
							' . ($thumbnail ? '<img src="' . htmlspecialchars($thumbnail->getPublicUrl(TRUE)) . '" vspace="5" style="border: solid black 1px;" alt="" /><br/>' : '') . '
							' . $this->lang->getLL('makesavefo_uploadThumbnail', TRUE) . '<br/>
							' . ($saveFolder ? '<input type="file" name="upload_1" ' . $this->doc->formWidth(30) . ' size="30" /><br/>
								<input type="hidden" name="file[upload][1][target]" value="' . htmlspecialchars($saveFolder->getCombinedIdentifier()) . '" />
								<input type="hidden" name="file[upload][1][data]" value="1" /><br />' : '') . '
						</td>
				</tr>';
        // Add file options:
        $opt = array();
        if ($this->export->compress) {
            $opt['t3d_compressed'] = $this->lang->getLL('makesavefo_t3dFileCompressed');
        }
        $opt['t3d'] = $this->lang->getLL('makesavefo_t3dFile');
        $opt['xml'] = $this->lang->getLL('makesavefo_xml');
        $fileName = '';
        if ($saveFolder) {
            $fileName = sprintf($this->lang->getLL('makesavefo_filenameSavedInS', TRUE), $saveFolder->getCombinedIdentifier()) . '<br/>
						<input type="text" name="tx_impexp[filename]" value="' . htmlspecialchars($inData['filename']) . '"' . $this->doc->formWidth(30) . ' /><br/>';
        }
        $row[] = '
				<tr class="bgColor4">
					<td><strong>' . $this->lang->getLL('makesavefo_fileFormat', TRUE) . '</strong>' . BackendUtility::cshItem('xMOD_tx_impexp', 'fileFormat', $GLOBALS['BACK_PATH'], '') . '</td>
					<td>' . $this->renderSelectBox('tx_impexp[filetype]', $inData['filetype'], $opt) . '<br/>
						' . $this->lang->getLL('makesavefo_maxSizeOfFiles', TRUE) . '<br/>
						<input type="text" name="tx_impexp[maxFileSize]" value="' . htmlspecialchars($inData['maxFileSize']) . '"' . $this->doc->formWidth(10) . ' /><br/>
						' . $fileName . '
					</td>
				</tr>';
        // Add buttons:
        $row[] = '
				<tr class="bgColor4">
					<td>&nbsp;</td>
					<td><input type="submit" value="' . $this->lang->getLL('makesavefo_update', TRUE) . '" /> - <input type="submit" value="' . $this->lang->getLL('makesavefo_downloadExport', TRUE) . '" name="tx_impexp[download_export]" />' . ($saveFolder ? ' - <input type="submit" value="' . $this->lang->getLL('importdata_saveToFilename', TRUE) . '" name="tx_impexp[save_export]" />' : '') . '</td>
				</tr>';
    }
Ejemplo n.º 13
0
    /**
     * Render the module content in HTML
     *
     * @param  array    Translation data for configuration
     * @param  integer    Sys language uid
     * @param  array    Configuration record
     * @return  string    HTML content
     */
    function renderOverview()
    {
        global $LANG;
        $sysLang = $this->sysLang;
        $accumObj = $this->l10ncfgObj->getL10nAccumulatedInformationsObjectForLanguage($sysLang);
        $accum = $accumObj->getInfoArray();
        $l10ncfg = $this->l10ncfg;
        $output = '';
        $showSingle = GeneralUtility::_GET('showSingle');
        if ($l10ncfg['displaymode'] > 0) {
            $showSingle = $showSingle ? $showSingle : 'NONE';
            if ($l10ncfg['displaymode'] == 2) {
                $noAnalysis = true;
            }
        } else {
            $noAnalysis = false;
        }
        // Traverse the structure and generate HTML output:
        foreach ($accum as $pId => $page) {
            $output .= '<h3>' . $page['header']['icon'] . htmlspecialchars($page['header']['title']) . ' [' . $pId . ']</h3>';
            $tableRows = array();
            foreach ($accum[$pId]['items'] as $table => $elements) {
                foreach ($elements as $elementUid => $data) {
                    if (is_array($data['fields'])) {
                        $FtableRows = array();
                        $flags = array();
                        if (!$noAnalysis || $showSingle === $table . ':' . $elementUid) {
                            foreach ($data['fields'] as $key => $tData) {
                                if (is_array($tData)) {
                                    list(, $uidString, $fieldName) = explode(':', $key);
                                    list($uidValue) = explode('/', $uidString);
                                    $diff = '';
                                    $edit = true;
                                    $noChangeFlag = !strcmp(trim($tData['diffDefaultValue']), trim($tData['defaultValue']));
                                    if ($uidValue === 'NEW') {
                                        $diff = '<em>' . $LANG->getLL('render_overview.new.message') . '</em>';
                                        $flags['new']++;
                                    } elseif (!isset($tData['diffDefaultValue'])) {
                                        $diff = '<em>' . $LANG->getLL('render_overview.nodiff.message') . '</em>';
                                        $flags['unknown']++;
                                    } elseif ($noChangeFlag) {
                                        $diff = $LANG->getLL('render_overview.nochange.message');
                                        $edit = true;
                                        $flags['noChange']++;
                                    } else {
                                        $diff = $this->diffCMP($tData['diffDefaultValue'], $tData['defaultValue']);
                                        $flags['update']++;
                                    }
                                    if (!$this->modeOnlyChanged || !$noChangeFlag) {
                                        $fieldCells = array();
                                        $fieldCells[] = '<b>' . htmlspecialchars($fieldName) . '</b>' . ($tData['msg'] ? '<br/><em>' . htmlspecialchars($tData['msg']) . '</em>' : '');
                                        $fieldCells[] = nl2br(htmlspecialchars($tData['defaultValue']));
                                        $fieldCells[] = $edit && $this->modeWithInlineEdit ? $tData['fieldType'] === 'text' ? '<textarea name="' . htmlspecialchars('translation[' . $table . '][' . $elementUid . '][' . $key . ']') . '" cols="60" rows="5">' . GeneralUtility::formatForTextarea($tData['translationValue']) . '</textarea>' : '<input name="' . htmlspecialchars('translation[' . $table . '][' . $elementUid . '][' . $key . ']') . '" value="' . htmlspecialchars($tData['translationValue']) . '" size="60" />' : nl2br(htmlspecialchars($tData['translationValue']));
                                        $fieldCells[] = $diff;
                                        if ($page['header']['prevLang']) {
                                            reset($tData['previewLanguageValues']);
                                            $fieldCells[] = nl2br(htmlspecialchars(current($tData['previewLanguageValues'])));
                                        }
                                        $FtableRows[] = '<tr class="db_list_normal"><td>' . implode('</td><td>', $fieldCells) . '</td></tr>';
                                    }
                                }
                            }
                        }
                        if (count($FtableRows) || $noAnalysis) {
                            // Link:
                            if ($this->modeShowEditLinks) {
                                reset($data['fields']);
                                list(, $uidString) = explode(':', key($data['fields']));
                                if (substr($uidString, 0, 3) !== 'NEW') {
                                    $editId = is_array($data['translationInfo']['translations'][$sysLang]) ? $data['translationInfo']['translations'][$sysLang]['uid'] : $data['translationInfo']['uid'];
                                    $editLink = ' - <a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick('&edit[' . $data['translationInfo']['translation_table'] . '][' . $editId . ']=edit', $this->doc->backPath)) . '"><em>[' . $LANG->getLL('render_overview.clickedit.message') . ']</em></a>';
                                } else {
                                    $editLink = ' - <a href="' . htmlspecialchars($this->doc->issueCommand('&cmd[' . $table . '][' . $data['translationInfo']['uid'] . '][localize]=' . $sysLang)) . '"><em>[' . $LANG->getLL('render_overview.clicklocalize.message') . ']</em></a>';
                                }
                            } else {
                                $editLink = '';
                            }
                            $tableRows[] = '<tr class="t3-row-header">
								<td colspan="2" style="width:300px;"><a href="' . htmlspecialchars('index.php?id=' . GeneralUtility::_GET('id') . '&showSingle=' . rawurlencode($table . ':' . $elementUid)) . '">' . htmlspecialchars($table . ':' . $elementUid) . '</a>' . $editLink . '</td>
								<td colspan="3" style="width:200px;">' . htmlspecialchars(GeneralUtility::arrayToLogString($flags)) . '</td>
							</tr>';
                            if (!$showSingle || $showSingle === $table . ':' . $elementUid) {
                                $tableRows[] = '<tr class="bgColor-20 tableheader">
									<td>Fieldname:</td>
									<td width="25%">Default:</td>
									<td width="25%">Translation:</td>
									<td width="25%">Diff:</td>
									' . ($page['header']['prevLang'] ? '<td width="25%">PrevLang:</td>' : '') . '
								</tr>';
                                $tableRows = array_merge($tableRows, $FtableRows);
                            }
                        }
                    }
                }
            }
            if (count($tableRows)) {
                $output .= '<table class="typo3-dblist" border="0" cellpadding="0" cellspacing="0">' . implode('', $tableRows) . '</table>';
            }
        }
        return $output;
    }
    /**
     * Create configuration form
     *
     * @param array $inData Form configurat data
     * @param array $row Table row accumulation variable. This is filled with table rows.
     * @return void Sets content in $this->content
     * @todo Define visibility
     */
    public function makeSaveForm($inData, &$row)
    {
        global $LANG;
        // Presets:
        $row[] = '
			<tr class="tableheader bgColor5">
				<td colspan="2">' . $LANG->getLL('makesavefo_presets', 1) . '</td>
			</tr>';
        $opt = array('');
        $presets = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'tx_impexp_presets', '(public>0 OR user_uid=' . intval($GLOBALS['BE_USER']->user['uid']) . ')' . ($inData['pagetree']['id'] ? ' AND (item_uid=' . intval($inData['pagetree']['id']) . ' OR item_uid=0)' : ''));
        if (is_array($presets)) {
            foreach ($presets as $presetCfg) {
                $opt[$presetCfg['uid']] = $presetCfg['title'] . ' [' . $presetCfg['uid'] . ']' . ($presetCfg['public'] ? ' [Public]' : '') . ($presetCfg['user_uid'] === $GLOBALS['BE_USER']->user['uid'] ? ' [Own]' : '');
            }
        }
        $row[] = '
				<tr class="bgColor4">
					<td><strong>' . $LANG->getLL('makesavefo_presets', 1) . '</strong>' . \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem('xMOD_tx_impexp', 'presets', $GLOBALS['BACK_PATH'], '') . '</td>
					<td>
						' . $LANG->getLL('makesavefo_selectPreset', 1) . '<br/>
						' . $this->renderSelectBox('preset[select]', '', $opt) . '
						<br/>
						<input type="submit" value="' . $LANG->getLL('makesavefo_load', 1) . '" name="preset[load]" />
						<input type="submit" value="' . $LANG->getLL('makesavefo_save', 1) . '" name="preset[save]" onclick="return confirm(\'' . $LANG->getLL('makesavefo_areYouSure', 1) . '\');" />
						<input type="submit" value="' . $LANG->getLL('makesavefo_delete', 1) . '" name="preset[delete]" onclick="return confirm(\'' . $LANG->getLL('makesavefo_areYouSure', 1) . '\');" />
						<input type="submit" value="' . $LANG->getLL('makesavefo_merge', 1) . '" name="preset[merge]" onclick="return confirm(\'' . $LANG->getLL('makesavefo_areYouSure', 1) . '\');" />
						<br/>
						' . $LANG->getLL('makesavefo_titleOfNewPreset', 1) . '
						<input type="text" name="tx_impexp[preset][title]" value="' . htmlspecialchars($inData['preset']['title']) . '"' . $this->doc->formWidth(30) . ' /><br/>
						<label for="checkPresetPublic">' . $LANG->getLL('makesavefo_public', 1) . '</label>
						<input type="checkbox" name="tx_impexp[preset][public]" id="checkPresetPublic" value="1"' . ($inData['preset']['public'] ? ' checked="checked"' : '') . ' /><br/>
					</td>
				</tr>';
        // Output options:
        $row[] = '
			<tr class="tableheader bgColor5">
				<td colspan="2">' . $LANG->getLL('makesavefo_outputOptions', 1) . '</td>
			</tr>';
        // Meta data:
        $tempDir = $this->userTempFolder();
        if ($tempDir) {
            $thumbnails = \TYPO3\CMS\Core\Utility\GeneralUtility::getFilesInDir($tempDir, 'png,gif,jpg');
            array_unshift($thumbnails, '');
        } else {
            $thumbnails = FALSE;
        }
        $row[] = '
				<tr class="bgColor4">
					<td><strong>' . $LANG->getLL('makesavefo_metaData', 1) . '</strong>' . \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem('xMOD_tx_impexp', 'metadata', $GLOBALS['BACK_PATH'], '') . '</td>
					<td>
							' . $LANG->getLL('makesavefo_title', 1) . ' <br/>
							<input type="text" name="tx_impexp[meta][title]" value="' . htmlspecialchars($inData['meta']['title']) . '"' . $this->doc->formWidth(30) . ' /><br/>
							' . $LANG->getLL('makesavefo_description', 1) . ' <br/>
							<input type="text" name="tx_impexp[meta][description]" value="' . htmlspecialchars($inData['meta']['description']) . '"' . $this->doc->formWidth(30) . ' /><br/>
							' . $LANG->getLL('makesavefo_notes', 1) . ' <br/>
							<textarea name="tx_impexp[meta][notes]"' . $this->doc->formWidth(30, 1) . '>' . \TYPO3\CMS\Core\Utility\GeneralUtility::formatForTextarea($inData['meta']['notes']) . '</textarea><br/>
							' . (is_array($thumbnails) ? '
							' . $LANG->getLL('makesavefo_thumbnail', 1) . '<br/>
							' . $this->renderSelectBox('tx_impexp[meta][thumbnail]', $inData['meta']['thumbnail'], $thumbnails) . '<br/>
							' . ($inData['meta']['thumbnail'] ? '<img src="' . $this->doc->backPath . '../' . substr($tempDir, strlen(PATH_site)) . $thumbnails[$inData['meta']['thumbnail']] . '" vspace="5" style="border: solid black 1px;" alt="" /><br/>' : '') . '
							' . $LANG->getLL('makesavefo_uploadThumbnail', 1) . '<br/>
							<input type="file" name="upload_1" ' . $this->doc->formWidth(30) . ' size="30" /><br/>
								<input type="hidden" name="file[upload][1][target]" value="' . htmlspecialchars($tempDir) . '" />
								<input type="hidden" name="file[upload][1][data]" value="1" /><br />
							' : '') . '
						</td>
				</tr>';
        // Add file options:
        $savePath = $this->userSaveFolder();
        $opt = array();
        if ($this->export->compress) {
            $opt['t3d_compressed'] = $LANG->getLL('makesavefo_t3dFileCompressed');
        }
        $opt['t3d'] = $LANG->getLL('makesavefo_t3dFile');
        $opt['xml'] = $LANG->getLL('makesavefo_xml');
        $row[] = '
				<tr class="bgColor4">
					<td><strong>' . $LANG->getLL('makesavefo_fileFormat', 1) . '</strong>' . \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem('xMOD_tx_impexp', 'fileFormat', $GLOBALS['BACK_PATH'], '') . '</td>
					<td>' . $this->renderSelectBox('tx_impexp[filetype]', $inData['filetype'], $opt) . '<br/>
						' . $LANG->getLL('makesavefo_maxSizeOfFiles', 1) . '<br/>
						<input type="text" name="tx_impexp[maxFileSize]" value="' . htmlspecialchars($inData['maxFileSize']) . '"' . $this->doc->formWidth(10) . ' /><br/>
						' . ($savePath ? sprintf($LANG->getLL('makesavefo_filenameSavedInS', 1), substr($savePath, strlen(PATH_site))) . '<br/>
						<input type="text" name="tx_impexp[filename]" value="' . htmlspecialchars($inData['filename']) . '"' . $this->doc->formWidth(30) . ' /><br/>' : '') . '
					</td>
				</tr>';
        // Add buttons:
        $row[] = '
				<tr class="bgColor4">
					<td>&nbsp;</td>
					<td><input type="submit" value="' . $LANG->getLL('makesavefo_update', 1) . '" /> - <input type="submit" value="' . $LANG->getLL('makesavefo_downloadExport', 1) . '" name="tx_impexp[download_export]" />' . ($savePath ? ' - <input type="submit" value="' . $LANG->getLL('importdata_saveToFilename', 1) . '" name="tx_impexp[save_export]" />' : '') . '</td>
				</tr>';
    }
Ejemplo n.º 15
0
 /**
  * show the quickmail input form (first step)
  *
  * @return	string		HTML input form
  */
 function cmd_quickmail()
 {
     $theOutput = '';
     $indata = GeneralUtility::_GP('quickmail');
     $senderName = $indata['senderName'] ? $indata['senderName'] : $GLOBALS['BE_USER']->user['realName'];
     $senderMail = $indata['senderEmail'] ? $indata['senderEmail'] : $GLOBALS['BE_USER']->user['email'];
     // Set up form:
     $theOutput .= '<input type="hidden" name="id" value="' . $this->id . '" />';
     $theOutput .= $GLOBALS['LANG']->getLL('quickmail_sender_name') . '<br /><input type="text" name="quickmail[senderName]" value="' . htmlspecialchars($senderName) . '"' . $this->doc->formWidth() . ' /><br />';
     $theOutput .= $GLOBALS['LANG']->getLL('quickmail_sender_email') . '<br /><input type="text" name="quickmail[senderEmail]" value="' . htmlspecialchars($senderMail) . '"' . $this->doc->formWidth() . ' /><br />';
     $theOutput .= $GLOBALS['LANG']->getLL('dmail_subject') . '<br /><input type="text" name="quickmail[subject]" value="' . htmlspecialchars($indata['subject']) . '"' . $this->doc->formWidth() . ' /><br />';
     $theOutput .= $GLOBALS['LANG']->getLL('quickmail_message') . '<br /><textarea rows="20" name="quickmail[message]"' . $this->doc->formWidthText() . '>' . GeneralUtility::formatForTextarea($indata['message']) . '</textarea><br />';
     $theOutput .= $GLOBALS['LANG']->getLL('quickmail_break_lines') . ' <input type="checkbox" name="quickmail[breakLines]" value="1"' . ($indata['breakLines'] ? ' checked="checked"' : '') . ' /><br /><br />';
     $theOutput .= '<input type="Submit" name="quickmail[send]" value="' . $GLOBALS['LANG']->getLL('dmail_wiz_next') . '" />';
     return $theOutput;
 }
Ejemplo n.º 16
0
    /**
     * Creates the HTML for the Form Wizard:
     *
     * @param string $formCfgArray Form config array
     * @param array $row Current parent record array
     * @return string HTML for the form wizard
     * @access private
     * @todo Define visibility
     */
    public function getFormHTML($formCfgArray, $row)
    {
        // Initialize variables:
        $specParts = array();
        $hiddenFields = array();
        $tRows = array();
        // Set header row:
        $cells = array($GLOBALS['LANG']->getLL('forms_preview', 1) . ':', $GLOBALS['LANG']->getLL('forms_element', 1) . ':', $GLOBALS['LANG']->getLL('forms_config', 1) . ':');
        $tRows[] = '
			<tr class="bgColor2" id="typo3-formWizardHeader">
				<td>&nbsp;</td>
				<td>' . implode('</td>
				<td>', $cells) . '</td>
			</tr>';
        // Traverse the number of form elements:
        $k = 0;
        foreach ($formCfgArray as $confData) {
            // Initialize:
            $cells = array();
            // If there is a configuration line which is active, then render it:
            if (!isset($confData['comment'])) {
                // Special parts:
                if ($this->special == 'formtype_mail' && \TYPO3\CMS\Core\Utility\GeneralUtility::inList('formtype_mail,subject,html_enabled', $confData['fieldname'])) {
                    $specParts[$confData['fieldname']] = $confData['default'];
                } else {
                    // Render title/field preview COLUMN
                    $cells[] = $confData['type'] != 'hidden' ? '<strong>' . htmlspecialchars($confData['label']) . '</strong>' : '';
                    // Render general type/title COLUMN:
                    $temp_cells = array();
                    // Field type selector:
                    $opt = array();
                    $opt[] = '<option value=""></option>';
                    $types = explode(',', 'input,textarea,select,check,radio,password,file,hidden,submit,property,label');
                    foreach ($types as $t) {
                        $opt[] = '
								<option value="' . $t . '"' . ($confData['type'] == $t ? ' selected="selected"' : '') . '>' . $GLOBALS['LANG']->getLL('forms_type_' . $t, 1) . '</option>';
                    }
                    $temp_cells[$GLOBALS['LANG']->getLL('forms_type')] = '
							<select name="FORMCFG[c][' . ($k + 1) * 2 . '][type]">
								' . implode('
								', $opt) . '
							</select>';
                    // Title field:
                    if (!\TYPO3\CMS\Core\Utility\GeneralUtility::inList('hidden,submit', $confData['type'])) {
                        $temp_cells[$GLOBALS['LANG']->getLL('forms_label')] = '<input type="text"' . $this->doc->formWidth(15) . ' name="FORMCFG[c][' . ($k + 1) * 2 . '][label]" value="' . htmlspecialchars($confData['label']) . '" />';
                    }
                    // Required checkbox:
                    if (!\TYPO3\CMS\Core\Utility\GeneralUtility::inList('check,hidden,submit,label', $confData['type'])) {
                        $temp_cells[$GLOBALS['LANG']->getLL('forms_required')] = '<input type="checkbox" name="FORMCFG[c][' . ($k + 1) * 2 . '][required]" value="1"' . ($confData['required'] ? ' checked="checked"' : '') . ' title="' . $GLOBALS['LANG']->getLL('forms_required', 1) . '" />';
                    }
                    // Put sub-items together into table cell:
                    $cells[] = $this->formatCells($temp_cells);
                    // Render specific field configuration COLUMN:
                    $temp_cells = array();
                    // Fieldname
                    if ($this->special == 'formtype_mail' && $confData['type'] == 'file') {
                        $confData['fieldname'] = 'attachment' . ++$this->attachmentCounter;
                    }
                    if (!\TYPO3\CMS\Core\Utility\GeneralUtility::inList('label', $confData['type'])) {
                        $temp_cells[$GLOBALS['LANG']->getLL('forms_fieldName')] = '<input type="text"' . $this->doc->formWidth(10) . ' name="FORMCFG[c][' . ($k + 1) * 2 . '][fieldname]" value="' . htmlspecialchars($confData['fieldname']) . '" title="' . $GLOBALS['LANG']->getLL('forms_fieldName', 1) . '" />';
                    }
                    // Field configuration depending on the fields type:
                    switch ((string) $confData['type']) {
                        case 'textarea':
                            $temp_cells[$GLOBALS['LANG']->getLL('forms_cols')] = '<input type="text"' . $this->doc->formWidth(5) . ' name="FORMCFG[c][' . ($k + 1) * 2 . '][cols]" value="' . htmlspecialchars($confData['cols']) . '" title="' . $GLOBALS['LANG']->getLL('forms_cols', 1) . '" />';
                            $temp_cells[$GLOBALS['LANG']->getLL('forms_rows')] = '<input type="text"' . $this->doc->formWidth(5) . ' name="FORMCFG[c][' . ($k + 1) * 2 . '][rows]" value="' . htmlspecialchars($confData['rows']) . '" title="' . $GLOBALS['LANG']->getLL('forms_rows', 1) . '" />';
                            $temp_cells[$GLOBALS['LANG']->getLL('forms_extra')] = '<input type="checkbox" name="FORMCFG[c][' . ($k + 1) * 2 . '][extra]" value="OFF"' . ($confData['extra'] == 'OFF' ? ' checked="checked"' : '') . ' title="' . $GLOBALS['LANG']->getLL('forms_extra', 1) . '" />';
                            break;
                        case 'input':
                        case 'password':
                            $temp_cells[$GLOBALS['LANG']->getLL('forms_size')] = '<input type="text"' . $this->doc->formWidth(5) . ' name="FORMCFG[c][' . ($k + 1) * 2 . '][size]" value="' . htmlspecialchars($confData['size']) . '" title="' . $GLOBALS['LANG']->getLL('forms_size', 1) . '" />';
                            $temp_cells[$GLOBALS['LANG']->getLL('forms_max')] = '<input type="text"' . $this->doc->formWidth(5) . ' name="FORMCFG[c][' . ($k + 1) * 2 . '][max]" value="' . htmlspecialchars($confData['max']) . '" title="' . $GLOBALS['LANG']->getLL('forms_max', 1) . '" />';
                            break;
                        case 'file':
                            $temp_cells[$GLOBALS['LANG']->getLL('forms_size')] = '<input type="text"' . $this->doc->formWidth(5) . ' name="FORMCFG[c][' . ($k + 1) * 2 . '][size]" value="' . htmlspecialchars($confData['size']) . '" title="' . $GLOBALS['LANG']->getLL('forms_size', 1) . '" />';
                            break;
                        case 'select':
                            $temp_cells[$GLOBALS['LANG']->getLL('forms_size')] = '<input type="text"' . $this->doc->formWidth(5) . ' name="FORMCFG[c][' . ($k + 1) * 2 . '][size]" value="' . htmlspecialchars($confData['size']) . '" title="' . $GLOBALS['LANG']->getLL('forms_size', 1) . '" />';
                            $temp_cells[$GLOBALS['LANG']->getLL('forms_autosize')] = '<input type="checkbox" name="FORMCFG[c][' . ($k + 1) * 2 . '][autosize]" value="1"' . ($confData['autosize'] ? ' checked="checked"' : '') . ' title="' . $GLOBALS['LANG']->getLL('forms_autosize', 1) . '" />';
                            $temp_cells[$GLOBALS['LANG']->getLL('forms_multiple')] = '<input type="checkbox" name="FORMCFG[c][' . ($k + 1) * 2 . '][multiple]" value="1"' . ($confData['multiple'] ? ' checked="checked"' : '') . ' title="' . $GLOBALS['LANG']->getLL('forms_multiple', 1) . '" />';
                            break;
                    }
                    // Field configuration depending on the fields type:
                    switch ((string) $confData['type']) {
                        case 'textarea':
                        case 'input':
                        case 'password':
                            if (strlen(trim($confData['specialEval']))) {
                                $hiddenFields[] = '<input type="hidden" name="FORMCFG[c][' . ($k + 1) * 2 . '][specialEval]" value="' . htmlspecialchars($confData['specialEval']) . '" />';
                            }
                            break;
                    }
                    // Default data
                    if ($confData['type'] == 'select' || $confData['type'] == 'radio') {
                        $temp_cells[$GLOBALS['LANG']->getLL('forms_options')] = '<textarea ' . $this->doc->formWidthText(15) . ' rows="4" name="FORMCFG[c][' . ($k + 1) * 2 . '][options]" title="' . $GLOBALS['LANG']->getLL('forms_options', 1) . '">' . \TYPO3\CMS\Core\Utility\GeneralUtility::formatForTextarea($confData['default']) . '</textarea>';
                    } elseif ($confData['type'] == 'check') {
                        $temp_cells[$GLOBALS['LANG']->getLL('forms_checked')] = '<input type="checkbox" name="FORMCFG[c][' . ($k + 1) * 2 . '][default]" value="1"' . (trim($confData['default']) ? ' checked="checked"' : '') . ' title="' . $GLOBALS['LANG']->getLL('forms_checked', 1) . '" />';
                    } elseif ($confData['type'] && $confData['type'] != 'file') {
                        $temp_cells[$GLOBALS['LANG']->getLL('forms_default')] = '<input type="text"' . $this->doc->formWidth(15) . ' name="FORMCFG[c][' . ($k + 1) * 2 . '][default]" value="' . htmlspecialchars($confData['default']) . '" title="' . $GLOBALS['LANG']->getLL('forms_default', 1) . '" />';
                    }
                    $cells[] = $confData['type'] ? $this->formatCells($temp_cells) : '';
                    // CTRL panel for an item (move up/down/around):
                    $ctrl = '';
                    $onClick = 'document.wizardForm.action+=\'#ANC_' . (($k + 1) * 2 - 2) . '\';';
                    $onClick = ' onclick="' . htmlspecialchars($onClick) . '"';
                    // FIXME $inputStyle undefined
                    $brTag = $inputStyle ? '' : '<br />';
                    if ($k != 0) {
                        $ctrl .= '<input type="image" name="FORMCFG[row_up][' . ($k + 1) * 2 . ']"' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->doc->backPath, 'gfx/pil2up.gif', '') . $onClick . ' title="' . $GLOBALS['LANG']->getLL('table_up', 1) . '" />' . $brTag;
                    } else {
                        $ctrl .= '<input type="image" name="FORMCFG[row_bottom][' . ($k + 1) * 2 . ']"' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->doc->backPath, 'gfx/turn_up.gif', '') . $onClick . ' title="' . $GLOBALS['LANG']->getLL('table_bottom', 1) . '" />' . $brTag;
                    }
                    $ctrl .= '<input type="image" name="FORMCFG[row_remove][' . ($k + 1) * 2 . ']"' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->doc->backPath, 'gfx/garbage.gif', '') . $onClick . ' title="' . $GLOBALS['LANG']->getLL('table_removeRow', 1) . '" />' . $brTag;
                    // FIXME $tLines undefined
                    if ($k + 1 != count($tLines)) {
                        $ctrl .= '<input type="image" name="FORMCFG[row_down][' . ($k + 1) * 2 . ']"' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->doc->backPath, 'gfx/pil2down.gif', '') . $onClick . ' title="' . $GLOBALS['LANG']->getLL('table_down', 1) . '" />' . $brTag;
                    } else {
                        $ctrl .= '<input type="image" name="FORMCFG[row_top][' . ($k + 1) * 2 . ']"' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->doc->backPath, 'gfx/turn_down.gif', '') . $onClick . ' title="' . $GLOBALS['LANG']->getLL('table_top', 1) . '" />' . $brTag;
                    }
                    $ctrl .= '<input type="image" name="FORMCFG[row_add][' . ($k + 1) * 2 . ']"' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->doc->backPath, 'gfx/add.gif', '') . $onClick . ' title="' . $GLOBALS['LANG']->getLL('table_addRow', 1) . '" />' . $brTag;
                    $ctrl = '<span class="c-wizButtonsV">' . $ctrl . '</span>';
                    // Finally, put together the full row from the generated content above:
                    $bgC = $confData['type'] ? ' class="bgColor5"' : '';
                    $tRows[] = '
						<tr' . $bgC . '>
							<td><a name="ANC_' . ($k + 1) * 2 . '"></a>' . $ctrl . '</td>
							<td class="bgColor4">' . implode('</td>
							<td valign="top">', $cells) . '</td>
						</tr>';
                }
            } else {
                $hiddenFields[] = '<input type="hidden" name="FORMCFG[c][' . ($k + 1) * 2 . '][comment]" value="' . htmlspecialchars($confData['comment']) . '" />';
            }
            // Increment counter:
            $k++;
        }
        // If the form is of the special type "formtype_mail" (used for tt_content elements):
        if ($this->special == 'formtype_mail') {
            // Blank spacer:
            $tRows[] = '
				<tr>
					<td colspan="4">&nbsp;</td>
				</tr>';
            // Header:
            $tRows[] = '
				<tr>
					<td colspan="2" class="bgColor2">&nbsp;</td>
					<td colspan="2" class="bgColor2"><strong>' . $GLOBALS['LANG']->getLL('forms_special_eform', 1) . ':</strong>' . \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem('xMOD_csh_corebe', 'wizard_forms_wiz_formmail_info', $GLOBALS['BACK_PATH'], '') . '</td>
				</tr>';
            // "FORM type":
            $tRows[] = '
				<tr class="bgColor5">
					<td>&nbsp;</td>
					<td class="bgColor4">&nbsp;</td>
					<td>' . $GLOBALS['LANG']->getLL('forms_eform_formtype_mail', 1) . ':</td>
					<td>
						<input type="hidden" name="FORMCFG[c][' . 1000 * 2 . '][fieldname]" value="formtype_mail" />
						<input type="hidden" name="FORMCFG[c][' . 1000 * 2 . '][type]" value="submit" />
						<input type="text"' . $this->doc->formWidth(15) . ' name="FORMCFG[c][' . 1000 * 2 . '][default]" value="' . htmlspecialchars($specParts['formtype_mail']) . '" />
					</td>
				</tr>';
            // "Send HTML mail":
            $tRows[] = '
				<tr class="bgColor5">
					<td>&nbsp;</td>
					<td class="bgColor4">&nbsp;</td>
					<td>' . $GLOBALS['LANG']->getLL('forms_eform_html_enabled', 1) . ':</td>
					<td>
						<input type="hidden" name="FORMCFG[c][' . 1001 * 2 . '][fieldname]" value="html_enabled" />
						<input type="hidden" name="FORMCFG[c][' . 1001 * 2 . '][type]" value="hidden" />
						<input type="checkbox" name="FORMCFG[c][' . 1001 * 2 . '][default]" value="1"' . ($specParts['html_enabled'] ? ' checked="checked"' : '') . ' />
					</td>
				</tr>';
            // "Subject":
            $tRows[] = '
				<tr class="bgColor5">
					<td>&nbsp;</td>
					<td class="bgColor4">&nbsp;</td>
					<td>' . $GLOBALS['LANG']->getLL('forms_eform_subject', 1) . ':</td>
					<td>
						<input type="hidden" name="FORMCFG[c][' . 1002 * 2 . '][fieldname]" value="subject" />
						<input type="hidden" name="FORMCFG[c][' . 1002 * 2 . '][type]" value="hidden" />
						<input type="text"' . $this->doc->formWidth(15) . ' name="FORMCFG[c][' . 1002 * 2 . '][default]" value="' . htmlspecialchars($specParts['subject']) . '" />
					</td>
				</tr>';
            // Recipient:
            $tRows[] = '
				<tr class="bgColor5">
					<td>&nbsp;</td>
					<td class="bgColor4">&nbsp;</td>
					<td>' . $GLOBALS['LANG']->getLL('forms_eform_recipient', 1) . ':</td>
					<td>
						<input type="text"' . $this->doc->formWidth(15) . ' name="FORMCFG[recipient]" value="' . htmlspecialchars($row['subheader']) . '" />
					</td>
				</tr>';
        }
        $content = '';
        // Implode all table rows into a string, wrapped in table tags.
        $content .= '

			<!--
				Form wizard
			-->
			<table border="0" cellpadding="1" cellspacing="1" id="typo3-formwizard">
				' . implode('', $tRows) . '
			</table>';
        // Add hidden fields:
        $content .= implode('', $hiddenFields);
        // Return content:
        return $content;
    }
Ejemplo n.º 17
0
    /**
     * Main function, redering the actual content of the editing page
     *
     * @return void
     * @todo Define visibility
     */
    public function main()
    {
        //TODO: change locallang*.php to locallang*.xml
        $docHeaderButtons = $this->getButtons();
        $this->content = $this->doc->startPage($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_edit.php.pagetitle'));
        // Hook	before compiling the output
        if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['preOutputProcessingHook'])) {
            $preOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['preOutputProcessingHook'];
            if (is_array($preOutputProcessingHook)) {
                $hookParameters = array('content' => &$this->content, 'target' => &$this->target);
                foreach ($preOutputProcessingHook as $hookFunction) {
                    \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this);
                }
            }
        }
        $pageContent = $this->doc->header($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_edit.php.pagetitle') . ' ' . htmlspecialchars($this->fileObject->getName()));
        $pageContent .= $this->doc->spacer(2);
        $code = '';
        $extList = $GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'];
        if ($extList && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($extList, $this->fileObject->getExtension())) {
            // Read file content to edit:
            $fileContent = $this->fileObject->getContents();
            // Making the formfields
            $hValue = 'file_edit.php?target=' . rawurlencode($this->origTarget) . '&returnUrl=' . rawurlencode($this->returnUrl);
            // Edit textarea:
            $code .= '
				<div id="c-edit">
					<textarea rows="30" name="file[editfile][0][data]" wrap="off"' . $this->doc->formWidthText(48, 'width:98%;height:80%', 'off') . ' class="fixed-font enable-tab">' . \TYPO3\CMS\Core\Utility\GeneralUtility::formatForTextarea($fileContent) . '</textarea>
					<input type="hidden" name="file[editfile][0][target]" value="' . $this->fileObject->getUid() . '" />
					<input type="hidden" name="redirect" value="' . htmlspecialchars($hValue) . '" />
				</div>
				<br />';
            // Make shortcut:
            if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
                $this->MCONF['name'] = 'xMOD_file_edit.php';
                $docHeaderButtons['shortcut'] = $this->doc->makeShortcutIcon('target', '', $this->MCONF['name'], 1);
            } else {
                $docHeaderButtons['shortcut'] = '';
            }
        } else {
            $code .= sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_edit.php.coundNot'), $extList);
        }
        // Ending of section and outputting editing form:
        $pageContent .= $this->doc->sectionEnd();
        $pageContent .= $code;
        // Hook	after compiling the output
        if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['postOutputProcessingHook'])) {
            $postOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['postOutputProcessingHook'];
            if (is_array($postOutputProcessingHook)) {
                $hookParameters = array('pageContent' => &$pageContent, 'target' => &$this->target);
                foreach ($postOutputProcessingHook as $hookFunction) {
                    \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this);
                }
            }
        }
        // Add the HTML as a section:
        $markerArray = array('CSH' => $docHeaderButtons['csh'], 'FUNC_MENU' => \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']), 'BUTTONS' => $docHeaderButtons, 'PATH' => $this->title, 'CONTENT' => $pageContent);
        $this->content .= $this->doc->moduleBody(array(), $docHeaderButtons, $markerArray);
        $this->content .= $this->doc->endPage();
        $this->content = $this->doc->insertStylesAndJS($this->content);
    }
Ejemplo n.º 18
0
    /**
     * Draws the RTE as an iframe
     *
     * @param 	object		Reference to parent object, which is an instance of the TCEforms.
     * @param 	string		The table name
     * @param 	string		The field name
     * @param 	array		The current row from which field is being rendered
     * @param 	array		Array of standard content for rendering form fields from TCEforms. See TCEforms for details on this. Includes for instance the value and the form field name, java script actions and more.
     * @param 	array		"special" configuration - what is found at position 4 in the types configuration of a field from record, parsed into an array.
     * @param 	array		Configuration for RTEs; A mix between TSconfig and otherwise. Contains configuration for display, which buttons are enabled, additional transformation information etc.
     * @param 	string		Record "type" field value.
     * @param 	string		Relative path for images/links in RTE; this is used when the RTE edits content from static files where the path of such media has to be transformed forth and back!
     * @param 	integer		PID value of record (true parent page id)
     * @return 	string		HTML code for RTE!
     * @todo Define visibility
     */
    public function drawRTE(&$parentObject, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue)
    {
        global $TSFE, $TYPO3_CONF_VARS, $TYPO3_DB;
        $this->TCEform = $parentObject;
        $this->client = $this->clientInfo();
        $this->typoVersion = \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version);
        /* =======================================
         * INIT THE EDITOR-SETTINGS
         * =======================================
         */
        // Get the path to this extension:
        $this->extHttpPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath($this->ID);
        // Get the site URL
        $this->siteURL = $GLOBALS['TSFE']->absRefPrefix ?: '';
        // Get the host URL
        $this->hostURL = '';
        // Element ID + pid
        $this->elementId = $PA['itemFormElName'];
        $this->elementParts[0] = $table;
        $this->elementParts[1] = $row['uid'];
        $this->tscPID = $thePidValue;
        $this->thePid = $thePidValue;
        // Record "type" field value:
        $this->typeVal = $RTEtypeVal;
        // TCA "type" value for record
        // RTE configuration
        $pageTSConfig = $TSFE->getPagesTSconfig();
        if (is_array($pageTSConfig) && is_array($pageTSConfig['RTE.'])) {
            $this->RTEsetup = $pageTSConfig['RTE.'];
        }
        if (is_array($thisConfig) && !empty($thisConfig)) {
            $this->thisConfig = $thisConfig;
        } elseif (is_array($this->RTEsetup['default.']) && is_array($this->RTEsetup['default.']['FE.'])) {
            $this->thisConfig = $this->RTEsetup['default.']['FE.'];
        }
        // Special configuration (line) and default extras:
        $this->specConf = $specConf;
        if ($this->thisConfig['forceHTTPS']) {
            $this->extHttpPath = preg_replace('/^(http|https)/', 'https', $this->extHttpPath);
            $this->siteURL = preg_replace('/^(http|https)/', 'https', $this->siteURL);
            $this->hostURL = preg_replace('/^(http|https)/', 'https', $this->hostURL);
        }
        // Register RTE windows:
        $this->TCEform->RTEwindows[] = $PA['itemFormElName'];
        $textAreaId = preg_replace('/[^a-zA-Z0-9_:.-]/', '_', $PA['itemFormElName']);
        $textAreaId = htmlspecialchars(preg_replace('/^[^a-zA-Z]/', 'x', $textAreaId)) . '_' . strval($this->TCEform->RTEcounter);
        /* =======================================
         * LANGUAGES & CHARACTER SETS
         * =======================================
         */
        // Language
        $TSFE->initLLvars();
        $this->language = $TSFE->lang;
        $this->LOCAL_LANG = \TYPO3\CMS\Core\Utility\GeneralUtility::readLLfile('EXT:' . $this->ID . '/locallang.xml', $this->language);
        if ($this->language == 'default' || !$this->language) {
            $this->language = 'en';
        }
        $this->contentLanguageUid = max($row['sys_language_uid'], 0);
        if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('static_info_tables')) {
            if ($this->contentLanguageUid) {
                $tableA = 'sys_language';
                $tableB = 'static_languages';
                $languagesUidsList = $this->contentLanguageUid;
                $selectFields = $tableA . '.uid,' . $tableB . '.lg_iso_2,' . $tableB . '.lg_country_iso_2,' . $tableB . '.lg_typo3';
                $tableAB = $tableA . ' LEFT JOIN ' . $tableB . ' ON ' . $tableA . '.static_lang_isocode=' . $tableB . '.uid';
                $whereClause = $tableA . '.uid IN (' . $languagesUidsList . ') ';
                $whereClause .= \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($tableA);
                $whereClause .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($tableA);
                $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
                while ($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
                    $this->contentISOLanguage = strtolower(trim($languageRow['lg_iso_2']) . (trim($languageRow['lg_country_iso_2']) ? '_' . trim($languageRow['lg_country_iso_2']) : ''));
                    $this->contentTypo3Language = strtolower(trim($languageRow['lg_typo3']));
                }
            } else {
                $this->contentISOLanguage = $GLOBALS['TSFE']->sys_language_isocode ?: 'en';
                $selectFields = 'lg_iso_2, lg_typo3';
                $tableAB = 'static_languages';
                $whereClause = 'lg_iso_2 = ' . $TYPO3_DB->fullQuoteStr(strtoupper($this->contentISOLanguage), $tableAB);
                $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
                while ($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
                    $this->contentTypo3Language = strtolower(trim($languageRow['lg_typo3']));
                }
            }
        }
        $this->contentISOLanguage = $this->contentISOLanguage ?: ($GLOBALS['TSFE']->sys_language_isocode ?: 'en');
        $this->contentTypo3Language = $this->contentTypo3Language ?: $GLOBALS['TSFE']->lang;
        if ($this->contentTypo3Language == 'default') {
            $this->contentTypo3Language = 'en';
        }
        // Character set
        $this->charset = $TSFE->renderCharset;
        $this->OutputCharset = $TSFE->metaCharset ?: $TSFE->renderCharset;
        // Set the charset of the content
        $this->contentCharset = $TSFE->csConvObj->charSetArray[$this->contentTypo3Language];
        $this->contentCharset = $this->contentCharset ?: 'utf-8';
        $this->contentCharset = trim($TSFE->config['config']['metaCharset']) ?: $this->contentCharset;
        /* =======================================
         * TOOLBAR CONFIGURATION
         * =======================================
         */
        $this->initializeToolbarConfiguration();
        /* =======================================
         * SET STYLES
         * =======================================
         */
        $width = 610;
        if (isset($this->thisConfig['RTEWidthOverride'])) {
            if (strstr($this->thisConfig['RTEWidthOverride'], '%')) {
                if ($this->client['browser'] != 'msie') {
                    $width = (int) $this->thisConfig['RTEWidthOverride'] > 0 ? $this->thisConfig['RTEWidthOverride'] : '100%';
                }
            } else {
                $width = (int) $this->thisConfig['RTEWidthOverride'] > 0 ? (int) $this->thisConfig['RTEWidthOverride'] : $width;
            }
        }
        $RTEWidth = strstr($width, '%') ? $width : $width . 'px';
        $editorWrapWidth = strstr($width, '%') ? $width : $width + 2 . 'px';
        $height = 380;
        $RTEHeightOverride = (int) $this->thisConfig['RTEHeightOverride'];
        $height = $RTEHeightOverride > 0 ? $RTEHeightOverride : $height;
        $RTEHeight = $height . 'px';
        $editorWrapHeight = $height + 2 . 'px';
        $this->RTEWrapStyle = $this->RTEWrapStyle ?: ($this->RTEdivStyle ?: 'height:' . $editorWrapHeight . '; width:' . $editorWrapWidth . ';');
        $this->RTEdivStyle = $this->RTEdivStyle ?: 'position:relative; left:0px; top:0px; height:' . $RTEHeight . '; width:' . $RTEWidth . '; border: 1px solid black;';
        /* =======================================
         * LOAD JS, CSS and more
         * =======================================
         */
        $this->getPageRenderer();
        // Register RTE in JS
        $this->TCEform->additionalJS_post[] = $this->wrapCDATA($this->registerRTEinJS($this->TCEform->RTEcounter, '', '', '', $textAreaId));
        // Set the save option for the RTE:
        $this->TCEform->additionalJS_submit[] = $this->setSaveRTE($this->TCEform->RTEcounter, $this->TCEform->formName, $textAreaId);
        // Loading ExtJs JavaScript files and inline code, if not configured in TS setup
        if (!is_array($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.'])) {
            $this->pageRenderer->loadExtJs();
            $this->pageRenderer->enableExtJSQuickTips();
        }
        $this->pageRenderer->addJsFile($this->getFullFileName('typo3/js/extjs/ux/ext.resizable.js'));
        $this->pageRenderer->addJsFile('sysext/backend/Resources/Public/JavaScript/notifications.js');
        // Preloading the pageStyle and including RTE skin stylesheets
        $this->addPageStyle();
        $this->pageRenderer->addCssFile($this->siteURL . 'typo3/contrib/extjs/resources/css/ext-all-notheme.css');
        $this->pageRenderer->addCssFile($this->siteURL . 'typo3/sysext/t3skin/extjs/xtheme-t3skin.css');
        $this->addSkin();
        $this->pageRenderer->addCssFile($this->siteURL . 'typo3/js/extjs/ux/resize.css');
        // Add RTE JavaScript
        $this->addRteJsFiles($this->TCEform->RTEcounter);
        $this->pageRenderer->addJsFile($this->buildJSMainLangFile($this->TCEform->RTEcounter));
        $this->pageRenderer->addJsInlineCode('HTMLArea-init', $this->getRteInitJsCode(), TRUE);
        /* =======================================
         * DRAW THE EDITOR
         * =======================================
         */
        // Transform value:
        $value = $this->transformContent('rte', $PA['itemFormElValue'], $table, $field, $row, $specConf, $thisConfig, $RTErelPath, $thePidValue);
        // Further content transformation by registered plugins
        foreach ($this->registeredPlugins as $pluginId => $plugin) {
            if ($this->isPluginEnabled($pluginId) && method_exists($plugin, 'transformContent')) {
                $value = $plugin->transformContent($value);
            }
        }
        // draw the textarea
        $item = $this->triggerField($PA['itemFormElName']) . '
			<div id="pleasewait' . $textAreaId . '" class="pleasewait" style="display: block;" >' . $TSFE->csConvObj->conv($TSFE->getLLL('Please wait', $this->LOCAL_LANG), $this->charset, $TSFE->renderCharset) . '</div>
			<div id="editorWrap' . $textAreaId . '" class="editorWrap" style="visibility: hidden; ' . htmlspecialchars($this->RTEWrapStyle) . '">
			<textarea id="RTEarea' . $textAreaId . '" name="' . htmlspecialchars($PA['itemFormElName']) . '" rows="0" cols="0" style="' . htmlspecialchars($this->RTEdivStyle) . '">' . \TYPO3\CMS\Core\Utility\GeneralUtility::formatForTextarea($value) . '</textarea>
			</div>' . LF;
        return $item;
    }
Ejemplo n.º 19
0
    /**
     * Draws the RTE as an iframe
     *
     * @param FormEngine $parentObject Reference to parent object, which is an instance of the TCEforms.
     * @param string $table The table name
     * @param string $field The field name
     * @param array $row The current row from which field is being rendered
     * @param array $PA Array of standard content for rendering form fields from TCEforms. See TCEforms for details on this. Includes for instance the value and the form field name, java script actions and more.
     * @param array $specConf "special" configuration - what is found at position 4 in the types configuration of a field from record, parsed into an array.
     * @param array $thisConfig Configuration for RTEs; A mix between TSconfig and otherwise. Contains configuration for display, which buttons are enabled, additional transformation information etc.
     * @param string $RTEtypeVal Record "type" field value.
     * @param string $RTErelPath Relative path for images/links in RTE; this is used when the RTE edits content from static files where the path of such media has to be transformed forth and back!
     * @param integer $thePidValue PID value of record (true parent page id)
     * @return string HTML code for RTE!
     * @todo Define visibility
     */
    public function drawRTE($parentObject, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue)
    {
        global $LANG, $TYPO3_DB;
        $this->TCEform = $parentObject;
        $inline = $this->TCEform->inline;
        $LANG->includeLLFile('EXT:' . $this->ID . '/locallang.xml');
        $this->client = $this->clientInfo();
        $this->typoVersion = \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version);
        $this->userUid = 'BE_' . $GLOBALS['BE_USER']->user['uid'];
        // Draw form element:
        if ($this->debugMode) {
            // Draws regular text area (debug mode)
            $item = parent::drawRTE($this->TCEform, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue);
        } else {
            // Draw real RTE
            /* =======================================
             * INIT THE EDITOR-SETTINGS
             * =======================================
             */
            // Set backPath
            $this->backPath = $this->TCEform->backPath;
            // Get the path to this extension:
            $this->extHttpPath = $this->backPath . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($this->ID);
            // Get the site URL
            $this->siteURL = GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
            // Get the host URL
            $this->hostURL = $this->siteURL . TYPO3_mainDir;
            // Element ID + pid
            $this->elementId = $PA['itemFormElName'];
            // Form element name
            $this->elementParts = explode('][', preg_replace('/\\]$/', '', preg_replace('/^(TSFE_EDIT\\[data\\]\\[|data\\[)/', '', $this->elementId)));
            // Find the page PIDs:
            list($this->tscPID, $this->thePid) = BackendUtility::getTSCpid(trim($this->elementParts[0]), trim($this->elementParts[1]), $thePidValue);
            // Record "types" field value:
            $this->typeVal = $RTEtypeVal;
            // TCA "types" value for record
            // Find "thisConfig" for record/editor:
            unset($this->RTEsetup);
            $this->RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', BackendUtility::getPagesTSconfig($this->tscPID));
            $this->thisConfig = $thisConfig;
            // Special configuration and default extras:
            $this->specConf = $specConf;
            if ($this->thisConfig['forceHTTPS']) {
                $this->extHttpPath = preg_replace('/^(http|https)/', 'https', $this->extHttpPath);
                $this->siteURL = preg_replace('/^(http|https)/', 'https', $this->siteURL);
                $this->hostURL = preg_replace('/^(http|https)/', 'https', $this->hostURL);
            }
            // Register RTE windows
            $this->TCEform->RTEwindows[] = $PA['itemFormElName'];
            $textAreaId = preg_replace('/[^a-zA-Z0-9_:.-]/', '_', $PA['itemFormElName']);
            $textAreaId = htmlspecialchars(preg_replace('/^[^a-zA-Z]/', 'x', $textAreaId));
            /* =======================================
             * LANGUAGES & CHARACTER SETS
             * =======================================
             */
            // Languages: interface and content
            $this->language = $LANG->lang;
            if ($this->language == 'default' || !$this->language) {
                $this->language = 'en';
            }
            $this->contentTypo3Language = $this->language == 'en' ? 'default' : $this->language;
            $this->contentISOLanguage = 'en';
            $this->contentLanguageUid = max($row['sys_language_uid'], 0);
            if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('static_info_tables')) {
                if ($this->contentLanguageUid) {
                    $tableA = 'sys_language';
                    $tableB = 'static_languages';
                    $languagesUidsList = $this->contentLanguageUid;
                    $selectFields = $tableA . '.uid,' . $tableB . '.lg_iso_2,' . $tableB . '.lg_country_iso_2,' . $tableB . '.lg_typo3';
                    $tableAB = $tableA . ' LEFT JOIN ' . $tableB . ' ON ' . $tableA . '.static_lang_isocode=' . $tableB . '.uid';
                    $whereClause = $tableA . '.uid IN (' . $languagesUidsList . ') ';
                    $whereClause .= BackendUtility::BEenableFields($tableA);
                    $whereClause .= BackendUtility::deleteClause($tableA);
                    $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
                    while ($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
                        $this->contentISOLanguage = strtolower(trim($languageRow['lg_iso_2']) . (trim($languageRow['lg_country_iso_2']) ? '_' . trim($languageRow['lg_country_iso_2']) : ''));
                        $this->contentTypo3Language = trim($languageRow['lg_typo3']) ? strtolower(trim($languageRow['lg_typo3'])) : 'default';
                    }
                } else {
                    $this->contentISOLanguage = trim($this->thisConfig['defaultContentLanguage']) ?: 'en';
                    $selectFields = 'lg_iso_2, lg_typo3';
                    $tableAB = 'static_languages';
                    $whereClause = 'lg_iso_2 = ' . $TYPO3_DB->fullQuoteStr(strtoupper($this->contentISOLanguage), $tableAB);
                    $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
                    while ($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
                        $this->contentTypo3Language = trim($languageRow['lg_typo3']) ? strtolower(trim($languageRow['lg_typo3'])) : 'default';
                    }
                }
            }
            // Create content laguage service
            $this->contentLanguageService = GeneralUtility::makeInstance('TYPO3\\CMS\\Lang\\LanguageService');
            $this->contentLanguageService->init($this->contentTypo3Language);
            /* =======================================
             * TOOLBAR CONFIGURATION
             * =======================================
             */
            $this->initializeToolbarConfiguration();
            /* =======================================
             * SET STYLES
             * =======================================
             */
            // Check if wizard_rte called this for fullscreen edtition
            if (GeneralUtility::_GP('M') === 'wizard_rte') {
                $this->fullScreen = TRUE;
                $RTEWidth = '100%';
                $RTEHeight = '100%';
                $RTEPaddingRight = '0';
                $editorWrapWidth = '100%';
            } else {
                $options = $GLOBALS['BE_USER']->userTS['options.'];
                $RTEWidth = 530 + (isset($options['RTELargeWidthIncrement']) ? (int) $options['RTELargeWidthIncrement'] : 150);
                $RTEWidth -= $inline->getStructureDepth() > 0 ? ($inline->getStructureDepth() + 1) * $inline->getLevelMargin() : 0;
                $RTEWidthOverride = is_object($GLOBALS['BE_USER']) && isset($GLOBALS['BE_USER']->uc['rteWidth']) && trim($GLOBALS['BE_USER']->uc['rteWidth']) ? trim($GLOBALS['BE_USER']->uc['rteWidth']) : trim($this->thisConfig['RTEWidthOverride']);
                if ($RTEWidthOverride) {
                    if (strstr($RTEWidthOverride, '%')) {
                        if ($this->client['browser'] != 'msie') {
                            $RTEWidth = (int) $RTEWidthOverride > 0 ? $RTEWidthOverride : '100%';
                        }
                    } else {
                        $RTEWidth = (int) $RTEWidthOverride > 0 ? (int) $RTEWidthOverride : $RTEWidth;
                    }
                }
                $RTEWidth = strstr($RTEWidth, '%') ? $RTEWidth : $RTEWidth . 'px';
                $RTEHeight = 380 + (isset($options['RTELargeHeightIncrement']) ? (int) $options['RTELargeHeightIncrement'] : 0);
                $RTEHeightOverride = is_object($GLOBALS['BE_USER']) && isset($GLOBALS['BE_USER']->uc['rteHeight']) && (int) $GLOBALS['BE_USER']->uc['rteHeight'] ? (int) $GLOBALS['BE_USER']->uc['rteHeight'] : (int) $this->thisConfig['RTEHeightOverride'];
                $RTEHeight = $RTEHeightOverride > 0 ? $RTEHeightOverride : $RTEHeight;
                $RTEPaddingRight = '2px';
                $editorWrapWidth = '99%';
            }
            $editorWrapHeight = '100%';
            $this->RTEdivStyle = 'position:relative; left:0px; top:0px; height:' . $RTEHeight . 'px; width:' . $RTEWidth . '; border: 1px solid black; padding: 2px ' . $RTEPaddingRight . ' 2px 2px;';
            /* =======================================
             * LOAD CSS AND JAVASCRIPT
             * =======================================
             */
            $this->pageRenderer = $GLOBALS['SOBE']->doc->getPageRenderer();
            // Preloading the pageStyle and including RTE skin stylesheets
            $this->addPageStyle();
            $this->addSkin();
            // Register RTE in JS
            $this->TCEform->additionalJS_post[] = $this->registerRTEinJS($this->TCEform->RTEcounter, $table, $row['uid'], $field, $textAreaId);
            // Set the save option for the RTE
            $this->TCEform->additionalJS_submit[] = $this->setSaveRTE($this->TCEform->RTEcounter, $this->TCEform->formName, $textAreaId, $PA['itemFormElName']);
            $this->TCEform->additionalJS_delete[] = $this->setDeleteRTE($this->TCEform->RTEcounter, $this->TCEform->formName, $textAreaId);
            // Loading ExtJs inline code
            $this->pageRenderer->enableExtJSQuickTips();
            // Add TYPO3 notifications JavaScript
            $this->pageRenderer->addJsFile('sysext/backend/Resources/Public/JavaScript/notifications.js');
            // Add RTE JavaScript
            $this->addRteJsFiles($this->TCEform->RTEcounter);
            $this->pageRenderer->addJsFile($this->buildJSMainLangFile($this->TCEform->RTEcounter));
            $this->pageRenderer->addJsInlineCode('HTMLArea-init', $this->getRteInitJsCode(), TRUE);
            /* =======================================
             * DRAW THE EDITOR
             * =======================================
             */
            // Transform value:
            $value = $this->transformContent('rte', $PA['itemFormElValue'], $table, $field, $row, $specConf, $thisConfig, $RTErelPath, $thePidValue);
            // Further content transformation by registered plugins
            foreach ($this->registeredPlugins as $pluginId => $plugin) {
                if ($this->isPluginEnabled($pluginId) && method_exists($plugin, 'transformContent')) {
                    $value = $plugin->transformContent($value);
                }
            }
            // Draw the textarea
            $visibility = 'hidden';
            $item = $this->triggerField($PA['itemFormElName']) . '
				<div id="pleasewait' . $textAreaId . '" class="pleasewait" style="display: block;" >' . $LANG->getLL('Please wait') . '</div>
				<div id="editorWrap' . $textAreaId . '" class="editorWrap" style="visibility: hidden; width:' . $editorWrapWidth . '; height:' . $editorWrapHeight . ';">
				<textarea id="RTEarea' . $textAreaId . '" name="' . htmlspecialchars($PA['itemFormElName']) . '" rows="0" cols="0" style="' . htmlspecialchars($this->RTEdivStyle, ENT_COMPAT, 'UTF-8', FALSE) . '">' . GeneralUtility::formatForTextarea($value) . '</textarea>
				</div>' . LF;
        }
        // Return form item:
        return $item;
    }
Ejemplo n.º 20
0
    /**
     * Main function, redering the actual content of the editing page
     *
     * @return void
     */
    public function main()
    {
        $docHeaderButtons = $this->getButtons();
        $this->content = $this->doc->startPage($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:file_edit.php.pagetitle'));
        // Hook	before compiling the output
        if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['preOutputProcessingHook'])) {
            $preOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['preOutputProcessingHook'];
            if (is_array($preOutputProcessingHook)) {
                $hookParameters = array('content' => &$this->content, 'target' => &$this->target);
                foreach ($preOutputProcessingHook as $hookFunction) {
                    GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this);
                }
            }
        }
        $pageContent = $this->doc->header($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:file_edit.php.pagetitle') . ' ' . htmlspecialchars($this->fileObject->getName()));
        $pageContent .= $this->doc->spacer(2);
        $code = '';
        $extList = $GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'];
        try {
            if (!$extList || !GeneralUtility::inList($extList, $this->fileObject->getExtension())) {
                throw new \Exception('Files with that extension are not editable.');
            }
            // Read file content to edit:
            $fileContent = $this->fileObject->getContents();
            // Making the formfields
            $hValue = BackendUtility::getModuleUrl('file_edit', array('target' => $this->origTarget, 'returnUrl' => $this->returnUrl));
            // Edit textarea:
            $code .= '
				<div id="c-edit">
					<textarea rows="30" name="file[editfile][0][data]" wrap="off" ' . $this->doc->formWidth(48, TRUE, 'width:98%;height:80%') . ' class="text-monospace t3js-enable-tab">' . GeneralUtility::formatForTextarea($fileContent) . '</textarea>
					<input type="hidden" name="file[editfile][0][target]" value="' . $this->fileObject->getUid() . '" />
					<input type="hidden" name="redirect" value="' . htmlspecialchars($hValue) . '" />
					' . \TYPO3\CMS\Backend\Form\FormEngine::getHiddenTokenField('tceAction') . '
				</div>
				<br />';
            // Make shortcut:
            if ($this->getBackendUser()->mayMakeShortcut()) {
                $docHeaderButtons['shortcut'] = $this->doc->makeShortcutIcon('target', '', 'file_edit', 1);
            } else {
                $docHeaderButtons['shortcut'] = '';
            }
        } catch (\Exception $e) {
            $code .= sprintf($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:file_edit.php.coundNot'), $extList);
        }
        // Ending of section and outputting editing form:
        $pageContent .= $this->doc->sectionEnd();
        $pageContent .= $code;
        // Hook	after compiling the output
        if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['postOutputProcessingHook'])) {
            $postOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['postOutputProcessingHook'];
            if (is_array($postOutputProcessingHook)) {
                $hookParameters = array('pageContent' => &$pageContent, 'target' => &$this->target);
                foreach ($postOutputProcessingHook as $hookFunction) {
                    GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this);
                }
            }
        }
        // Add the HTML as a section:
        $markerArray = array('CSH' => $docHeaderButtons['csh'], 'FUNC_MENU' => '', 'BUTTONS' => $docHeaderButtons, 'PATH' => $this->title, 'CONTENT' => $pageContent);
        $this->content .= $this->doc->moduleBody(array(), $docHeaderButtons, $markerArray);
        $this->content .= $this->doc->endPage();
        $this->content = $this->doc->insertStylesAndJS($this->content);
    }
Ejemplo n.º 21
0
 /**
  * This will render a <textarea>
  *
  * @return array As defined in initializeResultArray() of AbstractNode
  */
 public function render()
 {
     $languageService = $this->getLanguageService();
     $table = $this->globalOptions['table'];
     $fieldName = $this->globalOptions['fieldName'];
     $row = $this->globalOptions['databaseRow'];
     $parameterArray = $this->globalOptions['parameterArray'];
     $resultArray = $this->initializeResultArray();
     $backendUser = $this->getBackendUserAuthentication();
     $config = $parameterArray['fieldConf']['config'];
     // Setting columns number
     $cols = MathUtility::forceIntegerInRange($config['cols'] ?: $this->defaultInputWidth, $this->minimumInputWidth, $this->maxInputWidth);
     // Setting number of rows
     $rows = MathUtility::forceIntegerInRange($config['rows'] ?: 5, 1, 20);
     $originalRows = $rows;
     $itemFormElementValueLength = strlen($parameterArray['itemFormElValue']);
     if ($itemFormElementValueLength > $this->charactersPerRow * 2) {
         $cols = $this->maxInputWidth;
         $rows = MathUtility::forceIntegerInRange(round($itemFormElementValueLength / $this->charactersPerRow), count(explode(LF, $parameterArray['itemFormElValue'])), 20);
         if ($rows < $originalRows) {
             $rows = $originalRows;
         }
     }
     // must be called after the cols and rows calculation, so the parameters are applied
     // to read-only fields as well.
     // @todo: Same as in InputElement ...
     if ($this->isGlobalReadonly() || $config['readOnly']) {
         $config['cols'] = $cols;
         $config['rows'] = $rows;
         $options = $this->globalOptions;
         $options['parameterArray'] = array('fieldConf' => array('config' => $config), 'itemFormElValue' => $parameterArray['itemFormElValue']);
         $options['renderType'] = 'none';
         /** @var NodeFactory $nodeFactory */
         $nodeFactory = $this->globalOptions['nodeFactory'];
         return $nodeFactory->create($options)->render();
     }
     $evalList = GeneralUtility::trimExplode(',', $config['eval'], TRUE);
     // "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. Traditionally, this is where RTE configuration has been found.
     $specialConfiguration = BackendUtility::getSpecConfParts($parameterArray['fieldConf']['defaultExtras']);
     // Setting up the altItem form field, which is a hidden field containing the value
     $altItem = '<input type="hidden" name="' . htmlspecialchars($parameterArray['itemFormElName']) . '" value="' . htmlspecialchars($parameterArray['itemFormElValue']) . '" />';
     $html = '';
     // Show message, if no RTE (field can only be edited with RTE!)
     if ($specialConfiguration['rte_only']) {
         $html = '<p><em>' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.noRTEfound')) . '</em></p>';
     } else {
         $attributes = array();
         // validation
         foreach ($evalList as $func) {
             if ($func === 'required') {
                 $attributes['data-formengine-validation-rules'] = $this->getValidationDataAsJsonString(array('required' => TRUE));
             } else {
                 // @todo: This is ugly: The code should find out on it's own whether a eval definition is a
                 // @todo: keyword like "date", or a class reference. The global registration could be dropped then
                 // Pair hook to the one in \TYPO3\CMS\Core\DataHandling\DataHandler::checkValue_input_Eval()
                 // There is a similar hook for "evaluateFieldValue" in DataHandler and InputElement
                 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func])) {
                     if (class_exists($func)) {
                         $evalObj = GeneralUtility::makeInstance($func);
                         if (method_exists($evalObj, 'deevaluateFieldValue')) {
                             $_params = array('value' => $parameterArray['itemFormElValue']);
                             $parameterArray['itemFormElValue'] = $evalObj->deevaluateFieldValue($_params);
                         }
                     }
                 }
             }
         }
         // calculate classes
         $classes = array();
         $classes[] = 'form-control';
         $classes[] = 't3js-formengine-textarea';
         if ($specialConfiguration['fixed-font']) {
             $classes[] = 'text-monospace';
         }
         if ($specialConfiguration['enable-tab']) {
             $classes[] = 't3js-enable-tab';
         }
         // calculate styles
         $styles = array();
         // add the max-height from the users' preference to it
         $maximumHeight = (int) $backendUser->uc['resizeTextareas_MaxHeight'];
         if ($maximumHeight > 0) {
             $styles[] = 'max-height: ' . $maximumHeight . 'px';
         }
         // calculate attributes
         $attributes['id'] = str_replace('.', '', uniqid('formengine-textarea-', TRUE));
         $attributes['name'] = $parameterArray['itemFormElName'];
         if (!empty($styles)) {
             $attributes['style'] = implode(' ', $styles);
         }
         if (!empty($classes)) {
             $attributes['class'] = implode(' ', $classes);
         }
         $attributes['rows'] = $rows;
         $attributes['wrap'] = $specialConfiguration['nowrap'] ? 'off' : ($config['wrap'] ?: 'virtual');
         $attributes['onChange'] = implode('', $parameterArray['fieldChangeFunc']);
         if (isset($config['max']) && (int) $config['max'] > 0) {
             $attributes['maxlength'] = (int) $config['max'];
         }
         $attributeString = '';
         foreach ($attributes as $attributeName => $attributeValue) {
             $attributeString .= ' ' . $attributeName . '="' . htmlspecialchars($attributeValue) . '"';
         }
         // Build the textarea
         $placeholderValue = $this->getPlaceholderValue($table, $config, $row);
         $placeholderAttribute = '';
         if (!empty($placeholderValue)) {
             $placeholderAttribute = ' placeholder="' . htmlspecialchars(trim($languageService->sL($placeholderValue))) . '" ';
         }
         $html .= '<textarea' . $attributeString . $placeholderAttribute . $parameterArray['onFocus'] . '>' . GeneralUtility::formatForTextarea($parameterArray['itemFormElValue']) . '</textarea>';
         // Wrap a wizard around the item?
         $html = $this->renderWizards(array($html, $altItem), $config['wizards'], $table, $row, $fieldName, $parameterArray, $parameterArray['itemFormElName'], $specialConfiguration, FALSE);
         $maximumWidth = (int) $this->formMaxWidth($cols);
         $html = '<div class="form-control-wrap"' . ($maximumWidth ? ' style="max-width: ' . $maximumWidth . 'px"' : '') . '>' . $html . '</div>';
     }
     $resultArray['html'] = $html;
     return $resultArray;
 }