Пример #1
0
 /**
  * Returns the path (visually) of a page $uid, fx. "/First page/Second page/Another subpage"
  * Each part of the path will be limited to $titleLimit characters
  * Deleted pages are filtered out.
  *
  * @param 	integer		Page uid for which to create record path
  * @param 	string		$clause is additional where clauses, eg.
  * @param 	integer		Title limit
  * @param 	integer		Title limit of Full title (typ. set to 1000 or so)
  * @return 	mixed		Path of record (string) OR array with short/long title if $fullTitleLimit is set.
  */
 public static function getRecordPath($uid, $clause = '', $titleLimit = 1000, $fullTitleLimit = 0)
 {
     $loopCheck = 100;
     $output = $fullOutput = '/';
     while ($uid != 0 && $loopCheck > 0) {
         $loopCheck--;
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,pid,title,deleted,t3ver_oid,t3ver_wsid', 'pages', 'uid=' . (int) $uid . (strlen(trim($clause)) ? ' AND ' . $clause : ''));
         if (is_resource($res)) {
             $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
             $GLOBALS['TYPO3_DB']->sql_free_result($res);
             BackendUtility::workspaceOL('pages', $row);
             if (is_array($row)) {
                 BackendUtility::fixVersioningPid('pages', $row);
                 $uid = $row['pid'];
                 $output = '/' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($row['title'], $titleLimit)) . $output;
                 if ($row['deleted']) {
                     $output = '<span class="deletedPath">' . $output . '</span>';
                 }
                 if ($fullTitleLimit) {
                     $fullOutput = '/' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($row['title'], $fullTitleLimit)) . $fullOutput;
                 }
             } else {
                 break;
             }
         } else {
             break;
         }
     }
     if ($fullTitleLimit) {
         return array($output, $fullOutput);
     } else {
         return $output;
     }
 }
 /**
  * Overlay the given record with its workspace-version, if any
  *
  * @param array The record to get the workspace version for
  * @return void (passed by reference)
  */
 protected function makeWorkspaceOverlay(&$row)
 {
     // Check for workspace-versions
     if ($GLOBALS['BE_USER']->workspace != 0 && $GLOBALS['TCA'][$this->table]['ctrl']['versioningWS'] == TRUE) {
         \TYPO3\CMS\Backend\Utility\BackendUtility::workspaceOL($this->mmForeignTable ? $this->mmForeignTable : $this->table, $row);
     }
 }
Пример #3
0
 /**
  * Traverse the result pointer given, adding each record to array and setting some internal values at the same time.
  *
  * @param bool|\mysqli_result|object $result MySQLi result object / DBAL object
  * @param string $table Table name defaulting to tt_content
  * @return array The selected rows returned in this array.
  */
 public function getResult($result, $table = 'tt_content')
 {
     $output = array();
     // Traverse the result:
     while ($row = $this->getDatabase()->sql_fetch_assoc($result)) {
         BackendUtility::workspaceOL($table, $row, -99, true);
         if ($row) {
             // Add the row to the array:
             $output[] = $row;
         }
     }
     $this->generateTtContentDataArray($output);
     // Return selected records
     return $output;
 }
 /**
  * [Describe function...]
  *
  * @param 	[type]		$id: ...
  * @return 	[type]		...
  * @todo Define visibility
  */
 public function ext_getAllTemplates($id)
 {
     // Query is taken from the runThroughTemplates($theRootLine) function in the parent class.
     if ((int) $id) {
         $outRes = array();
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'pid=' . (int) $id . ' ' . $this->whereClause, '', 'sorting');
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             BackendUtility::workspaceOL('sys_template', $row);
             if (is_array($row)) {
                 $outRes[] = $row;
             }
         }
         $GLOBALS['TYPO3_DB']->sql_free_result($res);
         // Returns the template rows in an array.
         return $outRes;
     }
 }
Пример #5
0
 /**
  * Collects tt_content data from a single tt_content element
  * @param string $shortcutItem : The tt_content element to fetch the data from
  * @param array $collectedItems : The collected item data row
  * @param string $showHidden : query String containing enable fields
  * @param string $deleteClause : query String to check for deleted items
  * @param int $parentUid : uid of the referencing tt_content record
  */
 public function collectContentData($shortcutItem, &$collectedItems, &$showHidden, &$deleteClause, $parentUid)
 {
     $shortcutItem = str_replace('tt_content_', '', $shortcutItem);
     if ((int) $shortcutItem !== (int) $parentUid) {
         $itemRow = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', 'tt_content', 'uid=' . $shortcutItem . $showHidden . $deleteClause);
         if ($GLOBALS['BE_USER']->workspace > 0) {
             BackendUtility::workspaceOL('tt_content', $itemRow, $GLOBALS['BE_USER']->workspace);
         }
         $collectedItems[] = $itemRow;
     }
 }
Пример #6
0
 /**
  * Returns the path (visually) of a page $uid, fx. "/First page/Second page/Another subpage"
  * Each part of the path will be limited to $titleLimit characters
  * Deleted pages are filtered out.
  *
  * @param int $uid Page uid for which to create record path
  * @param string $clause is additional where clauses, eg.
  * @param int $titleLimit Title limit
  * @param int $fullTitleLimit Title limit of Full title (typ. set to 1000 or so)
  * @return mixed Path of record (string) OR array with short/long title if $fullTitleLimit is set.
  */
 public static function getRecordPath($uid, $clause = '', $titleLimit = 1000, $fullTitleLimit = 0)
 {
     $uid = (int) $uid;
     $output = $fullOutput = '/';
     if ($uid === 0) {
         return $output;
     }
     $databaseConnection = static::getDatabaseConnection();
     $clause = trim($clause) !== '' ? ' AND ' . $clause : '';
     $loopCheck = 100;
     while ($loopCheck > 0) {
         $loopCheck--;
         $res = $databaseConnection->exec_SELECTquery('uid,pid,title,deleted,t3ver_oid,t3ver_wsid', 'pages', 'uid=' . $uid . $clause);
         if ($res !== FALSE) {
             $row = $databaseConnection->sql_fetch_assoc($res);
             $databaseConnection->sql_free_result($res);
             BackendUtility::workspaceOL('pages', $row);
             if (is_array($row)) {
                 BackendUtility::fixVersioningPid('pages', $row);
                 $uid = (int) $row['pid'];
                 $output = '/' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($row['title'], $titleLimit)) . $output;
                 if ($row['deleted']) {
                     $output = '<span class="text-danger">' . $output . '</span>';
                 }
                 if ($fullTitleLimit) {
                     $fullOutput = '/' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($row['title'], $fullTitleLimit)) . $fullOutput;
                 }
             } else {
                 break;
             }
         } else {
             break;
         }
     }
     if ($fullTitleLimit) {
         return array($output, $fullOutput);
     } else {
         return $output;
     }
 }
Пример #7
0
 /**
  * Getting the tree data: next entry
  *
  * @param mixed $res Data handle
  * @param string $subCSSclass CSS class for sub elements (workspace related)
  * @return array item data array OR FALSE if end of elements.
  * @access private
  * @see getDataInit()
  */
 public function getDataNext(&$res, $subCSSclass = '')
 {
     if (is_array($this->data)) {
         if ($res < 0) {
             $row = FALSE;
         } else {
             list(, $row) = each($this->dataLookup[$res][$this->subLevelID]);
             // Passing on default <td> class for subelements:
             if (is_array($row) && $subCSSclass !== '') {
                 $row['_CSSCLASS'] = $row['_SUBCSSCLASS'] = $subCSSclass;
             }
         }
         return $row;
     } else {
         while ($row = @$GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             BackendUtility::workspaceOL($this->table, $row, $this->BE_USER->workspace, TRUE);
             if (is_array($row)) {
                 break;
             }
         }
         // Passing on default <td> class for subelements:
         if (is_array($row) && $subCSSclass !== '') {
             if ($this->table === 'pages' && $this->highlightPagesWithVersions && !isset($row['_CSSCLASS']) && count(BackendUtility::countVersionsOfRecordsOnPage($this->BE_USER->workspace, $row['uid']))) {
                 $row['_CSSCLASS'] = 'ver-versions';
             }
             if (!isset($row['_CSSCLASS'])) {
                 $row['_CSSCLASS'] = $subCSSclass;
             }
             if (!isset($row['_SUBCSSCLASS'])) {
                 $row['_SUBCSSCLASS'] = $subCSSclass;
             }
         }
         return $row;
     }
 }
Пример #8
0
 /**
  * Gets a page record.
  *
  * @param int $pageId
  * @return NULL|array
  */
 protected function getPage($pageId)
 {
     $page = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('uid, pid, backend_layout', 'pages', 'uid=' . (int) $pageId);
     BackendUtility::workspaceOL('pages', $page);
     return $page;
 }
Пример #9
0
 /**
  * Returns an array with record properties, like header and pid
  * No check for deleted or access is done!
  * For versionized records, pid is resolved to its live versions pid.
  * Used for logging
  *
  * @param string $table Table name
  * @param int $id Uid of record
  * @param bool $noWSOL If set, no workspace overlay is performed
  * @return array Properties of record
  */
 public function getRecordProperties($table, $id, $noWSOL = false)
 {
     $row = $table == 'pages' && !$id ? array('title' => '[root-level]', 'uid' => 0, 'pid' => 0) : $this->recordInfo($table, $id, '*');
     if (!$noWSOL) {
         BackendUtility::workspaceOL($table, $row);
     }
     return $this->getRecordPropertiesFromRow($table, $row);
 }
 /**
  * If "editPage" value is sent to script and it points to an accessible page, the internal var $this->theEditRec is set to the page record which should be loaded.
  * Returns void
  *
  * @return void
  * @todo Define visibility
  */
 public function editPageIdFunc()
 {
     if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('cms')) {
         return;
     }
     // EDIT page:
     $this->editPage = trim($GLOBALS['LANG']->csConvObj->conv_case($GLOBALS['LANG']->charSet, $this->editPage, 'toLower'));
     $this->editError = '';
     $this->theEditRec = '';
     $this->searchFor = '';
     if ($this->editPage) {
         // First, test alternative value consisting of [table]:[uid] and if not found, proceed with traditional page ID resolve:
         $this->alternativeTableUid = explode(':', $this->editPage);
         // We restrict it to admins only just because I'm not really sure if alt_doc.php properly
         // checks permissions of passed records for editing. If alt_doc.php does that, then we can remove this.
         if (!(count($this->alternativeTableUid) == 2 && $GLOBALS['BE_USER']->isAdmin())) {
             $where = ' AND (' . $GLOBALS['BE_USER']->getPagePermsClause(2) . ' OR ' . $GLOBALS['BE_USER']->getPagePermsClause(16) . ')';
             if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->editPage)) {
                 $this->theEditRec = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL('pages', $this->editPage, '*', $where);
             } else {
                 $records = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordsByField('pages', 'alias', $this->editPage, $where);
                 if (is_array($records)) {
                     $this->theEditRec = reset($records);
                     \TYPO3\CMS\Backend\Utility\BackendUtility::workspaceOL('pages', $this->theEditRec);
                 }
             }
             if (!is_array($this->theEditRec)) {
                 unset($this->theEditRec);
                 $this->searchFor = $this->editPage;
             } elseif (!$GLOBALS['BE_USER']->isInWebMount($this->theEditRec['uid'])) {
                 unset($this->theEditRec);
                 $this->editError = $GLOBALS['LANG']->getLL('bookmark_notEditable');
             } else {
                 // Visual path set:
                 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
                 $this->editPath = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordPath($this->theEditRec['pid'], $perms_clause, 30);
                 if (!$GLOBALS['BE_USER']->getTSConfigVal('options.bookmark_onEditId_dontSetPageTree')) {
                     $bookmarkKeepExpanded = $GLOBALS['BE_USER']->getTSConfigVal('options.bookmark_onEditId_keepExistingExpanded');
                     // Expanding page tree:
                     \TYPO3\CMS\Backend\Utility\BackendUtility::openPageTree($this->theEditRec['pid'], !$bookmarkKeepExpanded);
                 }
             }
         }
     }
 }
Пример #11
0
    /**
     * Rendering the quick-edit view.
     *
     * @return string
     */
    public function renderQuickEdit()
    {
        $databaseConnection = $this->getDatabaseConnection();
        $beUser = $this->getBackendUser();
        $lang = $this->getLanguageService();
        // Alternative template
        $this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/db_layout_quickedit.html');
        // Alternative form tag; Quick Edit submits its content to tce_db.php.
        $this->doc->form = '<form action="' . htmlspecialchars(BackendUtility::getModuleUrl('tce_db', ['prErr' => 1, 'uPT' => 1])) . '" method="post" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '" name="editform" onsubmit="return TBE_EDITOR.checkSubmit(1);">';
        // Setting up the context sensitive menu:
        $this->doc->getContextMenuCode();
        // Set the edit_record value for internal use in this function:
        $edit_record = $this->edit_record;
        // If a command to edit all records in a column is issue, then select all those elements, and redirect to FormEngine
        if (substr($edit_record, 0, 9) == '_EDIT_COL') {
            $res = $databaseConnection->exec_SELECTquery('*', 'tt_content', 'pid=' . (int) $this->id . ' AND colPos=' . (int) substr($edit_record, 10) . ' AND sys_language_uid=' . (int) $this->current_sys_language . ($this->MOD_SETTINGS['tt_content_showHidden'] ? '' : BackendUtility::BEenableFields('tt_content')) . BackendUtility::deleteClause('tt_content') . BackendUtility::versioningPlaceholderClause('tt_content'), '', 'sorting');
            $idListA = array();
            while ($cRow = $databaseConnection->sql_fetch_assoc($res)) {
                $idListA[] = $cRow['uid'];
            }
            $url = BackendUtility::getModuleUrl('record_edit', array('edit[tt_content][' . implode(',', $idListA) . ']' => 'edit', 'returnUrl' => $this->local_linkThisScript(array('edit_record' => ''))));
            HttpUtility::redirect($url);
        }
        // If the former record edited was the creation of a NEW record, this will look up the created records uid:
        if ($this->new_unique_uid) {
            $res = $databaseConnection->exec_SELECTquery('*', 'sys_log', 'userid=' . (int) $beUser->user['uid'] . ' AND NEWid=' . $databaseConnection->fullQuoteStr($this->new_unique_uid, 'sys_log'));
            $sys_log_row = $databaseConnection->sql_fetch_assoc($res);
            if (is_array($sys_log_row)) {
                $edit_record = $sys_log_row['tablename'] . ':' . $sys_log_row['recuid'];
            }
        }
        // Creating the selector box, allowing the user to select which element to edit:
        $opt = array();
        $is_selected = 0;
        $languageOverlayRecord = '';
        if ($this->current_sys_language) {
            list($languageOverlayRecord) = BackendUtility::getRecordsByField('pages_language_overlay', 'pid', $this->id, 'AND sys_language_uid=' . (int) $this->current_sys_language);
        }
        if (is_array($languageOverlayRecord)) {
            $inValue = 'pages_language_overlay:' . $languageOverlayRecord['uid'];
            $is_selected += (int) $edit_record == $inValue;
            $opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $lang->getLL('editLanguageHeader', TRUE) . ' ]</option>';
        } else {
            $inValue = 'pages:' . $this->id;
            $is_selected += (int) $edit_record == $inValue;
            $opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $lang->getLL('editPageProperties', TRUE) . ' ]</option>';
        }
        // Selecting all content elements from this language and allowed colPos:
        $res = $databaseConnection->exec_SELECTquery('*', 'tt_content', 'pid=' . (int) $this->id . ' AND sys_language_uid=' . (int) $this->current_sys_language . ' AND colPos IN (' . $this->colPosList . ')' . ($this->MOD_SETTINGS['tt_content_showHidden'] ? '' : BackendUtility::BEenableFields('tt_content')) . BackendUtility::deleteClause('tt_content') . BackendUtility::versioningPlaceholderClause('tt_content'), '', 'colPos,sorting');
        $colPos = NULL;
        $first = 1;
        // Page is the pid if no record to put this after.
        $prev = $this->id;
        while ($cRow = $databaseConnection->sql_fetch_assoc($res)) {
            BackendUtility::workspaceOL('tt_content', $cRow);
            if (is_array($cRow)) {
                if ($first) {
                    if (!$edit_record) {
                        $edit_record = 'tt_content:' . $cRow['uid'];
                    }
                    $first = 0;
                }
                if (!isset($colPos) || $cRow['colPos'] !== $colPos) {
                    $colPos = $cRow['colPos'];
                    $opt[] = '<option value=""></option>';
                    $opt[] = '<option value="_EDIT_COL:' . $colPos . '">__' . $lang->sL(BackendUtility::getLabelFromItemlist('tt_content', 'colPos', $colPos), TRUE) . ':__</option>';
                }
                $inValue = 'tt_content:' . $cRow['uid'];
                $is_selected += (int) $edit_record == $inValue;
                $opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($cRow['header'] ? $cRow['header'] : '[' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title') . '] ' . strip_tags($cRow['bodytext']), $beUser->uc['titleLen'])) . '</option>';
                $prev = -$cRow['uid'];
            }
        }
        // If edit_record is not set (meaning, no content elements was found for this language) we simply set it to create a new element:
        if (!$edit_record) {
            $edit_record = 'tt_content:new/' . $prev . '/' . $colPos;
            $inValue = 'tt_content:new/' . $prev . '/' . $colPos;
            $is_selected += (int) $edit_record == $inValue;
            $opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $lang->getLL('newLabel', 1) . ' ]</option>';
        }
        // If none is yet selected...
        if (!$is_selected) {
            $opt[] = '<option value=""></option>';
            $opt[] = '<option value="' . $edit_record . '"  selected="selected">[ ' . $lang->getLL('newLabel', TRUE) . ' ]</option>';
        }
        // Splitting the edit-record cmd value into table/uid:
        $this->eRParts = explode(':', $edit_record);
        // Delete-button flag?
        $this->deleteButton = MathUtility::canBeInterpretedAsInteger($this->eRParts[1]) && $edit_record && ($this->eRParts[0] != 'pages' && $this->EDIT_CONTENT || $this->eRParts[0] == 'pages' && $this->CALC_PERMS & Permission::PAGE_DELETE);
        // If undo-button should be rendered (depends on available items in sys_history)
        $this->undoButton = FALSE;
        $undoRes = $databaseConnection->exec_SELECTquery('tstamp', 'sys_history', 'tablename=' . $databaseConnection->fullQuoteStr($this->eRParts[0], 'sys_history') . ' AND recuid=' . (int) $this->eRParts[1], '', 'tstamp DESC', '1');
        if ($this->undoButtonR = $databaseConnection->sql_fetch_assoc($undoRes)) {
            $this->undoButton = TRUE;
        }
        // Setting up the Return URL for coming back to THIS script (if links take the user to another script)
        $R_URL_parts = parse_url(GeneralUtility::getIndpEnv('REQUEST_URI'));
        $R_URL_getvars = GeneralUtility::_GET();
        unset($R_URL_getvars['popView']);
        unset($R_URL_getvars['new_unique_uid']);
        $R_URL_getvars['edit_record'] = $edit_record;
        $this->R_URI = $R_URL_parts['path'] . '?' . GeneralUtility::implodeArrayForUrl('', $R_URL_getvars);
        // Setting close url/return url for exiting this script:
        // Goes to 'Columns' view if close is pressed (default)
        $this->closeUrl = $this->local_linkThisScript(array('SET' => array('function' => 1)));
        if ($this->returnUrl) {
            $this->closeUrl = $this->returnUrl;
        }
        // Return-url for JavaScript:
        $retUrlStr = $this->returnUrl ? '+\'&returnUrl=\'+' . GeneralUtility::quoteJSvalue(rawurlencode($this->returnUrl)) : '';
        // Drawing the edit record selectbox
        $this->editSelect = '<select name="edit_record" onchange="' . htmlspecialchars('jumpToUrl(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('web_layout') . '&id=' . $this->id . '&edit_record=') . '+escape(this.options[this.selectedIndex].value)' . $retUrlStr . ',this);') . '">' . implode('', $opt) . '</select>';
        $content = '';
        // Creating editing form:
        if ($beUser->check('tables_modify', $this->eRParts[0]) && $edit_record && ($this->eRParts[0] !== 'pages' && $this->EDIT_CONTENT || $this->eRParts[0] === 'pages' && $this->CALC_PERMS & Permission::PAGE_SHOW)) {
            // Splitting uid parts for special features, if new:
            list($uidVal, $ex_pid, $ex_colPos) = explode('/', $this->eRParts[1]);
            // Convert $uidVal to workspace version if any:
            if ($uidVal != 'new') {
                if ($draftRecord = BackendUtility::getWorkspaceVersionOfRecord($beUser->workspace, $this->eRParts[0], $uidVal, 'uid')) {
                    $uidVal = $draftRecord['uid'];
                }
            }
            // Initializing transfer-data object:
            $trData = GeneralUtility::makeInstance(DataPreprocessor::class);
            $trData->addRawData = TRUE;
            $trData->defVals[$this->eRParts[0]] = array('colPos' => (int) $ex_colPos, 'sys_language_uid' => (int) $this->current_sys_language);
            $trData->lockRecords = 1;
            // 'new'
            $trData->fetchRecord($this->eRParts[0], $uidVal == 'new' ? $this->id : $uidVal, $uidVal);
            $new_unique_uid = '';
            // Getting/Making the record:
            reset($trData->regTableItems_data);
            $rec = current($trData->regTableItems_data);
            if ($uidVal == 'new') {
                $new_unique_uid = uniqid('NEW', TRUE);
                $rec['uid'] = $new_unique_uid;
                $rec['pid'] = (int) $ex_pid ?: $this->id;
                $recordAccess = TRUE;
            } else {
                $rec['uid'] = $uidVal;
                // Checking internals access:
                $recordAccess = $beUser->recordEditAccessInternals($this->eRParts[0], $uidVal);
            }
            if (!$recordAccess) {
                // If no edit access, print error message:
                $content = $this->doc->section($lang->getLL('noAccess'), $lang->getLL('noAccess_msg') . '<br /><br />' . ($beUser->errorMsg ? 'Reason: ' . $beUser->errorMsg . '<br /><br />' : ''), 0, 1);
            } elseif (is_array($rec)) {
                // If the record is an array (which it will always be... :-)
                // Create instance of TCEforms, setting defaults:
                $tceForms = GeneralUtility::makeInstance(FormEngine::class);
                // Render form, wrap it:
                $panel = '';
                $panel .= $tceForms->getMainFields($this->eRParts[0], $rec);
                $panel = $tceForms->wrapTotal($panel, $rec, $this->eRParts[0]);
                // Add hidden fields:
                $theCode = $panel;
                if ($uidVal == 'new') {
                    $theCode .= '<input type="hidden" name="data[' . $this->eRParts[0] . '][' . $rec['uid'] . '][pid]" value="' . $rec['pid'] . '" />';
                }
                $theCode .= '
					<input type="hidden" name="_serialNumber" value="' . md5(microtime()) . '" />
					<input type="hidden" name="edit_record" value="' . $edit_record . '" />
					<input type="hidden" name="redirect" value="' . htmlspecialchars($uidVal == 'new' ? BackendUtility::getModuleUrl('web_layout', array('id' => $this->id, 'new_unique_uid' => $new_unique_uid, 'returnUrl' => $this->returnUrl)) : $this->R_URI) . '" />
					' . FormEngine::getHiddenTokenField('tceAction');
                // Add JavaScript as needed around the form:
                $theCode = $tceForms->printNeededJSFunctions_top() . $theCode . $tceForms->printNeededJSFunctions();
                // Add warning sign if record was "locked":
                if ($lockInfo = BackendUtility::isRecordLocked($this->eRParts[0], $rec['uid'])) {
                    /** @var \TYPO3\CMS\Core\Messaging\FlashMessage $flashMessage */
                    $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, htmlspecialchars($lockInfo['msg']), '', FlashMessage::WARNING);
                    /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */
                    $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
                    /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
                    $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
                    $defaultFlashMessageQueue->enqueue($flashMessage);
                }
                // Add whole form as a document section:
                $content = $this->doc->section('', $theCode);
            }
        } else {
            // If no edit access, print error message:
            $content = $this->doc->section($lang->getLL('noAccess'), $lang->getLL('noAccess_msg') . '<br /><br />', 0, 1);
        }
        // Bottom controls (function menus):
        $q_count = $this->getNumberOfHiddenElements();
        if ($q_count) {
            $h_func_b = '<div class="checkbox">' . '<label for="checkTt_content_showHidden">' . BackendUtility::getFuncCheck($this->id, 'SET[tt_content_showHidden]', $this->MOD_SETTINGS['tt_content_showHidden'], '', '', 'id="checkTt_content_showHidden"') . (!$q_count ? '<span class="text-muted">' . $lang->getLL('hiddenCE', TRUE) . '</span>' : $lang->getLL('hiddenCE', TRUE) . ' (' . $q_count . ')') . '</label>' . '</div>';
            $content .= $this->doc->section('', $h_func_b, 0, 0);
            $content .= $this->doc->spacer(10);
        }
        // Select element matrix:
        if ($this->eRParts[0] == 'tt_content' && MathUtility::canBeInterpretedAsInteger($this->eRParts[1])) {
            $posMap = GeneralUtility::makeInstance(ContentLayoutPagePositionMap::class);
            $posMap->backPath = $GLOBALS['BACK_PATH'];
            $posMap->cur_sys_language = $this->current_sys_language;
            $HTMLcode = '';
            // CSH:
            $HTMLcode .= BackendUtility::cshItem($this->descrTable, 'quickEdit_selElement', NULL, '|<br />');
            $HTMLcode .= $posMap->printContentElementColumns($this->id, $this->eRParts[1], $this->colPosList, $this->MOD_SETTINGS['tt_content_showHidden'], $this->R_URI);
            $content .= $this->doc->spacer(20);
            $content .= $this->doc->section($lang->getLL('CEonThisPage'), $HTMLcode, 0, 1);
            $content .= $this->doc->spacer(20);
        }
        return $content;
    }
 /**
  * @param string $table Table name
  * @param array $row Record array passed by reference. As minimum, the "uid" and  "pid" fields must exist! Fake fields cannot exist since the fields in the array is used as field names in the SQL look up. It would be nice to have fields like "t3ver_state" and "t3ver_mode_id" as well to avoid a new lookup inside movePlhOL().
  * @param int $wsid Workspace ID, if not specified will use static::getBackendUserAuthentication()->workspace
  * @param bool $unsetMovePointers If TRUE the function does not return a "pointer" row for moved records in a workspace
  * @return void
  * @see fixVersioningPid()
  */
 public function workspaceOL($table, &$row, $wsid = -99, $unsetMovePointers = FALSE)
 {
     BackendUtility::workspaceOL($table, $row, $wsid, $unsetMovePointers);
 }
Пример #13
0
 public function readPageAccess($id, $perms_clause)
 {
     if ((string) $id != '') {
         $id = intval($id);
         if (!$id) {
             if ($GLOBALS['BE_USER']->isAdmin()) {
                 $path = '/';
                 $pageinfo['_thePath'] = $path;
                 return $pageinfo;
             }
         } else {
             $pageinfo = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('pages', $id, '*', $perms_clause ? ' AND ' . $perms_clause : '');
             if ($pageinfo['uid'] && $GLOBALS['BE_USER']->isInWebMount($id, $perms_clause)) {
                 \TYPO3\CMS\Backend\Utility\BackendUtility::workspaceOL('pages', $pageinfo);
                 \TYPO3\CMS\Backend\Utility\BackendUtility::fixVersioningPid('pages', $pageinfo);
                 list($pageinfo['_thePath'], $pageinfo['_thePathFull']) = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordPath(intval($pageinfo['uid']), $perms_clause, 15, 1000);
                 return $pageinfo;
             }
         }
     }
     return false;
 }
Пример #14
0
 /**
  * Adds records from a foreign table (for selector boxes)
  *
  * @param array $items The array of items (label,value,icon)
  * @param array $fieldValue The 'columns' array for the field (from TCA)
  * @param array $TSconfig TSconfig for the table/row
  * @param string $field The fieldname
  * @param boolean $pFFlag If set, then we are fetching the 'neg_' foreign tables.
  * @return array The $items array modified.
  * @see addSelectOptionsToItemArray(), BackendUtility::exec_foreign_table_where_query()
  * @todo Define visibility
  */
 public function foreignTable($items, $fieldValue, $TSconfig, $field, $pFFlag = FALSE)
 {
     // Init:
     $pF = $pFFlag ? 'neg_' : '';
     $f_table = $fieldValue['config'][$pF . 'foreign_table'];
     $uidPre = $pFFlag ? '-' : '';
     // Exec query:
     $res = BackendUtility::exec_foreign_table_where_query($fieldValue, $field, $TSconfig, $pF);
     // Perform error test
     $db = $this->getDatabaseConnection();
     if ($db->sql_error()) {
         $msg = htmlspecialchars($db->sql_error());
         $msg .= '<br />' . LF;
         $msg .= $this->sL('LLL:EXT:lang/locallang_core.xlf:error.database_schema_mismatch');
         $msgTitle = $this->sL('LLL:EXT:lang/locallang_core.xlf:error.database_schema_mismatch_title');
         /** @var $flashMessage FlashMessage */
         $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $msg, $msgTitle, FlashMessage::ERROR, TRUE);
         /** @var $flashMessageService FlashMessageService */
         $flashMessageService = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService');
         /** @var $defaultFlashMessageQueue FlashMessageQueue */
         $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
         $defaultFlashMessageQueue->enqueue($flashMessage);
         return array();
     }
     // Get label prefix.
     $lPrefix = $this->sL($fieldValue['config'][$pF . 'foreign_table_prefix']);
     // Get icon field + path if any:
     $iField = $GLOBALS['TCA'][$f_table]['ctrl']['selicon_field'];
     $iPath = trim($GLOBALS['TCA'][$f_table]['ctrl']['selicon_field_path']);
     // Traverse the selected rows to add them:
     while ($row = $db->sql_fetch_assoc($res)) {
         BackendUtility::workspaceOL($f_table, $row);
         if (is_array($row)) {
             // Prepare the icon if available:
             if ($iField && $iPath && $row[$iField]) {
                 $iParts = GeneralUtility::trimExplode(',', $row[$iField], TRUE);
                 $icon = '../' . $iPath . '/' . trim($iParts[0]);
             } elseif (GeneralUtility::inList('singlebox,checkbox', $fieldValue['config']['renderMode'])) {
                 $icon = IconUtility::mapRecordTypeToSpriteIconName($f_table, $row);
             } else {
                 $icon = '';
             }
             // Add the item:
             $items[] = array($lPrefix . htmlspecialchars(BackendUtility::getRecordTitle($f_table, $row)), $uidPre . $row['uid'], $icon);
         }
     }
     $db->sql_free_result($res);
     return $items;
 }
Пример #15
0
 /**
  * Determine whether this page for the current
  *
  * @param int $pageUid
  * @param int $workspaceUid
  * @return bool
  */
 public function canCreatePreviewLink($pageUid, $workspaceUid)
 {
     $result = true;
     if ($pageUid > 0 && $workspaceUid > 0) {
         $pageRecord = BackendUtility::getRecord('pages', $pageUid);
         BackendUtility::workspaceOL('pages', $pageRecord, $workspaceUid);
         if (!GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['FE']['content_doktypes'], $pageRecord['doktype']) || VersionState::cast($pageRecord['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
             $result = false;
         }
     } else {
         $result = false;
     }
     return $result;
 }
 /**
  * Creating versioning overlay of a sys_template record.
  * This will use either frontend or backend overlay functionality depending on environment.
  *
  * @param array $row Row to overlay (passed by reference)
  * @return void
  * @todo Define visibility
  */
 public function versionOL(&$row)
 {
     // Distinguish frontend and backend call:
     // To do the fronted call a full frontend is required, just checking for
     // TYPO3_MODE === 'FE' is not enough. This could otherwise lead to fatals in
     // eId scripts that run in frontend scope, but do not have a full blown frontend.
     if (is_object($GLOBALS['TSFE']) === TRUE && property_exists($GLOBALS['TSFE'], 'sys_page') === TRUE && method_exists($GLOBALS['TSFE']->sys_page, 'versionOL') === TRUE) {
         // Frontend
         $GLOBALS['TSFE']->sys_page->versionOL('sys_template', $row);
     } else {
         // Backend
         \TYPO3\CMS\Backend\Utility\BackendUtility::workspaceOL('sys_template', $row);
     }
 }
Пример #17
0
 /**
  * Creates HTML for inserting/moving content elements.
  *
  * @param int $pid page id onto which to insert content element.
  * @param int $moveUid Move-uid (tt_content element uid?)
  * @param string $colPosList List of columns to show
  * @param bool $showHidden If not set, then hidden/starttime/endtime records are filtered out.
  * @param string $R_URI Request URI
  * @return string HTML
  */
 public function printContentElementColumns($pid, $moveUid, $colPosList, $showHidden, $R_URI)
 {
     $this->R_URI = $R_URI;
     $this->moveUid = $moveUid;
     $colPosArray = GeneralUtility::trimExplode(',', $colPosList, TRUE);
     $lines = array();
     foreach ($colPosArray as $kk => $vv) {
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_content', 'pid=' . (int) $pid . ($showHidden ? '' : BackendUtility::BEenableFields('tt_content')) . ' AND colPos=' . (int) $vv . ((string) $this->cur_sys_language !== '' ? ' AND sys_language_uid=' . (int) $this->cur_sys_language : '') . BackendUtility::deleteClause('tt_content') . BackendUtility::versioningPlaceholderClause('tt_content'), '', 'sorting');
         $lines[$vv] = array();
         $lines[$vv][] = $this->insertPositionIcon('', $vv, $kk, $moveUid, $pid);
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             BackendUtility::workspaceOL('tt_content', $row);
             if (is_array($row)) {
                 $lines[$vv][] = $this->wrapRecordHeader($this->getRecordHeader($row), $row);
                 $lines[$vv][] = $this->insertPositionIcon($row, $vv, $kk, $moveUid, $pid);
             }
         }
         $GLOBALS['TYPO3_DB']->sql_free_result($res);
     }
     return $this->printRecordMap($lines, $colPosArray, $pid);
 }
Пример #18
0
 /**
  * Creates HTML for inserting/moving content elements.
  *
  * @param int $pid page id onto which to insert content element.
  * @param int $moveUid Move-uid (tt_content element uid?)
  * @param string $colPosList List of columns to show
  * @param bool $showHidden If not set, then hidden/starttime/endtime records are filtered out.
  * @param string $R_URI Request URI
  * @return string HTML
  */
 public function printContentElementColumns($pid, $moveUid, $colPosList, $showHidden, $R_URI)
 {
     $this->R_URI = $R_URI;
     $this->moveUid = $moveUid;
     $colPosArray = GeneralUtility::trimExplode(',', $colPosList, true);
     $lines = [];
     foreach ($colPosArray as $kk => $vv) {
         $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content');
         $queryBuilder->getRestrictions()->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class));
         if ($showHidden) {
             $queryBuilder->getRestrictions()->removeByType(HiddenRestriction::class)->removeByType(StartTimeRestriction::class)->removeByType(EndTimeRestriction::class);
         }
         $queryBuilder->select('*')->from('tt_content')->where($queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($pid, \PDO::PARAM_INT)), $queryBuilder->expr()->eq('colPos', $queryBuilder->createNamedParameter($vv, \PDO::PARAM_INT)))->orderBy('sorting');
         if ((string) $this->cur_sys_language !== '') {
             $queryBuilder->andWhere($queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter($this->cur_sys_language, \PDO::PARAM_INT)));
         }
         $res = $queryBuilder->execute();
         $lines[$vv] = [];
         $lines[$vv][] = $this->insertPositionIcon('', $vv, $kk, $moveUid, $pid);
         while ($row = $res->fetch()) {
             BackendUtility::workspaceOL('tt_content', $row);
             if (is_array($row)) {
                 $lines[$vv][] = $this->wrapRecordHeader($this->getRecordHeader($row), $row);
                 $lines[$vv][] = $this->insertPositionIcon($row, $vv, $kk, $moveUid, $pid);
             }
         }
     }
     return $this->printRecordMap($lines, $colPosArray, $pid);
 }
Пример #19
0
    /**
     * Creates the listing of records from a single table
     *
     * @param string $table Table name
     * @param int $id Page id
     * @param string $rowList List of fields to show in the listing. Pseudo fields will be added including the record header.
     * @throws \UnexpectedValueException
     * @return string HTML table with the listing for the record.
     */
    public function getTable($table, $id, $rowList = '')
    {
        $rowListArray = GeneralUtility::trimExplode(',', $rowList, true);
        // if no columns have been specified, show description (if configured)
        if (!empty($GLOBALS['TCA'][$table]['ctrl']['descriptionColumn']) && empty($rowListArray)) {
            array_push($rowListArray, $GLOBALS['TCA'][$table]['ctrl']['descriptionColumn']);
        }
        $backendUser = $this->getBackendUserAuthentication();
        $lang = $this->getLanguageService();
        $db = $this->getDatabaseConnection();
        // Init
        $addWhere = '';
        $titleCol = $GLOBALS['TCA'][$table]['ctrl']['label'];
        $thumbsCol = $GLOBALS['TCA'][$table]['ctrl']['thumbnail'];
        $l10nEnabled = $GLOBALS['TCA'][$table]['ctrl']['languageField'] && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] && !$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'];
        $tableCollapsed = (bool) $this->tablesCollapsed[$table];
        // prepare space icon
        $this->spaceIcon = '<span class="btn btn-default disabled">' . $this->iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>';
        // Cleaning rowlist for duplicates and place the $titleCol as the first column always!
        $this->fieldArray = array();
        // title Column
        // Add title column
        $this->fieldArray[] = $titleCol;
        // Control-Panel
        if (!GeneralUtility::inList($rowList, '_CONTROL_')) {
            $this->fieldArray[] = '_CONTROL_';
        }
        // Clipboard
        if ($this->showClipboard) {
            $this->fieldArray[] = '_CLIPBOARD_';
        }
        // Ref
        if (!$this->dontShowClipControlPanels) {
            $this->fieldArray[] = '_REF_';
        }
        // Path
        if ($this->searchLevels) {
            $this->fieldArray[] = '_PATH_';
        }
        // Localization
        if ($this->localizationView && $l10nEnabled) {
            $this->fieldArray[] = '_LOCALIZATION_';
            $this->fieldArray[] = '_LOCALIZATION_b';
            $addWhere .= ' AND (
				' . $GLOBALS['TCA'][$table]['ctrl']['languageField'] . '<=0
				OR
				' . $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] . ' = 0
			)';
        }
        // Cleaning up:
        $this->fieldArray = array_unique(array_merge($this->fieldArray, $rowListArray));
        if ($this->noControlPanels) {
            $tempArray = array_flip($this->fieldArray);
            unset($tempArray['_CONTROL_']);
            unset($tempArray['_CLIPBOARD_']);
            $this->fieldArray = array_keys($tempArray);
        }
        // Creating the list of fields to include in the SQL query:
        $selectFields = $this->fieldArray;
        $selectFields[] = 'uid';
        $selectFields[] = 'pid';
        // adding column for thumbnails
        if ($thumbsCol) {
            $selectFields[] = $thumbsCol;
        }
        if ($table == 'pages') {
            $selectFields[] = 'module';
            $selectFields[] = 'extendToSubpages';
            $selectFields[] = 'nav_hide';
            $selectFields[] = 'doktype';
            $selectFields[] = 'shortcut';
            $selectFields[] = 'shortcut_mode';
            $selectFields[] = 'mount_pid';
        }
        if (is_array($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) {
            $selectFields = array_merge($selectFields, $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']);
        }
        foreach (array('type', 'typeicon_column', 'editlock') as $field) {
            if ($GLOBALS['TCA'][$table]['ctrl'][$field]) {
                $selectFields[] = $GLOBALS['TCA'][$table]['ctrl'][$field];
            }
        }
        if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
            $selectFields[] = 't3ver_id';
            $selectFields[] = 't3ver_state';
            $selectFields[] = 't3ver_wsid';
        }
        if ($l10nEnabled) {
            $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['languageField'];
            $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'];
        }
        if ($GLOBALS['TCA'][$table]['ctrl']['label_alt']) {
            $selectFields = array_merge($selectFields, GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$table]['ctrl']['label_alt'], true));
        }
        // Unique list!
        $selectFields = array_unique($selectFields);
        $fieldListFields = $this->makeFieldList($table, 1);
        if (empty($fieldListFields) && $GLOBALS['TYPO3_CONF_VARS']['BE']['debug']) {
            $message = sprintf($lang->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:missingTcaColumnsMessage', true), $table, $table);
            $messageTitle = $lang->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:missingTcaColumnsMessageTitle', true);
            /** @var FlashMessage $flashMessage */
            $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $message, $messageTitle, FlashMessage::WARNING, true);
            /** @var $flashMessageService FlashMessageService */
            $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
            /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
            $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
            $defaultFlashMessageQueue->enqueue($flashMessage);
        }
        // Making sure that the fields in the field-list ARE in the field-list from TCA!
        $selectFields = array_intersect($selectFields, $fieldListFields);
        // Implode it into a list of fields for the SQL-statement.
        $selFieldList = implode(',', $selectFields);
        $this->selFieldList = $selFieldList;
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'])) {
            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'] as $classData) {
                $hookObject = GeneralUtility::getUserObj($classData);
                if (!$hookObject instanceof RecordListGetTableHookInterface) {
                    throw new \UnexpectedValueException('$hookObject must implement interface ' . RecordListGetTableHookInterface::class, 1195114460);
                }
                $hookObject->getDBlistQuery($table, $id, $addWhere, $selFieldList, $this);
            }
        }
        // Create the SQL query for selecting the elements in the listing:
        // do not do paging when outputting as CSV
        if ($this->csvOutput) {
            $this->iLimit = 0;
        }
        if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
            // Get the two previous rows for sorting if displaying page > 1
            $this->firstElementNumber = $this->firstElementNumber - 2;
            $this->iLimit = $this->iLimit + 2;
            // (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
            $queryParts = $this->makeQueryArray($table, $id, $addWhere, $selFieldList);
            $this->firstElementNumber = $this->firstElementNumber + 2;
            $this->iLimit = $this->iLimit - 2;
        } else {
            // (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
            $queryParts = $this->makeQueryArray($table, $id, $addWhere, $selFieldList);
        }
        // Finding the total amount of records on the page
        // (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
        $this->setTotalItems($queryParts);
        // Init:
        $dbCount = 0;
        $out = '';
        $tableHeader = '';
        $result = null;
        $listOnlyInSingleTableMode = $this->listOnlyInSingleTableMode && !$this->table;
        // If the count query returned any number of records, we perform the real query,
        // selecting records.
        if ($this->totalItems) {
            // Fetch records only if not in single table mode
            if ($listOnlyInSingleTableMode) {
                $dbCount = $this->totalItems;
            } else {
                // Set the showLimit to the number of records when outputting as CSV
                if ($this->csvOutput) {
                    $this->showLimit = $this->totalItems;
                    $this->iLimit = $this->totalItems;
                }
                $result = $db->exec_SELECT_queryArray($queryParts);
                $dbCount = $db->sql_num_rows($result);
            }
        }
        // If any records was selected, render the list:
        if ($dbCount) {
            $tableTitle = $lang->sL($GLOBALS['TCA'][$table]['ctrl']['title'], true);
            if ($tableTitle === '') {
                $tableTitle = $table;
            }
            // Header line is drawn
            $theData = array();
            if ($this->disableSingleTableView) {
                $theData[$titleCol] = '<span class="c-table">' . BackendUtility::wrapInHelp($table, '', $tableTitle) . '</span> (<span class="t3js-table-total-items">' . $this->totalItems . '</span>)';
            } else {
                $icon = $this->table ? '<span title="' . $lang->getLL('contractView', true) . '">' . $this->iconFactory->getIcon('actions-view-table-collapse', Icon::SIZE_SMALL)->render() . '</span>' : '<span title="' . $lang->getLL('expandView', true) . '">' . $this->iconFactory->getIcon('actions-view-table-expand', Icon::SIZE_SMALL)->render() . '</span>';
                $theData[$titleCol] = $this->linkWrapTable($table, $tableTitle . ' (<span class="t3js-table-total-items">' . $this->totalItems . '</span>) ' . $icon);
            }
            if ($listOnlyInSingleTableMode) {
                $tableHeader .= BackendUtility::wrapInHelp($table, '', $theData[$titleCol]);
            } else {
                // Render collapse button if in multi table mode
                $collapseIcon = '';
                if (!$this->table) {
                    $href = htmlspecialchars($this->listURL() . '&collapse[' . $table . ']=' . ($tableCollapsed ? '0' : '1'));
                    $title = $tableCollapsed ? $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.expandTable', true) : $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.collapseTable', true);
                    $icon = '<span class="collapseIcon">' . $this->iconFactory->getIcon($tableCollapsed ? 'actions-view-list-expand' : 'actions-view-list-collapse', Icon::SIZE_SMALL)->render() . '</span>';
                    $collapseIcon = '<a href="' . $href . '" title="' . $title . '" class="pull-right t3js-toggle-recordlist" data-table="' . htmlspecialchars($table) . '" data-toggle="collapse" data-target="#recordlist-' . htmlspecialchars($table) . '">' . $icon . '</a>';
                }
                $tableHeader .= $theData[$titleCol] . $collapseIcon;
            }
            // Render table rows only if in multi table view or if in single table view
            $rowOutput = '';
            if (!$listOnlyInSingleTableMode || $this->table) {
                // Fixing an order table for sortby tables
                $this->currentTable = array();
                $currentIdList = array();
                $doSort = $GLOBALS['TCA'][$table]['ctrl']['sortby'] && !$this->sortField;
                $prevUid = 0;
                $prevPrevUid = 0;
                // Get first two rows and initialize prevPrevUid and prevUid if on page > 1
                if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
                    $row = $db->sql_fetch_assoc($result);
                    $prevPrevUid = -(int) $row['uid'];
                    $row = $db->sql_fetch_assoc($result);
                    $prevUid = $row['uid'];
                }
                $accRows = array();
                // Accumulate rows here
                while ($row = $db->sql_fetch_assoc($result)) {
                    if (!$this->isRowListingConditionFulfilled($table, $row)) {
                        continue;
                    }
                    // In offline workspace, look for alternative record:
                    BackendUtility::workspaceOL($table, $row, $backendUser->workspace, true);
                    if (is_array($row)) {
                        $accRows[] = $row;
                        $currentIdList[] = $row['uid'];
                        if ($doSort) {
                            if ($prevUid) {
                                $this->currentTable['prev'][$row['uid']] = $prevPrevUid;
                                $this->currentTable['next'][$prevUid] = '-' . $row['uid'];
                                $this->currentTable['prevUid'][$row['uid']] = $prevUid;
                            }
                            $prevPrevUid = isset($this->currentTable['prev'][$row['uid']]) ? -$prevUid : $row['pid'];
                            $prevUid = $row['uid'];
                        }
                    }
                }
                $db->sql_free_result($result);
                $this->totalRowCount = count($accRows);
                // CSV initiated
                if ($this->csvOutput) {
                    $this->initCSV();
                }
                // Render items:
                $this->CBnames = array();
                $this->duplicateStack = array();
                $this->eCounter = $this->firstElementNumber;
                $cc = 0;
                foreach ($accRows as $row) {
                    // Render item row if counter < limit
                    if ($cc < $this->iLimit) {
                        $cc++;
                        $this->translations = false;
                        $rowOutput .= $this->renderListRow($table, $row, $cc, $titleCol, $thumbsCol);
                        // If localization view is enabled it means that the selected records are
                        // either default or All language and here we will not select translations
                        // which point to the main record:
                        if ($this->localizationView && $l10nEnabled) {
                            // For each available translation, render the record:
                            if (is_array($this->translations)) {
                                foreach ($this->translations as $lRow) {
                                    // $lRow isn't always what we want - if record was moved we've to work with the
                                    // placeholder records otherwise the list is messed up a bit
                                    if ($row['_MOVE_PLH_uid'] && $row['_MOVE_PLH_pid']) {
                                        $where = 't3ver_move_id="' . (int) $lRow['uid'] . '" AND pid="' . $row['_MOVE_PLH_pid'] . '" AND t3ver_wsid=' . $row['t3ver_wsid'] . BackendUtility::deleteClause($table);
                                        $tmpRow = BackendUtility::getRecordRaw($table, $where, $selFieldList);
                                        $lRow = is_array($tmpRow) ? $tmpRow : $lRow;
                                    }
                                    // In offline workspace, look for alternative record:
                                    BackendUtility::workspaceOL($table, $lRow, $backendUser->workspace, true);
                                    if (is_array($lRow) && $backendUser->checkLanguageAccess($lRow[$GLOBALS['TCA'][$table]['ctrl']['languageField']])) {
                                        $currentIdList[] = $lRow['uid'];
                                        $rowOutput .= $this->renderListRow($table, $lRow, $cc, $titleCol, $thumbsCol, 18);
                                    }
                                }
                            }
                        }
                    }
                    // Counter of total rows incremented:
                    $this->eCounter++;
                }
                // Record navigation is added to the beginning and end of the table if in single
                // table mode
                if ($this->table) {
                    $rowOutput = $this->renderListNavigation('top') . $rowOutput . $this->renderListNavigation('bottom');
                } else {
                    // Show that there are more records than shown
                    if ($this->totalItems > $this->itemsLimitPerTable) {
                        $countOnFirstPage = $this->totalItems > $this->itemsLimitSingleTable ? $this->itemsLimitSingleTable : $this->totalItems;
                        $hasMore = $this->totalItems > $this->itemsLimitSingleTable;
                        $colspan = $this->showIcon ? count($this->fieldArray) + 1 : count($this->fieldArray);
                        $rowOutput .= '<tr><td colspan="' . $colspan . '">
								<a href="' . htmlspecialchars($this->listURL() . '&table=' . rawurlencode($table)) . '" class="btn btn-default">' . '<span class="t3-icon fa fa-chevron-down"></span> <i>[1 - ' . $countOnFirstPage . ($hasMore ? '+' : '') . ']</i></a>
								</td></tr>';
                    }
                }
                // The header row for the table is now created:
                $out .= $this->renderListHeader($table, $currentIdList);
            }
            $collapseClass = $tableCollapsed && !$this->table ? 'collapse' : 'collapse in';
            $dataState = $tableCollapsed && !$this->table ? 'collapsed' : 'expanded';
            // The list of records is added after the header:
            $out .= $rowOutput;
            // ... and it is all wrapped in a table:
            $out = '



			<!--
				DB listing of elements:	"' . htmlspecialchars($table) . '"
			-->
				<div class="panel panel-space panel-default">
					<div class="panel-heading">
					' . $tableHeader . '
					</div>
					<div class="table-fit ' . $collapseClass . '" id="recordlist-' . htmlspecialchars($table) . '" data-state="' . $dataState . '">
						<table data-table="' . htmlspecialchars($table) . '" class="table table-striped table-hover' . ($listOnlyInSingleTableMode ? ' typo3-dblist-overview' : '') . '">
							' . $out . '
						</table>
					</div>
				</div>
			';
            // Output csv if...
            // This ends the page with exit.
            if ($this->csvOutput) {
                $this->outputCSV($table);
            }
        }
        // Return content:
        return $out;
    }
 /**
  * Initializes the page tree.
  *
  * @return \TYPO3\CMS\Backend\Tree\View\PageTreeView
  */
 protected function initializeTree()
 {
     $tree = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Tree\\View\\PageTreeView');
     /** @var \TYPO3\CMS\Backend\Tree\View\PageTreeView $tree */
     $tree->addField('nav_title', true);
     $tree->addField('alias', true);
     $tree->addField('tx_realurl_pathsegment', true);
     $tree->init('AND ' . $GLOBALS['BE_USER']->getPagePermsClause(1));
     $treeStartingPoint = intval($this->pObj->id);
     $treeStartingRecord = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('pages', $treeStartingPoint);
     \TYPO3\CMS\Backend\Utility\BackendUtility::workspaceOL('pages', $treeStartingRecord);
     // Creating top icon; the current page
     $tree->tree[] = array('row' => $treeStartingRecord, 'HTML' => $tree->getIcon($treeStartingRecord));
     // Create the tree from starting point:
     if ($this->pObj->MOD_SETTINGS['depth'] > 0) {
         $tree->getTree($treeStartingPoint, $this->pObj->MOD_SETTINGS['depth'], '');
     }
     return $tree;
 }
Пример #21
0
    /**
     * Creates the listing of records from a single table
     *
     * @param string $table Table name
     * @param int $id Page id
     * @param string $rowlist List of fields to show in the listing.
     * 	Pseudo fields will be added including the record header.
     *
     * @return string HTML table with the listing for the record.
     * @throws UnexpectedValueException If hook was of wrong interface
     */
    public function getTable($table, $id, $rowlist)
    {
        $database = $this->getDatabaseConnection();
        $language = $this->getLanguageService();
        $backendUser = $this->getBackendUser();
        // Init
        $addWhere = '';
        $titleCol = $GLOBALS['TCA'][$table]['ctrl']['label'];
        $thumbsCol = $GLOBALS['TCA'][$table]['ctrl']['thumbnail'];
        $l10nEnabled = $GLOBALS['TCA'][$table]['ctrl']['languageField'] && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] && !$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'];
        $tableCollapsed = !$this->tablesCollapsed[$table] ? FALSE : TRUE;
        // prepare space icon
        $this->spaceIcon = IconUtility::getSpriteIcon('empty-empty', array('style' => 'background-position: 0 10px;'));
        // Cleaning rowlist for duplicates and place the $titleCol
        // as the first column always!
        $this->fieldArray = array();
        // title Column
        // Add title column
        $this->fieldArray[] = $titleCol;
        // Control-Panel
        if (!GeneralUtility::inList($rowlist, '_CONTROL_')) {
            $this->fieldArray[] = '_CONTROL_';
            $this->fieldArray[] = '_AFTERCONTROL_';
        }
        // Clipboard
        if ($this->showClipboard) {
            $this->fieldArray[] = '_CLIPBOARD_';
        }
        // Ref
        if (!$this->dontShowClipControlPanels) {
            $this->fieldArray[] = '_REF_';
            $this->fieldArray[] = '_AFTERREF_';
        }
        // Path
        if ($this->searchLevels) {
            $this->fieldArray[] = '_PATH_';
        }
        // Localization
        if ($this->localizationView && $l10nEnabled) {
            $this->fieldArray[] = '_LOCALIZATION_';
            $this->fieldArray[] = '_LOCALIZATION_b';
            $addWhere .= ' AND (
				' . $GLOBALS['TCA'][$table]['ctrl']['languageField'] . ' <= 0
				OR
				' . $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] . ' = 0
			)';
        }
        // Cleaning up:
        $this->fieldArray = array_unique(array_merge($this->fieldArray, GeneralUtility::trimExplode(',', $rowlist, 1)));
        if ($this->noControlPanels) {
            $tempArray = array_flip($this->fieldArray);
            unset($tempArray['_CONTROL_']);
            unset($tempArray['_CLIPBOARD_']);
            $this->fieldArray = array_keys($tempArray);
        }
        // Creating the list of fields to include in the SQL query:
        $selectFields = $this->fieldArray;
        $selectFields[] = 'uid';
        $selectFields[] = 'pid';
        // adding column for thumbnails
        if ($thumbsCol) {
            $selectFields[] = $thumbsCol;
        }
        if ($table == 'pages') {
            if (ExtensionManagementUtility::isLoaded('cms')) {
                $selectFields[] = 'module';
                $selectFields[] = 'extendToSubpages';
                $selectFields[] = 'nav_hide';
            }
            $selectFields[] = 'doktype';
        }
        if (is_array($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) {
            $selectFields = array_merge($selectFields, $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']);
        }
        if ($GLOBALS['TCA'][$table]['ctrl']['type']) {
            $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['type'];
        }
        if ($GLOBALS['TCA'][$table]['ctrl']['typeicon_column']) {
            $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['typeicon_column'];
        }
        if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
            $selectFields[] = 't3ver_id';
            $selectFields[] = 't3ver_state';
            $selectFields[] = 't3ver_wsid';
            // Filtered out when tx_commerce_categories in makeFieldList()
            $selectFields[] = 't3ver_swapmode';
        }
        if ($l10nEnabled) {
            $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['languageField'];
            $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'];
        }
        if ($GLOBALS['TCA'][$table]['ctrl']['label_alt']) {
            $selectFields = array_merge($selectFields, GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$table]['ctrl']['label_alt'], 1));
        }
        // Unique list!
        $selectFields = array_unique($selectFields);
        // Making sure that the fields in the field-list ARE in the field-list from TCA!
        $selectFields = array_intersect($selectFields, $this->makeFieldList($table, 1));
        // implode it into a list of fields for the SQL-statement.
        $selFieldList = implode(',', $selectFields);
        $this->selFieldList = $selFieldList;
        /**
         * DB-List getTable
         *
         * @date 2007-11-16
         * @request Malte Jansen <*****@*****.**>
         */
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'])) {
            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'] as $classData) {
                $hookObject = GeneralUtility::getUserObj($classData);
                if (!$hookObject instanceof \TYPO3\CMS\Backend\RecordList\RecordListGetTableHookInterface) {
                    throw new UnexpectedValueException('$hookObject must implement interface \\TYPO3\\CMS\\Backend\\RecordList\\RecordListGetTableHookInterface', 1195114460);
                }
                $hookObject->getDBlistQuery($table, $id, $addWhere, $selFieldList, $this);
            }
        }
        // Create the SQL query for selecting the elements in the listing:
        // do not do paging when outputting as CSV
        if ($this->csvOutput) {
            $this->iLimit = 0;
        }
        if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
            // Get the two previous rows for sorting if displaying page > 1
            $this->firstElementNumber = $this->firstElementNumber - 2;
            $this->iLimit = $this->iLimit + 2;
            // (API function from class.db_list.inc)
            $queryParts = $this->makeQueryArray($table, $id, $addWhere, $selFieldList);
            $this->firstElementNumber = $this->firstElementNumber + 2;
            $this->iLimit = $this->iLimit - 2;
        } else {
            // (API function from class.db_list.inc)
            $queryParts = $this->makeQueryArray($table, $id, $addWhere, $selFieldList);
        }
        // Finding the total amount of records on the page
        $this->setTotalItems($queryParts);
        // Init:
        $dbCount = 0;
        $out = '';
        $listOnlyInSingleTableMode = $this->listOnlyInSingleTableMode && !$this->table;
        $result = FALSE;
        // If the count query returned any number of records,
        // we perform the real query, selecting records.
        if ($this->totalItems) {
            // Fetch records only if not in single table mode or
            // if in multi table mode and not collapsed
            if ($listOnlyInSingleTableMode || !$this->table && $tableCollapsed) {
                $dbCount = $this->totalItems;
            } else {
                // set the showLimit to the number of records when outputting as CSV
                if ($this->csvOutput) {
                    $this->showLimit = $this->totalItems;
                    $this->iLimit = $this->totalItems;
                }
                $result = $database->exec_SELECT_queryArray($queryParts);
                $dbCount = $database->sql_num_rows($result);
            }
        }
        // If any records was selected, render the list:
        if ($dbCount) {
            // Half line is drawn between tables:
            if (!$listOnlyInSingleTableMode) {
                $theData = array();
                if (!$this->table && !$rowlist) {
                    $theData[$titleCol] = '<img src="/' . TYPO3_mainDir . '/clear.gif" width="' . ($GLOBALS['SOBE']->MOD_SETTINGS['bigControlPanel'] ? '230' : '350') . '" height="1" alt="" />';
                    if (in_array('_CONTROL_', $this->fieldArray)) {
                        $theData['_CONTROL_'] = '';
                    }
                    if (in_array('_CLIPBOARD_', $this->fieldArray)) {
                        $theData['_CLIPBOARD_'] = '';
                    }
                }
                $out .= $this->addelement(0, '', $theData, 'class="c-table-row-spacer"', $this->leftMargin);
            }
            // Header line is drawn
            $theData = array();
            if ($this->disableSingleTableView) {
                $theData[$titleCol] = '<span class="c-table">' . BackendUtility::wrapInHelp($table, '', $language->sL($GLOBALS['TCA'][$table]['ctrl']['title'], TRUE)) . '</span> (' . $this->totalItems . ')';
            } else {
                $theData[$titleCol] = $this->linkWrapTable($table, '<span class="c-table">' . $language->sL($GLOBALS['TCA'][$table]['ctrl']['title'], TRUE) . '</span> (' . $this->totalItems . ') ' . ($this->table ? IconUtility::getSpriteIcon('actions-view-table-collapse', array('title' => $language->getLL('contractView', TRUE))) : IconUtility::getSpriteIcon('actions-view-table-expand', array('title' => $language->getLL('expandView', TRUE)))));
            }
            if ($listOnlyInSingleTableMode) {
                $out .= '
					<tr>
						<td class="t3-row-header" style="width: 95%;">' . BackendUtility::wrapInHelp($table, '', $theData[$titleCol]) . '</td>
					</tr>';
            } else {
                // Render collapse button if in multi table mode
                $collapseIcon = '';
                if (!$this->table) {
                    if ($tableCollapsed) {
                        $options = array('class' => 'collapseIcon', 'title' => $language->sL('LLL:EXT:lang/locallang_core.php:labels.expandTable', TRUE));
                    } else {
                        $options = array('class' => 'collapseIcon', 'title' => $language->sL('LLL:EXT:lang/locallang_core.php:labels.collapseTable', TRUE));
                    }
                    $value = $tableCollapsed ? '0' : '1';
                    $collapseIcon = '<a href="' . htmlspecialchars($this->listURL() . '&collapse[' . $table . ']=' . $value) . '">' . ($tableCollapsed ? IconUtility::getSpriteIcon('actions-view-list-expand', $options) : IconUtility::getSpriteIcon('actions-view-list-collapse', $options)) . '</a>';
                }
                $out .= $this->addElement(1, $collapseIcon, $theData, ' class="t3-row-header"', '');
            }
            $iOut = '';
            // Render table rows only if in multi table view
            // and not collapsed or if in single table view
            if (!$listOnlyInSingleTableMode && (!$tableCollapsed || $this->table)) {
                // Fixing a order table for sortby tables
                $this->currentTable = array();
                $currentIdList = array();
                $doSort = $GLOBALS['TCA'][$table]['ctrl']['sortby'] && !$this->sortField;
                $prevUid = 0;
                $prevPrevUid = 0;
                // Get first two rows and initialize prevPrevUid and prevUid if on page > 1
                if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
                    $row = $database->sql_fetch_assoc($result);
                    $prevPrevUid = -(int) $row['uid'];
                    $row = $database->sql_fetch_assoc($result);
                    $prevUid = $row['uid'];
                }
                // Accumulate rows here
                $accRows = array();
                while ($row = $database->sql_fetch_assoc($result)) {
                    // In offline workspace, look for alternative record:
                    BackendUtility::workspaceOL($table, $row, $this->getBackendUser()->workspace, TRUE);
                    if (is_array($row)) {
                        $accRows[] = $row;
                        $currentIdList[] = $row['uid'];
                        if ($doSort) {
                            if ($prevUid) {
                                $this->currentTable['prev'][$row['uid']] = $prevPrevUid;
                                $this->currentTable['next'][$prevUid] = '-' . $row['uid'];
                                $this->currentTable['prevUid'][$row['uid']] = $prevUid;
                            }
                            $prevPrevUid = isset($this->currentTable['prev'][$row['uid']]) ? -$prevUid : $row['pid'];
                            $prevUid = $row['uid'];
                        }
                    }
                }
                $database->sql_free_result($result);
                $this->totalRowCount = count($accRows);
                // CSV initiated
                if ($this->csvOutput) {
                    $this->initCSV();
                }
                // Render items:
                $this->CBnames = array();
                $this->duplicateStack = array();
                $this->eCounter = $this->firstElementNumber;
                $iOut = '';
                $cc = 0;
                foreach ($accRows as $row) {
                    // Render item row if counter < limit
                    if ($cc < $this->iLimit) {
                        $cc++;
                        $this->translations = FALSE;
                        $iOut .= $this->renderListRow($table, $row, $cc, $titleCol, $thumbsCol);
                        // If localization view is enabled it means that the selected records are
                        // either default or All language and here we will not select translations
                        // which point to the main record:
                        if ($this->localizationView && $l10nEnabled) {
                            // For each available translation, render the record:
                            if (is_array($this->translations)) {
                                foreach ($this->translations as $lRow) {
                                    // $lRow isn't always what we want - if record was moved we've to work with the
                                    // placeholder records otherwise the list is messed up a bit
                                    if ($row['_MOVE_PLH_uid'] && $row['_MOVE_PLH_pid']) {
                                        $tmpRow = BackendUtility::getRecordRaw($table, 't3ver_move_id="' . (int) $lRow['uid'] . '" AND pid="' . $row['_MOVE_PLH_pid'] . '" AND t3ver_wsid=' . $row['t3ver_wsid'] . BackendUtility::deleteClause($table), $selFieldList);
                                        $lRow = is_array($tmpRow) ? $tmpRow : $lRow;
                                    }
                                    // In offline workspace, look for alternative record:
                                    BackendUtility::workspaceOL($table, $lRow, $this->getBackendUser()->workspace, TRUE);
                                    if (is_array($lRow) && $backendUser->checkLanguageAccess($lRow[$GLOBALS['TCA'][$table]['ctrl']['languageField']])) {
                                        $currentIdList[] = $lRow['uid'];
                                        $iOut .= $this->renderListRow($table, $lRow, $cc, $titleCol, $thumbsCol, 18);
                                    }
                                }
                            }
                        }
                    }
                    // Counter of total rows incremented:
                    $this->eCounter++;
                }
                // Record navigation is added to the beginning and
                // end of the table if in single table mode
                if ($this->table) {
                    $iOut = $this->renderListNavigation('top') . $iOut . $this->renderListNavigation('bottom');
                } else {
                    // show that there are more records than shown
                    if ($this->totalItems > $this->itemsLimitPerTable) {
                        $countOnFirstPage = $this->totalItems > $this->itemsLimitSingleTable ? $this->itemsLimitSingleTable : $this->totalItems;
                        $hasMore = $this->totalItems > $this->itemsLimitSingleTable;
                        $iOut .= '<tr><td colspan="' . count($this->fieldArray) . '" style="padding: 5px;">
							<a href="' . htmlspecialchars($this->listURL() . '&table=' . rawurlencode($table)) . '">' . '<img' . IconUtility::skinImg($this->backPath, 'gfx/pildown.gif', 'width="14" height="14"') . ' alt="" />' . ' <i>[1 - ' . $countOnFirstPage . ($hasMore ? '+' : '') . ']</i></a>
							</td></tr>';
                    }
                }
                // The header row for the table is now created:
                $out .= $this->renderListHeader($table, $currentIdList);
            }
            // The list of records is added after the header:
            $out .= $iOut;
            unset($iOut);
            // ... and it is all wrapped in a table:
            $out = '



			<!--
				DB listing of elements:	"' . htmlspecialchars($table) . '"
			-->
				<table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist' . ($listOnlyInSingleTableMode ? ' typo3-dblist-overview' : '') . '">
					' . $out . '
				</table>';
            // Output csv if...
            if ($this->csvOutput) {
                // This ends the page with exit.
                $this->outputCSV($table);
            }
        }
        // Return content:
        return $out;
    }
Пример #22
0
 /**
  * Adds the record $row from $table.
  * No checking for relations done here. Pure data.
  *
  * @param string $table Table name
  * @param array $row Record row.
  * @param int $relationLevel (Internal) if the record is added as a relation, this is set to the "level" it was on.
  * @return void
  */
 public function export_addRecord($table, $row, $relationLevel = 0)
 {
     BackendUtility::workspaceOL($table, $row);
     if ($this->excludeDisabledRecords && !$this->isActive($table, $row['uid'])) {
         return;
     }
     if ((string) $table !== '' && is_array($row) && $row['uid'] > 0 && !$this->excludeMap[$table . ':' . $row['uid']]) {
         if ($this->checkPID($table === 'pages' ? $row['uid'] : $row['pid'])) {
             if (!isset($this->dat['records'][$table . ':' . $row['uid']])) {
                 // Prepare header info:
                 $row = $this->filterRecordFields($table, $row);
                 $headerInfo = array();
                 $headerInfo['uid'] = $row['uid'];
                 $headerInfo['pid'] = $row['pid'];
                 $headerInfo['title'] = GeneralUtility::fixed_lgd_cs(BackendUtility::getRecordTitle($table, $row), 40);
                 $headerInfo['size'] = strlen(serialize($row));
                 if ($relationLevel) {
                     $headerInfo['relationLevel'] = $relationLevel;
                 }
                 // If record content is not too large in size, set the header content and add the rest:
                 if ($headerInfo['size'] < $this->maxRecordSize) {
                     // Set the header summary:
                     $this->dat['header']['records'][$table][$row['uid']] = $headerInfo;
                     // Create entry in the PID lookup:
                     $this->dat['header']['pid_lookup'][$row['pid']][$table][$row['uid']] = 1;
                     // Initialize reference index object:
                     $refIndexObj = GeneralUtility::makeInstance(ReferenceIndex::class);
                     // Yes to workspace overlays for exporting....
                     $refIndexObj->WSOL = true;
                     $relations = $refIndexObj->getRelations($table, $row);
                     $relations = $this->fixFileIDsInRelations($relations);
                     $relations = $this->removeSoftrefsHavingTheSameDatabaseRelation($relations);
                     // Data:
                     $this->dat['records'][$table . ':' . $row['uid']] = array();
                     $this->dat['records'][$table . ':' . $row['uid']]['data'] = $row;
                     $this->dat['records'][$table . ':' . $row['uid']]['rels'] = $relations;
                     // Add information about the relations in the record in the header:
                     $this->dat['header']['records'][$table][$row['uid']]['rels'] = $this->flatDBrels($this->dat['records'][$table . ':' . $row['uid']]['rels']);
                     // Add information about the softrefs to header:
                     $this->dat['header']['records'][$table][$row['uid']]['softrefs'] = $this->flatSoftRefs($this->dat['records'][$table . ':' . $row['uid']]['rels']);
                 } else {
                     $this->error('Record ' . $table . ':' . $row['uid'] . ' was larger than maxRecordSize (' . GeneralUtility::formatSize($this->maxRecordSize) . ')');
                 }
             } else {
                 $this->error('Record ' . $table . ':' . $row['uid'] . ' already added.');
             }
         } else {
             $this->error('Record ' . $table . ':' . $row['uid'] . ' was outside your DB mounts!');
         }
     }
 }
Пример #23
0
 /**
  * Finds page UIDs for the element from table <code>$table</code> with UIDs from <code>$idList</code>
  *
  * @param string $table Table to search
  * @param array $idList List of records' UIDs
  * @param int $workspaceId Workspace ID. We need this parameter because user can be in LIVE but he still can publisg DRAFT from ws module!
  * @param array $pageIdList List of found page UIDs
  * @param array $elementList List of found element UIDs. Key is table name, value is list of UIDs
  * @return void
  */
 public function findPageIdsForVersionStateChange($table, array $idList, $workspaceId, array &$pageIdList, array &$elementList)
 {
     if ($workspaceId == 0) {
         return;
     }
     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('DISTINCT B.pid', $table . ' A,' . $table . ' B', 'A.pid=-1' . ' AND A.t3ver_wsid=' . $workspaceId . ' AND A.uid IN (' . implode(',', $idList) . ') AND A.t3ver_oid=B.uid' . BackendUtility::deleteClause($table, 'A') . BackendUtility::deleteClause($table, 'B'));
     while (FALSE !== ($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res))) {
         $pageIdList[] = $row[0];
         // Find ws version
         // Note: cannot use BackendUtility::getRecordWSOL()
         // here because it does not accept workspace id!
         $rec = BackendUtility::getRecord('pages', $row[0]);
         BackendUtility::workspaceOL('pages', $rec, $workspaceId);
         if ($rec['_ORIG_uid']) {
             $elementList['pages'][$row[0]] = $rec['_ORIG_uid'];
         }
     }
     $GLOBALS['TYPO3_DB']->sql_free_result($res);
     // The line below is necessary even with DISTINCT
     // because several elements can be passed by caller
     $pageIdList = array_unique($pageIdList);
 }
Пример #24
0
 /**
  * Return a page tree
  *
  * @param integer $pageUid page to start with
  * @param integer $treeLevel count of levels
  * @return \TYPO3\CMS\Backend\Tree\View\PageTreeView
  * @throws \Exception
  */
 public static function pageTree($pageUid, $treeLevel)
 {
     if (TYPO3_MODE !== 'BE') {
         throw new \Exception('Page::pageTree does only work in the backend!');
     }
     /* @var $tree \TYPO3\CMS\Backend\Tree\View\PageTreeView */
     $tree = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Tree\\View\\PageTreeView');
     $tree->init('AND ' . $GLOBALS['BE_USER']->getPagePermsClause(1));
     $treeStartingRecord = BackendUtility::getRecord('pages', $pageUid);
     BackendUtility::workspaceOL('pages', $treeStartingRecord);
     // Creating top icon; the current page
     $tree->tree[] = array('row' => $treeStartingRecord, 'HTML' => IconUtility::getSpriteIconForRecord('pages', $treeStartingRecord));
     $tree->getTree($pageUid, $treeLevel, '');
     return $tree;
 }
Пример #25
0
 /**
  * TCA config "foreign_table" evaluation. Add them to $items
  *
  * Used by TcaSelectItems and TcaSelectTreeItems data providers
  *
  * @param array $result Result array
  * @param string $fieldName Current handle field name
  * @param array $items Incoming items
  * @return array Modified item array
  */
 protected function addItemsFromForeignTable(array $result, $fieldName, array $items)
 {
     // Guard
     if (empty($result['processedTca']['columns'][$fieldName]['config']['foreign_table']) || !is_string($result['processedTca']['columns'][$fieldName]['config']['foreign_table'])) {
         return $items;
     }
     $languageService = $this->getLanguageService();
     $database = $this->getDatabaseConnection();
     $foreignTable = $result['processedTca']['columns'][$fieldName]['config']['foreign_table'];
     $foreignTableQueryArray = $this->buildForeignTableQuery($result, $fieldName);
     $queryResource = $database->exec_SELECT_queryArray($foreignTableQueryArray);
     // Early return on error with flash message
     $databaseError = $database->sql_error();
     if (!empty($databaseError)) {
         $msg = htmlspecialchars($databaseError) . '<br />' . LF;
         $msg .= $languageService->sL('LLL:EXT:lang/locallang_core.xlf:error.database_schema_mismatch');
         $msgTitle = $languageService->sL('LLL:EXT:lang/locallang_core.xlf:error.database_schema_mismatch_title');
         /** @var $flashMessage FlashMessage */
         $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $msg, $msgTitle, FlashMessage::ERROR, true);
         /** @var $flashMessageService FlashMessageService */
         $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
         /** @var $defaultFlashMessageQueue FlashMessageQueue */
         $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
         $defaultFlashMessageQueue->enqueue($flashMessage);
         $database->sql_free_result($queryResource);
         return $items;
     }
     $labelPrefix = '';
     if (!empty($result['processedTca']['columns'][$fieldName]['config']['foreign_table_prefix'])) {
         $labelPrefix = $result['processedTca']['columns'][$fieldName]['config']['foreign_table_prefix'];
         $labelPrefix = $languageService->sL($labelPrefix);
     }
     $iconFieldName = '';
     if (!empty($result['processedTca']['ctrl']['selicon_field'])) {
         $iconFieldName = $result['processedTca']['ctrl']['selicon_field'];
     }
     $iconPath = '';
     if (!empty($result['processedTca']['ctrl']['selicon_field_path'])) {
         $iconPath = $result['processedTca']['ctrl']['selicon_field_path'];
     }
     $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
     while ($foreignRow = $database->sql_fetch_assoc($queryResource)) {
         BackendUtility::workspaceOL($foreignTable, $foreignRow);
         if (is_array($foreignRow)) {
             // Prepare the icon if available:
             if ($iconFieldName && $iconPath && $foreignRow[$iconFieldName]) {
                 $iParts = GeneralUtility::trimExplode(',', $foreignRow[$iconFieldName], true);
                 $icon = '../' . $iconPath . '/' . trim($iParts[0]);
             } else {
                 $icon = $iconFactory->mapRecordTypeToIconIdentifier($foreignTable, $foreignRow);
             }
             // Add the item
             $items[] = [$labelPrefix . htmlspecialchars(BackendUtility::getRecordTitle($foreignTable, $foreignRow)), $foreignRow['uid'], $icon];
         }
     }
     $database->sql_free_result($queryResource);
     return $items;
 }
Пример #26
0
    /**
     * Checking if the "&edit" variable was sent so we can open it for editing the page.
     *
     * @return void
     */
    protected function handlePageEditing()
    {
        $beUser = $this->getBackendUser();
        // EDIT page:
        $editId = preg_replace('/[^[:alnum:]_]/', '', GeneralUtility::_GET('edit'));
        $editRecord = '';
        if ($editId) {
            // Looking up the page to edit, checking permissions:
            $where = ' AND (' . $beUser->getPagePermsClause(2) . ' OR ' . $beUser->getPagePermsClause(16) . ')';
            if (MathUtility::canBeInterpretedAsInteger($editId)) {
                $editRecord = BackendUtility::getRecordWSOL('pages', $editId, '*', $where);
            } else {
                $records = BackendUtility::getRecordsByField('pages', 'alias', $editId, $where);
                if (is_array($records)) {
                    $editRecord = reset($records);
                    BackendUtility::workspaceOL('pages', $editRecord);
                }
            }
            // If the page was accessible, then let the user edit it.
            if (is_array($editRecord) && $beUser->isInWebMount($editRecord['uid'])) {
                // Setting JS code to open editing:
                $this->js .= '
		// Load page to edit:
	window.setTimeout("top.loadEditId(' . (int) $editRecord['uid'] . ');", 500);
			';
                // Checking page edit parameter:
                if (!$beUser->getTSConfigVal('options.bookmark_onEditId_dontSetPageTree')) {
                    $bookmarkKeepExpanded = $beUser->getTSConfigVal('options.bookmark_onEditId_keepExistingExpanded');
                    // Expanding page tree:
                    BackendUtility::openPageTree((int) $editRecord['pid'], !$bookmarkKeepExpanded);
                }
            } else {
                $this->js .= '
		// Warning about page editing:
	alert(' . GeneralUtility::quoteJSvalue(sprintf($this->getLanguageService()->getLL('noEditPage'), $editId)) . ');
			';
            }
        }
    }
    /**
     * Main function creating the content for the module.
     *
     * @return string HTML content for the module, actually a "section" made through the parent object in $this->pObj
     */
    public function main()
    {
        $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
        $this->getLanguageService()->includeLLFile('EXT:wizard_crpages/Resources/Private/Language/locallang.xlf');
        $theCode = '';
        $this->tsConfig = BackendUtility::getPagesTSconfig($this->pObj->id);
        $this->pagesTsConfig = isset($this->tsConfig['TCEFORM.']['pages.']) ? $this->tsConfig['TCEFORM.']['pages.'] : array();
        // Create new pages here?
        $pageRecord = BackendUtility::getRecord('pages', $this->pObj->id, 'uid', ' AND ' . $this->getBackendUser()->getPagePermsClause(8));
        $pageRepository = GeneralUtility::makeInstance(PageRepository::class);
        $menuItems = $pageRepository->getMenu($this->pObj->id, '*', 'sorting', '', false);
        if (is_array($pageRecord)) {
            $data = GeneralUtility::_GP('data');
            if (is_array($data['pages'])) {
                if (GeneralUtility::_GP('createInListEnd')) {
                    $endI = end($menuItems);
                    $thePid = -(int) $endI['uid'];
                    if (!$thePid) {
                        $thePid = $this->pObj->id;
                    }
                } else {
                    $thePid = $this->pObj->id;
                }
                $firstRecord = true;
                $previousIdentifier = '';
                foreach ($data['pages'] as $identifier => $dat) {
                    if (!trim($dat['title'])) {
                        unset($data['pages'][$identifier]);
                    } else {
                        $data['pages'][$identifier]['hidden'] = GeneralUtility::_GP('hidePages') ? 1 : 0;
                        $data['pages'][$identifier]['nav_hide'] = GeneralUtility::_GP('hidePagesInMenus') ? 1 : 0;
                        if ($firstRecord) {
                            $firstRecord = false;
                            $data['pages'][$identifier]['pid'] = $thePid;
                        } else {
                            $data['pages'][$identifier]['pid'] = '-' . $previousIdentifier;
                        }
                        $previousIdentifier = $identifier;
                    }
                }
                if (!empty($data['pages'])) {
                    reset($data);
                    $dataHandler = GeneralUtility::makeInstance(\TYPO3\CMS\Core\DataHandling\DataHandler::class);
                    $dataHandler->stripslashes_values = 0;
                    // set default TCA values specific for the user
                    $TCAdefaultOverride = $this->getBackendUser()->getTSConfigProp('TCAdefaults');
                    if (is_array($TCAdefaultOverride)) {
                        $dataHandler->setDefaultsFromUserTS($TCAdefaultOverride);
                    }
                    $dataHandler->start($data, array());
                    $dataHandler->process_datamap();
                    BackendUtility::setUpdateSignal('updatePageTree');
                    $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, '', $this->getLanguageService()->getLL('wiz_newPages_create'));
                } else {
                    $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, '', $this->getLanguageService()->getLL('wiz_newPages_noCreate'), FlashMessage::ERROR);
                }
                $theCode .= $flashMessage->render();
                // Display result:
                $menuItems = $pageRepository->getMenu($this->pObj->id, '*', 'sorting', '', false);
                $lines = array();
                foreach ($menuItems as $record) {
                    BackendUtility::workspaceOL('pages', $record);
                    if (is_array($record)) {
                        $lines[] = '<span class="text-nowrap" title="' . BackendUtility::titleAttribForPages($record, '', false) . '">' . $this->iconFactory->getIconForRecord('pages', $record, Icon::SIZE_SMALL)->render() . htmlspecialchars(GeneralUtility::fixed_lgd_cs($record['title'], $this->getBackendUser()->uc['titleLen'])) . '</span>';
                    }
                }
                $theCode .= '<h4>' . $this->getLanguageService()->getLL('wiz_newPages_currentMenu') . '</h4>' . implode('<br />', $lines);
            } else {
                // Display create form
                $this->typeSelectHtml = $this->getTypeSelectHtml();
                $tableData = array();
                for ($a = 0; $a < 5; $a++) {
                    $tableData[] = $this->getFormLine($a);
                }
                $theCode .= '
					<h4>' . $this->getLanguageService()->getLL('wiz_newPages') . ':</h4>
					<div class="form-group t3js-wizardcrpages-container">
						' . implode(LF, $tableData) . '
					</div>
					<div class="form-group">
						<input class="btn btn-default t3js-wizardcrpages-createnewfields" type="button" value="' . $this->getLanguageService()->getLL('wiz_newPages_addMoreLines') . '" />
					</div>
					<div class="form-group">
						<div class="checkbox">
							<label for="createInListEnd">
								<input type="checkbox" name="createInListEnd" id="createInListEnd" value="1" />
								' . $this->getLanguageService()->getLL('wiz_newPages_listEnd') . '
							</label>
						</div>
						<div class="checkbox">
							<label for="hidePages">
								<input type="checkbox" name="hidePages" id="hidePages" value="1" />
								' . $this->getLanguageService()->getLL('wiz_newPages_hidePages') . '
							</label>
						</div>
						<div class="checkbox">
							<label for="hidePagesInMenus">
								<input type="checkbox" name="hidePagesInMenus" id="hidePagesInMenus" value="1" />
								' . $this->getLanguageService()->getLL('wiz_newPages_hidePagesInMenus') . '
							</label>
						</div>
					</div>
					<div class="form-group">
						<input class="btn btn-default" type="submit" name="create" value="' . $this->getLanguageService()->getLL('wiz_newPages_lCreate') . '" />
						<input class="btn btn-default" type="reset" value="' . $this->getLanguageService()->getLL('wiz_newPages_lReset') . '" />
					</div>';
                $this->getPageRenderer()->loadJquery();
                $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/WizardCrpages/WizardCreatePages');
                // Add inline code
                $inlineJavaScriptCode = 'var tpl = "' . addslashes(str_replace(array(LF, TAB), array('', ''), $this->getFormLine('#'))) . '", i, line, div, bg, label;';
                $this->getPageRenderer()->addJsInlineCode('wizard_crpages', $inlineJavaScriptCode);
            }
        } else {
            $theCode .= GeneralUtility::makeInstance(FlashMessage::class, '', $this->getLanguageService()->getLL('wiz_newPages_errorMsg1'), FlashMessage::ERROR)->render();
        }
        // CSH
        $theCode .= BackendUtility::cshItem('_MOD_web_func', 'tx_wizardcrpages', null, '<div class="t3-help">|</div>');
        $out = $this->pObj->doc->header($this->getLanguageService()->getLL('wiz_crMany'));
        $out .= $this->pObj->doc->section('', $theCode, false, true);
        return $out;
    }
Пример #28
0
 /**
  * Creating versioning overlay of a sys_template record.
  * This will use either frontend or backend overlay functionality depending on environment.
  *
  * @param array $row Row to overlay (passed by reference)
  * @return void
  */
 public function versionOL(&$row)
 {
     // Distinguish frontend and backend call:
     // To do the fronted call a full frontend is required, just checking for
     // TYPO3_MODE === 'FE' is not enough. This could otherwise lead to fatals in
     // eId scripts that run in frontend scope, but do not have a full blown frontend.
     if (is_object($this->getTypoScriptFrontendController()) && property_exists($this->getTypoScriptFrontendController(), 'sys_page') && method_exists($this->getTypoScriptFrontendController()->sys_page, 'versionOL')) {
         // Frontend
         $this->getTypoScriptFrontendController()->sys_page->versionOL('sys_template', $row);
     } else {
         // Backend
         BackendUtility::workspaceOL('sys_template', $row);
     }
 }
Пример #29
0
 /**
  * Add entries for a single record
  *
  * @param string $table Table name
  * @param int $uid Record uid
  * @param array $lines Output lines array (is passed by reference and modified)
  * @param string $preCode Pre-HTML code
  * @param bool $checkImportInPidRecord If you want import validation, you can set this so it checks if the import can take place on the specified page.
  * @return void
  */
 public function singleRecordLines($table, $uid, &$lines, $preCode, $checkImportInPidRecord = false)
 {
     // Get record:
     $record = $this->dat['header']['records'][$table][$uid];
     unset($this->remainHeader['records'][$table][$uid]);
     if (!is_array($record) && !($table === 'pages' && !$uid)) {
         $this->error('MISSING RECORD: ' . $table . ':' . $uid);
     }
     // Begin to create the line arrays information record, pInfo:
     $pInfo = array();
     $pInfo['ref'] = $table . ':' . $uid;
     // Unknown table name:
     $lang = $this->getLanguageService();
     if ($table === '_SOFTREF_') {
         $pInfo['preCode'] = $preCode;
         $pInfo['title'] = '<em>' . $lang->getLL('impexpcore_singlereco_softReferencesFiles', true) . '</em>';
     } elseif (!isset($GLOBALS['TCA'][$table])) {
         // Unknown table name:
         $pInfo['preCode'] = $preCode;
         $pInfo['msg'] = 'UNKNOWN TABLE \'' . $pInfo['ref'] . '\'';
         $pInfo['title'] = '<em>' . htmlspecialchars($record['title']) . '</em>';
     } else {
         // Otherwise, set table icon and title.
         // Import Validation (triggered by $this->display_import_pid_record) will show messages if import is not possible of various items.
         if (is_array($this->display_import_pid_record) && !empty($this->display_import_pid_record)) {
             if ($checkImportInPidRecord) {
                 if (!$this->getBackendUser()->doesUserHaveAccess($this->display_import_pid_record, $table === 'pages' ? 8 : 16)) {
                     $pInfo['msg'] .= '\'' . $pInfo['ref'] . '\' cannot be INSERTED on this page! ';
                 }
                 if (!$this->checkDokType($table, $this->display_import_pid_record['doktype']) && !$GLOBALS['TCA'][$table]['ctrl']['rootLevel']) {
                     $pInfo['msg'] .= '\'' . $table . '\' cannot be INSERTED on this page type (change page type to \'Folder\'.) ';
                 }
             }
             if (!$this->getBackendUser()->check('tables_modify', $table)) {
                 $pInfo['msg'] .= 'You are not allowed to CREATE \'' . $table . '\' tables! ';
             }
             if ($GLOBALS['TCA'][$table]['ctrl']['readOnly']) {
                 $pInfo['msg'] .= 'TABLE \'' . $table . '\' is READ ONLY! ';
             }
             if ($GLOBALS['TCA'][$table]['ctrl']['adminOnly'] && !$this->getBackendUser()->isAdmin()) {
                 $pInfo['msg'] .= 'TABLE \'' . $table . '\' is ADMIN ONLY! ';
             }
             if ($GLOBALS['TCA'][$table]['ctrl']['is_static']) {
                 $pInfo['msg'] .= 'TABLE \'' . $table . '\' is a STATIC TABLE! ';
             }
             if ((int) $GLOBALS['TCA'][$table]['ctrl']['rootLevel'] === 1) {
                 $pInfo['msg'] .= 'TABLE \'' . $table . '\' will be inserted on ROOT LEVEL! ';
             }
             $diffInverse = false;
             $recInf = null;
             if ($this->update) {
                 // In case of update-PREVIEW we swap the diff-sources.
                 $diffInverse = true;
                 $recInf = $this->doesRecordExist($table, $uid, $this->showDiff ? '*' : '');
                 $pInfo['updatePath'] = $recInf ? htmlspecialchars($this->getRecordPath($recInf['pid'])) : '<strong>NEW!</strong>';
                 // Mode selector:
                 $optValues = array();
                 $optValues[] = $recInf ? $lang->getLL('impexpcore_singlereco_update') : $lang->getLL('impexpcore_singlereco_insert');
                 if ($recInf) {
                     $optValues['as_new'] = $lang->getLL('impexpcore_singlereco_importAsNew');
                 }
                 if ($recInf) {
                     if (!$this->global_ignore_pid) {
                         $optValues['ignore_pid'] = $lang->getLL('impexpcore_singlereco_ignorePid');
                     } else {
                         $optValues['respect_pid'] = $lang->getLL('impexpcore_singlereco_respectPid');
                     }
                 }
                 if (!$recInf && $this->getBackendUser()->isAdmin()) {
                     $optValues['force_uid'] = sprintf($lang->getLL('impexpcore_singlereco_forceUidSAdmin'), $uid);
                 }
                 $optValues['exclude'] = $lang->getLL('impexpcore_singlereco_exclude');
                 if ($table === 'sys_file') {
                     $pInfo['updateMode'] = '';
                 } else {
                     $pInfo['updateMode'] = $this->renderSelectBox('tx_impexp[import_mode][' . $table . ':' . $uid . ']', $this->import_mode[$table . ':' . $uid], $optValues);
                 }
             }
             // Diff view:
             if ($this->showDiff) {
                 // For IMPORTS, get new id:
                 if ($newUid = $this->import_mapId[$table][$uid]) {
                     $diffInverse = false;
                     $recInf = $this->doesRecordExist($table, $newUid, '*');
                     BackendUtility::workspaceOL($table, $recInf);
                 }
                 if (is_array($recInf)) {
                     $pInfo['showDiffContent'] = $this->compareRecords($recInf, $this->dat['records'][$table . ':' . $uid]['data'], $table, $diffInverse);
                 }
             }
         }
         $pInfo['preCode'] = $preCode . '<span title="' . htmlspecialchars($table . ':' . $uid) . '">' . $this->iconFactory->getIconForRecord($table, (array) $this->dat['records'][$table . ':' . $uid]['data'], Icon::SIZE_SMALL)->render() . '</span>';
         $pInfo['title'] = htmlspecialchars($record['title']);
         // View page:
         if ($table === 'pages') {
             $viewID = $this->mode === 'export' ? $uid : ($this->doesImport ? $this->import_mapId['pages'][$uid] : 0);
             if ($viewID) {
                 $pInfo['title'] = '<a href="#" onclick="' . htmlspecialchars(BackendUtility::viewOnClick($viewID)) . 'return false;">' . $pInfo['title'] . '</a>';
             }
         }
     }
     $pInfo['class'] = $table == 'pages' ? 'bgColor4-20' : 'bgColor4';
     $pInfo['type'] = 'record';
     $pInfo['size'] = $record['size'];
     $lines[] = $pInfo;
     // File relations:
     if (is_array($record['filerefs'])) {
         $this->addFiles($record['filerefs'], $lines, $preCode);
     }
     // DB relations
     if (is_array($record['rels'])) {
         $this->addRelations($record['rels'], $lines, $preCode);
     }
     // Soft ref
     if (!empty($record['softrefs'])) {
         $preCode_A = $preCode . '&nbsp;&nbsp;&nbsp;&nbsp;';
         $preCode_B = $preCode . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
         foreach ($record['softrefs'] as $info) {
             $pInfo = array();
             $pInfo['preCode'] = $preCode_A . $this->iconFactory->getIcon('status-status-reference-soft', Icon::SIZE_SMALL)->render();
             $pInfo['title'] = '<em>' . $info['field'] . ', "' . $info['spKey'] . '" </em>: <span title="' . htmlspecialchars($info['matchString']) . '">' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($info['matchString'], 60)) . '</span>';
             if ($info['subst']['type']) {
                 if (strlen($info['subst']['title'])) {
                     $pInfo['title'] .= '<br/>' . $preCode_B . '<strong>' . $lang->getLL('impexpcore_singlereco_title', true) . '</strong> ' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($info['subst']['title'], 60));
                 }
                 if (strlen($info['subst']['description'])) {
                     $pInfo['title'] .= '<br/>' . $preCode_B . '<strong>' . $lang->getLL('impexpcore_singlereco_descr', true) . '</strong> ' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($info['subst']['description'], 60));
                 }
                 $pInfo['title'] .= '<br/>' . $preCode_B . ($info['subst']['type'] == 'file' ? $lang->getLL('impexpcore_singlereco_filename', true) . ' <strong>' . $info['subst']['relFileName'] . '</strong>' : '') . ($info['subst']['type'] == 'string' ? $lang->getLL('impexpcore_singlereco_value', true) . ' <strong>' . $info['subst']['tokenValue'] . '</strong>' : '') . ($info['subst']['type'] == 'db' ? $lang->getLL('impexpcore_softrefsel_record', true) . ' <strong>' . $info['subst']['recordRef'] . '</strong>' : '');
             }
             $pInfo['ref'] = 'SOFTREF';
             $pInfo['size'] = '';
             $pInfo['class'] = 'bgColor3';
             $pInfo['type'] = 'softref';
             $pInfo['_softRefInfo'] = $info;
             $pInfo['type'] = 'softref';
             $mode = $this->softrefCfg[$info['subst']['tokenID']]['mode'];
             if ($info['error'] && $mode !== 'editable' && $mode !== 'exclude') {
                 $pInfo['msg'] .= $info['error'];
             }
             $lines[] = $pInfo;
             // Add relations:
             if ($info['subst']['type'] == 'db') {
                 list($tempTable, $tempUid) = explode(':', $info['subst']['recordRef']);
                 $this->addRelations(array(array('table' => $tempTable, 'id' => $tempUid, 'tokenID' => $info['subst']['tokenID'])), $lines, $preCode_B, array(), '');
             }
             // Add files:
             if ($info['subst']['type'] == 'file') {
                 $this->addFiles(array($info['file_ID']), $lines, $preCode_B, '', $info['subst']['tokenID']);
             }
         }
     }
 }
Пример #30
0
 /**
  * @param $edit_record array
  *
  * @return array
  */
 protected function makeQuickEditMenu($edit_record)
 {
     $lang = $this->getLanguageService();
     $databaseConnection = $this->getDatabaseConnection();
     $beUser = $this->getBackendUser();
     $quickEditMenu = $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
     $quickEditMenu->setIdentifier('quickEditMenu');
     $quickEditMenu->setLabel('');
     // Setting close url/return url for exiting this script:
     // Goes to 'Columns' view if close is pressed (default)
     $this->closeUrl = $this->local_linkThisScript(array('SET' => array('function' => 1)));
     if ($this->returnUrl) {
         $this->closeUrl = $this->returnUrl;
     }
     $retUrlStr = $this->returnUrl ? '&returnUrl=' . rawurlencode($this->returnUrl) : '';
     // Creating the selector box, allowing the user to select which element to edit:
     $isSelected = 0;
     $languageOverlayRecord = '';
     if ($this->current_sys_language) {
         list($languageOverlayRecord) = BackendUtility::getRecordsByField('pages_language_overlay', 'pid', $this->id, 'AND sys_language_uid=' . (int) $this->current_sys_language);
     }
     if (is_array($languageOverlayRecord)) {
         $inValue = 'pages_language_overlay:' . $languageOverlayRecord['uid'];
         $isSelected += (int) $edit_record == $inValue;
         $menuItem = $quickEditMenu->makeMenuItem()->setTitle('[ ' . $lang->getLL('editLanguageHeader', true) . ' ]')->setHref(BackendUtility::getModuleUrl($this->moduleName) . '&id=' . $this->id . '&edit_record=' . $inValue . $retUrlStr)->setActive($edit_record == $inValue);
         $quickEditMenu->addMenuItem($menuItem);
     } else {
         $inValue = 'pages:' . $this->id;
         $isSelected += (int) $edit_record == $inValue;
         $menuItem = $quickEditMenu->makeMenuItem()->setTitle('[ ' . $lang->getLL('editPageProperties', true) . ' ]')->setHref(BackendUtility::getModuleUrl($this->moduleName) . '&id=' . $this->id . '&edit_record=' . $inValue . $retUrlStr)->setActive($edit_record == $inValue);
         $quickEditMenu->addMenuItem($menuItem);
     }
     // Selecting all content elements from this language and allowed colPos:
     $whereClause = 'pid=' . (int) $this->id . ' AND sys_language_uid=' . (int) $this->current_sys_language . ' AND colPos IN (' . $this->colPosList . ')' . ($this->MOD_SETTINGS['tt_content_showHidden'] ? '' : BackendUtility::BEenableFields('tt_content')) . BackendUtility::deleteClause('tt_content') . BackendUtility::versioningPlaceholderClause('tt_content');
     if (!$this->getBackendUser()->user['admin']) {
         $whereClause .= ' AND editlock = 0';
     }
     $res = $databaseConnection->exec_SELECTquery('*', 'tt_content', $whereClause, '', 'colPos,sorting');
     $colPos = null;
     $first = 1;
     // Page is the pid if no record to put this after.
     $prev = $this->id;
     while ($cRow = $databaseConnection->sql_fetch_assoc($res)) {
         BackendUtility::workspaceOL('tt_content', $cRow);
         if (is_array($cRow)) {
             if ($first) {
                 if (!$edit_record) {
                     $edit_record = 'tt_content:' . $cRow['uid'];
                 }
                 $first = 0;
             }
             if (!isset($colPos) || $cRow['colPos'] !== $colPos) {
                 $colPos = $cRow['colPos'];
                 $menuItem = $quickEditMenu->makeMenuItem()->setTitle(' ')->setHref('#');
                 $quickEditMenu->addMenuItem($menuItem);
                 $menuItem = $quickEditMenu->makeMenuItem()->setTitle('__' . $lang->sL(BackendUtility::getLabelFromItemlist('tt_content', 'colPos', $colPos), true) . ':__')->setHref(BackendUtility::getModuleUrl($this->moduleName) . '&id=' . $this->id . '&edit_record=_EDIT_COL:' . $colPos . $retUrlStr);
                 $quickEditMenu->addMenuItem($menuItem);
             }
             $inValue = 'tt_content:' . $cRow['uid'];
             $isSelected += (int) $edit_record == $inValue;
             $menuItem = $quickEditMenu->makeMenuItem()->setTitle(htmlspecialchars(GeneralUtility::fixed_lgd_cs($cRow['header'] ? $cRow['header'] : '[' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title') . '] ' . strip_tags($cRow['bodytext']), $beUser->uc['titleLen'])))->setHref(BackendUtility::getModuleUrl($this->moduleName) . '&id=' . $this->id . '&edit_record=' . $inValue . $retUrlStr)->setActive($edit_record == $inValue);
             $quickEditMenu->addMenuItem($menuItem);
             $prev = -$cRow['uid'];
         }
     }
     // If edit_record is not set (meaning, no content elements was found for this language) we simply set it to create a new element:
     if (!$edit_record) {
         $edit_record = 'tt_content:new/' . $prev . '/' . $colPos;
         $inValue = 'tt_content:new/' . $prev . '/' . $colPos;
         $isSelected += (int) $edit_record == $inValue;
         $menuItem = $quickEditMenu->makeMenuItem()->setTitle('[ ' . $lang->getLL('newLabel', 1) . ' ]')->setHref(BackendUtility::getModuleUrl($this->moduleName) . '&id=' . $this->id . '&edit_record=' . $inValue . $retUrlStr)->setActive($edit_record == $inValue);
         $quickEditMenu->addMenuItem($menuItem);
     }
     // If none is yet selected...
     if (!$isSelected) {
         $menuItem = $quickEditMenu->makeMenuItem()->setTitle('__________')->setHref('#');
         $quickEditMenu->addMenuItem($menuItem);
         $menuItem = $quickEditMenu->makeMenuItem()->setTitle('[ ' . $lang->getLL('newLabel', true) . ' ]')->setHref(BackendUtility::getModuleUrl($this->moduleName) . '&id=' . $this->id . '&edit_record=' . $edit_record . $retUrlStr)->setActive($edit_record == $inValue);
         $quickEditMenu->addMenuItem($menuItem);
     }
     $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($quickEditMenu);
     return $edit_record;
 }