Beispiel #1
0
 /**
  * Process every columns of a row to convert value
  *
  * @param array  $row
  * @param string $table
  * @return array
  */
 public static function getResultRow($row, $table, $excludeFields = '', $export = false)
 {
     $record = array();
     foreach ($row as $fieldName => $fieldValue) {
         if (!\TYPO3\CMS\Core\Utility\GeneralUtility::inList($excludeFields, $fieldName)) {
             $record[$fieldName] = \TYPO3\CMS\Backend\Utility\BackendUtility::getProcessedValueExtra($table, $fieldName, $fieldValue, 0, $row['uid']);
             if (trim($record[$fieldName]) == 'N/A') {
                 $record[$fieldName] = '';
             }
         } else {
             if (!\TYPO3\CMS\Core\Utility\GeneralUtility::inList('input', $GLOBALS['TCA'][$table]['columns'][$fieldName]['config']['type'])) {
                 $record[$fieldName] = \TYPO3\CMS\Backend\Utility\BackendUtility::getProcessedValue($table, $fieldName, $fieldValue, 0, 1, 1, $row['uid'], true);
             } else {
                 $record[$fieldName] = $fieldValue;
             }
             if ($GLOBALS['TCA'][$table]['columns'][$fieldName]['config']['type'] == 'input') {
                 if ($GLOBALS['TCA'][$table]['columns'][$fieldName]['config']['eval'] == 'datetime' || $GLOBALS['TCA'][$table]['columns'][$fieldName]['config']['eval'] == 'date') {
                     $record[$fieldName] = $fieldValue;
                 }
             }
             if (empty($record[$fieldName])) {
                 $record[$fieldName] = $fieldValue;
             }
             if (trim($record[$fieldName]) == 'N/A') {
                 $record[$fieldName] = '';
             }
         }
         if ($export === true) {
             // add path to files
             if ($GLOBALS['TCA'][$table]['columns'][$fieldName]['config']['type'] == 'group' && $GLOBALS['TCA'][$table]['columns'][$fieldName]['config']['internal_type'] == 'file') {
                 if (!empty($record[$fieldName])) {
                     $files = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $record[$fieldName]);
                     $newFiles = array();
                     foreach ($files as $file) {
                         $newFiles[] = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_HOST') . '/' . $GLOBALS['TCA'][$table]['columns'][$fieldName]['config']['uploadfolder'] . '/' . $file;
                     }
                     $record[$fieldName] = implode(', ', $newFiles);
                 }
             }
             if ($GLOBALS['TCA'][$table]['columns'][$fieldName]['config']['type'] == 'text' && !empty($GLOBALS['TCA'][$table]['columns'][$fieldName]['config']['wizards']['RTE'])) {
                 $lCobj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
                 $lCobj->start(array(), '');
                 $record[$fieldName] = $lCobj->parseFunc($record[$fieldName], array(), '< lib.parseFunc_RTE');
             }
         }
     }
     return $record;
 }
 /**
  * Get the result row with getProcessedValueExtra()
  * It allow you to respect the TCA rules
  *
  * @param  array  $row
  * @param  string $table
  * @return array
  */
 public static function getResultRow($row, $table)
 {
     $record = array();
     foreach ($row as $fieldName => $fieldValue) {
         if (TYPO3_MODE == 'FE') {
             // $GLOBALS['TSFE']->includeTCA();
             $GLOBALS['LANG'] = TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Lang\\LanguageService');
             $GLOBALS['LANG']->init($GLOBALS['TSFE']->tmpl->setup['config.']['language']);
         }
         $record[$fieldName] = \TYPO3\CMS\Backend\Utility\BackendUtility::getProcessedValueExtra($table, $fieldName, $fieldValue, 0, $row['uid']);
     }
     return $record;
 }
    /**
     * Render property array as html table
     *
     * @return string
     */
    protected function renderPropertiesAsTable()
    {
        $tableRows = array();
        $extraFields = array();
        if (in_array($this->type, array('folder', 'file'), TRUE)) {
            if ($this->type === 'file') {
                $extraFields['creation_date'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationDate', TRUE);
                $extraFields['modification_date'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.timestamp', TRUE);
            }
            $extraFields['storage'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_tca.xlf:sys_file.storage', TRUE);
            $extraFields['folder'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:folder', TRUE);
        } else {
            $extraFields['crdate'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationDate', TRUE);
            $extraFields['cruser_id'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationUserId', TRUE);
            $extraFields['tstamp'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.timestamp', TRUE);
            // check if the special fields are defined in the TCA ctrl section of the table
            foreach ($extraFields as $fieldName => $fieldLabel) {
                if (isset($GLOBALS['TCA'][$this->table]['ctrl'][$fieldName])) {
                    $extraFields[$GLOBALS['TCA'][$this->table]['ctrl'][$fieldName]] = $fieldLabel;
                } else {
                    unset($extraFields[$fieldName]);
                }
            }
        }
        foreach ($extraFields as $name => $fieldLabel) {
            $rowValue = '';
            if (!isset($this->row[$name])) {
                $resourceObject = $this->fileObject ?: $this->folderObject;
                if ($name === 'storage') {
                    $rowValue = $resourceObject->getStorage()->getName();
                } elseif ($name === 'folder') {
                    $rowValue = $resourceObject->getParentFolder()->getReadablePath();
                }
            } elseif (in_array($name, array('creation_date', 'modification_date'), TRUE)) {
                $rowValue = BackendUtility::datetime($this->row[$name]);
            } else {
                $rowValue = BackendUtility::getProcessedValueExtra($this->table, $name, $this->row[$name]);
            }
            // show the backend username who created the issue
            if ($name === 'cruser_id' && $rowValue) {
                $userTemp = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('username, realName', 'be_users', 'uid = ' . (int) $rowValue);
                if ($userTemp['username'] !== '') {
                    $rowValue = $userTemp['username'];
                    if ($userTemp['realName'] !== '') {
                        $rowValue .= ' - ' . $userTemp['realName'];
                    }
                }
            }
            $tableRows[] = '
				<tr>
					<th>' . rtrim($fieldLabel, ':') . '</th>
					<td>' . htmlspecialchars($rowValue) . '</td>
				</tr>';
        }
        // Traverse the list of fields to display for the record:
        $fieldList = GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$this->table]['interface']['showRecordFieldList'], TRUE);
        foreach ($fieldList as $name) {
            $name = trim($name);
            $uid = $this->row['uid'];
            if (!isset($GLOBALS['TCA'][$this->table]['columns'][$name])) {
                continue;
            }
            // Storage is already handled above
            if ($this->type === 'file' && $name === 'storage') {
                continue;
            }
            $isExcluded = !(!$GLOBALS['TCA'][$this->table]['columns'][$name]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $this->table . ':' . $name));
            if ($isExcluded) {
                continue;
            }
            $itemValue = BackendUtility::getProcessedValue($this->table, $name, $this->row[$name], 0, 0, FALSE, $uid);
            $itemLabel = $GLOBALS['LANG']->sL(BackendUtility::getItemLabel($this->table, $name), TRUE);
            $tableRows[] = '
				<tr>
					<td><strong>' . $itemLabel . '</strong></td>
					<td>' . htmlspecialchars($itemValue) . '</td>
				</tr>';
        }
        return '<table class="t3-table">' . implode('', $tableRows) . '</table>';
    }
    /**
     * Renders the HTML header for a foreign record, such as the title, toggle-function, drag'n'drop, etc.
     * Later on the command-icons are inserted here.
     *
     * @param string $parentUid The uid of the parent (embedding) record (uid or NEW...)
     * @param string $foreign_table The foreign_table we create a header for
     * @param array $data Current data
     * @param array $config content of $PA['fieldConf']['config']
     * @param bool $isVirtualRecord
     * @return string The HTML code of the header
     */
    protected function renderForeignRecordHeader($parentUid, $foreign_table, $data, $config, $isVirtualRecord = false)
    {
        $rec = $data['databaseRow'];
        // Init:
        $domObjectId = $this->inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($this->data['inlineFirstPid']);
        $objectId = $domObjectId . '-' . $foreign_table . '-' . $rec['uid'];
        // We need the returnUrl of the main script when loading the fields via AJAX-call (to correct wizard code, so include it as 3rd parameter)
        // Pre-Processing:
        $isOnSymmetricSide = RelationHandler::isOnSymmetricSide($parentUid, $config, $rec);
        $hasForeignLabel = (bool) (!$isOnSymmetricSide && $config['foreign_label']);
        $hasSymmetricLabel = (bool) $isOnSymmetricSide && $config['symmetric_label'];
        // Get the record title/label for a record:
        // Try using a self-defined user function only for formatted labels
        if (isset($GLOBALS['TCA'][$foreign_table]['ctrl']['formattedLabel_userFunc'])) {
            $params = array('table' => $foreign_table, 'row' => $rec, 'title' => '', 'isOnSymmetricSide' => $isOnSymmetricSide, 'options' => isset($GLOBALS['TCA'][$foreign_table]['ctrl']['formattedLabel_userFunc_options']) ? $GLOBALS['TCA'][$foreign_table]['ctrl']['formattedLabel_userFunc_options'] : array(), 'parent' => array('uid' => $parentUid, 'config' => $config));
            // callUserFunction requires a third parameter, but we don't want to give $this as reference!
            $null = null;
            GeneralUtility::callUserFunction($GLOBALS['TCA'][$foreign_table]['ctrl']['formattedLabel_userFunc'], $params, $null);
            $recTitle = $params['title'];
            // Try using a normal self-defined user function
        } elseif (isset($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc'])) {
            $recTitle = $data['recordTitle'];
        } elseif ($hasForeignLabel || $hasSymmetricLabel) {
            $titleCol = $hasForeignLabel ? $config['foreign_label'] : $config['symmetric_label'];
            // Render title for everything else than group/db:
            if (isset($this->data['processedTca']['columns'][$titleCol]['config']['type']) && $this->data['processedTca']['columns'][$titleCol]['config']['type'] === 'group' && isset($this->data['processedTca']['columns'][$titleCol]['config']['internal_type']) && $this->data['processedTca']['columns'][$titleCol]['config']['internal_type'] === 'db') {
                $recTitle = BackendUtility::getProcessedValueExtra($foreign_table, $titleCol, $rec[$titleCol], 0, 0, false);
            } else {
                // $recTitle could be something like: "tx_table_123|...",
                $valueParts = GeneralUtility::trimExplode('|', $rec[$titleCol]);
                $itemParts = GeneralUtility::revExplode('_', $valueParts[0], 2);
                $recTemp = BackendUtility::getRecordWSOL($itemParts[0], $itemParts[1]);
                $recTitle = BackendUtility::getRecordTitle($itemParts[0], $recTemp, false);
            }
            $recTitle = BackendUtility::getRecordTitlePrep($recTitle);
            if (trim($recTitle) === '') {
                $recTitle = BackendUtility::getNoRecordTitle(true);
            }
        } else {
            $recTitle = BackendUtility::getRecordTitle($foreign_table, FormEngineUtility::databaseRowCompatibility($rec), true);
        }
        $altText = BackendUtility::getRecordIconAltText($rec, $foreign_table);
        $iconImg = '<span title="' . $altText . '" id="' . htmlspecialchars($objectId) . '_icon' . '">' . $this->iconFactory->getIconForRecord($foreign_table, $rec, Icon::SIZE_SMALL)->render() . '</span>';
        $label = '<span id="' . $objectId . '_label">' . $recTitle . '</span>';
        $ctrl = $this->renderForeignRecordHeaderControl($parentUid, $foreign_table, $data, $config, $isVirtualRecord);
        $thumbnail = false;
        // Renders a thumbnail for the header
        if (!empty($config['appearance']['headerThumbnail']['field'])) {
            $fieldValue = $rec[$config['appearance']['headerThumbnail']['field']];
            $firstElement = array_shift(GeneralUtility::trimExplode('|', array_shift(GeneralUtility::trimExplode(',', $fieldValue))));
            $fileUid = array_pop(BackendUtility::splitTable_Uid($firstElement));
            if (!empty($fileUid)) {
                $fileObject = ResourceFactory::getInstance()->getFileObject($fileUid);
                if ($fileObject && $fileObject->isMissing()) {
                    $flashMessage = \TYPO3\CMS\Core\Resource\Utility\BackendUtility::getFlashMessageForMissingFile($fileObject);
                    $thumbnail = $flashMessage->render();
                } elseif ($fileObject) {
                    $imageSetup = $config['appearance']['headerThumbnail'];
                    unset($imageSetup['field']);
                    if (!empty($rec['crop'])) {
                        $imageSetup['crop'] = $rec['crop'];
                    }
                    $imageSetup = array_merge(array('width' => '45', 'height' => '45c'), $imageSetup);
                    $processedImage = $fileObject->process(ProcessedFile::CONTEXT_IMAGECROPSCALEMASK, $imageSetup);
                    // Only use a thumbnail if the processing process was successful by checking if image width is set
                    if ($processedImage->getProperty('width')) {
                        $imageUrl = $processedImage->getPublicUrl(true);
                        $thumbnail = '<img src="' . $imageUrl . '" ' . 'width="' . $processedImage->getProperty('width') . '" ' . 'height="' . $processedImage->getProperty('height') . '" ' . 'alt="' . htmlspecialchars($altText) . '" ' . 'title="' . htmlspecialchars($altText) . '">';
                    }
                }
            }
        }
        if (!empty($config['appearance']['headerThumbnail']['field']) && $thumbnail) {
            $mediaContainer = '<div class="form-irre-header-cell form-irre-header-thumbnail" id="' . $objectId . '_thumbnailcontainer">' . $thumbnail . '</div>';
        } else {
            $mediaContainer = '<div class="form-irre-header-cell form-irre-header-icon" id="' . $objectId . '_iconcontainer">' . $iconImg . '</div>';
        }
        $header = $mediaContainer . '
				<div class="form-irre-header-cell form-irre-header-body">' . $label . '</div>
				<div class="form-irre-header-cell form-irre-header-control t3js-formengine-irre-control">' . $ctrl . '</div>';
        return $header;
    }
    /**
     * Renders the value list to a value
     *
     * @param array $parameter Parameter
     *
     * @return string HTML-Content
     */
    public function valuelist(array $parameter)
    {
        $database = $this->getDatabaseConnection();
        $language = $this->getLanguageService();
        $content = '';
        $foreignTable = 'tx_commerce_attribute_values';
        $table = 'tx_commerce_attributes';
        /**
         * Document template
         *
         * @var \TYPO3\CMS\Backend\Template\SmallDocumentTemplate $doc
         */
        $doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\SmallDocumentTemplate');
        $doc->backPath = $GLOBALS['BACK_PATH'];
        $attributeStoragePid = $parameter['row']['pid'];
        $attributeUid = $parameter['row']['uid'];
        /**
         * Select Attribute Values
         */
        // @todo TS config of fields in list
        $rowFields = array('attributes_uid', 'value');
        $titleCol = $GLOBALS['TCA'][$foreignTable]['ctrl']['label'];
        // Create the SQL query for selecting the elements in the listing:
        $result = $database->exec_SELECTquery('*', $foreignTable, 'pid = $attributeStoragePid ' . BackendUtility::deleteClause($foreignTable) . ' AND attributes_uid=\'' . $database->quoteStr($attributeUid, $foreignTable) . '\'');
        $dbCount = $database->sql_num_rows($result);
        $out = '';
        if ($dbCount) {
            /**
             * Only if we have a result
             */
            $theData[$titleCol] = '<span class="c-table">' . $language->sL('LLL:EXT:commerce/Resources/Private/Language/locallang_be.xml:attributeview.valuelist', 1) . '</span> (' . $dbCount . ')';
            $fieldCount = count($rowFields);
            $out .= '
					<tr>
						<td class="c-headLineTable" style="width:95%;" colspan="' . ($fieldCount + 1) . '">' . $theData[$titleCol] . '</td>
					</tr>';
            /**
             * Header colum
             */
            $out .= '<tr>';
            foreach ($rowFields as $field) {
                $out .= '<td class="c-headLineTable"><b>' . $language->sL(BackendUtility::getItemLabel($foreignTable, $field)) . '</b></td>';
            }
            $out .= '<td class="c-headLineTable"></td>';
            $out .= '</tr>';
            /**
             * Walk true Data
             */
            $cc = 0;
            $iOut = '';
            while ($row = $database->sql_fetch_assoc($result)) {
                $cc++;
                $rowBackgroundColor = $cc % 2 ? '' : ' bgcolor="' . \TYPO3\CMS\Core\Utility\GeneralUtility::modifyHTMLColor($GLOBALS['SOBE']->doc->bgColor4, 10, 10, 10) . '"';
                /**
                 * Not very noice to render html_code directly
                 *
                 * @todo change rendering html code here
                 * */
                $iOut .= '<tr ' . $rowBackgroundColor . '>';
                foreach ($rowFields as $field) {
                    $iOut .= '<td>';
                    $wrap = array('', '');
                    switch ($field) {
                        case $titleCol:
                            $params = '&edit[' . $foreignTable . '][' . $row['uid'] . ']=edit';
                            $wrap = array('<a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $GLOBALS['BACK_PATH'])) . '">', '</a>');
                            break;
                        default:
                    }
                    $iOut .= implode(BackendUtility::getProcessedValue($foreignTable, $field, $row[$field], 100), $wrap);
                    $iOut .= '</td>';
                }
                /**
                 * Trash icon
                 */
                $onClick = 'deleteRecord(\'' . $foreignTable . '\', ' . $row['uid'] . ', \'alt_doc.php?edit[tx_commerce_attributes][' . $attributeUid . ']=edit\');';
                $iOut .= '<td>&nbsp;';
                $iOut .= '<a href="#" onclick="' . $onClick . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-edit-delete') . '</a></td>';
                $iOut .= '</tr>';
            }
            $out .= $iOut;
            /**
             * Cerate the summ row
             */
            $out .= '<tr>';
            foreach ($rowFields as $field) {
                $out .= '<td class="c-headLineTable"><b>';
                if ($sum[$field] > 0) {
                    $out .= BackendUtility::getProcessedValueExtra($foreignTable, $field, $sum[$field], 100);
                }
                $out .= '</b></td>';
            }
            $out .= '<td class="c-headLineTable"></td>';
            $out .= '</tr>';
        }
        $out = '
			<!--
				DB listing of elements: "' . htmlspecialchars($table) . '"
			-->
			<table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist">
				' . $out . '
			</table>';
        $content .= $out;
        /**
         * New article
         */
        $params = '&edit[' . $foreignTable . '][' . $attributeStoragePid . ']=new&defVals[' . $foreignTable . '][attributes_uid]=' . urlencode($attributeUid);
        $onClickAction = 'onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $GLOBALS['BACK_PATH'])) . '"';
        $content .= '<div id="typo3-newRecordLink">
			<a href="#" ' . $onClickAction . '>
				' . $language->sL('LLL:EXT:commerce/Resources/Private/Language/locallang_be.xml:attributeview.addvalue', 1) . '</a>
			</div>';
        return $content;
    }
 /**
  * Rendering a single row for the list
  *
  * @param string $table Table name
  * @param array $row Current record
  * @param integer $cc Counter, counting for each time an element is rendered (used for alternating colors)
  * @param string $titleCol Table field (column) where header value is found
  * @param string $thumbsCol Table field (column) where (possible) thumbnails can be found
  * @param integer $indent Indent from left.
  * @param integer $level
  * @return string Table row for the element
  * @access private
  * @see getTable()
  */
 public function renderListRow($table, $row, $cc, $titleCol, $thumbsCol, $indent = 0, $level = 0)
 {
     $iOut = '';
     // If in search mode, make sure the preview will show the correct page
     if (strlen($this->searchString)) {
         $id_orig = $this->id;
         $this->id = $row['pid'];
     }
     if (is_array($row)) {
         // Add special classes for first and last row
         $rowSpecial = '';
         if ($cc == 1 && $indent == 0) {
             $rowSpecial .= ' firstcol';
         }
         if ($cc == $this->totalRowCount || $cc == $this->iLimit) {
             $rowSpecial .= ' lastcol';
         }
         // Background color, if any:
         if ($this->alternateBgColors) {
             $row_bgColor = $cc % 2 ? ' class="db_list_normal' . $rowSpecial . '"' : ' class="db_list_alt' . $rowSpecial . '"';
         } else {
             $row_bgColor = ' class="db_list_normal' . $rowSpecial . '"';
         }
         // Overriding with versions background color if any:
         $row_bgColor = $row['_CSSCLASS'] ? ' class="' . $row['_CSSCLASS'] . '"' : $row_bgColor;
         // Incr. counter.
         $this->counter++;
         // The icon with link
         $alttext = BackendUtility::getRecordIconAltText($row, $table);
         $iconImg = IconUtility::getSpriteIconForRecord($table, $row, array('title' => htmlspecialchars($alttext), 'style' => $indent ? ' margin-left: ' . $indent . 'px;' : ''));
         $theIcon = $this->clickMenuEnabled ? $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg, $table, $row['uid']) : $iconImg;
         // Preparing and getting the data-array
         $theData = array();
         foreach ($this->fieldArray as $fCol) {
             if ($fCol == $titleCol) {
                 $recTitle = BackendUtility::getRecordTitle($table, $row, FALSE, TRUE);
                 // If the record is edit-locked	by another user, we will show a little warning sign:
                 if ($lockInfo = BackendUtility::isRecordLocked($table, $row['uid'])) {
                     $warning = '<a href="#" onclick="alert(' . GeneralUtility::quoteJSvalue($lockInfo['msg']) . '); return false;" title="' . htmlspecialchars($lockInfo['msg']) . '">' . IconUtility::getSpriteIcon('status-warning-in-use') . '</a>';
                 }
                 $theData[$fCol] = $warning . $this->linkWrapItems($table, $row['uid'], $recTitle, $row);
                 // Render thumbnails, if:
                 // - a thumbnail column exists
                 // - there is content in it
                 // - the thumbnail column is visible for the current type
                 $type = 0;
                 if (isset($GLOBALS['TCA'][$table]['ctrl']['type'])) {
                     $typeColumn = $GLOBALS['TCA'][$table]['ctrl']['type'];
                     $type = $row[$typeColumn];
                 }
                 // If current type doesn't exist, set it to 0 (or to 1 for historical reasons, if 0 doesn't exist)
                 if (!isset($GLOBALS['TCA'][$table]['types'][$type])) {
                     $type = isset($GLOBALS['TCA'][$table]['types'][0]) ? 0 : 1;
                 }
                 $visibleColumns = $GLOBALS['TCA'][$table]['types'][$type]['showitem'];
                 if ($this->thumbs && trim($row[$thumbsCol]) && preg_match('/(^|(.*(;|,)?))' . $thumbsCol . '(((;|,).*)|$)/', $visibleColumns) === 1) {
                     $theData[$fCol] .= '<br />' . $this->thumbCode($row, $table, $thumbsCol);
                 }
                 $localizationMarkerClass = '';
                 if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField']) && $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] != 0 && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0) {
                     // It's a translated record with a language parent
                     $localizationMarkerClass = ' localization';
                 }
             } elseif ($fCol == 'pid') {
                 $theData[$fCol] = $row[$fCol];
             } elseif ($fCol == '_PATH_') {
                 $theData[$fCol] = $this->recPath($row['pid']);
             } elseif ($fCol == '_REF_') {
                 $theData[$fCol] = $this->createReferenceHtml($table, $row['uid']);
             } elseif ($fCol == '_CONTROL_') {
                 $theData[$fCol] = $this->makeControl($table, $row, $level);
             } elseif ($fCol == '_AFTERCONTROL_' || $fCol == '_AFTERREF_') {
                 $theData[$fCol] = '&nbsp;';
             } elseif ($fCol == '_CLIPBOARD_') {
                 $theData[$fCol] = $this->makeClip($table, $row);
             } elseif ($fCol == '_LOCALIZATION_') {
                 list($lC1, $lC2) = $this->makeLocalizationPanel($table, $row);
                 $theData[$fCol] = $lC1;
             } elseif (!$fCol == '_LOCALIZATION_b') {
                 $tmpProc = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid']);
                 $theData[$fCol] = $this->linkUrlMail(htmlspecialchars($tmpProc), $row[$fCol]);
                 if ($this->csvOutput) {
                     $row[$fCol] = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 0, $row['uid']);
                 }
             } elseif ($fCol == '_LOCALIZATION_b') {
                 $theData[$fCol] = $lC2;
             } else {
                 $tmpProc = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid']);
                 $theData[$fCol] = $this->linkUrlMail(htmlspecialchars($tmpProc), $row[$fCol]);
                 if ($this->csvOutput) {
                     $row[$fCol] = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 0, $row['uid']);
                 }
             }
         }
         // Reset the ID if it was overwritten
         if (strlen($this->searchString)) {
             $this->id = $id_orig;
         }
         // Add row to CSV list:
         if ($this->csvOutput) {
             $this->addToCSV($row, $table);
         }
         // Add classes to table cells
         $this->addElement_tdCssClass[$titleCol] = 'col-title' . $localizationMarkerClass;
         if (!$this->dontShowClipControlPanels) {
             $this->addElement_tdCssClass['_CONTROL_'] = 'col-control';
             $this->addElement_tdCssClass['_AFTERCONTROL_'] = 'col-control-space';
             $this->addElement_tdCssClass['_CLIPBOARD_'] = 'col-clipboard';
         }
         $this->addElement_tdCssClass['_PATH_'] = 'col-path';
         $this->addElement_tdCssClass['_LOCALIZATION_'] = 'col-localizationa';
         $this->addElement_tdCssClass['_LOCALIZATION_b'] = 'col-localizationb';
         /**
          * @hook checkChildren
          * @date 2014-02-11
          * @request Alexander Grein <*****@*****.**>
          */
         if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
             foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
                 $hookObject = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classData);
                 if (!$this->searchString && is_object($hookObject) && method_exists($hookObject, 'checkChildren')) {
                     $hookObject->checkChildren($table, $row, $level, $theData, $this);
                 }
             }
         }
         // Create element in table cells:
         $iOut .= $this->addelement(1, $theIcon, $theData, $row_bgColor, '', '', $level);
         // Finally, return table row element:
         if ($cc > 0 || !$this->csvOutput) {
             return $iOut;
         } else {
             return '';
         }
     }
 }
Beispiel #7
0
 /**
  * Get property array for html table
  *
  * @return array
  */
 protected function getPropertiesForTable() : array
 {
     $propertiesForTable = [];
     $extraFields = [];
     $lang = $this->getLanguageService();
     if (in_array($this->type, ['folder', 'file'], true)) {
         if ($this->type === 'file') {
             $extraFields['creation_date'] = htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.creationDate'));
             $extraFields['modification_date'] = htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.timestamp'));
         }
         $extraFields['storage'] = htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_tca.xlf:sys_file.storage'));
         $extraFields['folder'] = htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_common.xlf:folder'));
     } else {
         $extraFields['crdate'] = htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.creationDate'));
         $extraFields['cruser_id'] = htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.creationUserId'));
         $extraFields['tstamp'] = htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.timestamp'));
         // check if the special fields are defined in the TCA ctrl section of the table
         foreach ($extraFields as $fieldName => $fieldLabel) {
             if (isset($GLOBALS['TCA'][$this->table]['ctrl'][$fieldName])) {
                 $extraFields[$GLOBALS['TCA'][$this->table]['ctrl'][$fieldName]] = $fieldLabel;
             } else {
                 unset($extraFields[$fieldName]);
             }
         }
     }
     foreach ($extraFields as $name => $fieldLabel) {
         $rowValue = '';
         $thisRow = [];
         if (!isset($this->row[$name])) {
             $resourceObject = $this->fileObject ?: $this->folderObject;
             if ($name === 'storage') {
                 $rowValue = $resourceObject->getStorage()->getName();
             } elseif ($name === 'folder') {
                 $rowValue = $resourceObject->getParentFolder()->getReadablePath();
             }
         } elseif (in_array($name, ['creation_date', 'modification_date'], true)) {
             $rowValue = BackendUtility::datetime($this->row[$name]);
         } else {
             $rowValue = BackendUtility::getProcessedValueExtra($this->table, $name, $this->row[$name]);
         }
         $thisRow['value'] = $rowValue;
         $thisRow['fieldLabel'] = rtrim($fieldLabel, ':');
         // show the backend username who created the issue
         if ($name === 'cruser_id' && $rowValue) {
             $creatorRecord = BackendUtility::getRecord('be_users', $rowValue);
             if ($creatorRecord) {
                 /** @var Avatar $avatar */
                 $avatar = GeneralUtility::makeInstance(Avatar::class);
                 $creatorRecord['icon'] = $avatar->render($creatorRecord);
                 $thisRow['creatorRecord'] = $creatorRecord;
                 $thisRow['value'] = '';
             }
         }
         $propertiesForTable['extraFields'][] = $thisRow;
     }
     // Traverse the list of fields to display for the record:
     $fieldList = GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$this->table]['interface']['showRecordFieldList'], true);
     foreach ($fieldList as $name) {
         $thisRow = [];
         $name = trim($name);
         $uid = $this->row['uid'];
         if (!isset($GLOBALS['TCA'][$this->table]['columns'][$name])) {
             continue;
         }
         // Storage is already handled above
         if ($this->type === 'file' && $name === 'storage') {
             continue;
         }
         // format file size as bytes/kilobytes/megabytes
         if ($this->type === 'file' && $name === 'size') {
             $this->row[$name] = GeneralUtility::formatSize($this->row[$name], htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_common.xlf:byteSizeUnits')));
         }
         $isExcluded = !(!$GLOBALS['TCA'][$this->table]['columns'][$name]['exclude'] || $this->getBackendUser()->check('non_exclude_fields', $this->table . ':' . $name));
         if ($isExcluded) {
             continue;
         }
         $thisRow['fieldValue'] = BackendUtility::getProcessedValue($this->table, $name, $this->row[$name], 0, 0, false, $uid);
         $thisRow['fieldLabel'] = htmlspecialchars($lang->sL(BackendUtility::getItemLabel($this->table, $name)));
         $propertiesForTable['fields'][] = $thisRow;
     }
     return $propertiesForTable;
 }
    /**
     * Render property array as html table
     *
     * @return string
     */
    protected function renderPropertiesAsTable()
    {
        $tableRows = array();
        $extraFields = array();
        $lang = $this->getLanguageService();
        if (in_array($this->type, array('folder', 'file'), true)) {
            if ($this->type === 'file') {
                $extraFields['creation_date'] = $lang->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationDate', true);
                $extraFields['modification_date'] = $lang->sL('LLL:EXT:lang/locallang_general.xlf:LGL.timestamp', true);
            }
            $extraFields['storage'] = $lang->sL('LLL:EXT:lang/locallang_tca.xlf:sys_file.storage', true);
            $extraFields['folder'] = $lang->sL('LLL:EXT:lang/locallang_common.xlf:folder', true);
        } else {
            $extraFields['crdate'] = $lang->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationDate', true);
            $extraFields['cruser_id'] = $lang->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationUserId', true);
            $extraFields['tstamp'] = $lang->sL('LLL:EXT:lang/locallang_general.xlf:LGL.timestamp', true);
            // check if the special fields are defined in the TCA ctrl section of the table
            foreach ($extraFields as $fieldName => $fieldLabel) {
                if (isset($GLOBALS['TCA'][$this->table]['ctrl'][$fieldName])) {
                    $extraFields[$GLOBALS['TCA'][$this->table]['ctrl'][$fieldName]] = $fieldLabel;
                } else {
                    unset($extraFields[$fieldName]);
                }
            }
        }
        foreach ($extraFields as $name => $fieldLabel) {
            $rowValue = '';
            if (!isset($this->row[$name])) {
                $resourceObject = $this->fileObject ?: $this->folderObject;
                if ($name === 'storage') {
                    $rowValue = $resourceObject->getStorage()->getName();
                } elseif ($name === 'folder') {
                    $rowValue = $resourceObject->getParentFolder()->getReadablePath();
                }
            } elseif (in_array($name, array('creation_date', 'modification_date'), true)) {
                $rowValue = BackendUtility::datetime($this->row[$name]);
            } else {
                $rowValue = BackendUtility::getProcessedValueExtra($this->table, $name, $this->row[$name]);
            }
            // show the backend username who created the issue
            if ($name === 'cruser_id' && $rowValue) {
                $creatorRecord = BackendUtility::getRecord('be_users', $rowValue);
                if ($creatorRecord) {
                    /** @var Avatar $avatar */
                    $avatar = GeneralUtility::makeInstance(Avatar::class);
                    $icon = $avatar->render($creatorRecord);
                    $rowValue = '
                        <div class="media">
                            <div class="media-left">
                                ' . $icon . '
                            </div>
                            <div class="media-body">
                                <strong>' . htmlspecialchars($GLOBALS['BE_USER']->user['username']) . '</strong><br>
                                ' . ($GLOBALS['BE_USER']->user['realName'] ? htmlspecialchars($GLOBALS['BE_USER']->user['realName']) : '') . '
                            </div>
                        </div>';
                }
            }
            $tableRows[] = '
				<tr>
					<th class="col-nowrap">' . rtrim($fieldLabel, ':') . '</th>
					<td>' . ($name === 'cruser_id' ? $rowValue : htmlspecialchars($rowValue)) . '</td>
				</tr>';
        }
        // Traverse the list of fields to display for the record:
        $fieldList = GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$this->table]['interface']['showRecordFieldList'], true);
        foreach ($fieldList as $name) {
            $name = trim($name);
            $uid = $this->row['uid'];
            if (!isset($GLOBALS['TCA'][$this->table]['columns'][$name])) {
                continue;
            }
            // Storage is already handled above
            if ($this->type === 'file' && $name === 'storage') {
                continue;
            }
            $isExcluded = !(!$GLOBALS['TCA'][$this->table]['columns'][$name]['exclude'] || $this->getBackendUser()->check('non_exclude_fields', $this->table . ':' . $name));
            if ($isExcluded) {
                continue;
            }
            $itemValue = BackendUtility::getProcessedValue($this->table, $name, $this->row[$name], 0, 0, false, $uid);
            $itemLabel = $lang->sL(BackendUtility::getItemLabel($this->table, $name), true);
            $tableRows[] = '
				<tr>
					<th class="col-nowrap">' . $itemLabel . '</th>
					<td>' . htmlspecialchars($itemValue) . '</td>
				</tr>';
        }
        return '
			<div class="table-fit table-fit-wrap">
				<table class="table table-striped table-hover">
					' . implode('', $tableRows) . '
				</table>
			</div>';
    }
Beispiel #9
0
 /**
  * Returns TCA label, used in TCA only.
  *
  * @param array $params Record value
  */
 public function getTcaRecordTitle(array &$params)
 {
     $languageService = $this->getLanguageService();
     $feGroup = '';
     if ($params['row']['fe_group']) {
         $feGroup = $languageService->sL(BackendUtility::getItemLabel('tx_commerce_article_prices', 'fe_group'), 1) . BackendUtility::getProcessedValueExtra('tx_commerce_article_prices', 'fe_group', $params['row']['fe_group'], 100, $params['row']['uid']);
     }
     $params['title'] = $languageService->sL(BackendUtility::getItemLabel('tx_commerce_article_prices', 'price_gross'), 1) . ': ' . sprintf('%01.2f', $params['row']['price_gross'] / 100) . ', ' . $languageService->sL(BackendUtility::getItemLabel('tx_commerce_article_prices', 'price_net'), 1) . ': ' . sprintf('%01.2f', $params['row']['price_net'] / 100) . ' (' . $languageService->sL(BackendUtility::getItemLabel('tx_commerce_article_prices', 'price_scale_amount_start'), 1) . ': ' . $params['row']['price_scale_amount_start'] . ' ' . $languageService->sL(BackendUtility::getItemLabel('tx_commerce_article_prices', 'price_scale_amount_end'), 1) . ': ' . $params['row']['price_scale_amount_end'] . ') ' . $feGroup;
 }
    /**
     * Main function. Will generate the information to display for the item
     * set internally.
     *
     * @return 	void
     * @todo Define visibility
     */
    public function renderDBInfo()
    {
        // Print header, path etc:
        // @TODO invalid context menu code in the output
        $code = $this->doc->getHeader($this->table, $this->row, $this->pageinfo['_thePath'], 1) . '<br />';
        $this->content .= $this->doc->section('', $code);
        $tableRows = array();
        $extraFields = array('crdate' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xml:LGL.creationDate', 1), 'cruser_id' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xml:LGL.creationUserId', 1), 'tstamp' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xml:LGL.timestamp', 1));
        foreach ($extraFields as $name => $value) {
            $rowValue = \TYPO3\CMS\Backend\Utility\BackendUtility::getProcessedValueExtra($this->table, $name, $this->row[$name]);
            if ($name === 'cruser_id' && $rowValue) {
                $userTemp = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('username, realName', 'be_users', 'uid = ' . intval($rowValue));
                if ($userTemp[0]['username'] !== '') {
                    $rowValue = $userTemp[0]['username'];
                    if ($userTemp[0]['realName'] !== '') {
                        $rowValue .= ' - ' . $userTemp[0]['realName'];
                    }
                }
            }
            $tableRows[] = '
				<tr>
					<td class="t3-col-header">' . $value . '</td>
					<td>' . htmlspecialchars($rowValue) . '</td>
				</tr>';
        }
        // Traverse the list of fields to display for the record:
        $fieldList = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$this->table]['interface']['showRecordFieldList'], 1);
        foreach ($fieldList as $name) {
            $name = trim($name);
            if (!isset($GLOBALS['TCA'][$this->table]['columns'][$name])) {
                continue;
            }
            $isExcluded = !(!$GLOBALS['TCA'][$this->table]['columns'][$name]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $this->table . ':' . $name));
            if ($isExcluded) {
                continue;
            }
            $uid = $this->row['uid'];
            $itemValue = \TYPO3\CMS\Backend\Utility\BackendUtility::getProcessedValue($this->table, $name, $this->row[$name], 0, 0, FALSE, $uid);
            $itemLabel = $GLOBALS['LANG']->sL(\TYPO3\CMS\Backend\Utility\BackendUtility::getItemLabel($this->table, $name), 1);
            $tableRows[] = '
				<tr>
					<td class="t3-col-header">' . $itemLabel . '</td>
					<td>' . htmlspecialchars($itemValue) . '</td>
				</tr>';
        }
        // Create table from the information:
        $tableCode = '
			<table border="0" cellpadding="0" cellspacing="0" id="typo3-showitem" class="t3-table-info">
				' . implode('', $tableRows) . '
			</table>';
        $this->content .= $this->doc->section('', $tableCode);
        // Add path and table information in the bottom:
        $code = '';
        $code .= $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.path') . ': ' . \TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($this->pageinfo['_thePath'], -48) . '<br />';
        $code .= $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.table') . ': ' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$this->table]['ctrl']['title']) . ' (' . $this->table . ') - UID: ' . $this->uid . '<br />';
        $this->content .= $this->doc->section('', $code);
        // References:
        $references = $this->makeRef($this->table, $this->row['uid']);
        if (!empty($references)) {
            $this->content .= $this->doc->section($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.referencesToThisItem'), $references);
        }
        $referencesFrom = $this->makeRefFrom($this->table, $this->row['uid']);
        if (!empty($referencesFrom)) {
            $this->content .= $this->doc->section($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.referencesFromThisItem'), $referencesFrom);
        }
    }
 /**
  * Rendering a single row for the list.
  *
  * @param string $table Table name
  * @param array $row Current record
  * @param int $cc Counter, counting for each time an element is rendered
  *      (used for alternating colors)
  * @param string $titleCol Table field (column) where header value is found
  * @param string $thumbsCol Table field (column) where (possible) thumbnails
  *      can be found
  * @param int $indent Indent from left.
  *
  * @return string Table row for the element
  */
 public function renderListRow($table, array $row, $cc, $titleCol, $thumbsCol, $indent = 0)
 {
     $database = $this->getDatabaseConnection();
     $language = $this->getLanguageService();
     $iOut = '';
     if (substr(TYPO3_version, 0, 3) >= '4.0') {
         // In offline workspace, look for alternative record:
         BackendUtility::workspaceOL($table, $row, $this->getBackendUser()->workspace);
     }
     // Background color, if any:
     $rowBackgroundColor = '';
     if ($this->alternateBgColors) {
         $rowBackgroundColor = $cc % 2 ? '' : ' bgcolor="' . GeneralUtility::modifyHTMLColor($this->getControllerDocumentTemplate()->bgColor4, 10, 10, 10) . '"';
     }
     // Overriding with versions background color if any:
     $rowBackgroundColor = $row['_CSSCLASS'] ? ' class="' . $row['_CSSCLASS'] . '"' : $rowBackgroundColor;
     // Initialization
     $alttext = BackendUtility::getRecordIconAltText($row, $table);
     // Incr. counter.
     ++$this->counter;
     $indentStyle = $indent ? ' style="margin-left: ' . $indent . 'px;"' : '';
     $iconAttributes = 'title="' . htmlspecialchars($alttext) . '"' . $indentStyle;
     // Icon for order comment and delivery address
     $iconPath = '';
     $iconImg = '';
     if ($row['comment'] != '' && $row['internalcomment'] != '') {
         if ($row['tx_commerce_address_type_id'] == 2) {
             $iconPath = 'orders_add_user_int.gif';
         } else {
             $iconPath = 'orders_user_int.gif';
         }
     } elseif ($row['comment'] != '') {
         if ($row['tx_commerce_address_type_id'] == 2) {
             $iconPath = 'orders_add_user.gif';
         } else {
             $iconPath = 'orders_user.gif';
         }
     } elseif ($row['internalcomment'] != '') {
         if ($row['tx_commerce_address_type_id'] == 2) {
             $iconPath = 'orders_add_int.gif';
         } else {
             $iconPath = 'orders_int.gif';
         }
     } else {
         if ($row['tx_commerce_address_type_id'] == 2) {
             $iconPath = 'orders_add.gif';
         } else {
             $iconImg = '<img ' . IconUtility::skinImg($this->backPath, IconUtility::getIcon($table, $row), $iconAttributes) . ' />';
         }
     }
     if ($iconPath != '') {
         $iconImg = '<img' . IconUtility::skinImg($this->backPath, PATH_TXCOMMERCE_REL . 'Resources/Public/Icons/Table/' . $iconPath, $iconAttributes) . '/>';
     }
     $theIcon = $this->clickMenuEnabled ? $this->getControllerDocumentTemplate()->wrapClickMenuOnIcon($iconImg, $table, $row['uid']) : $iconImg;
     // Preparing and getting the data-array
     $theData = array();
     foreach ($this->fieldArray as $fCol) {
         if ($fCol == 'pid') {
             $theData[$fCol] = $row[$fCol];
         } elseif ($fCol == 'sum_price_gross') {
             if ($this->csvOutput) {
                 $row[$fCol] = $row[$fCol] / 100;
             } else {
                 $theData[$fCol] = \CommerceTeam\Commerce\ViewHelpers\Money::format($row[$fCol], $row['cu_iso_3'], false);
             }
         } elseif ($fCol == 'crdate') {
             $theData[$fCol] = BackendUtility::date($row[$fCol]);
             $row[$fCol] = BackendUtility::date($row[$fCol]);
         } elseif ($fCol == 'tstamp') {
             $theData[$fCol] = BackendUtility::date($row[$fCol]);
             $row[$fCol] = BackendUtility::date($row[$fCol]);
         } elseif ($fCol == 'articles') {
             $articleNumber = array();
             $articleName = array();
             $resArticles = $database->exec_SELECTquery('article_number, title, order_uid', 'tx_commerce_order_articles', 'order_uid = ' . (int) $row['uid']);
             $articles = array();
             while ($lokalRow = $database->sql_fetch_assoc($resArticles)) {
                 $articles[] = $lokalRow['article_number'] . ':' . $lokalRow['title'];
                 $articleNumber[] = $lokalRow['article_number'];
                 $articleName[] = $lokalRow['title'];
             }
             if ($this->csvOutput) {
                 $theData[$fCol] = implode(',', $articles);
                 $row[$fCol] = implode(',', $articles);
             } else {
                 $theData[$fCol] = '<input type="checkbox" name="orderUid[]" value="' . $row['uid'] . '">';
             }
         } elseif ($fCol == 'numarticles') {
             $resArticles = $database->exec_SELECTquery('sum(amount) amount', 'tx_commerce_order_articles', 'order_uid = ' . (int) $row['uid'] . ' AND article_type_uid = ' . NORMALARTICLETYPE);
             if ($lokalRow = $database->sql_fetch_assoc($resArticles)) {
                 $theData[$fCol] = $lokalRow['amount'];
                 $row[$fCol] = $lokalRow['amount'];
             }
         } elseif ($fCol == 'article_number') {
             $articleNumber = array();
             $resArticles = $database->exec_SELECTquery('article_number', 'tx_commerce_order_articles', 'order_uid = ' . (int) $row['uid'] . ' AND article_type_uid = ' . NORMALARTICLETYPE);
             while ($lokalRow = $database->sql_fetch_assoc($resArticles)) {
                 $articleNumber[] = $lokalRow['article_number'] ? $lokalRow['article_number'] : $language->sL('no_article_number');
             }
             $theData[$fCol] = implode(',', $articleNumber);
         } elseif ($fCol == 'article_name') {
             $articleName = array();
             $resArticles = $database->exec_SELECTquery('title', 'tx_commerce_order_articles', 'order_uid = ' . (int) $row['uid'] . ' AND article_type_uid = ' . NORMALARTICLETYPE);
             while ($lokalRow = $database->sql_fetch_assoc($resArticles)) {
                 $articleName[] = $lokalRow['title'] ? $lokalRow['title'] : $language->sL('no_article_title');
             }
             $theData[$fCol] = implode(',', $articleName);
         } elseif ($fCol == 'order_type_uid_noName') {
             $typesResult = $database->exec_SELECTquery('*', 'tx_commerce_order_types', 'uid = ' . (int) $row['order_type_uid_noName']);
             while ($localRow = $database->sql_fetch_assoc($typesResult)) {
                 if ($localRow['icon']) {
                     $filepath = $this->backPath . SettingsFactory::getInstance()->getTcaValue('tx_commerce_order_types.columns.icon.config.uploadfolder') . '/' . $localRow['icon'];
                     $theData[$fCol] = '<img ' . IconUtility::skinImg($this->backPath, $filepath, ' title="' . htmlspecialchars($localRow['title']) . '"' . $indentStyle);
                 } else {
                     $theData[$fCol] = $localRow['title'];
                 }
             }
         } elseif ($fCol == '_PATH_') {
             $theData[$fCol] = $this->recPath($row['pid']);
         } elseif ($fCol == '_CONTROL_') {
             $theData[$fCol] = $this->makeControl($table, $row);
         } elseif ($fCol == '_CLIPBOARD_') {
             $theData[$fCol] = $this->makeClip($table, $row);
         } elseif ($fCol == '_LOCALIZATION_') {
             list($lC1, $lC2) = $this->makeLocalizationPanel($table, $row);
             $theData[$fCol] = $lC1;
             $theData[$fCol . 'b'] = $lC2;
         } elseif ($fCol == '_LOCALIZATION_b') {
             // Do nothing, has been done above.
             $theData[$fCol] .= '';
         } elseif ($fCol == 'order_id') {
             $theData[$fCol] = $row[$fCol];
         } else {
             $theData[$fCol] = $this->linkUrlMail(htmlspecialchars(BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid'])), $row[$fCol]);
         }
     }
     // Add row to CSV list:
     if ($this->csvOutput) {
         $beCsvCharset = SettingsFactory::getInstance()->getExtConf('BECSVCharset');
         // Charset Conversion
         /**
          * Charset converter.
          *
          * @var \TYPO3\CMS\Core\Charset\CharsetConverter $csObj
          */
         $csObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Charset\\CharsetConverter');
         $csObj->initCharset($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset']);
         if (!$beCsvCharset) {
             $beCsvCharset = 'iso-8859-1';
         }
         $csObj->initCharset($beCsvCharset);
         $csObj->convArray($row, $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'], $beCsvCharset);
         $this->addToCSV($row);
     }
     // Create element in table cells:
     $iOut .= $this->addelement(1, $theIcon, $theData, $rowBackgroundColor);
     // Render thumbsnails if a thumbnail column exists and there is content in it:
     if ($this->thumbs && trim($row[$thumbsCol])) {
         $iOut .= $this->addelement(4, '', array($titleCol => $this->thumbCode($row, $table, $thumbsCol)), $rowBackgroundColor);
     }
     // Finally, return table row element:
     return $iOut;
 }
 /**
  * Rendering a single row for the list
  *
  * @param string $table Table name
  * @param mixed[] $row Current record
  * @param int $cc Counter, counting for each time an element is rendered (used for alternating colors)
  * @param string $titleCol Table field (column) where header value is found
  * @param string $thumbsCol Table field (column) where (possible) thumbnails can be found
  * @param int $indent Indent from left.
  * @param integer $level
  * @param string $expanded
  *
  * @return string Table row for the element
  * @access private
  * @see getTable()
  */
 public function renderListRow($table, $row, $cc, $titleCol, $thumbsCol, $indent = 0, $level = 0, $expanded = '')
 {
     if (!is_array($row)) {
         return '';
     }
     $rowOutput = '';
     $id_orig = null;
     // If in search mode, make sure the preview will show the correct page
     if ((string) $this->searchString !== '') {
         $id_orig = $this->id;
         $this->id = $row['pid'];
     }
     // Add special classes for first and last row
     $rowSpecial = '';
     if ($cc == 1 && $indent == 0) {
         $rowSpecial .= ' firstcol';
     }
     if ($cc == $this->totalRowCount || $cc == $this->iLimit) {
         $rowSpecial .= ' lastcol';
     }
     $row_bgColor = ' class="' . $rowSpecial . '"';
     // Overriding with versions background color if any:
     $row_bgColor = $row['_CSSCLASS'] ? ' class="' . $row['_CSSCLASS'] . '"' : $row_bgColor;
     // Incr. counter.
     $this->counter++;
     // The icon with link
     $altText = BackendUtility::getRecordIconAltText($row, $table);
     $additionalStyle = $indent ? ' style="margin-left: ' . $indent . 'px;"' : '';
     $iconImg = '<span title="' . $altText . '" ' . $additionalStyle . '>' . $this->iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render() . '</span>';
     $theIcon = $this->clickMenuEnabled ? BackendUtility::wrapClickMenuOnIcon($iconImg, $table, $row['uid']) : $iconImg;
     // Preparing and getting the data-array
     $theData = array();
     $localizationMarkerClass = '';
     $lC2 = '';
     foreach ($this->fieldArray as $fCol) {
         if ($fCol == $titleCol) {
             $recTitle = BackendUtility::getRecordTitle($table, $row, false, true);
             $warning = '';
             // If the record is edit-locked	by another user, we will show a little warning sign:
             $lockInfo = BackendUtility::isRecordLocked($table, $row['uid']);
             if ($lockInfo) {
                 $warning = '<a href="#" onclick="alert(' . GeneralUtility::quoteJSvalue($lockInfo['msg']) . '); return false;" title="' . htmlspecialchars($lockInfo['msg']) . '">' . $this->iconFactory->getIcon('status-warning-in-use', Icon::SIZE_SMALL)->render() . '</a>';
             }
             $theData[$fCol] = $theData['__label'] = $warning . $this->linkWrapItems($table, $row['uid'], $recTitle, $row);
             // Render thumbnails, if:
             // - a thumbnail column exists
             // - there is content in it
             // - the thumbnail column is visible for the current type
             $type = 0;
             if (isset($GLOBALS['TCA'][$table]['ctrl']['type'])) {
                 $typeColumn = $GLOBALS['TCA'][$table]['ctrl']['type'];
                 $type = $row[$typeColumn];
             }
             // If current type doesn't exist, set it to 0 (or to 1 for historical reasons,
             // if 0 doesn't exist)
             if (!isset($GLOBALS['TCA'][$table]['types'][$type])) {
                 $type = isset($GLOBALS['TCA'][$table]['types'][0]) ? 0 : 1;
             }
             $visibleColumns = $GLOBALS['TCA'][$table]['types'][$type]['showitem'];
             if ($this->thumbs && trim($row[$thumbsCol]) && preg_match('/(^|(.*(;|,)?))' . $thumbsCol . '(((;|,).*)|$)/', $visibleColumns) === 1) {
                 $theData[$fCol] .= '<br />' . $this->thumbCode($row, $table, $thumbsCol);
             }
             if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField']) && $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] != 0 && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0) {
                 // It's a translated record with a language parent
                 $localizationMarkerClass = ' localization';
             }
         } elseif ($fCol == 'pid') {
             $theData[$fCol] = $row[$fCol];
         } elseif ($fCol == '_PATH_') {
             $theData[$fCol] = $this->recPath($row['pid']);
         } elseif ($fCol == '_REF_') {
             $theData[$fCol] = $this->createReferenceHtml($table, $row['uid']);
         } elseif ($fCol == '_CONTROL_') {
             $theData[$fCol] = $this->makeControl($table, $row, $level);
         } elseif ($fCol == '_CLIPBOARD_') {
             $theData[$fCol] = $this->makeClip($table, $row);
         } elseif ($fCol == '_LOCALIZATION_') {
             list($lC1, $lC2) = $this->makeLocalizationPanel($table, $row);
             $theData[$fCol] = $lC1;
         } elseif ($fCol != '_LOCALIZATION_b') {
             $tmpProc = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid']);
             $theData[$fCol] = $this->linkUrlMail(htmlspecialchars($tmpProc), $row[$fCol]);
             if ($this->csvOutput) {
                 $row[$fCol] = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 0, $row['uid']);
             }
         } elseif ($fCol == '_LOCALIZATION_b') {
             $theData[$fCol] = $lC2;
         } else {
             $theData[$fCol] = htmlspecialchars(BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 0, $row['uid']));
         }
     }
     // Reset the ID if it was overwritten
     if ((string) $this->searchString !== '') {
         $this->id = $id_orig;
     }
     // Add row to CSV list:
     if ($this->csvOutput) {
         $this->addToCSV($row);
     }
     // Add classes to table cells
     $this->addElement_tdCssClass[$titleCol] = 'col-title' . $localizationMarkerClass;
     $this->addElement_tdCssClass['_CONTROL_'] = 'col-control';
     if ($this->getModule()->MOD_SETTINGS['clipBoard']) {
         $this->addElement_tdCssClass['_CLIPBOARD_'] = 'col-clipboard';
     }
     $this->addElement_tdCssClass['_PATH_'] = 'col-path';
     $this->addElement_tdCssClass['_LOCALIZATION_'] = 'col-localizationa';
     $this->addElement_tdCssClass['_LOCALIZATION_b'] = 'col-localizationb';
     /**
      * @hook checkChildren
      * @date 2014-02-11
      * @request Alexander Grein <*****@*****.**>
      */
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
             $hookObject = GeneralUtility::getUserObj($classData);
             if (is_object($hookObject) && method_exists($hookObject, 'checkChildren')) {
                 $hookObject->checkChildren($table, $row, $level, $theData, $this);
             }
         }
     }
     // Create element in table cells:
     $theData['uid'] = $row['uid'];
     if ($table === 'tt_content') {
         $theData['tx_gridelements_container'] = $row['tx_gridelements_container'];
     }
     if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField']) && isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']) && !isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'])) {
         $theData['parent'] = $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']];
     }
     $rowOutput .= $this->addElement(1, $theIcon, $theData, $row_bgColor, '', '', '', $level);
     if ($this->localizationView && $this->l10nEnabled) {
         // For each available translation, render the record:
         if (is_array($this->translations)) {
             foreach ($this->translations as $lRow) {
                 // $lRow isn't always what we want - if record was moved we've to work with the
                 // placeholder records otherwise the list is messed up a bit
                 if ($row['_MOVE_PLH_uid'] && $row['_MOVE_PLH_pid']) {
                     $where = 't3ver_move_id="' . (int) $lRow['uid'] . '" AND pid="' . $row['_MOVE_PLH_pid'] . '" AND t3ver_wsid=' . $row['t3ver_wsid'] . BackendUtility::deleteClause($table);
                     $tmpRow = BackendUtility::getRecordRaw($table, $where, $this->selFieldList);
                     $lRow = is_array($tmpRow) ? $tmpRow : $lRow;
                 }
                 // In offline workspace, look for alternative record:
                 BackendUtility::workspaceOL($table, $lRow, $this->backendUser->workspace, true);
                 if (is_array($lRow) && $this->backendUser->checkLanguageAccess($lRow[$GLOBALS['TCA'][$table]['ctrl']['languageField']])) {
                     $this->currentIdList[] = $lRow['uid'];
                     if ($row['tx_gridelements_container']) {
                         $lRow['_CSSCLASS'] = 't3-gridelements-child" data-trigger-container="' . $row['tx_gridelements_container'] . $expanded;
                     }
                     $rowOutput .= $this->renderListRow($table, $lRow, $cc, $titleCol, $thumbsCol, 20, $level);
                 }
             }
         }
     }
     if ($theData['_EXPANDABLE_'] && $level < 8 && ($row['l18n_parent'] == 0 || !$this->localizationView)) {
         if (!empty($theData['_CHILDREN_'])) {
             $expanded = $this->expandedGridelements[$row['uid']] ? '" style="display: table-row;' : '';
             $lastGridColumn = '';
             $originalMoveUp = $this->showMoveUp;
             $originalMoveDown = $this->showMoveDown;
             $prevPrevUid = (int) $theData['_CHILDREN_'][0]['uid'];
             $prevUid = (int) $theData['_CHILDREN_'][1]['uid'];
             foreach ($theData['_CHILDREN_'] as $key => $child) {
                 if ($key > 1) {
                     if ($prevUid) {
                         $this->currentTable['prev'][$child['uid']] = $prevPrevUid;
                         $this->currentTable['next'][$prevUid] = -(int) $child['uid'];
                         $this->currentTable['prevUid'][$child['uid']] = $prevUid;
                     }
                     $prevPrevUid = isset($this->currentTable['prev'][$child['uid']]) ? -$prevUid : $row['pid'];
                     $prevUid = $child['uid'];
                 }
             }
             foreach ($theData['_CHILDREN_'] as $key => $child) {
                 if (isset($child['tx_gridelements_columns']) && $child['tx_gridelements_columns'] != $lastGridColumn) {
                     $lastGridColumn = $child['tx_gridelements_columns'];
                     $this->showMoveUp = false;
                     $rowOutput .= '<tr class="t3-gridelements-child" data-trigger-container="' . ($this->localizationView && $row['l18n_parent'] ? $row['l18n_parent'] : $row['uid']) . $expanded . '" data-grid-container="' . $row['uid'] . '">
                                 <td colspan="2"></td>
                                 <td colspan="' . (count($this->fieldArray) - 1 + $this->maxDepth) . '" style="padding:5px;">
                                     <br />
                                     <strong>' . $this->getLanguageService()->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:list.columnName') . ' ' . ($backendLayoutColumns[$child['tx_gridelements_columns']] ? $backendLayoutColumns[$child['tx_gridelements_columns']] : (int) $child['tx_gridelements_columns']) . '</strong>
                                 </td>
                             </tr>';
                 } else {
                     $this->showMoveUp = true;
                 }
                 if (isset($child['tx_gridelements_columns']) && isset($theData['_CHILDREN_'][$key + 1]) && $child['tx_gridelements_columns'] != $theData['_CHILDREN_'][$key + 1]['tx_gridelements_columns']) {
                     $this->showMoveDown = false;
                 } else {
                     $this->showMoveDown = true;
                 }
                 $this->currentIdList[] = $child['uid'];
                 if ($row['CType'] === 'gridelements_pi1') {
                     $this->currentContainerIdList[] = $row['uid'];
                 }
                 $child['_CSSCLASS'] = 't3-gridelements-child" data-trigger-container="' . ($this->localizationView && $row['l18n_parent'] ? $row['l18n_parent'] : $row['uid']) . $expanded;
                 $rowOutput .= $this->renderListRow($table, $child, $cc, $titleCol, $thumbsCol, 0, $level + 1, $expanded);
             }
             $this->showMoveUp = $originalMoveUp;
             $this->showMoveDown = $originalMoveDown;
         }
     }
     // Finally, return table row element:
     return $rowOutput;
 }
Beispiel #13
0
    /**
     * Oder Articles
     * Renders the List of aricles.
     *
     * @param array $parameter Parameter
     *
     * @return string HTML-Content
     */
    public function orderArticles(array $parameter)
    {
        $language = $this->getLanguageService();
        $settingsFactory = SettingsFactory::getInstance();
        $content = '';
        $orderArticleTable = 'tx_commerce_order_articles';
        $orderTable = 'tx_commerce_orders';
        /**
         * Document template.
         *
         * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
         */
        $doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
        $doc->backPath = $this->getBackPath();
        /*
         * GET Storage PID and order_id from Data
         */
        $orderStoragePid = $parameter['row']['pid'];
        $orderId = $parameter['row']['order_id'];
        /*
         * Select Order_articles
         */
        // @todo TS config of fields in list
        $fieldRows = array('amount', 'title', 'article_number', 'price_net', 'price_gross');
        /*
         * Taken from class.db_list_extra.php
         */
        $titleCol = $settingsFactory->getTcaValue($orderArticleTable . '.ctrl.label');
        // Check if Orders in this folder are editable
        /**
         * Page repository.
         *
         * @var \CommerceTeam\Commerce\Domain\Repository\PageRepository $pageRepository
         */
        $pageRepository = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Repository\\PageRepository');
        $orderEditable = !empty($pageRepository->findEditFolderByUid($orderStoragePid));
        /**
         * Order article repository.
         *
         * @var OrderArticleRepository
         */
        $orderArticleRepository = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Repository\\OrderArticleRepository');
        $orderArticles = $orderArticleRepository->findByOrderIdInPage($orderId, $orderStoragePid);
        $sum = array();
        $out = '';
        if (!empty($orderArticles)) {
            /*
             * Only if we have a result
             */
            $theData[$titleCol] = '<span class="c-table">' . $language->sL('LLL:EXT:commerce/Resources/Private/Language/locallang_be.xml:order_view.items.article_list', 1) . '</span> (' . count($orderArticles) . ')';
            if ($settingsFactory->getExtConf('invoicePageID')) {
                $theData[$titleCol] .= '<a href="../index.php?id=' . $settingsFactory->getExtConf('invoicePageID') . '&amp;tx_commerce_pi6[order_id]=' . $orderId . '&amp;type=' . $settingsFactory->getExtConf('invoicePageType') . '" target="_blank">' . $language->sL('LLL:EXT:commerce/Resources/Private/Language/locallang_be.xml:order_view.items.print_invoice', 1) . ' *</a>';
            }
            $out .= '
                <tr>
                    <td class="c-headLineTable" style="width: 95%;" colspan="' . (count($fieldRows) + 1) . '">' . $theData[$titleCol] . '</td>
                </tr>';
            /*
             * Header colum
             */
            foreach ($fieldRows as $field) {
                $out .= '<td class="c-headLineTable"><b>' . $language->sL(BackendUtility::getItemLabel($orderArticleTable, $field)) . '</b></td>';
            }
            $out .= '<td class="c-headLineTable"></td></tr>';
            // @todo Switch to moneylib to use formating
            $cc = 0;
            $iOut = '';
            $currency = 'EUR';
            if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce']['extConf']['defaultCurrency'])) {
                $currency = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce']['extConf']['defaultCurrency'];
            }
            foreach ($orderArticles as $row) {
                ++$cc;
                $sum['amount'] += $row['amount'];
                if ($parameter['row']['pricefromnet'] == 1) {
                    $row['price_net'] = $row['price_net'] * $row['amount'];
                    $row['price_gross'] = $row['price_net'] * (1 + (double) $row['tax'] / 100);
                } else {
                    $row['price_gross'] = $row['price_gross'] * $row['amount'];
                    $row['price_net'] = $row['price_gross'] / (1 + (double) $row['tax'] / 100);
                }
                $sum['price_net_value'] += $row['price_net'];
                $sum['price_gross_value'] += $row['price_gross'];
                $row['price_net'] = Money::format(strval($row['price_net']), $currency);
                $row['price_gross'] = Money::format(strval($row['price_gross']), $currency);
                $rowBgColor = $cc % 2 ? '' : ' bgcolor="' . GeneralUtility::modifyHTMLColor($this->getControllerDocumentTemplate()->bgColor4, +10, +10, +10) . '"';
                /*
                 * Not very nice to render html_code directly
                 * @todo change rendering html code here
                 */
                $iOut .= '<tr ' . $rowBgColor . '>';
                foreach ($fieldRows as $field) {
                    $wrap = array('', '');
                    switch ($field) {
                        case $titleCol:
                            $iOut .= '<td>';
                            if ($orderEditable) {
                                $params = '&edit[' . $orderArticleTable . '][' . $row['uid'] . ']=edit';
                                $wrap = array('<a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $this->getBackPath())) . '">', '</a>');
                            }
                            break;
                        case 'amount':
                            $iOut .= '<td>';
                            if ($orderEditable) {
                                $params = '&edit[' . $orderArticleTable . '][' . $row['uid'] . ']=edit&columnsOnly=amount';
                                $onclickAction = 'onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $this->getBackPath())) . '"';
                                $wrap = array('<b><a href="#" ' . $onclickAction . '>' . IconUtility::getSpriteIcon('actions-document-open'), '</a></b>');
                            }
                            break;
                        case 'price_net':
                            // fall through
                        // fall through
                        case 'price_gross':
                            $iOut .= '<td style="text-align: right">';
                            break;
                        default:
                            $iOut .= '<td>';
                    }
                    $iOut .= implode(BackendUtility::getProcessedValue($orderArticleTable, $field, $row[$field], 100), $wrap);
                    $iOut .= '</td>';
                }
                /*
                 * Trash icon
                 */
                $iOut .= '<td></td>
					</tr>';
            }
            $out .= $iOut;
            /*
             * Cerate the summ row
             */
            $out .= '<tr>';
            $sum['price_net'] = Money::format(strval($sum['price_net_value']), $currency);
            $sum['price_gross'] = Money::format(strval($sum['price_gross_value']), $currency);
            foreach ($fieldRows as $field) {
                switch ($field) {
                    case 'price_net':
                        // fall through
                    // fall through
                    case 'price_gross':
                        $out .= '<td class="c-headLineTable" style="text-align: right"><b>';
                        break;
                    default:
                        $out .= '<td class="c-headLineTable"><b>';
                }
                if (!empty($sum[$field])) {
                    $out .= BackendUtility::getProcessedValueExtra($orderArticleTable, $field, $sum[$field], 100);
                }
                $out .= '</b></td>';
            }
            $out .= '<td class="c-headLineTable"></td></tr>';
            /*
             * Always
             * Update sum_price_net and sum_price_gross
             * To Be shure everything is ok
             */
            $values = array('sum_price_gross' => $sum['price_gross_value'], 'sum_price_net' => $sum['price_net_value']);
            /**
             * Order repository.
             *
             * @var OrderRepository
             */
            $orderRepository = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Repository\\OrderRepository');
            $orderRepository->updateByOrderId($orderId, $values);
        }
        $out = '
            <!--
                DB listing of elements: "' . htmlspecialchars($orderTable) . '"
            -->
            <table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist">
                ' . $out . '
            </table>';
        $content .= $out;
        return $content;
    }
 /**
  * Rendering a single row for the list
  *
  * @param string $table Table name
  * @param array $row Current record
  * @param integer $cc Counter, counting for each time an element is rendered (used for alternating colors)
  * @param string $titleCol Table field (column) where header value is found
  * @param string $thumbsCol Table field (column) where (possible) thumbnails can be found
  * @param integer $indent Indent from left.
  * @return string Table row for the element
  * @access private
  * @see getTable()
  * @todo Define visibility
  */
 public function renderListRow($table, $row, $cc, $titleCol, $thumbsCol, $indent = 0)
 {
     $iOut = '';
     // If in search mode, make sure the preview will show the correct page
     if (strlen($this->searchString)) {
         $id_orig = $this->id;
         $this->id = $row['pid'];
     }
     if (is_array($row)) {
         // Add special classes for first and last row
         $rowSpecial = '';
         if ($cc == 1 && $indent == 0) {
             $rowSpecial .= ' firstcol';
         }
         if ($cc == $this->totalRowCount || $cc == $this->iLimit) {
             $rowSpecial .= ' lastcol';
         }
         // Background color, if any:
         if ($this->alternateBgColors) {
             $row_bgColor = $cc % 2 ? ' class="db_list_normal' . $rowSpecial . '"' : ' class="db_list_alt' . $rowSpecial . '"';
         } else {
             $row_bgColor = ' class="db_list_normal' . $rowSpecial . '"';
         }
         // Overriding with versions background color if any:
         $row_bgColor = $row['_CSSCLASS'] ? ' class="' . $row['_CSSCLASS'] . '"' : $row_bgColor;
         // Incr. counter.
         $this->counter++;
         // The icon with link
         $alttext = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordIconAltText($row, $table);
         $iconImg = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($table, $row, array('title' => htmlspecialchars($alttext), 'style' => $indent ? ' margin-left: ' . $indent . 'px;' : ''));
         $theIcon = $this->clickMenuEnabled ? $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg, $table, $row['uid']) : $iconImg;
         // Preparing and getting the data-array
         $theData = array();
         foreach ($this->fieldArray as $fCol) {
             if ($fCol == $titleCol) {
                 $recTitle = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle($table, $row, FALSE, TRUE);
                 // If the record is edit-locked	by another user, we will show a little warning sign:
                 if ($lockInfo = \TYPO3\CMS\Backend\Utility\BackendUtility::isRecordLocked($table, $row['uid'])) {
                     $warning = '<a href="#" onclick="' . htmlspecialchars('alert(' . $GLOBALS['LANG']->JScharCode($lockInfo['msg']) . '); return false;') . '" title="' . htmlspecialchars($lockInfo['msg']) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('status-warning-in-use') . '</a>';
                 }
                 $theData[$fCol] = $warning . $this->linkWrapItems($table, $row['uid'], $recTitle, $row);
                 // Render thumbsnails if a thumbnail column exists and there is content in it:
                 if ($this->thumbs && trim($row[$thumbsCol])) {
                     $theData[$fCol] .= '<br />' . $this->thumbCode($row, $table, $thumbsCol);
                 }
                 $localizationMarkerClass = '';
                 if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField']) && $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] != 0 && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0) {
                     // It's a translated record with a language parent
                     $localizationMarkerClass = ' localization';
                 }
             } elseif ($fCol == 'pid') {
                 $theData[$fCol] = $row[$fCol];
             } elseif ($fCol == '_PATH_') {
                 $theData[$fCol] = $this->recPath($row['pid']);
             } elseif ($fCol == '_REF_') {
                 $theData[$fCol] = $this->createReferenceHtml($table, $row['uid']);
             } elseif ($fCol == '_CONTROL_') {
                 $theData[$fCol] = $this->makeControl($table, $row);
             } elseif ($fCol == '_AFTERCONTROL_' || $fCol == '_AFTERREF_') {
                 $theData[$fCol] = '&nbsp;';
             } elseif ($fCol == '_CLIPBOARD_') {
                 $theData[$fCol] = $this->makeClip($table, $row);
             } elseif ($fCol == '_LOCALIZATION_') {
                 list($lC1, $lC2) = $this->makeLocalizationPanel($table, $row);
                 $theData[$fCol] = $lC1;
                 $theData[$fCol . 'b'] = $lC2;
             } elseif ($fCol == '_LOCALIZATION_b') {
             } else {
                 $tmpProc = \TYPO3\CMS\Backend\Utility\BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid']);
                 $theData[$fCol] = $this->linkUrlMail(htmlspecialchars($tmpProc), $row[$fCol]);
                 if ($this->csvOutput) {
                     $row[$fCol] = \TYPO3\CMS\Backend\Utility\BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 0, $row['uid']);
                 }
             }
         }
         // Reset the ID if it was overwritten
         if (strlen($this->searchString)) {
             $this->id = $id_orig;
         }
         // Add row to CSV list:
         if ($this->csvOutput) {
             $this->addToCSV($row, $table);
         }
         // Add classes to table cells
         $this->addElement_tdCssClass[$titleCol] = 'col-title' . $localizationMarkerClass;
         if (!$this->dontShowClipControlPanels) {
             $this->addElement_tdCssClass['_CONTROL_'] = 'col-control';
             $this->addElement_tdCssClass['_AFTERCONTROL_'] = 'col-control-space';
             $this->addElement_tdCssClass['_CLIPBOARD_'] = 'col-clipboard';
         }
         $this->addElement_tdCssClass['_PATH_'] = 'col-path';
         $this->addElement_tdCssClass['_LOCALIZATION_'] = 'col-localizationa';
         $this->addElement_tdCssClass['_LOCALIZATION_b'] = 'col-localizationb';
         // Create element in table cells:
         $iOut .= $this->addelement(1, $theIcon, $theData, $row_bgColor);
         // Finally, return table row element:
         return $iOut;
     }
 }
 /**
  * Renders the HTML header for a foreign record, such as the title, toggle-function, drag'n'drop, etc.
  * Later on the command-icons are inserted here.
  *
  * @param string $parentUid The uid of the parent (embedding) record (uid or NEW...)
  * @param string $foreign_table The foreign_table we create a header for
  * @param array $rec The current record of that foreign_table
  * @param array $config content of $PA['fieldConf']['config']
  * @param boolean $isVirtualRecord
  * @return string The HTML code of the header
  * @todo Define visibility
  */
 public function renderForeignRecordHeader($parentUid, $foreign_table, $rec, $config, $isVirtualRecord = FALSE)
 {
     // Init:
     $objectId = $this->inlineNames['object'] . self::Structure_Separator . $foreign_table . self::Structure_Separator . $rec['uid'];
     // We need the returnUrl of the main script when loading the fields via AJAX-call (to correct wizard code, so include it as 3rd parameter)
     // Pre-Processing:
     $isOnSymmetricSide = \TYPO3\CMS\Core\Database\RelationHandler::isOnSymmetricSide($parentUid, $config, $rec);
     $hasForeignLabel = !$isOnSymmetricSide && $config['foreign_label'] ? TRUE : FALSE;
     $hasSymmetricLabel = $isOnSymmetricSide && $config['symmetric_label'] ? TRUE : FALSE;
     // Get the record title/label for a record:
     // render using a self-defined user function
     if ($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc']) {
         $params = array('table' => $foreign_table, 'row' => $rec, 'title' => '', 'isOnSymmetricSide' => $isOnSymmetricSide, 'parent' => array('uid' => $parentUid, 'config' => $config));
         // callUserFunction requires a third parameter, but we don't want to give $this as reference!
         $null = NULL;
         \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc'], $params, $null);
         $recTitle = $params['title'];
     } elseif ($hasForeignLabel || $hasSymmetricLabel) {
         $titleCol = $hasForeignLabel ? $config['foreign_label'] : $config['symmetric_label'];
         $foreignConfig = $this->getPossibleRecordsSelectorConfig($config, $titleCol);
         // Render title for everything else than group/db:
         if ($foreignConfig['type'] != 'groupdb') {
             $recTitle = \TYPO3\CMS\Backend\Utility\BackendUtility::getProcessedValueExtra($foreign_table, $titleCol, $rec[$titleCol], 0, 0, FALSE);
         } else {
             // $recTitle could be something like: "tx_table_123|...",
             $valueParts = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('|', $rec[$titleCol]);
             $itemParts = \TYPO3\CMS\Core\Utility\GeneralUtility::revExplode('_', $valueParts[0], 2);
             $recTemp = \t3lib_befunc::getRecordWSOL($itemParts[0], $itemParts[1]);
             $recTitle = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle($itemParts[0], $recTemp, FALSE);
         }
         $recTitle = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitlePrep($recTitle);
         if (!strcmp(trim($recTitle), '')) {
             $recTitle = \TYPO3\CMS\Backend\Utility\BackendUtility::getNoRecordTitle(TRUE);
         }
     } else {
         $recTitle = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle($foreign_table, $rec, TRUE);
     }
     // Renders a thumbnail for the header
     if (!empty($config['appearance']['headerThumbnail']['field'])) {
         $fieldValue = $rec[$config['appearance']['headerThumbnail']['field']];
         $firstElement = array_shift(\TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $fieldValue));
         $fileUid = array_pop(\TYPO3\CMS\Backend\Utility\BackendUtility::splitTable_Uid($firstElement));
         if (!empty($fileUid)) {
             $fileObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFileObject($fileUid);
             if ($fileObject) {
                 $imageSetup = $config['appearance']['headerThumbnail'];
                 unset($imageSetup['field']);
                 $imageSetup = array_merge(array('width' => 64, 'height' => 64), $imageSetup);
                 $imageUrl = $fileObject->process(\TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGEPREVIEW, $imageSetup)->getPublicUrl(TRUE);
                 $thumbnail = '<img src="' . $imageUrl . '" alt="' . htmlspecialchars($recTitle) . '">';
             } else {
                 $thumbnail = FALSE;
             }
         }
     }
     $altText = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordIconAltText($rec, $foreign_table);
     $iconImg = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($foreign_table, $rec, array('title' => htmlspecialchars($altText), 'id' => $objectId . '_icon'));
     $label = '<span id="' . $objectId . '_label">' . $recTitle . '</span>';
     $ctrl = $this->renderForeignRecordHeaderControl($parentUid, $foreign_table, $rec, $config, $isVirtualRecord);
     $header = '<table>' . '<tr>' . (!empty($config['appearance']['headerThumbnail']['field']) && $thumbnail ? '<td class="t3-form-field-header-inline-thumbnail" id="' . $objectId . '_thumbnailcontainer">' . $thumbnail . '</td>' : '<td class="t3-form-field-header-inline-icon" id="' . $objectId . '_iconcontainer">' . $iconImg . '</td>') . '<td class="t3-form-field-header-inline-summary">' . $label . '</td>' . '<td clasS="t3-form-field-header-inline-ctrl">' . $ctrl . '</td>' . '</tr>' . '</table>';
     return $header;
 }
Beispiel #16
0
 /**
  * Rendering a single row for the list
  *
  * @param string $table Table name
  * @param mixed[] $row Current record
  * @param int $cc Counter, counting for each time an element is rendered (used for alternating colors)
  * @param string $titleCol Table field (column) where header value is found
  * @param string $thumbsCol Table field (column) where (possible) thumbnails can be found
  * @param int $indent Indent from left.
  * @return string Table row for the element
  * @access private
  * @see getTable()
  */
 public function renderListRow($table, $row, $cc, $titleCol, $thumbsCol, $indent = 0)
 {
     if (!is_array($row)) {
         return '';
     }
     $rowOutput = '';
     $id_orig = null;
     // If in search mode, make sure the preview will show the correct page
     if ((string) $this->searchString !== '') {
         $id_orig = $this->id;
         $this->id = $row['pid'];
     }
     // Add special classes for first and last row
     $rowSpecial = '';
     if ($cc == 1 && $indent == 0) {
         $rowSpecial .= ' firstcol';
     }
     if ($cc == $this->totalRowCount || $cc == $this->iLimit) {
         $rowSpecial .= ' lastcol';
     }
     $row_bgColor = ' class="' . $rowSpecial . '"';
     // Overriding with versions background color if any:
     $row_bgColor = $row['_CSSCLASS'] ? ' class="' . $row['_CSSCLASS'] . '"' : $row_bgColor;
     // Incr. counter.
     $this->counter++;
     // The icon with link
     $toolTip = BackendUtility::getRecordToolTip($row, $table);
     $additionalStyle = $indent ? ' style="margin-left: ' . $indent . 'px;"' : '';
     $iconImg = '<span ' . $toolTip . ' ' . $additionalStyle . '>' . $this->iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render() . '</span>';
     $theIcon = $this->clickMenuEnabled ? BackendUtility::wrapClickMenuOnIcon($iconImg, $table, $row['uid']) : $iconImg;
     // Preparing and getting the data-array
     $theData = array();
     $localizationMarkerClass = '';
     foreach ($this->fieldArray as $fCol) {
         if ($fCol == $titleCol) {
             $recTitle = BackendUtility::getRecordTitle($table, $row, false, true);
             $warning = '';
             // If the record is edit-locked	by another user, we will show a little warning sign:
             $lockInfo = BackendUtility::isRecordLocked($table, $row['uid']);
             if ($lockInfo) {
                 $warning = '<a href="#" onclick="alert(' . GeneralUtility::quoteJSvalue($lockInfo['msg']) . '); return false;" title="' . htmlspecialchars($lockInfo['msg']) . '">' . $this->iconFactory->getIcon('status-warning-in-use', Icon::SIZE_SMALL)->render() . '</a>';
             }
             $theData[$fCol] = $theData['__label'] = $warning . $this->linkWrapItems($table, $row['uid'], $recTitle, $row);
             // Render thumbnails, if:
             // - a thumbnail column exists
             // - there is content in it
             // - the thumbnail column is visible for the current type
             $type = 0;
             if (isset($GLOBALS['TCA'][$table]['ctrl']['type'])) {
                 $typeColumn = $GLOBALS['TCA'][$table]['ctrl']['type'];
                 $type = $row[$typeColumn];
             }
             // If current type doesn't exist, set it to 0 (or to 1 for historical reasons,
             // if 0 doesn't exist)
             if (!isset($GLOBALS['TCA'][$table]['types'][$type])) {
                 $type = isset($GLOBALS['TCA'][$table]['types'][0]) ? 0 : 1;
             }
             $visibleColumns = $GLOBALS['TCA'][$table]['types'][$type]['showitem'];
             if ($this->thumbs && trim($row[$thumbsCol]) && preg_match('/(^|(.*(;|,)?))' . $thumbsCol . '(((;|,).*)|$)/', $visibleColumns) === 1) {
                 $theData[$fCol] .= '<br />' . $this->thumbCode($row, $table, $thumbsCol);
             }
             if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField']) && $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] != 0 && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0) {
                 // It's a translated record with a language parent
                 $localizationMarkerClass = ' localization';
             }
         } elseif ($fCol == 'pid') {
             $theData[$fCol] = $row[$fCol];
         } elseif ($fCol == '_PATH_') {
             $theData[$fCol] = $this->recPath($row['pid']);
         } elseif ($fCol == '_REF_') {
             $theData[$fCol] = $this->createReferenceHtml($table, $row['uid']);
         } elseif ($fCol == '_CONTROL_') {
             $theData[$fCol] = $this->makeControl($table, $row);
         } elseif ($fCol == '_CLIPBOARD_') {
             $theData[$fCol] = $this->makeClip($table, $row);
         } elseif ($fCol == '_LOCALIZATION_') {
             list($lC1, $lC2) = $this->makeLocalizationPanel($table, $row);
             $theData[$fCol] = $lC1;
             $theData[$fCol . 'b'] = '<div class="btn-group">' . $lC2 . '</div>';
         } elseif ($fCol == '_LOCALIZATION_b') {
             // deliberately empty
         } else {
             $pageId = $table === 'pages' ? $row['uid'] : $row['pid'];
             $tmpProc = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid'], true, $pageId);
             $theData[$fCol] = $this->linkUrlMail(htmlspecialchars($tmpProc), $row[$fCol]);
             if ($this->csvOutput) {
                 $row[$fCol] = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 0, $row['uid']);
             }
         }
     }
     // Reset the ID if it was overwritten
     if ((string) $this->searchString !== '') {
         $this->id = $id_orig;
     }
     // Add row to CSV list:
     if ($this->csvOutput) {
         $this->addToCSV($row);
     }
     // Add classes to table cells
     $this->addElement_tdCssClass[$titleCol] = 'col-title' . $localizationMarkerClass;
     $this->addElement_tdCssClass['_CONTROL_'] = 'col-control';
     if ($this->getModule()->MOD_SETTINGS['clipBoard']) {
         $this->addElement_tdCssClass['_CLIPBOARD_'] = 'col-clipboard';
     }
     $this->addElement_tdCssClass['_PATH_'] = 'col-path';
     $this->addElement_tdCssClass['_LOCALIZATION_'] = 'col-localizationa';
     $this->addElement_tdCssClass['_LOCALIZATION_b'] = 'col-localizationb';
     // Create element in table cells:
     $theData['uid'] = $row['uid'];
     if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField']) && isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']) && !isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'])) {
         $theData['parent'] = $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']];
     }
     $rowOutput .= $this->addElement(1, $theIcon, $theData, $row_bgColor);
     // Finally, return table row element:
     return $rowOutput;
 }
Beispiel #17
0
 /**
  * Rendering a single row for the list
  *
  * @param string $table Table name
  * @param array $row Current record
  * @param int $cc Counter, counting for each time an element
  * 	is rendered (used for alternating colors)
  * @param string $titleCol Table field (column) where header value is found
  * @param string $thumbsCol Table field (column) where (possible)
  * 	thumbnails can be found
  * @param int $indent Indent from left.
  *
  * @return string Table row for the element
  * @see getTable()
  */
 public function renderListRow($table, array $row, $cc, $titleCol, $thumbsCol, $indent = 0)
 {
     $backendUser = $this->getBackendUser();
     $iOut = '';
     $extConf = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][COMMERCE_EXTKEY]['extConf'];
     if (substr(TYPO3_version, 0, 3) >= '4.0') {
         // In offline workspace, look for alternative record:
         BackendUtility::workspaceOL($table, $row, $GLOBALS['BE_USER']->workspace);
     }
     $rowBackgroundColor = '';
     if ($this->alternateBgColors) {
         $rowBackgroundColor = $cc % 2 ? '' : ' bgcolor="' . GeneralUtility::modifyHTMLColor($GLOBALS['SOBE']->doc->bgColor4, 10, 10, 10) . '"';
     }
     if ($backendUser->getModuleData('commerce_orders/index.php/userid', 'ses') == $row['uid']) {
         $rowBackgroundColor = ' bgcolor="' . GeneralUtility::modifyHTMLColor($GLOBALS['SOBE']->doc->bgColor4, 30, 30, 30) . '"';
     }
     // Overriding with versions background color if any:
     $rowBackgroundColor = $row['_CSSCLASS'] ? ' class="' . $row['_CSSCLASS'] . '"' : $rowBackgroundColor;
     // Initialization
     $alttext = BackendUtility::getRecordIconAltText($row, $table);
     // Incr. counter.
     $this->counter++;
     // The icon with link
     $iconImg = IconUtility::skinImg($this->backPath, IconUtility::getIcon($table, $row), 'title="' . htmlspecialchars($alttext) . '"' . ($indent ? ' style="margin-left: ' . $indent . 'px;"' : ''));
     $theIcon = $this->clickMenuEnabled ? $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg, $table, $row['uid']) : $iconImg;
     // Preparing and getting the data-array
     $theData = array();
     foreach ($this->fieldArray as $fCol) {
         if ($fCol == 'pid') {
             $theData[$fCol] = $row[$fCol];
         }
         if ($fCol == 'username') {
             $theData[$fCol] = $row[$fCol];
         } elseif ($fCol == 'crdate') {
             $theData[$fCol] = BackendUtility::date($row[$fCol]);
         } elseif ($fCol == '_PATH_') {
             $theData[$fCol] = $this->recPath($row['pid']);
         } elseif ($fCol == '_CONTROL_') {
             $theData[$fCol] = $this->makeControl($table, $row);
         } elseif ($fCol == '_CLIPBOARD_') {
             $theData[$fCol] = $this->makeClip($table, $row);
         } elseif ($fCol == '_LOCALIZATION_') {
             list($lC1, $lC2) = $this->makeLocalizationPanel($table, $row);
             $theData[$fCol] = $lC1;
             $theData[$fCol . 'b'] = $lC2;
         } elseif ($fCol == '_LOCALIZATION_b') {
             // Do nothing, has been done above.
             $theData[$fCol] .= '';
         } else {
             /**
              * Use own method, if typo3 4.0.0 is not installed
              */
             if (substr(TYPO3_version, 0, 3) >= '4.0') {
                 $theData[$fCol] = $this->linkUrlMail(htmlspecialchars(BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid'])), $row[$fCol]);
             } else {
                 $theData[$fCol] = $this->myLinkUrlMail(htmlspecialchars(BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid'])), $row[$fCol]);
             }
         }
     }
     // Add row to CSV list:
     if ($this->csvOutput) {
         // Charset Conversion
         /**
          * Charset converter
          *
          * @var \TYPO3\CMS\Core\Charset\CharsetConverter $csObj
          */
         $csObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Charset\\CharsetConverter');
         $csObj->initCharset($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset']);
         if (!$extConf['BECSVCharset']) {
             $extConf['BECSVCharset'] = 'iso-8859-1';
         }
         $csObj->initCharset($extConf['BECSVCharset']);
         $csObj->convArray($row, $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'], $extConf['BECSVCharset']);
         $this->addToCSV($row);
     }
     // Create element in table cells:
     $iOut .= $this->addelement(1, $theIcon, $theData, $rowBackgroundColor);
     // Render thumbsnails if a thumbnail column exists and there is content in it:
     if ($this->thumbs && trim($row[$thumbsCol])) {
         $iOut .= $this->addelement(4, '', array($titleCol => $this->thumbCode($row, $table, $thumbsCol)), $rowBackgroundColor);
     }
     // Finally, return table row element:
     return $iOut;
 }
Beispiel #18
0
 /**
  * Renders the HTML header for a foreign record, such as the title, toggle-function, drag'n'drop, etc.
  * Later on the command-icons are inserted here.
  *
  * @param string $parentUid The uid of the parent (embedding) record (uid or NEW...)
  * @param string $foreign_table The foreign_table we create a header for
  * @param array $rec The current record of that foreign_table
  * @param array $config content of $PA['fieldConf']['config']
  * @param boolean $isVirtualRecord
  * @return string The HTML code of the header
  * @todo Define visibility
  */
 public function renderForeignRecordHeader($parentUid, $foreign_table, $rec, $config, $isVirtualRecord = FALSE)
 {
     // Init:
     $objectId = $this->inlineNames['object'] . self::Structure_Separator . $foreign_table . self::Structure_Separator . $rec['uid'];
     // We need the returnUrl of the main script when loading the fields via AJAX-call (to correct wizard code, so include it as 3rd parameter)
     // Pre-Processing:
     $isOnSymmetricSide = RelationHandler::isOnSymmetricSide($parentUid, $config, $rec);
     $hasForeignLabel = !$isOnSymmetricSide && $config['foreign_label'] ? TRUE : FALSE;
     $hasSymmetricLabel = $isOnSymmetricSide && $config['symmetric_label'] ? TRUE : FALSE;
     // Get the record title/label for a record:
     // Try using a self-defined user function only for formatted labels
     if (isset($GLOBALS['TCA'][$foreign_table]['ctrl']['formattedLabel_userFunc'])) {
         $params = array('table' => $foreign_table, 'row' => $rec, 'title' => '', 'isOnSymmetricSide' => $isOnSymmetricSide, 'options' => isset($GLOBALS['TCA'][$foreign_table]['ctrl']['formattedLabel_userFunc_options']) ? $GLOBALS['TCA'][$foreign_table]['ctrl']['formattedLabel_userFunc_options'] : array(), 'parent' => array('uid' => $parentUid, 'config' => $config));
         // callUserFunction requires a third parameter, but we don't want to give $this as reference!
         $null = NULL;
         GeneralUtility::callUserFunction($GLOBALS['TCA'][$foreign_table]['ctrl']['formattedLabel_userFunc'], $params, $null);
         $recTitle = $params['title'];
         // Try using a normal self-defined user function
     } elseif (isset($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc'])) {
         $params = array('table' => $foreign_table, 'row' => $rec, 'title' => '', 'isOnSymmetricSide' => $isOnSymmetricSide, 'parent' => array('uid' => $parentUid, 'config' => $config));
         // callUserFunction requires a third parameter, but we don't want to give $this as reference!
         $null = NULL;
         GeneralUtility::callUserFunction($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc'], $params, $null);
         $recTitle = $params['title'];
     } elseif ($hasForeignLabel || $hasSymmetricLabel) {
         $titleCol = $hasForeignLabel ? $config['foreign_label'] : $config['symmetric_label'];
         $foreignConfig = $this->getPossibleRecordsSelectorConfig($config, $titleCol);
         // Render title for everything else than group/db:
         if ($foreignConfig['type'] != 'groupdb') {
             $recTitle = BackendUtility::getProcessedValueExtra($foreign_table, $titleCol, $rec[$titleCol], 0, 0, FALSE);
         } else {
             // $recTitle could be something like: "tx_table_123|...",
             $valueParts = GeneralUtility::trimExplode('|', $rec[$titleCol]);
             $itemParts = GeneralUtility::revExplode('_', $valueParts[0], 2);
             $recTemp = BackendUtility::getRecordWSOL($itemParts[0], $itemParts[1]);
             $recTitle = BackendUtility::getRecordTitle($itemParts[0], $recTemp, FALSE);
         }
         $recTitle = BackendUtility::getRecordTitlePrep($recTitle);
         if (trim($recTitle) === '') {
             $recTitle = BackendUtility::getNoRecordTitle(TRUE);
         }
     } else {
         $recTitle = BackendUtility::getRecordTitle($foreign_table, $rec, TRUE);
     }
     $altText = BackendUtility::getRecordIconAltText($rec, $foreign_table);
     $iconImg = IconUtility::getSpriteIconForRecord($foreign_table, $rec, array('title' => htmlspecialchars($altText), 'id' => $objectId . '_icon'));
     $label = '<span id="' . $objectId . '_label">' . $recTitle . '</span>';
     $ctrl = $this->renderForeignRecordHeaderControl($parentUid, $foreign_table, $rec, $config, $isVirtualRecord);
     $thumbnail = FALSE;
     // Renders a thumbnail for the header
     if (!empty($config['appearance']['headerThumbnail']['field'])) {
         $fieldValue = $rec[$config['appearance']['headerThumbnail']['field']];
         $firstElement = array_shift(GeneralUtility::trimExplode(',', $fieldValue));
         $fileUid = array_pop(BackendUtility::splitTable_Uid($firstElement));
         if (!empty($fileUid)) {
             $fileObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFileObject($fileUid);
             if ($fileObject && $fileObject->isMissing()) {
                 $flashMessage = \TYPO3\CMS\Core\Resource\Utility\BackendUtility::getFlashMessageForMissingFile($fileObject);
                 $thumbnail = $flashMessage->render();
             } elseif ($fileObject) {
                 $imageSetup = $config['appearance']['headerThumbnail'];
                 unset($imageSetup['field']);
                 $imageSetup = array_merge(array('width' => '45', 'height' => '45c'), $imageSetup);
                 $processedImage = $fileObject->process(\TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGECROPSCALEMASK, $imageSetup);
                 // Only use a thumbnail if the processing was successful.
                 if (!$processedImage->usesOriginalFile()) {
                     $imageUrl = $processedImage->getPublicUrl(TRUE);
                     $thumbnail = '<img class="t3-form-field-header-inline-thumbnail-image" src="' . $imageUrl . '" alt="' . htmlspecialchars($altText) . '" title="' . htmlspecialchars($altText) . '">';
                 }
             }
         }
     }
     if (!empty($config['appearance']['headerThumbnail']['field']) && $thumbnail) {
         $headerClasses = ' t3-form-field-header-inline-has-thumbnail';
         $mediaContainer = '<div class="t3-form-field-header-inline-thumbnail" id="' . $objectId . '_thumbnailcontainer">' . $thumbnail . '</div>';
     } else {
         $headerClasses = ' t3-form-field-header-inline-has-icon';
         $mediaContainer = '<div class="t3-form-field-header-inline-icon" id="' . $objectId . '_iconcontainer">' . $iconImg . '</div>';
     }
     $header = '<div class="t3-form-field-header-inline-wrap' . $headerClasses . '">' . '<div class="t3-form-field-header-inline-ctrl">' . $ctrl . '</div>' . '<div class="t3-form-field-header-inline-body">' . $mediaContainer . '<div class="t3-form-field-header-inline-summary">' . $label . '</div>' . '</div>' . '</div>';
     return $header;
 }
Beispiel #19
0
    /**
     * Oder Articles
     * Renders the List of aricles
     *
     * @param array $parameter Parameter
     *
     * @return string HTML-Content
     */
    public function orderArticles(array $parameter)
    {
        $database = $this->getDatabaseConnection();
        $language = $this->getLanguageService();
        $content = '';
        $foreignTable = 'tx_commerce_order_articles';
        $table = 'tx_commerce_orders';
        /**
         * Document template
         *
         * @var \TYPO3\CMS\Backend\Template\DocumentTemplate $doc
         */
        $doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
        $doc->backPath = $GLOBALS['BACK_PATH'];
        /**
         * GET Storage PID and order_id from Data
         */
        $orderStoragePid = $parameter['row']['pid'];
        $orderId = $parameter['row']['order_id'];
        /**
         * Select Order_articles
         */
        // @todo TS config of fields in list
        $fieldRows = array('amount', 'title', 'article_number', 'price_net', 'price_gross');
        /**
         * Taken from class.db_list_extra.php
         */
        $titleCol = $GLOBALS['TCA'][$foreignTable]['ctrl']['label'];
        // Check if Orders in this folder are editable
        $orderEditable = FALSE;
        $checkResult = $database->exec_SELECTquery('tx_commerce_foldereditorder', 'pages', 'uid = ' . $orderStoragePid);
        if ($database->sql_num_rows($checkResult) == 1) {
            if ($checkRow = $database->sql_fetch_assoc($checkResult)) {
                if ($checkRow['tx_commerce_foldereditorder'] == 1) {
                    $orderEditable = TRUE;
                }
            }
        }
        // Create the SQL query for selecting the elements in the listing:
        $result = $database->exec_SELECTquery('*', $foreignTable, 'pid = ' . $orderStoragePid . BackendUtility::deleteClause($foreignTable) . ' AND order_id = \'' . $database->quoteStr($orderId, $foreignTable) . '\'');
        $dbCount = $database->sql_num_rows($result);
        $sum = array();
        $out = '';
        if ($dbCount) {
            /**
             * Only if we have a result
             */
            $theData[$titleCol] = '<span class="c-table">' . $language->sL('LLL:EXT:commerce/Resources/Private/Language/locallang_be.xml:order_view.items.article_list', 1) . '</span> (' . $dbCount . ')';
            $extConf = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][COMMERCE_EXTKEY]['extConf'];
            if ($extConf['invoicePageID'] > 0) {
                $theData[$titleCol] .= '<a href="../index.php?id=' . $extConf['invoicePageID'] . '&amp;tx_commerce_pi6[order_id]=' . $orderId . '&amp;type=' . $extConf['invoicePageType'] . '" target="_blank">' . $language->sL('LLL:EXT:commerce/Resources/Private/Language/locallang_be.xml:order_view.items.print_invoice', 1) . ' *</a>';
            }
            $colCount = count($fieldRows);
            $out .= '
				<tr>
					<td class="c-headLineTable" style="width: 95%;" colspan="' . ($colCount + 1) . '">' . $theData[$titleCol] . '</td>
				</tr>';
            /**
             * Header colum
             */
            foreach ($fieldRows as $field) {
                $out .= '<td class="c-headLineTable"><b>' . $language->sL(BackendUtility::getItemLabel($foreignTable, $field)) . '</b></td>';
            }
            $out .= '<td class="c-headLineTable"></td></tr>';
            // @todo Switch to moneylib to use formating
            $cc = 0;
            $iOut = '';
            while ($row = $database->sql_fetch_assoc($result)) {
                $cc++;
                $sum['amount'] += $row['amount'];
                if ($parameter['row']['pricefromnet'] == 1) {
                    $row['price_net'] = $row['price_net'] * $row['amount'];
                    $row['price_gross'] = $row['price_net'] * (1 + (double) $row['tax'] / 100);
                } else {
                    $row['price_gross'] = $row['price_gross'] * $row['amount'];
                    $row['price_net'] = $row['price_gross'] / (1 + (double) $row['tax'] / 100);
                }
                $sum['price_net_value'] += $row['price_net'];
                $sum['price_gross_value'] += $row['price_gross'];
                $row['price_net'] = Tx_Commerce_ViewHelpers_Money::format(intval(round($row['price_net'])), '');
                $row['price_gross'] = Tx_Commerce_ViewHelpers_Money::format(intval(round($row['price_gross'])), '');
                $rowBgColor = $cc % 2 ? '' : ' bgcolor="' . GeneralUtility::modifyHTMLColor($GLOBALS['SOBE']->doc->bgColor4, +10, +10, +10) . '"';
                /**
                 * Not very noice to render html_code directly
                 * @todo change rendering html code here
                 */
                $iOut .= '<tr ' . $rowBgColor . '>';
                foreach ($fieldRows as $field) {
                    $wrap = array('', '');
                    switch ($field) {
                        case $titleCol:
                            $iOut .= '<td>';
                            if ($orderEditable) {
                                $params = '&edit[' . $foreignTable . '][' . $row['uid'] . ']=edit';
                                $wrap = array('<a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $GLOBALS['BACK_PATH'])) . '">', '</a>');
                            }
                            break;
                        case 'amount':
                            $iOut .= '<td>';
                            if ($orderEditable) {
                                $params = '&edit[' . $foreignTable . '][' . $row['uid'] . ']=edit&columnsOnly=amount';
                                $onclickAction = 'onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $GLOBALS['BACK_PATH'])) . '"';
                                $wrap = array('<b><a href="#" ' . $onclickAction . '>' . IconUtility::getSpriteIcon('actions-document-open'), '</a></b>');
                            }
                            break;
                        case 'price_net':
                            // fall through
                        // fall through
                        case 'price_gross':
                            $iOut .= '<td style="text-align: right">';
                            break;
                        default:
                            $iOut .= '<td>';
                    }
                    $iOut .= implode(BackendUtility::getProcessedValue($foreignTable, $field, $row[$field], 100), $wrap);
                    $iOut .= '</td>';
                }
                /**
                 * Trash icon
                 */
                $iOut .= '<td></td>
					</tr>';
            }
            $out .= $iOut;
            /**
             * Cerate the sum row
             */
            $out .= '<tr>';
            $sum['price_net'] = Tx_Commerce_ViewHelpers_Money::format(intval(round($sum['price_net_value'])), '');
            $sum['price_gross'] = Tx_Commerce_ViewHelpers_Money::format(intval(round($sum['price_gross_value'])), '');
            foreach ($fieldRows as $field) {
                switch ($field) {
                    case 'price_net':
                        // fall through
                    // fall through
                    case 'price_gross':
                        $out .= '<td class="c-headLineTable" style="text-align: right"><b>';
                        break;
                    default:
                        $out .= '<td class="c-headLineTable"><b>';
                }
                if ($sum[$field] != '') {
                    $out .= BackendUtility::getProcessedValueExtra($foreignTable, $field, $sum[$field], 100);
                }
                $out .= '</b></td>';
            }
            $out .= '<td class="c-headLineTable"></td></tr>';
        }
        $out = '
			<!--
				DB listing of elements: "' . htmlspecialchars($table) . '"
			-->
			<table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist">
				' . $out . '
			</table>';
        $content .= $out;
        return $content;
    }