Exemplo n.º 1
0
 /**
  * Renders a HTML Block with file information
  *
  * @param File $file
  * @return string
  */
 protected function renderFileInformationContent(File $file = null)
 {
     /** @var LanguageService $lang */
     $lang = $GLOBALS['LANG'];
     if ($file !== null) {
         $processedFile = $file->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, array('width' => 150, 'height' => 150));
         $previewImage = $processedFile->getPublicUrl(true);
         $content = '';
         if ($file->isMissing()) {
             $flashMessage = \TYPO3\CMS\Core\Resource\Utility\BackendUtility::getFlashMessageForMissingFile($file);
             $content .= $flashMessage->render();
         }
         if ($previewImage) {
             $content .= '<img src="' . htmlspecialchars($previewImage) . '" ' . 'width="' . $processedFile->getProperty('width') . '" ' . 'height="' . $processedFile->getProperty('height') . '" ' . 'alt="" class="t3-tceforms-sysfile-imagepreview" />';
         }
         $content .= '<strong>' . htmlspecialchars($file->getName()) . '</strong>';
         $content .= ' (' . htmlspecialchars(GeneralUtility::formatSize($file->getSize())) . 'bytes)<br />';
         $content .= BackendUtility::getProcessedValue('sys_file', 'type', $file->getType()) . ' (' . $file->getMimeType() . ')<br />';
         $content .= $lang->sL('LLL:EXT:lang/locallang_misc.xlf:fileMetaDataLocation', true) . ': ';
         $content .= htmlspecialchars($file->getStorage()->getName()) . ' - ' . htmlspecialchars($file->getIdentifier()) . '<br />';
         $content .= '<br />';
     } else {
         $content = '<h2>' . $lang->sL('LLL:EXT:lang/locallang_misc.xlf:fileMetaErrorInvalidRecord', true) . '</h2>';
     }
     return $content;
 }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
0
 /**
  * User function for sys_file (element)
  *
  * @param array $PA the array with additional configuration options.
  * @param \TYPO3\CMS\Backend\Form\FormEngine $tceformsObj the TCEforms parent object
  * @return string The HTML code for the TCEform field
  */
 public function renderFileInfo(array $PA, \TYPO3\CMS\Backend\Form\FormEngine $tceformsObj)
 {
     $fileRecord = $PA['row'];
     if ($fileRecord['uid'] > 0) {
         $fileObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFileObject($fileRecord['uid']);
         $processedFile = $fileObject->process(\TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGEPREVIEW, array('width' => 150, 'height' => 150));
         $previewImage = $processedFile->getPublicUrl(TRUE);
         $content = '';
         if ($previewImage) {
             $content .= '<img src="' . htmlspecialchars($previewImage) . '" alt="" class="t3-tceforms-sysfile-imagepreview" />';
         }
         $content .= '<strong>' . htmlspecialchars($fileObject->getName()) . '</strong> (' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($fileObject->getSize())) . ')<br />';
         $content .= \TYPO3\CMS\Backend\Utility\BackendUtility::getProcessedValue($PA['table'], 'type', $fileObject->getType()) . ' (' . $fileObject->getMimeType() . ')<br />';
         $content .= $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xlf:fileMetaDataLocation', TRUE) . ': ' . htmlspecialchars($fileObject->getStorage()->getName()) . ' - ' . htmlspecialchars($fileObject->getIdentifier()) . '<br />';
         $content .= '<br />';
     } else {
         $content = '<h2>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xlf:fileMetaErrorInvalidRecord', TRUE) . '</h2>';
     }
     return $content;
 }
Exemplo n.º 4
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;
    }
Exemplo n.º 5
0
 /**
  * Creates processed values for all field names in $fieldList based on values from $row array.
  * The result is 'returned' through $info which is passed as a reference
  *
  * @param string $table Table name
  * @param string $fieldList Comma separated list of fields.
  * @param array $row Record from which to take values for processing.
  * @param array $info Array to which the processed values are added.
  * @return void
  */
 public function getProcessedValue($table, $fieldList, array $row, array &$info)
 {
     // Splitting values from $fieldList
     $fieldArr = explode(',', $fieldList);
     // Traverse fields from $fieldList
     foreach ($fieldArr as $field) {
         if ($row[$field]) {
             $info[] = '<strong>' . htmlspecialchars($this->itemLabels[$field]) . '</strong> ' . htmlspecialchars(BackendUtility::getProcessedValue($table, $field, $row[$field]));
         }
     }
 }
Exemplo n.º 6
0
    /**
     * Management of versions for record
     *
     * @return void
     */
    public function versioningMgm()
    {
        // Diffing:
        $diff_1 = GeneralUtility::_POST('diff_1');
        $diff_2 = GeneralUtility::_POST('diff_2');
        if (GeneralUtility::_POST('do_diff')) {
            $content = '';
            $content .= '<div class="panel panel-space panel-default">';
            $content .= '<div class="panel-heading">' . $GLOBALS['LANG']->getLL('diffing') . '</div>';
            if ($diff_1 && $diff_2) {
                $diff_1_record = BackendUtility::getRecord($this->table, $diff_1);
                $diff_2_record = BackendUtility::getRecord($this->table, $diff_2);
                if (is_array($diff_1_record) && is_array($diff_2_record)) {
                    $diffUtility = GeneralUtility::makeInstance(DiffUtility::class);
                    $rows = array();
                    $rows[] = '
									<tr>
										<th>' . $GLOBALS['LANG']->getLL('fieldname') . '</th>
										<th width="98%">' . $GLOBALS['LANG']->getLL('coloredDiffView') . ':</th>
									</tr>
								';
                    foreach ($diff_1_record as $fN => $fV) {
                        if ($GLOBALS['TCA'][$this->table]['columns'][$fN] && $GLOBALS['TCA'][$this->table]['columns'][$fN]['config']['type'] !== 'passthrough' && $fN !== 't3ver_label') {
                            if ((string) $diff_1_record[$fN] !== (string) $diff_2_record[$fN]) {
                                $diffres = $diffUtility->makeDiffDisplay(BackendUtility::getProcessedValue($this->table, $fN, $diff_2_record[$fN], 0, 1), BackendUtility::getProcessedValue($this->table, $fN, $diff_1_record[$fN], 0, 1));
                                $rows[] = '
									<tr>
										<td>' . $fN . '</td>
										<td width="98%">' . $diffres . '</td>
									</tr>
								';
                            }
                        }
                    }
                    if (count($rows) > 1) {
                        $content .= '<div class="table-fit"><table class="table">' . implode('', $rows) . '</table></div>';
                    } else {
                        $content .= '<div class="panel-body">' . $GLOBALS['LANG']->getLL('recordsMatchesCompletely') . '</div>';
                    }
                } else {
                    $content .= '<div class="panel-body">' . $GLOBALS['LANG']->getLL('errorRecordsNotFound') . '</div>';
                }
            } else {
                $content .= '<div class="panel-body">' . $GLOBALS['LANG']->getLL('errorDiffSources') . '</div>';
            }
            $content .= '</div>';
        }
        // Element:
        $record = BackendUtility::getRecord($this->table, $this->uid);
        $recTitle = BackendUtility::getRecordTitle($this->table, $record, true);
        // Display versions:
        $content .= '
			<form name="theform" action="' . str_replace('&sendToReview=1', '', $this->REQUEST_URI) . '" method="post">
				<div class="panel panel-space panel-default">
				<div class="panel-heading">' . $recTitle . '</div>
					<div class="table-fit">
						<table class="table">
							<thead>
								<tr>
									<th colspan="2" class="col-icon"></th>
									<th title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_title') . '">' . $GLOBALS['LANG']->getLL('tblHeader_title') . '</th>
									<th title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_uid') . '"><i>' . $GLOBALS['LANG']->getLL('tblHeader_uid') . '</i></th>
									<th title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_oid') . '"><i>' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_oid') . '</i></th>
									<th title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_id') . '"><i>' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_id') . '</i></th>
									<th title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_wsid') . '"><i>' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_wsid') . '</i></th>
									<th title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_state', true) . '"><i>' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_state') . '</i></th>
									<th title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_stage') . '"><i>' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_stage') . '</i></th>
									<th title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_count') . '"><i>' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_count') . '</i></th>
									<th title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_pid') . '"><i>' . $GLOBALS['LANG']->getLL('tblHeader_pid') . '</i></th>
									<th title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_label') . '"><i>' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_label') . '</i></th>
									<th></th>
									<th colspan="2">
										<button class="btn btn-default btn-sm" type="submit"  name="do_diff" value="true">
											' . $GLOBALS['LANG']->getLL('diff') . '
										</button>
									</th>
								</tr>
							</thead>
							<tbody>
			';
        $versions = BackendUtility::selectVersionsOfRecord($this->table, $this->uid, '*', $GLOBALS['BE_USER']->workspace);
        foreach ($versions as $row) {
            $adminLinks = $this->adminLinks($this->table, $row);
            $editUrl = BackendUtility::getModuleUrl('record_edit', ['edit' => [$this->table => [$row['uid'] => 'edit']], 'columnsOnly' => 't3ver_label', 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')]);
            $content .= '
				<tr' . ($row['uid'] != $this->uid ? '' : ' class="active"') . '>
					<td class="col-icon">' . ($row['uid'] != $this->uid ? '<a href="' . BackendUtility::getLinkToDataHandlerAction('&cmd[' . $this->table . '][' . $this->uid . '][version][swapWith]=' . $row['uid'] . '&cmd[' . $this->table . '][' . $this->uid . '][version][action]=swap') . '" title="' . $GLOBALS['LANG']->getLL('swapWithCurrent', true) . '">' . $this->moduleTemplate->getIconFactory()->getIcon('actions-version-swap-version', Icon::SIZE_SMALL)->render() . '</a>' : '<span title="' . $GLOBALS['LANG']->getLL('currentOnlineVersion', true) . '">' . $this->moduleTemplate->getIconFactory()->getIcon('status-status-current', Icon::SIZE_SMALL)->render() . '</span>') . '
					</td>
					<td class="col-icon">' . $this->moduleTemplate->getIconFactory()->getIconForRecord($this->table, $row, Icon::SIZE_SMALL)->render() . '</td>
					<td>' . htmlspecialchars(BackendUtility::getRecordTitle($this->table, $row, true)) . '</td>
					<td>' . $row['uid'] . '</td>
					<td>' . $row['t3ver_oid'] . '</td>
					<td>' . $row['t3ver_id'] . '</td>
					<td>' . $row['t3ver_wsid'] . '</td>
					<td>' . $row['t3ver_state'] . '</td>
					<td>' . $row['t3ver_stage'] . '</td>
					<td>' . $row['t3ver_count'] . '</td>
					<td>' . $row['pid'] . '</td>
					<td>
						<a href="' . htmlspecialchars($editUrl) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.edit', true) . '">
							' . $this->moduleTemplate->getIconFactory()->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '
						</a>' . htmlspecialchars($row['t3ver_label']) . '
					</td>
					<td class="col-control">' . $adminLinks . '</td>
					<td class="text-center success"><input type="radio" name="diff_1" value="' . $row['uid'] . '"' . ($diff_1 == $row['uid'] ? ' checked="checked"' : '') . '/></td>
					<td class="text-center danger"><input type="radio" name="diff_2" value="' . $row['uid'] . '"' . ($diff_2 == $row['uid'] ? ' checked="checked"' : '') . '/></td>
				</tr>';
            // Show sub-content if the table is pages AND it is not the online branch (because that will mostly render the WHOLE tree below - not smart;)
            if ($this->table === 'pages' && $row['uid'] != $this->uid) {
                $sub = $this->pageSubContent($row['uid']);
                if ($sub) {
                    $content .= '
						<tr>
							<td colspan="2"></td>
							<td colspan="11">' . $sub . '</td>
							<td class="success"></td>
							<td class="danger"></td>
						</tr>';
                }
            }
        }
        $content .= '
							</tbody>
						</table>
					</div>
				</div>
			</form>';
        $this->content .= '<h2>' . $GLOBALS['LANG']->getLL('title', true) . '</h2><div>' . $content . '</div>';
        // Create new:
        $content = '
			<form action="' . htmlspecialchars(BackendUtility::getModuleUrl('tce_db')) . '" method="post">
				<div class="row">
					<div class="col-sm-6 col-md-4 col-lg-3">
						<div class="form-group">
							<label for="typo3-new-version-label">' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_label') . '</label>
							<input id="typo3-new-version-label" class="form-control" type="text" name="cmd[' . $this->table . '][' . $this->uid . '][version][label]" />
						</div>
						<div class="form-group">
							<input type="hidden" name="cmd[' . $this->table . '][' . $this->uid . '][version][action]" value="new" />
							<input type="hidden" name="prErr" value="1" />
							<input type="hidden" name="redirect" value="' . htmlspecialchars($this->REQUEST_URI) . '" />
							<input class="btn btn-default" type="submit" name="_" value="' . $GLOBALS['LANG']->getLL('createNewVersion') . '" />
						</div>
					</div>
				</div>
			</form>

		';
        $this->content .= '<h2>' . $GLOBALS['LANG']->getLL('createNewVersion', true) . '</h2><div>' . $content . '</div>';
    }
Exemplo n.º 7
0
    /**
     * Renders HTML table-rows with the comparison information of an sys_history entry record
     *
     * @param array $entry sys_history entry record.
     * @param string $table The table name
     * @param integer $rollbackUid If set to UID of record, display rollback links
     * @return string HTML table
     * @access private
     * @todo Define visibility
     */
    public function renderDiff($entry, $table, $rollbackUid = 0)
    {
        $lines = array();
        if (is_array($entry['newRecord'])) {
            $t3lib_diff_Obj = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Utility\\DiffUtility');
            $fieldsToDisplay = array_keys($entry['newRecord']);
            foreach ($fieldsToDisplay as $fN) {
                if (is_array($GLOBALS['TCA'][$table]['columns'][$fN]) && $GLOBALS['TCA'][$table]['columns'][$fN]['config']['type'] != 'passthrough') {
                    // Create diff-result:
                    $diffres = $t3lib_diff_Obj->makeDiffDisplay(BackendUtility::getProcessedValue($table, $fN, $entry['oldRecord'][$fN], 0, 1), BackendUtility::getProcessedValue($table, $fN, $entry['newRecord'][$fN], 0, 1));
                    $lines[] = '
						<tr class="bgColor4">
						' . ($rollbackUid ? '<td style="width:33px">' . $this->createRollbackLink($table . ':' . $rollbackUid . ':' . $fN, $GLOBALS['LANG']->getLL('revertField', 1), 2) . '</td>' : '') . '
							<td style="width:90px"><em>' . $GLOBALS['LANG']->sl(BackendUtility::getItemLabel($table, $fN), 1) . '</em></td>
							<td style="width:300px">' . nl2br($diffres) . '</td>
						</tr>';
                }
            }
        }
        if ($lines) {
            $content = '<table border="0" cellpadding="2" cellspacing="2" id="typo3-history-item">
					' . implode('', $lines) . '
				</table>';
            return $content;
        }
        // error fallback
        return NULL;
    }
Exemplo n.º 8
0
 /**
  * Fetch futher information to current selected worspace record.
  *
  * @param object $parameter
  * @return array $data
  */
 public function getRowDetails($parameter)
 {
     $diffReturnArray = array();
     $liveReturnArray = array();
     /** @var $t3lib_diff \TYPO3\CMS\Core\Utility\DiffUtility */
     $t3lib_diff = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Utility\\DiffUtility');
     /** @var $parseObj \TYPO3\CMS\Core\Html\RteHtmlParser */
     $parseObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Html\\RteHtmlParser');
     $liveRecord = BackendUtility::getRecord($parameter->table, $parameter->t3ver_oid);
     $versionRecord = BackendUtility::getRecord($parameter->table, $parameter->uid);
     $icon_Live = \TYPO3\CMS\Backend\Utility\IconUtility::mapRecordTypeToSpriteIconClass($parameter->table, $liveRecord);
     $icon_Workspace = \TYPO3\CMS\Backend\Utility\IconUtility::mapRecordTypeToSpriteIconClass($parameter->table, $versionRecord);
     $stagePosition = $this->getStagesService()->getPositionOfCurrentStage($parameter->stage);
     $fieldsOfRecords = array_keys($liveRecord);
     if ($GLOBALS['TCA'][$parameter->table]) {
         if ($GLOBALS['TCA'][$parameter->table]['interface']['showRecordFieldList']) {
             $fieldsOfRecords = $GLOBALS['TCA'][$parameter->table]['interface']['showRecordFieldList'];
             $fieldsOfRecords = GeneralUtility::trimExplode(',', $fieldsOfRecords, TRUE);
         }
     }
     foreach ($fieldsOfRecords as $fieldName) {
         // check for exclude fields
         if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['TCA'][$parameter->table]['columns'][$fieldName]['exclude'] == 0 || GeneralUtility::inList($GLOBALS['BE_USER']->groupData['non_exclude_fields'], $parameter->table . ':' . $fieldName)) {
             // call diff class only if there is a difference
             if ((string) $liveRecord[$fieldName] !== (string) $versionRecord[$fieldName]) {
                 // Select the human readable values before diff
                 $liveRecord[$fieldName] = BackendUtility::getProcessedValue($parameter->table, $fieldName, $liveRecord[$fieldName], 0, 1, FALSE, $liveRecord['uid']);
                 $versionRecord[$fieldName] = BackendUtility::getProcessedValue($parameter->table, $fieldName, $versionRecord[$fieldName], 0, 1, FALSE, $versionRecord['uid']);
                 // Get the field's label. If not available, use the field name
                 $fieldTitle = $GLOBALS['LANG']->sL(BackendUtility::getItemLabel($parameter->table, $fieldName));
                 if (empty($fieldTitle)) {
                     $fieldTitle = $fieldName;
                 }
                 if ($GLOBALS['TCA'][$parameter->table]['columns'][$fieldName]['config']['type'] == 'group' && $GLOBALS['TCA'][$parameter->table]['columns'][$fieldName]['config']['internal_type'] == 'file') {
                     $versionThumb = BackendUtility::thumbCode($versionRecord, $parameter->table, $fieldName, '');
                     $liveThumb = BackendUtility::thumbCode($liveRecord, $parameter->table, $fieldName, '');
                     $diffReturnArray[] = array('field' => $fieldName, 'label' => $fieldTitle, 'content' => $versionThumb);
                     $liveReturnArray[] = array('field' => $fieldName, 'label' => $fieldTitle, 'content' => $liveThumb);
                 } else {
                     $diffReturnArray[] = array('field' => $fieldName, 'label' => $fieldTitle, 'content' => $t3lib_diff->makeDiffDisplay($liveRecord[$fieldName], $versionRecord[$fieldName]));
                     $liveReturnArray[] = array('field' => $fieldName, 'label' => $fieldTitle, 'content' => $parseObj->TS_images_rte($liveRecord[$fieldName]));
                 }
             }
         }
     }
     // Hook for modifying the difference and live arrays
     // (this may be used by custom or dynamically-defined fields)
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['workspaces']['modifyDifferenceArray'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['workspaces']['modifyDifferenceArray'] as $className) {
             $hookObject =& GeneralUtility::getUserObj($className);
             $hookObject->modifyDifferenceArray($parameter, $diffReturnArray, $liveReturnArray, $t3lib_diff);
         }
     }
     $commentsForRecord = $this->getCommentsForRecord($parameter->uid, $parameter->table);
     return array('total' => 1, 'data' => array(array('diff' => $diffReturnArray, 'live_record' => $liveReturnArray, 'path_Live' => $parameter->path_Live, 'label_Stage' => $parameter->label_Stage, 'stage_position' => $stagePosition['position'], 'stage_count' => $stagePosition['count'], 'comments' => $commentsForRecord, 'icon_Live' => $icon_Live, 'icon_Workspace' => $icon_Workspace)));
 }
Exemplo n.º 9
0
 /**
  * Renders HTML table-rows with the comparison information of an sys_history entry record
  *
  * @param array $entry sys_history entry record.
  * @param string $table The table name
  * @param int $rollbackUid If set to UID of record, display rollback links
  * @return string|NULL HTML table
  * @access private
  */
 public function renderDiff($entry, $table, $rollbackUid = 0)
 {
     $lines = array();
     if (is_array($entry['newRecord'])) {
         /* @var DiffUtility $diffUtility */
         $diffUtility = GeneralUtility::makeInstance(DiffUtility::class);
         $fieldsToDisplay = array_keys($entry['newRecord']);
         $languageService = $this->getLanguageService();
         foreach ($fieldsToDisplay as $fN) {
             if (is_array($GLOBALS['TCA'][$table]['columns'][$fN]) && $GLOBALS['TCA'][$table]['columns'][$fN]['config']['type'] !== 'passthrough') {
                 // Create diff-result:
                 $diffres = $diffUtility->makeDiffDisplay(BackendUtility::getProcessedValue($table, $fN, $entry['oldRecord'][$fN], 0, true), BackendUtility::getProcessedValue($table, $fN, $entry['newRecord'][$fN], 0, true));
                 $lines[] = array('title' => ($rollbackUid ? $this->createRollbackLink($table . ':' . $rollbackUid . ':' . $fN, $languageService->getLL('revertField', true), 2) : '') . '
                       ' . $languageService->sL(BackendUtility::getItemLabel($table, $fN), true), 'result' => str_replace('\\n', PHP_EOL, str_replace('\\r\\n', '\\n', $diffres)));
             }
         }
     }
     if ($lines) {
         return $lines;
     }
     // error fallback
     return null;
 }
Exemplo n.º 10
0
    /**
     * shows the infos of a directmail
     * record in a table
     *
     * @param	array	$row: DirectMail DB record
     * @return	string	the HTML output
     */
    protected function renderRecordDetailsTable($row)
    {
        if (!$row['issent']) {
            if ($GLOBALS['BE_USER']->check('tables_modify', 'sys_dmail')) {
                $retUrl = 'returnUrl=' . rawurlencode(GeneralUtility::linkThisScript(array('sys_dmail_uid' => $row['uid'], 'createMailFrom_UID' => '', 'createMailFrom_URL' => '')));
                $Eparams = '&edit[sys_dmail][' . $row['uid'] . ']=edit';
                $editOnClick = 'document.location=\'' . $GLOBALS['BACK_PATH'] . 'alt_doc.php?' . $retUrl . $Eparams . '\'; return false;';
                $content = '<a href="#" onClick="' . $editOnClick . '"><img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/edit2.gif', 'width="12" height="12"') . ' alt="' . $GLOBALS['LANG']->getLL("dmail_edit") . '" width="12" height="12" style="margin: 2px 3px; vertical-align:top;" title="' . $GLOBALS['LANG']->getLL("dmail_edit") . '" />' . '<b>' . $GLOBALS['LANG']->getLL('dmail_edit') . '</b>' . '</a>';
            } else {
                $content = '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/edit2.gif', 'width="12" height="12"') . ' alt="' . $GLOBALS['LANG']->getLL("dmail_edit") . '" width="12" height="12" style="margin: 2px 3px; vertical-align:top;" title="' . $GLOBALS['LANG']->getLL("dmail_edit") . '" />' . '(' . $GLOBALS['LANG']->getLL('dmail_noEdit_noPerms') . ')';
            }
        } else {
            $content = '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/edit2.gif', 'width="12" height="12"') . ' alt="' . $GLOBALS['LANG']->getLL("dmail_edit") . '" width="12" height="12" style="margin: 2px 3px; vertical-align:top;" title="' . $GLOBALS['LANG']->getLL("dmail_edit") . '" />' . '(' . $GLOBALS['LANG']->getLL('dmail_noEdit_isSent') . ')';
        }
        $content = '<tr>
			<td class="t3-row-header">' . DirectMailUtility::fName('subject') . ' <b>' . GeneralUtility::fixed_lgd_cs(htmlspecialchars($row['subject']), 60) . '</b></td>
			<td class="t3-row-header" style="text-align: right;">' . $content . '</td>
		</tr>';
        $nameArr = explode(',', 'from_name,from_email,replyto_name,replyto_email,organisation,return_path,priority,attachment,type,page,sendOptions,includeMedia,flowedFormat,plainParams,HTMLParams,encoding,charset,issent,renderedsize');
        foreach ($nameArr as $name) {
            $content .= '
			<tr>
				<td>' . DirectMailUtility::fName($name) . '</td>
				<td>' . htmlspecialchars(BackendUtility::getProcessedValue('sys_dmail', $name, $row[$name])) . '</td>
			</tr>';
        }
        $content = '<table border="0" cellpadding="1" cellspacing="1" width="460" class="typo3-dblist">' . $content . '</table>';
        $sectionTitle = IconUtility::getSpriteIconForRecord('sys_dmail', $row) . '&nbsp;' . htmlspecialchars($row['subject']);
        return $this->doc->section($sectionTitle, $content, 1, 1, 0, TRUE);
    }
Exemplo n.º 11
0
    /**
     * Shows the existing recipient lists and shows link to create a new one or import a list
     *
     * @return string List of existing recipient list, link to create a new list and link to import
     */
    public function showExistingRecipientLists()
    {
        $out = '<thead>
					<th colspan="2">&nbsp;</th>
					<th>' . $this->getLanguageService()->sL(BackendUtility::getItemLabel('sys_dmail_group', 'title')) . '</th>
					<th>' . $this->getLanguageService()->sL(BackendUtility::getItemLabel('sys_dmail_group', 'type')) . '</th>
					<th>' . $this->getLanguageService()->sL(BackendUtility::getItemLabel('sys_dmail_group', 'description')) . '</th>
					<th>' . $this->getLanguageService()->getLL('recip_group_amount') . '</th>
				</thead>';
        $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,pid,title,description,type', 'sys_dmail_group', 'pid = ' . intval($this->id) . BackendUtility::deleteClause('sys_dmail_group'), '', $GLOBALS['TYPO3_DB']->stripOrderBy($GLOBALS['TCA']['sys_dmail_group']['ctrl']['default_sortby']));
        while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
            $result = $this->cmd_compileMailGroup(intval($row['uid']));
            $count = 0;
            $idLists = $result['queryInfo']['id_lists'];
            if (is_array($idLists['tt_address'])) {
                $count += count($idLists['tt_address']);
            }
            if (is_array($idLists['fe_users'])) {
                $count += count($idLists['fe_users']);
            }
            if (is_array($idLists['PLAINLIST'])) {
                $count += count($idLists['PLAINLIST']);
            }
            if (is_array($idLists[$this->userTable])) {
                $count += count($idLists[$this->userTable]);
            }
            $out .= '<tr class="db_list_normal">
					<td nowrap="nowrap">' . $this->iconFactory->getIconForRecord('sys_dmail_group', $row, Icon::SIZE_SMALL)->render() . '</td>
					<td>' . $this->editLink('sys_dmail_group', $row['uid']) . '</td>
					<td nowrap="nowrap">' . $this->linkRecip_record('<strong>' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($row['title'], 30)) . '</strong>&nbsp;&nbsp;', $row['uid']) . '</td>
					<td nowrap="nowrap">' . htmlspecialchars(BackendUtility::getProcessedValue('sys_dmail_group', 'type', $row['type'])) . '&nbsp;&nbsp;</td>
					<td>' . BackendUtility::getProcessedValue('sys_dmail_group', 'description', htmlspecialchars($row['description'])) . '&nbsp;&nbsp;</td>
					<td>' . $count . '</td>
				</tr>';
        }
        $out = ' <table class="table table-striped table-hover">' . $out . '</table>';
        $theOutput = $this->doc->section(BackendUtility::cshItem($this->cshTable, 'select_mailgroup', $GLOBALS['BACK_PATH']) . $this->getLanguageService()->getLL('recip_select_mailgroup'), $out, 1, 1, 0, true);
        // New:
        $out = '<a href="#" class="t3-link" onClick="' . BackendUtility::editOnClick('&edit[sys_dmail_group][' . $this->id . ']=new', $GLOBALS['BACK_PATH'], '') . '">' . $this->iconFactory->getIconForRecord('sys_dmail_group', array(), Icon::SIZE_SMALL) . $this->getLanguageService()->getLL('recip_create_mailgroup_msg') . '</a>';
        $theOutput .= '<div style="padding-top: 20px;"></div>';
        $theOutput .= $this->doc->section(BackendUtility::cshItem($this->cshTable, 'create_mailgroup', $GLOBALS['BACK_PATH']) . $this->getLanguageService()->getLL('recip_create_mailgroup'), $out, 1, 0, false, true, false, true);
        // Import
        $out = '<a class="t3-link" href="' . BackendUtility::getModuleUrl('DirectMailNavFrame_RecipientList') . '&id=' . $this->id . '&CMD=displayImport">' . $this->getLanguageService()->getLL('recip_import_mailgroup_msg') . '</a>';
        $theOutput .= '<div style="padding-top: 20px;"></div>';
        $theOutput .= $this->doc->section($this->getLanguageService()->getLL('mailgroup_import'), $out, 1, 1, 0, true);
        return $theOutput;
    }
Exemplo n.º 12
0
 /**
  * show the compact information of a direct mail record
  *
  * @param	array		$row: direct mail record
  * @return	string		the compact infos of the direct mail record
  */
 function directMail_compactView($row)
 {
     // Render record:
     if ($row['type']) {
         $dmailData = $row['plainParams'] . ', ' . $row['HTMLParams'];
     } else {
         $page = BackendUtility::getRecord('pages', $row['page'], 'title');
         $dmailData = $row['page'] . ', ' . htmlspecialchars($page['title']);
         $dmail_info = DirectMailUtility::fName('plainParams') . ' ' . htmlspecialchars($row['plainParams'] . LF . DirectMailUtility::fName('HTMLParams') . $row['HTMLParams']) . '; ' . LF;
     }
     $dmail_info .= $GLOBALS["LANG"]->getLL('view_media') . ' ' . BackendUtility::getProcessedValue('sys_dmail', 'includeMedia', $row['includeMedia']) . '; ' . LF . $GLOBALS["LANG"]->getLL('view_flowed') . ' ' . BackendUtility::getProcessedValue('sys_dmail', 'flowedFormat', $row['flowedFormat']);
     $dmail_info = '<img' . IconUtility::skinImg($GLOBALS["BACK_PATH"], 'gfx/zoom2.gif', 'width="12" height="12"') . ' title="' . $dmail_info . '">';
     $from_info = $GLOBALS["LANG"]->getLL('view_replyto') . ' ' . htmlspecialchars($row['replyto_name'] . ' <' . $row['replyto_email'] . '>') . '; ' . LF . DirectMailUtility::fName('organisation') . ' ' . htmlspecialchars($row['organisation']) . '; ' . LF . DirectMailUtility::fName('return_path') . ' ' . htmlspecialchars($row['return_path']);
     $from_info = '<img' . IconUtility::skinImg($GLOBALS["BACK_PATH"], 'gfx/zoom2.gif', 'width="12" height="12"') . ' title="' . $from_info . '">';
     $mail_info = DirectMailUtility::fName('priority') . ' ' . BackendUtility::getProcessedValue('sys_dmail', 'priority', $row['priority']) . '; ' . LF . DirectMailUtility::fName('encoding') . ' ' . BackendUtility::getProcessedValue('sys_dmail', 'encoding', $row['encoding']) . '; ' . LF . DirectMailUtility::fName('charset') . ' ' . BackendUtility::getProcessedValue('sys_dmail', 'charset', $row['charset']);
     $mail_info = '<img' . IconUtility::skinImg($GLOBALS["BACK_PATH"], 'gfx/zoom2.gif', 'width="12" height="12"') . ' title="' . $mail_info . '">';
     $delBegin = $row["scheduled_begin"] ? BackendUtility::datetime($row["scheduled_begin"]) : '-';
     $delEnd = $row["scheduled_end"] ? BackendUtility::datetime($row["scheduled_begin"]) : '-';
     //count total recipient from the query_info
     $totalRecip = 0;
     $id_lists = unserialize($row['query_info']);
     foreach ($id_lists['id_lists'] as $idArray) {
         $totalRecip += count($idArray);
     }
     $sentRecip = $GLOBALS['TYPO3_DB']->sql_num_rows($GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_dmail_maillog', 'mid=' . $row['uid'] . ' AND response_type = 0', '', 'rid ASC'));
     $out = '<table cellpadding="3" cellspacing="0" class="stats-table">';
     $out .= '<tr class="bgColor2"><td colspan="3">' . IconUtility::getSpriteIconForRecord('sys_dmail', $row) . htmlspecialchars($row['subject']) . '</td></tr>';
     $out .= '<tr class="bgColor4"><td>' . $GLOBALS["LANG"]->getLL('view_from') . '</td><td>' . htmlspecialchars($row['from_name'] . ' <' . htmlspecialchars($row['from_email']) . '>') . '</td><td>' . $from_info . '</td></tr>';
     $out .= '<tr class="bgColor4"><td>' . $GLOBALS["LANG"]->getLL('view_dmail') . '</td><td>' . BackendUtility::getProcessedValue('sys_dmail', 'type', $row['type']) . ': ' . $dmailData . '</td><td>' . $dmail_info . '</td></tr>';
     $out .= '<tr class="bgColor4"><td>' . $GLOBALS["LANG"]->getLL('view_mail') . '</td><td>' . BackendUtility::getProcessedValue('sys_dmail', 'sendOptions', $row['sendOptions']) . ($row['attachment'] ? '; ' : '') . BackendUtility::getProcessedValue('sys_dmail', 'attachment', $row['attachment']) . '</td><td>' . $mail_info . '</td></tr>';
     $out .= '<tr class="bgColor4"><td>' . $GLOBALS["LANG"]->getLL('view_delivery_begin_end') . '</td><td>' . $delBegin . ' / ' . $delEnd . '</td><td>&nbsp;</td></tr>';
     $out .= '<tr class="bgColor4"><td>' . $GLOBALS["LANG"]->getLL('view_recipient_total_sent') . '</td><td>' . $totalRecip . ' / ' . $sentRecip . '</td><td>&nbsp;</td></tr>';
     $out .= '</table>';
     $out .= $this->doc->spacer(5);
     return $out;
 }
Exemplo n.º 13
0
    /**
     * Creates an info-box for the current page (identified by input record).
     *
     * @param array $rec Page record
     * @param boolean $edit If set, there will be shown an edit icon, linking to editing of the page properties.
     * @return string HTML for the box.
     * @deprecated and unused since 6.0, will be removed two versions later
     * @todo Define visibility
     */
    public function getPageInfoBox($rec, $edit = 0)
    {
        \TYPO3\CMS\Core\Utility\GeneralUtility::logDeprecatedFunction();
        // If editing of the page properties is allowed:
        if ($edit) {
            $params = '&edit[pages][' . $rec['uid'] . ']=edit';
            $editIcon = '<a href="#" onclick="' . htmlspecialchars(\TYPO3\CMS\Backend\Utility\BackendUtility::editOnClick($params, $this->backPath)) . '" title="' . $GLOBALS['LANG']->getLL('edit', TRUE) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-open') . '</a>';
        } else {
            $editIcon = $this->noEditIcon('noEditPage');
        }
        // Setting page icon, link, title:
        $outPutContent = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', $rec, array('title' => \TYPO3\CMS\Backend\Utility\BackendUtility::titleAttribForPages($rec))) . $editIcon . '&nbsp;' . htmlspecialchars($rec['title']);
        // Init array where infomation is accumulated as label/value pairs.
        $lines = array();
        // Owner user/group:
        if ($this->pI_showUser) {
            // User:
            $users = \TYPO3\CMS\Backend\Utility\BackendUtility::getUserNames('username,usergroup,usergroup_cached_list,uid,realName');
            $groupArray = explode(',', $GLOBALS['BE_USER']->user['usergroup_cached_list']);
            $users = \TYPO3\CMS\Backend\Utility\BackendUtility::blindUserNames($users, $groupArray);
            $lines[] = array($GLOBALS['LANG']->getLL('pI_crUser') . ':', htmlspecialchars($users[$rec['cruser_id']]['username']) . ' (' . $users[$rec['cruser_id']]['realName'] . ')');
        }
        // Created:
        $lines[] = array($GLOBALS['LANG']->getLL('pI_crDate') . ':', \TYPO3\CMS\Backend\Utility\BackendUtility::datetime($rec['crdate']) . ' (' . \TYPO3\CMS\Backend\Utility\BackendUtility::calcAge($GLOBALS['EXEC_TIME'] - $rec['crdate'], $this->agePrefixes) . ')');
        // Last change:
        $lines[] = array($GLOBALS['LANG']->getLL('pI_lastChange') . ':', \TYPO3\CMS\Backend\Utility\BackendUtility::datetime($rec['tstamp']) . ' (' . \TYPO3\CMS\Backend\Utility\BackendUtility::calcAge($GLOBALS['EXEC_TIME'] - $rec['tstamp'], $this->agePrefixes) . ')');
        // Last change of content:
        if ($rec['SYS_LASTCHANGED']) {
            $lines[] = array($GLOBALS['LANG']->getLL('pI_lastChangeContent') . ':', \TYPO3\CMS\Backend\Utility\BackendUtility::datetime($rec['SYS_LASTCHANGED']) . ' (' . \TYPO3\CMS\Backend\Utility\BackendUtility::calcAge($GLOBALS['EXEC_TIME'] - $rec['SYS_LASTCHANGED'], $this->agePrefixes) . ')');
        }
        // Spacer:
        $lines[] = '';
        // Display contents of certain page fields, if any value:
        $dfields = explode(',', 'alias,target,hidden,starttime,endtime,fe_group,no_cache,cache_timeout,newUntil,lastUpdated,subtitle,keywords,description,abstract,author,author_email');
        foreach ($dfields as $fV) {
            if ($rec[$fV]) {
                $lines[] = array($GLOBALS['LANG']->sL(\TYPO3\CMS\Backend\Utility\BackendUtility::getItemLabel('pages', $fV)), \TYPO3\CMS\Backend\Utility\BackendUtility::getProcessedValue('pages', $fV, $rec[$fV]));
            }
        }
        // Finally, wrap the elements in the $lines array in table cells/rows
        foreach ($lines as $fV) {
            if (is_array($fV)) {
                if (!$fV[2]) {
                    $fV[1] = htmlspecialchars($fV[1]);
                }
                $out .= '
				<tr>
					<td class="bgColor4" nowrap="nowrap"><strong>' . htmlspecialchars($fV[0]) . '&nbsp;&nbsp;</strong></td>
					<td class="bgColor4">' . $fV[1] . '</td>
				</tr>';
            } else {
                $out .= '
				<tr>
					<td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
				</tr>';
            }
        }
        // Wrap table tags around...
        $outPutContent .= '



			<!--
				Page info box:
			-->
			<table border="0" cellpadding="0" cellspacing="1" id="typo3-page-info">
				' . $out . '
			</table>';
        // ... and return it.
        return $outPutContent;
    }
Exemplo n.º 14
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;
 }
    /**
     * Main function. Will generate the information to display for the item
     * set internally.
     *
     * @param string $returnLinkTag <a> tag closing/returning.
     * @return void
     * @todo Define visibility
     */
    public function renderFileInfo($returnLinkTag)
    {
        $fileExtension = $this->fileObject->getExtension();
        $code = '<div class="fileInfoContainer">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForFile($fileExtension) . '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.file', TRUE) . ':</strong> ' . $this->fileObject->getName() . '&nbsp;&nbsp;' . '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.filesize') . ':</strong> ' . \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($this->fileObject->getSize()) . '</div>
			';
        $this->content .= $this->doc->section('', $code);
        $this->content .= $this->doc->divider(2);
        // If the file was an image...
        // @todo: add this check in the domain model, or in the processing folder
        if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileExtension)) {
            // @todo: find a way to make getimagesize part of the t3lib_file object
            $imgInfo = @getimagesize($this->fileObject->getForLocalProcessing(FALSE));
            $thumbUrl = $this->fileObject->process(\TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGEPREVIEW, array('width' => '150m', 'height' => '150m'))->getPublicUrl(TRUE);
            $code = '<div class="fileInfoContainer fileDimensions">' . '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.dimensions') . ':</strong> ' . $imgInfo[0] . 'x' . $imgInfo[1] . ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.pixels') . '</div>';
            $code .= '<br />
				<div align="center">' . $returnLinkTag . '<img src="' . $thumbUrl . '" alt="' . htmlspecialchars(trim($this->fileObject->getName())) . '" title="' . htmlspecialchars(trim($this->fileObject->getName())) . '" /></a></div>';
            $this->content .= $this->doc->section('', $code);
        } elseif ($fileExtension == 'ttf') {
            $thumbUrl = $this->fileObject->process(\TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGEPREVIEW, array('width' => '530m', 'height' => '600m'))->getPublicUrl(TRUE);
            $thumb = '<br />
				<div align="center">' . $returnLinkTag . '<img src="' . $thumbUrl . '" border="0" title="' . htmlspecialchars(trim($this->fileObject->getName())) . '" alt="" /></a></div>';
            $this->content .= $this->doc->section('', $thumb);
        }
        // Traverse the list of fields to display for the record:
        $tableRows = array();
        $showRecordFieldList = $GLOBALS['TCA'][$this->table]['interface']['showRecordFieldList'];
        $fieldList = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $showRecordFieldList, TRUE);
        foreach ($fieldList as $name) {
            // Ignored fields
            if ($name === 'size') {
                continue;
            }
            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);
        // References:
        if ($this->fileObject->isIndexed()) {
            $references = $this->makeRef('_FILE', $this->fileObject);
            if (!empty($references)) {
                $header = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.referencesToThisItem');
                $this->content .= $this->doc->section($header, $references);
            }
        }
    }
Exemplo n.º 16
0
 /**
  * Renders the diff-view of default language record content compared with what the record was originally translated from.
  * Will render content if any is found in the internal array, $this->defaultLanguageData,
  * depending on registerDefaultLanguageData() being called prior to this.
  *
  * @param string $table Table name of the record being edited
  * @param string $field Field name represented by $item
  * @param array $row Record array of the record being edited
  * @param string  $item HTML of the form field. This is what we add the content to.
  * @return string Item string returned again, possibly with the original value added to.
  * @see getSingleField(), registerDefaultLanguageData()
  * @todo Define visibility
  */
 public function renderDefaultLanguageDiff($table, $field, $row, $item)
 {
     if (is_array($this->defaultLanguageData_diff[$table . ':' . $row['uid']])) {
         // Initialize:
         $dLVal = array('old' => $this->defaultLanguageData_diff[$table . ':' . $row['uid']], 'new' => $this->defaultLanguageData[$table . ':' . $row['uid']]);
         // There must be diff-data:
         if (isset($dLVal['old'][$field])) {
             if ((string) $dLVal['old'][$field] !== (string) $dLVal['new'][$field]) {
                 // Create diff-result:
                 $t3lib_diff_Obj = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Utility\\DiffUtility');
                 $diffres = $t3lib_diff_Obj->makeDiffDisplay(BackendUtility::getProcessedValue($table, $field, $dLVal['old'][$field], 0, 1), BackendUtility::getProcessedValue($table, $field, $dLVal['new'][$field], 0, 1));
                 $item .= '<div class="typo3-TCEforms-diffBox">' . '<div class="typo3-TCEforms-diffBox-header">' . htmlspecialchars($this->getLL('l_changeInOrig')) . ':</div>' . $diffres . '</div>';
             }
         }
     }
     return $item;
 }
Exemplo n.º 17
0
    /**
     * Renders the diff-view of default language record content compared with what the record was originally translated from.
     * Will render content if any is found in the internal array
     *
     * @param string $table Table name of the record being edited
     * @param string $field Field name represented by $item
     * @param array $row Record array of the record being edited
     * @param string  $item HTML of the form field. This is what we add the content to.
     * @return string Item string returned again, possibly with the original value added to.
     */
    protected function renderDefaultLanguageDiff($table, $field, $row, $item)
    {
        if (is_array($this->data['defaultLanguageDataDiff'][$table . ':' . $row['uid']])) {
            // Initialize:
            $dLVal = array('old' => $this->data['defaultLanguageDataDiff'][$table . ':' . $row['uid']], 'new' => $this->data['defaultLanguageData'][$table . ':' . $row['uid']]);
            // There must be diff-data:
            if (isset($dLVal['old'][$field])) {
                if ((string) $dLVal['old'][$field] !== (string) $dLVal['new'][$field]) {
                    // Create diff-result:
                    $diffUtility = GeneralUtility::makeInstance(DiffUtility::class);
                    $diffres = $diffUtility->makeDiffDisplay(BackendUtility::getProcessedValue($table, $field, $dLVal['old'][$field], 0, 1), BackendUtility::getProcessedValue($table, $field, $dLVal['new'][$field], 0, 1));
                    $item .= '<div class="t3-form-original-language-diff">
						<div class="t3-form-original-language-diffheader">' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.changeInOrig')) . '</div>
						<div class="t3-form-original-language-diffcontent">' . $diffres . '</div>
					</div>';
                }
            }
        }
        return $item;
    }
Exemplo n.º 18
0
    /**
     * Shows the infos of a directmail record in a table
     *
     * @param array $row DirectMail DB record
     *
     * @return string the HTML output
     */
    protected function renderRecordDetailsTable(array $row)
    {
        if (!$row['issent']) {
            if ($GLOBALS['BE_USER']->check('tables_modify', 'sys_dmail')) {
                // $requestUri = rawurlencode(GeneralUtility::linkThisScript(array('sys_dmail_uid' => $row['uid'], 'createMailFrom_UID' => '', 'createMailFrom_URL' => '')));
                $requestUri = BackendUtility::getModuleUrl('DirectMailNavFrame_DirectMail') . '&id=' . $this->id . '&CMD=info&sys_dmail_uid=' . $row['uid'] . '&fetchAtOnce=1';
                $editParams = BackendUtility::editOnClick('&edit[sys_dmail][' . $row['uid'] . ']=edit', $GLOBALS['BACK_PATH'], $requestUri);
                $content = '<a href="#" onClick="' . $editParams . '" title="' . $this->getLanguageService()->getLL("dmail_edit") . '">' . $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL) . '<b>' . $this->getLanguageService()->getLL('dmail_edit') . '</b></a>';
            } else {
                $content = $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL) . ' (' . $this->getLanguageService()->getLL('dmail_noEdit_noPerms') . ')';
            }
        } else {
            $content = $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL) . '(' . $this->getLanguageService()->getLL('dmail_noEdit_isSent') . ')';
        }
        $content = '<thead >
			<th>' . DirectMailUtility::fName('subject') . ' <b>' . GeneralUtility::fixed_lgd_cs(htmlspecialchars($row['subject']), 60) . '</b></th>
			<th style="text-align: right;">' . $content . '</th>
		</thead>';
        $nameArr = explode(',', 'from_name,from_email,replyto_name,replyto_email,organisation,return_path,priority,attachment,type,page,sendOptions,includeMedia,flowedFormat,sys_language_uid,plainParams,HTMLParams,encoding,charset,issent,renderedsize');
        foreach ($nameArr as $name) {
            $content .= '
			<tr class="db_list_normal">
				<td>' . DirectMailUtility::fName($name) . '</td>
				<td>' . htmlspecialchars(BackendUtility::getProcessedValue('sys_dmail', $name, $row[$name])) . '</td>
			</tr>';
        }
        $content = '<table width="460" class="table table-striped table-hover">' . $content . '</table>';
        $sectionTitle = $this->iconFactory->getIconForRecord('sys_dmail', $row, Icon::SIZE_SMALL)->render() . '&nbsp;' . htmlspecialchars($row['subject']);
        return $this->doc->section($sectionTitle, $content, 1, 1, 0, true);
    }
Exemplo n.º 19
0
 /**
  * Gets the differences between two record versions out
  * of one record history entry.
  *
  * @param array $entry Record history entry
  * @return array
  */
 protected function getDifferences(array $entry)
 {
     $differences = array();
     $tableName = $entry['tablename'];
     if (is_array($entry['newRecord'])) {
         $fields = array_keys($entry['newRecord']);
         foreach ($fields as $field) {
             if (!empty($GLOBALS['TCA'][$tableName]['columns'][$field]['config']['type']) && $GLOBALS['TCA'][$tableName]['columns'][$field]['config']['type'] !== 'passthrough') {
                 // Create diff-result:
                 $fieldDifferences = $this->getDifferencesObject()->makeDiffDisplay(BackendUtility::getProcessedValue($tableName, $field, $entry['oldRecord'][$field], 0, TRUE), BackendUtility::getProcessedValue($tableName, $field, $entry['newRecord'][$field], 0, TRUE));
                 if (!empty($fieldDifferences)) {
                     $differences[] = array('label' => $this->getLanguageService()->sl((string) BackendUtility::getItemLabel($tableName, $field)), 'html' => nl2br(trim($fieldDifferences)));
                 }
             }
         }
     }
     return $differences;
 }
Exemplo n.º 20
0
 /**
  * @test
  */
 public function getProcessedValueReturnsPlainValueIfItemIsNotFound()
 {
     $table = 'foobar';
     $col = 'someColumn';
     $tca = array('columns' => array('someColumn' => array('config' => array('type' => 'select', 'items' => array('0' => array('aFooLabel', 'foo'))))));
     // Stub LanguageService and let sL() return the same value that came in again
     $GLOBALS['LANG'] = $this->getMock(\TYPO3\CMS\Lang\LanguageService::class, array(), array(), '', FALSE);
     $GLOBALS['LANG']->charSet = 'utf-8';
     $GLOBALS['LANG']->csConvObj = $this->getMock(\TYPO3\CMS\Core\Charset\CharsetConverter::class);
     $GLOBALS['LANG']->expects($this->any())->method('sL')->will($this->returnCallback(function ($name) {
         return $name;
     }));
     $GLOBALS['LANG']->csConvObj->expects($this->any())->method('crop')->will($this->returnCallback(function ($charset, $string, $len, $crop = '') {
         return $string;
     }));
     $GLOBALS['TCA'][$table] = $tca;
     $label = BackendUtility::getProcessedValue($table, $col, 'invalidKey');
     $this->assertEquals('invalidKey', $label);
 }
Exemplo n.º 21
0
 /**
  * Show the compact information of a direct mail record
  *
  * @param array $row Direct mail record
  *
  * @return string The compact infos of the direct mail record
  */
 function directMail_compactView($row)
 {
     // Render record:
     if ($row['type']) {
         $dmailData = $row['plainParams'] . ', ' . $row['HTMLParams'];
     } else {
         $page = BackendUtility::getRecord('pages', $row['page'], 'title');
         $dmailData = $row['page'] . ', ' . htmlspecialchars($page['title']);
         $dmailInfo = DirectMailUtility::fName('plainParams') . ' ' . htmlspecialchars($row['plainParams'] . LF . DirectMailUtility::fName('HTMLParams') . $row['HTMLParams']) . '; ' . LF;
     }
     $dmailInfo .= $this->getLanguageService()->getLL('view_media') . ' ' . BackendUtility::getProcessedValue('sys_dmail', 'includeMedia', $row['includeMedia']) . '; ' . LF . $this->getLanguageService()->getLL('view_flowed') . ' ' . BackendUtility::getProcessedValue('sys_dmail', 'flowedFormat', $row['flowedFormat']);
     $dmailInfo = '<span title="' . $dmailInfo . '">' . $this->iconFactory->getIcon('actions-document-info', Icon::SIZE_SMALL) . '</span>';
     $fromInfo = $this->getLanguageService()->getLL('view_replyto') . ' ' . htmlspecialchars($row['replyto_name'] . ' <' . $row['replyto_email'] . '>') . '; ' . LF . DirectMailUtility::fName('organisation') . ' ' . htmlspecialchars($row['organisation']) . '; ' . LF . DirectMailUtility::fName('return_path') . ' ' . htmlspecialchars($row['return_path']);
     $fromInfo = '<span title="' . $fromInfo . '">' . $this->iconFactory->getIcon('actions-document-info', Icon::SIZE_SMALL) . '</span>';
     $mailInfo = DirectMailUtility::fName('priority') . ' ' . BackendUtility::getProcessedValue('sys_dmail', 'priority', $row['priority']) . '; ' . LF . DirectMailUtility::fName('encoding') . ' ' . BackendUtility::getProcessedValue('sys_dmail', 'encoding', $row['encoding']) . '; ' . LF . DirectMailUtility::fName('charset') . ' ' . BackendUtility::getProcessedValue('sys_dmail', 'charset', $row['charset']);
     $mailInfo = '<span title="' . $mailInfo . '">' . $this->iconFactory->getIcon('actions-document-info', Icon::SIZE_SMALL) . '</span>';
     $delBegin = $row["scheduled_begin"] ? BackendUtility::datetime($row["scheduled_begin"]) : '-';
     $delEnd = $row["scheduled_end"] ? BackendUtility::datetime($row["scheduled_begin"]) : '-';
     // count total recipient from the query_info
     $totalRecip = 0;
     $idLists = unserialize($row['query_info']);
     foreach ($idLists['id_lists'] as $idArray) {
         $totalRecip += count($idArray);
     }
     $sentRecip = $GLOBALS['TYPO3_DB']->sql_num_rows($GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_dmail_maillog', 'mid=' . $row['uid'] . ' AND response_type = 0', '', 'rid ASC'));
     $out = '<table class="table table-striped table-hover">';
     $out .= '<tr class="t3-row-header"><td colspan="3">' . $this->iconFactory->getIconForRecord('sys_dmail', $row)->render() . htmlspecialchars($row['subject']) . '</td></tr>';
     $out .= '<tr class="db_list_normal"><td>' . $this->getLanguageService()->getLL('view_from') . '</td>' . '<td>' . htmlspecialchars($row['from_name'] . ' <' . htmlspecialchars($row['from_email']) . '>') . '</td>' . '<td>' . $fromInfo . '</td></tr>';
     $out .= '<tr class="db_list_normal"><td>' . $this->getLanguageService()->getLL('view_dmail') . '</td>' . '<td>' . BackendUtility::getProcessedValue('sys_dmail', 'type', $row['type']) . ': ' . $dmailData . '</td>' . '<td>' . $dmailInfo . '</td></tr>';
     $out .= '<tr class="db_list_normal"><td>' . $this->getLanguageService()->getLL('view_mail') . '</td>' . '<td>' . BackendUtility::getProcessedValue('sys_dmail', 'sendOptions', $row['sendOptions']) . ($row['attachment'] ? '; ' : '') . BackendUtility::getProcessedValue('sys_dmail', 'attachment', $row['attachment']) . '</td>' . '<td>' . $mailInfo . '</td></tr>';
     $out .= '<tr class="db_list_normal"><td>' . $this->getLanguageService()->getLL('view_delivery_begin_end') . '</td>' . '<td>' . $delBegin . ' / ' . $delEnd . '</td>' . '<td>&nbsp;</td></tr>';
     $out .= '<tr class="db_list_normal"><td>' . $this->getLanguageService()->getLL('view_recipient_total_sent') . '</td>' . '<td>' . $totalRecip . ' / ' . $sentRecip . '</td>' . '<td>&nbsp;</td></tr>';
     $out .= '</table>';
     $out .= '<div style="padding-top: 5px;"></div>';
     return $out;
 }
Exemplo n.º 22
0
 /**
  * @test
  * @see http://bugs.typo3.org/view.php?id=11875
  */
 public function getProcessedValueForZeroStringIsZero()
 {
     $this->assertEquals('0', $this->fixture->getProcessedValue('tt_content', 'header', '0'));
 }
Exemplo n.º 23
0
 /**
  * Fetch further information to current selected workspace record.
  *
  * @param \stdClass $parameter
  * @return array $data
  */
 public function getRowDetails($parameter)
 {
     $diffReturnArray = array();
     $liveReturnArray = array();
     /** @var $diffUtility \TYPO3\CMS\Core\Utility\DiffUtility */
     $diffUtility = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Utility\DiffUtility::class);
     /** @var $parseObj \TYPO3\CMS\Core\Html\RteHtmlParser */
     $parseObj = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Html\RteHtmlParser::class);
     $liveRecord = BackendUtility::getRecord($parameter->table, $parameter->t3ver_oid);
     $versionRecord = BackendUtility::getRecord($parameter->table, $parameter->uid);
     $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
     $icon_Live = $iconFactory->getIconForRecord($parameter->table, $liveRecord, Icon::SIZE_SMALL)->render();
     $icon_Workspace = $iconFactory->getIconForRecord($parameter->table, $versionRecord, Icon::SIZE_SMALL)->render();
     $stagePosition = $this->getStagesService()->getPositionOfCurrentStage($parameter->stage);
     $fieldsOfRecords = array_keys($liveRecord);
     if ($GLOBALS['TCA'][$parameter->table]) {
         if ($GLOBALS['TCA'][$parameter->table]['interface']['showRecordFieldList']) {
             $fieldsOfRecords = $GLOBALS['TCA'][$parameter->table]['interface']['showRecordFieldList'];
             $fieldsOfRecords = GeneralUtility::trimExplode(',', $fieldsOfRecords, true);
         }
     }
     foreach ($fieldsOfRecords as $fieldName) {
         if (empty($GLOBALS['TCA'][$parameter->table]['columns'][$fieldName]['config'])) {
             continue;
         }
         // Get the field's label. If not available, use the field name
         $fieldTitle = $GLOBALS['LANG']->sL(BackendUtility::getItemLabel($parameter->table, $fieldName));
         if (empty($fieldTitle)) {
             $fieldTitle = $fieldName;
         }
         // Gets the TCA configuration for the current field
         $configuration = $GLOBALS['TCA'][$parameter->table]['columns'][$fieldName]['config'];
         // check for exclude fields
         if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['TCA'][$parameter->table]['columns'][$fieldName]['exclude'] == 0 || GeneralUtility::inList($GLOBALS['BE_USER']->groupData['non_exclude_fields'], $parameter->table . ':' . $fieldName)) {
             // call diff class only if there is a difference
             if ($configuration['type'] === 'inline' && $configuration['foreign_table'] === 'sys_file_reference') {
                 $useThumbnails = false;
                 if (!empty($configuration['foreign_selector_fieldTcaOverride']['config']['appearance']['elementBrowserAllowed']) && !empty($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'])) {
                     $fileExtensions = GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], true);
                     $allowedExtensions = GeneralUtility::trimExplode(',', $configuration['foreign_selector_fieldTcaOverride']['config']['appearance']['elementBrowserAllowed'], true);
                     $differentExtensions = array_diff($allowedExtensions, $fileExtensions);
                     $useThumbnails = empty($differentExtensions);
                 }
                 $liveFileReferences = BackendUtility::resolveFileReferences($parameter->table, $fieldName, $liveRecord, 0);
                 $versionFileReferences = BackendUtility::resolveFileReferences($parameter->table, $fieldName, $versionRecord, $this->getCurrentWorkspace());
                 $fileReferenceDifferences = $this->prepareFileReferenceDifferences($liveFileReferences, $versionFileReferences, $useThumbnails);
                 if ($fileReferenceDifferences === null) {
                     continue;
                 }
                 $diffReturnArray[] = array('field' => $fieldName, 'label' => $fieldTitle, 'content' => $fileReferenceDifferences['differences']);
                 $liveReturnArray[] = array('field' => $fieldName, 'label' => $fieldTitle, 'content' => $fileReferenceDifferences['live']);
             } elseif ((string) $liveRecord[$fieldName] !== (string) $versionRecord[$fieldName]) {
                 // Select the human readable values before diff
                 $liveRecord[$fieldName] = BackendUtility::getProcessedValue($parameter->table, $fieldName, $liveRecord[$fieldName], 0, 1, false, $liveRecord['uid']);
                 $versionRecord[$fieldName] = BackendUtility::getProcessedValue($parameter->table, $fieldName, $versionRecord[$fieldName], 0, 1, false, $versionRecord['uid']);
                 if ($configuration['type'] == 'group' && $configuration['internal_type'] == 'file') {
                     $versionThumb = BackendUtility::thumbCode($versionRecord, $parameter->table, $fieldName, '');
                     $liveThumb = BackendUtility::thumbCode($liveRecord, $parameter->table, $fieldName, '');
                     $diffReturnArray[] = array('field' => $fieldName, 'label' => $fieldTitle, 'content' => $versionThumb);
                     $liveReturnArray[] = array('field' => $fieldName, 'label' => $fieldTitle, 'content' => $liveThumb);
                 } else {
                     $diffReturnArray[] = array('field' => $fieldName, 'label' => $fieldTitle, 'content' => $diffUtility->makeDiffDisplay($liveRecord[$fieldName], $versionRecord[$fieldName]));
                     $liveReturnArray[] = array('field' => $fieldName, 'label' => $fieldTitle, 'content' => $parseObj->TS_images_rte($liveRecord[$fieldName]));
                 }
             }
         }
     }
     // Hook for modifying the difference and live arrays
     // (this may be used by custom or dynamically-defined fields)
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['workspaces']['modifyDifferenceArray'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['workspaces']['modifyDifferenceArray'] as $className) {
             $hookObject = GeneralUtility::getUserObj($className);
             if (method_exists($hookObject, 'modifyDifferenceArray')) {
                 $hookObject->modifyDifferenceArray($parameter, $diffReturnArray, $liveReturnArray, $diffUtility);
             }
         }
     }
     $commentsForRecord = $this->getCommentsForRecord($parameter->uid, $parameter->table);
     return array('total' => 1, 'data' => array(array('diff' => $diffReturnArray, 'live_record' => $liveReturnArray, 'icon_Live' => $icon_Live, 'icon_Workspace' => $icon_Workspace, 'comments' => $commentsForRecord, 'path_Live' => htmlspecialchars($parameter->path_Live), 'label_Stage' => htmlspecialchars($parameter->label_Stage), 'stage_position' => (int) $stagePosition['position'], 'stage_count' => (int) $stagePosition['count'])));
 }
    /**
     * Renders file properties as html table
     *
     * @param array $fieldList
     * @return string
     */
    protected function renderFileInformationAsTable($fieldList)
    {
        $tableRows = array();
        foreach ($fieldList as $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 = 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>';
        }
        if (!$tableRows) {
            return '';
        }
        return '<table id="typo3-showitem" class="t3-table-info">' . implode('', $tableRows) . '</table>';
    }
    /**
     * Renders file properties as html table
     *
     * @param array $fieldList
     * @return string
     */
    protected function renderFileInformationAsTable($fieldList)
    {
        $tableRows = array();
        foreach ($fieldList as $name) {
            if (!isset($GLOBALS['TCA'][$this->table]['columns'][$name])) {
                continue;
            }
            $isExcluded = !(!$GLOBALS['TCA'][$this->table]['columns'][$name]['exclude'] || $this->getBackendUser()->check('non_exclude_fields', $this->table . ':' . $name));
            if ($isExcluded) {
                continue;
            }
            $uid = $this->row['uid'];
            $itemValue = BackendUtility::getProcessedValue($this->table, $name, $this->row[$name], 0, 0, false, $uid);
            $itemLabel = $this->getLanguageService()->sL(BackendUtility::getItemLabel($this->table, $name), true);
            $tableRows[] = '
				<tr>
					<th>' . $itemLabel . '</th>
					<td>' . htmlspecialchars($itemValue) . '</td>
				</tr>';
        }
        if (!$tableRows) {
            return '';
        }
        return '
			<div class="table-fit table-fit-wrap">
				<table class="table table-striped table-hover">
					' . implode('', $tableRows) . '
				</table>
			</div>';
    }
Exemplo n.º 26
0
    /**
     * Management of versions for record
     *
     * @return void
     * @todo Define visibility
     */
    public function versioningMgm()
    {
        // Diffing:
        $diff_1 = GeneralUtility::_POST('diff_1');
        $diff_2 = GeneralUtility::_POST('diff_2');
        if (GeneralUtility::_POST('do_diff')) {
            $content = '';
            $content .= '<h3>' . $GLOBALS['LANG']->getLL('diffing') . ':</h3>';
            if ($diff_1 && $diff_2) {
                $diff_1_record = BackendUtility::getRecord($this->table, $diff_1);
                $diff_2_record = BackendUtility::getRecord($this->table, $diff_2);
                if (is_array($diff_1_record) && is_array($diff_2_record)) {
                    $t3lib_diff_Obj = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Utility\\DiffUtility');
                    $tRows = array();
                    $tRows[] = '
									<tr class="bgColor5 tableheader">
										<td>' . $GLOBALS['LANG']->getLL('fieldname') . '</td>
										<td width="98%">' . $GLOBALS['LANG']->getLL('coloredDiffView') . ':</td>
									</tr>
								';
                    foreach ($diff_1_record as $fN => $fV) {
                        if ($GLOBALS['TCA'][$this->table]['columns'][$fN] && $GLOBALS['TCA'][$this->table]['columns'][$fN]['config']['type'] !== 'passthrough' && !GeneralUtility::inList('t3ver_label', $fN)) {
                            if ((string) $diff_1_record[$fN] !== (string) $diff_2_record[$fN]) {
                                $diffres = $t3lib_diff_Obj->makeDiffDisplay(BackendUtility::getProcessedValue($this->table, $fN, $diff_2_record[$fN], 0, 1), BackendUtility::getProcessedValue($this->table, $fN, $diff_1_record[$fN], 0, 1));
                                $tRows[] = '
									<tr class="bgColor4">
										<td>' . $fN . '</td>
										<td width="98%">' . $diffres . '</td>
									</tr>
								';
                            }
                        }
                    }
                    if (count($tRows) > 1) {
                        $content .= '<table border="0" cellpadding="1" cellspacing="1" width="100%">' . implode('', $tRows) . '</table><br /><br />';
                    } else {
                        $content .= $GLOBALS['LANG']->getLL('recordsMatchesCompletely');
                    }
                } else {
                    $content .= $GLOBALS['LANG']->getLL('errorRecordsNotFound');
                }
            } else {
                $content .= $GLOBALS['LANG']->getLL('errorDiffSources');
            }
        }
        // Element:
        $record = BackendUtility::getRecord($this->table, $this->uid);
        $recordIcon = IconUtility::getSpriteIconForRecord($this->table, $record);
        $recTitle = BackendUtility::getRecordTitle($this->table, $record, TRUE);
        // Display versions:
        $content .= '
			' . $recordIcon . $recTitle . '
			<form name="theform" action="' . str_replace('&sendToReview=1', '', $this->REQUEST_URI) . '" method="post">
			<table border="0" cellspacing="1" cellpadding="1">';
        $content .= '
				<tr class="bgColor5 tableheader">
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_title') . '">' . $GLOBALS['LANG']->getLL('tblHeader_title') . '</td>
					<td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_uid') . '">' . $GLOBALS['LANG']->getLL('tblHeader_uid') . '</td>
					<td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_oid') . '">' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_oid') . '</td>
					<td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_id') . '">' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_id') . '</td>
					<td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_wsid') . '">' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_wsid') . '</td>
					<td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_state') . '">' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_state') . '</td>
					<td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_stage') . '">' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_stage') . '</td>
					<td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_count') . '">' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_count') . '</td>
					<td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_pid') . '">' . $GLOBALS['LANG']->getLL('tblHeader_pid') . '</td>
					<td title="' . $GLOBALS['LANG']->getLL('tblHeaderDesc_t3ver_label') . '">' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_label') . '</td>
					<td colspan="2"><input type="submit" name="do_diff" value="' . $GLOBALS['LANG']->getLL('diff') . '" /></td>
				</tr>';
        $versions = BackendUtility::selectVersionsOfRecord($this->table, $this->uid, '*', $GLOBALS['BE_USER']->workspace);
        foreach ($versions as $row) {
            $adminLinks = $this->adminLinks($this->table, $row);
            $content .= '
				<tr class="' . ($row['uid'] != $this->uid ? 'bgColor4' : 'bgColor2 tableheader') . '">
					<td>' . ($row['uid'] != $this->uid ? '<a href="' . $this->doc->issueCommand('&cmd[' . $this->table . '][' . $this->uid . '][version][swapWith]=' . $row['uid'] . '&cmd[' . $this->table . '][' . $this->uid . '][version][action]=swap') . '" title="' . $GLOBALS['LANG']->getLL('swapWithCurrent', TRUE) . '">' . IconUtility::getSpriteIcon('actions-version-swap-version') . '</a>' : IconUtility::getSpriteIcon('status-status-current', array('title' => $GLOBALS['LANG']->getLL('currentOnlineVersion', TRUE)))) . '</td>
					<td nowrap="nowrap">' . $adminLinks . '</td>
					<td nowrap="nowrap">' . BackendUtility::getRecordTitle($this->table, $row, TRUE) . '</td>
					<td>' . $row['uid'] . '</td>
					<td>' . $row['t3ver_oid'] . '</td>
					<td>' . $row['t3ver_id'] . '</td>
					<td>' . $row['t3ver_wsid'] . '</td>
					<td>' . $row['t3ver_state'] . '</td>
					<td>' . $row['t3ver_stage'] . '</td>
					<td>' . $row['t3ver_count'] . '</td>
					<td>' . $row['pid'] . '</td>
					<td nowrap="nowrap"><a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick('&edit[' . $this->table . '][' . $row['uid'] . ']=edit&columnsOnly=t3ver_label', $this->doc->backPath)) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.edit', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-open') . '</a>' . htmlspecialchars($row['t3ver_label']) . '</td>
					<td class="version-diff-1"><input type="radio" name="diff_1" value="' . $row['uid'] . '"' . ($diff_1 == $row['uid'] ? ' checked="checked"' : '') . '/></td>
					<td class="version-diff-2"><input type="radio" name="diff_2" value="' . $row['uid'] . '"' . ($diff_2 == $row['uid'] ? ' checked="checked"' : '') . '/></td>
				</tr>';
            // Show sub-content if the table is pages AND it is not the online branch (because that will mostly render the WHOLE tree below - not smart;)
            if ($this->table == 'pages' && $row['uid'] != $this->uid) {
                $sub = $this->pageSubContent($row['uid']);
                if ($sub) {
                    $content .= '
						<tr>
							<td></td>
							<td></td>
							<td colspan="10">' . $sub . '</td>
							<td colspan="2"></td>
						</tr>';
                }
            }
        }
        $content .= '</table></form>';
        $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('title'), $content, 0, 1);
        // Create new:
        $content = '

			<form action="' . $this->doc->backPath . 'tce_db.php" method="post">
			' . $GLOBALS['LANG']->getLL('tblHeader_t3ver_label') . ': <input type="text" name="cmd[' . $this->table . '][' . $this->uid . '][version][label]" /><br />
			<br /><input type="hidden" name="cmd[' . $this->table . '][' . $this->uid . '][version][action]" value="new" />
			<input type="hidden" name="prErr" value="1" />
			<input type="hidden" name="redirect" value="' . htmlspecialchars($this->REQUEST_URI) . '" />
			<input type="submit" name="_" value="' . $GLOBALS['LANG']->getLL('createNewVersion') . '" />
			' . \TYPO3\CMS\Backend\Form\FormEngine::getHiddenTokenField('tceAction') . '
			</form>

		';
        $this->content .= $this->doc->spacer(15);
        $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('createNewVersion'), $content, 0, 1);
    }
Exemplo n.º 27
0
    /**
     * Compares two records, the current database record and the one from the import memory. Will return HTML code to show any differences between them!
     *
     * @param array $databaseRecord Database record, all fields (new values)
     * @param array $importRecord Import memorys record for the same table/uid, all fields (old values)
     * @param string $table The table name of the record
     * @param boolean $inverseDiff Inverse the diff view (switch red/green, needed for pre-update difference view)
     * @return string HTML
     * @todo Define visibility
     */
    public function compareRecords($databaseRecord, $importRecord, $table, $inverseDiff = FALSE)
    {
        global $LANG;
        // Initialize:
        $output = array();
        $t3lib_diff_Obj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Utility\\DiffUtility');
        // Check if both inputs are records:
        if (is_array($databaseRecord) && is_array($importRecord)) {
            // Traverse based on database record
            foreach ($databaseRecord as $fN => $value) {
                if (is_array($GLOBALS['TCA'][$table]['columns'][$fN]) && $GLOBALS['TCA'][$table]['columns'][$fN]['config']['type'] != 'passthrough') {
                    if (isset($importRecord[$fN])) {
                        if (strcmp(trim($databaseRecord[$fN]), trim($importRecord[$fN]))) {
                            // Create diff-result:
                            $output[$fN] = $t3lib_diff_Obj->makeDiffDisplay(\TYPO3\CMS\Backend\Utility\BackendUtility::getProcessedValue($table, $fN, !$inverseDiff ? $importRecord[$fN] : $databaseRecord[$fN], 0, 1, 1), \TYPO3\CMS\Backend\Utility\BackendUtility::getProcessedValue($table, $fN, !$inverseDiff ? $databaseRecord[$fN] : $importRecord[$fN], 0, 1, 1));
                        }
                        unset($importRecord[$fN]);
                    }
                }
            }
            // Traverse remaining in import record:
            foreach ($importRecord as $fN => $value) {
                if (is_array($GLOBALS['TCA'][$table]['columns'][$fN]) && $GLOBALS['TCA'][$table]['columns'][$fN]['config']['type'] !== 'passthrough') {
                    $output[$fN] = '<strong>Field missing</strong> in database';
                }
            }
            // Create output:
            if (count($output)) {
                $tRows = array();
                foreach ($output as $fN => $state) {
                    $tRows[] = '
						<tr>
							<td class="bgColor5">' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['columns'][$fN]['label'], 1) . ' (' . htmlspecialchars($fN) . ')</td>
							<td class="bgColor4">' . $state . '</td>
						</tr>
					';
                }
                $output = '<table border="0" cellpadding="0" cellspacing="1">' . implode('', $tRows) . '</table>';
            } else {
                $output = 'Match';
            }
            return '<strong class="nobr">[' . htmlspecialchars($table . ':' . $importRecord['uid'] . ' => ' . $databaseRecord['uid']) . ']:</strong> ' . $output;
        }
        return 'ERROR: One of the inputs were not an array!';
    }
Exemplo n.º 28
0
 /**
  * @test
  */
 public function getProcessedValueReturnsPlainValueIfItemIsNotFound()
 {
     $table = 'foobar';
     $col = 'someColumn';
     $tca = array('columns' => array('someColumn' => array('config' => array('type' => 'select', 'items' => array('0' => array('aFooLabel', 'foo'))))));
     // Stub LanguageService and let sL() return the same value that came in again
     $GLOBALS['LANG'] = $this->getMock(LanguageService::class, array(), array(), '', false);
     $GLOBALS['LANG']->csConvObj = $this->getMock(CharsetConverter::class);
     $GLOBALS['LANG']->expects($this->any())->method('sL')->will($this->returnArgument(0));
     $GLOBALS['LANG']->csConvObj->expects($this->any())->method('crop')->will($this->returnArgument(1));
     $GLOBALS['TCA'][$table] = $tca;
     $label = BackendUtility::getProcessedValue($table, $col, 'invalidKey');
     $this->assertEquals('invalidKey', $label);
 }
Exemplo n.º 29
0
    /**
     * Compares two records, the current database record and the one from the import memory.
     * Will return HTML code to show any differences between them!
     *
     * @param array $databaseRecord Database record, all fields (new values)
     * @param array $importRecord Import memorys record for the same table/uid, all fields (old values)
     * @param string $table The table name of the record
     * @param bool $inverseDiff Inverse the diff view (switch red/green, needed for pre-update difference view)
     * @return string HTML
     */
    public function compareRecords($databaseRecord, $importRecord, $table, $inverseDiff = false)
    {
        // Initialize:
        $output = array();
        $diffUtility = GeneralUtility::makeInstance(DiffUtility::class);
        // Check if both inputs are records:
        if (is_array($databaseRecord) && is_array($importRecord)) {
            // Traverse based on database record
            foreach ($databaseRecord as $fN => $value) {
                if (is_array($GLOBALS['TCA'][$table]['columns'][$fN]) && $GLOBALS['TCA'][$table]['columns'][$fN]['config']['type'] != 'passthrough') {
                    if (isset($importRecord[$fN])) {
                        if (trim($databaseRecord[$fN]) !== trim($importRecord[$fN])) {
                            // Create diff-result:
                            $output[$fN] = $diffUtility->makeDiffDisplay(BackendUtility::getProcessedValue($table, $fN, !$inverseDiff ? $importRecord[$fN] : $databaseRecord[$fN], 0, 1, 1), BackendUtility::getProcessedValue($table, $fN, !$inverseDiff ? $databaseRecord[$fN] : $importRecord[$fN], 0, 1, 1));
                        }
                        unset($importRecord[$fN]);
                    }
                }
            }
            // Traverse remaining in import record:
            foreach ($importRecord as $fN => $value) {
                if (is_array($GLOBALS['TCA'][$table]['columns'][$fN]) && $GLOBALS['TCA'][$table]['columns'][$fN]['config']['type'] !== 'passthrough') {
                    $output[$fN] = '<strong>Field missing</strong> in database';
                }
            }
            // Create output:
            if (!empty($output)) {
                $tRows = array();
                foreach ($output as $fN => $state) {
                    $tRows[] = '
						<tr>
							<td class="bgColor5">' . $this->getLanguageService()->sL($GLOBALS['TCA'][$table]['columns'][$fN]['label'], true) . ' (' . htmlspecialchars($fN) . ')</td>
							<td class="bgColor4">' . $state . '</td>
						</tr>
					';
                }
                $output = '<table border="0" cellpadding="0" cellspacing="1">' . implode('', $tRows) . '</table>';
            } else {
                $output = 'Match';
            }
            return '<strong class="text-nowrap">[' . htmlspecialchars($table . ':' . $importRecord['uid'] . ' => ' . $databaseRecord['uid']) . ']:</strong> ' . $output;
        }
        return 'ERROR: One of the inputs were not an array!';
    }
Exemplo n.º 30
0
    /**
     * 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;
    }