php TYPO3-CMS-Core-Versioning-VersionState类(方法)实例源码

下面列出了php TYPO3-CMS-Core-Versioning-VersionState 类(方法)源码代码实例,从而了解它的用法。

作者:plan2ne    项目:TYPO3.CM   
/**
  * Creates a node with the given record information
  *
  * @param array $record
  * @param int $mountPoint
  * @return \TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNode
  */
 public static function getNewNode($record, $mountPoint = 0)
 {
     if (self::$titleLength === NULL) {
         self::$useNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
         self::$addIdAsPrefix = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showPageIdWithTitle');
         self::$addDomainName = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showDomainNameWithTitle');
         self::$backgroundColors = $GLOBALS['BE_USER']->getTSConfigProp('options.pageTree.backgroundColor');
         self::$titleLength = (int) $GLOBALS['BE_USER']->uc['titleLen'];
     }
     /** @var $subNode \TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNode */
     $subNode = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNode::class);
     $subNode->setRecord($record);
     $subNode->setCls($record['_CSSCLASS']);
     $subNode->setType('pages');
     $subNode->setId($record['uid']);
     $subNode->setMountPoint($mountPoint);
     $subNode->setWorkspaceId($record['_ORIG_uid'] ?: $record['uid']);
     $subNode->setBackgroundColor(self::$backgroundColors[$record['uid']]);
     $field = 'title';
     $text = $record['title'];
     if (self::$useNavTitle && trim($record['nav_title']) !== '') {
         $field = 'nav_title';
         $text = $record['nav_title'];
     }
     if (trim($text) === '') {
         $visibleText = '[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title', TRUE) . ']';
     } else {
         $visibleText = $text;
     }
     $visibleText = GeneralUtility::fixed_lgd_cs($visibleText, self::$titleLength);
     $suffix = '';
     if (self::$addDomainName) {
         $domain = self::getDomainName($record['uid']);
         $suffix = $domain !== '' ? ' [' . $domain . ']' : '';
     }
     $qtip = str_replace(' - ', '<br />', htmlspecialchars(BackendUtility::titleAttribForPages($record, '', FALSE)));
     $prefix = '';
     $lockInfo = BackendUtility::isRecordLocked('pages', $record['uid']);
     if (is_array($lockInfo)) {
         $qtip .= '<br />' . htmlspecialchars($lockInfo['msg']);
         $prefix .= IconUtility::getSpriteIcon('status-warning-in-use', array('class' => 'typo3-pagetree-status'));
     }
     // Call stats information hook
     $stat = '';
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'])) {
         $_params = array('pages', $record['uid']);
         $fakeThis = NULL;
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] as $_funcRef) {
             $stat .= GeneralUtility::callUserFunction($_funcRef, $_params, $fakeThis);
         }
     }
     $prefix .= htmlspecialchars(self::$addIdAsPrefix ? '[' . $record['uid'] . '] ' : '');
     $subNode->setEditableText($text);
     $subNode->setText(htmlspecialchars($visibleText), $field, $prefix, htmlspecialchars($suffix) . $stat);
     $subNode->setQTip($qtip);
     if ((int) $record['uid'] !== 0) {
         $spriteIconCode = IconUtility::getSpriteIconForRecord('pages', $record);
     } else {
         $spriteIconCode = IconUtility::getSpriteIcon('apps-pagetree-root');
     }
     $subNode->setSpriteIconCode($spriteIconCode);
     if (!$subNode->canCreateNewPages() || VersionState::cast($record['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
         $subNode->setIsDropTarget(FALSE);
     }
     if (!$subNode->canBeEdited() || !$subNode->canBeRemoved() || VersionState::cast($record['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
         $subNode->setDraggable(FALSE);
     }
     return $subNode;
 }

作者:samuweis    项目:TYPO3-Sit   
/**
  * Checks if record is a move-placeholder (t3ver_state==VersionState::MOVE_PLACEHOLDER) and if so
  * it will set $row to be the pointed-to live record (and return TRUE)
  *
  * @param string $table Table name
  * @param array $row Row (passed by reference) - must be online record!
  * @return boolean TRUE if overlay is made.
  * @see PageRepository::movePlhOl()
  */
 public static function movePlhOL($table, &$row)
 {
     // Only for WS ver 2... (moving)
     if ($table == 'pages' || (int) $GLOBALS['TCA'][$table]['ctrl']['versioningWS'] >= 2) {
         // If t3ver_move_id or t3ver_state is not found, then find it... (but we like best if it is here...)
         if (!isset($row['t3ver_move_id']) || !isset($row['t3ver_state'])) {
             $moveIDRec = self::getRecord($table, $row['uid'], 't3ver_move_id, t3ver_state');
             $moveID = $moveIDRec['t3ver_move_id'];
             $versionState = VersionState::cast($moveIDRec['t3ver_state']);
         } else {
             $moveID = $row['t3ver_move_id'];
             $versionState = VersionState::cast($row['t3ver_state']);
         }
         // Find pointed-to record.
         if ($versionState->equals(VersionState::MOVE_PLACEHOLDER) && $moveID) {
             if ($origRow = self::getRecord($table, $moveID, implode(',', array_keys($row)))) {
                 $row = $origRow;
                 return TRUE;
             }
         }
     }
     return FALSE;
 }

作者:khanhdeu    项目:typo3tes   
/**
  * Creates the icon for input table/row
  * Returns filename for the image icon, relative to PATH_typo3
  *
  * @param string $table The table name
  * @param array $row The table row ("enablefields" are at least needed for correct icon display and for pages records some more fields in addition!)
  * @param boolean $shaded If set, the icon will be grayed/shaded
  * @return string Icon filename
  * @see getIconImage()
  */
 public static function getIcon($table, $row = array(), $shaded = FALSE)
 {
     // Flags
     // If set, then the usergroup number will NOT be printed unto the icon. NOTICE.
     // The icon is generated only if a default icon for groups is not found... So effectively this is ineffective.
     $doNotRenderUserGroupNumber = TRUE;
     // Shadow
     if (!empty($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) && !empty($row['t3ver_state'])) {
         switch (VersionState::cast($row['t3ver_state'])) {
             case new VersionState(VersionState::NEW_PLACEHOLDER):
                 return 'gfx/i/shadow_hide.png';
                 break;
             case new VersionState(VersionState::DELETE_PLACEHOLDER):
                 return 'gfx/i/shadow_delete.png';
                 break;
             case new VersionState(VersionState::MOVE_PLACEHOLDER):
                 return 'gfx/i/shadow_moveto_plh.png';
                 break;
             case new VersionState(VersionState::MOVE_POINTER):
                 return 'gfx/i/shadow_moveto_pointer.png';
                 break;
         }
     }
     // First, find the icon file name. This can depend on configuration in TCA, field values and more:
     if ($table == 'pages') {
         $iconfile = $GLOBALS['PAGES_TYPES'][$row['doktype']]['icon'];
         if (!$iconfile) {
             $iconfile = $GLOBALS['PAGES_TYPES']['default']['icon'];
         }
     } else {
         if (!($iconfile = $GLOBALS['TCA'][$table]['ctrl']['typeicons'][$row[$GLOBALS['TCA'][$table]['ctrl']['typeicon_column']]])) {
             $iconfile = $GLOBALS['TCA'][$table]['ctrl']['iconfile'] ?: $table . '.gif';
         }
     }
     // Setting path of iconfile if not already set. Default is "gfx/i/"
     if (!strstr($iconfile, '/')) {
         $iconfile = 'gfx/i/' . $iconfile;
     }
     // Setting the absolute path where the icon should be found as a file:
     if (substr($iconfile, 0, 3) == '../') {
         $absfile = PATH_site . substr($iconfile, 3);
     } else {
         $absfile = PATH_typo3 . $iconfile;
     }
     // Initializing variables, all booleans except otherwise stated:
     $hidden = FALSE;
     $timing = FALSE;
     $futuretiming = FALSE;
     // In fact an integer value
     $user = FALSE;
     $deleted = FALSE;
     // Set, if a page-record (only pages!) has the extend-to-subpages flag set.
     $protectSection = FALSE;
     $noIconFound = $row['_NO_ICON_FOUND'] ? TRUE : FALSE;
     // + $shaded which is also boolean!
     // Icon state based on "enableFields":
     if (is_array($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) {
         $enCols = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns'];
         // If "hidden" is enabled:
         if ($enCols['disabled']) {
             if ($row[$enCols['disabled']]) {
                 $hidden = TRUE;
             }
         }
         // If a "starttime" is set and higher than current time:
         if ($enCols['starttime']) {
             if ($GLOBALS['EXEC_TIME'] < (int) $row[$enCols['starttime']]) {
                 $timing = TRUE;
                 // And if "endtime" is NOT set:
                 if ((int) $row[$enCols['endtime']] === 0) {
                     $futuretiming = TRUE;
                 }
             }
         }
         // If an "endtime" is set:
         if ($enCols['endtime']) {
             if ((int) $row[$enCols['endtime']] > 0) {
                 if ((int) $row[$enCols['endtime']] < $GLOBALS['EXEC_TIME']) {
                     // End-timing applies at this point.
                     $timing = TRUE;
                 } else {
                     // End-timing WILL apply in the future for this element.
                     $futuretiming = TRUE;
                 }
             }
         }
         // If a user-group field is set:
         if ($enCols['fe_group']) {
             $user = $row[$enCols['fe_group']];
             if ($user && $doNotRenderUserGroupNumber) {
//.........这里部分代码省略.........

作者:vip3ou    项目:TYPO3.CM   
/**
  * Helper function for getQuery(), creating the WHERE clause of the SELECT query
  *
  * @param string $table The table name
  * @param array $conf The TypoScript configuration properties
  * @param bool $returnQueryArray If set, the function will return the query not as a string but array with the various parts. RECOMMENDED!
  * @return mixed A WHERE clause based on the relevant parts of the TypoScript properties for a "select" function in TypoScript, see link. If $returnQueryArray is FALSE the where clause is returned as a string with WHERE, GROUP BY and ORDER BY parts, otherwise as an array with these parts.
  * @access private
  * @see getQuery()
  */
 public function getWhere($table, $conf, $returnQueryArray = false)
 {
     // Init:
     $query = '';
     $pid_uid_flag = 0;
     $enableFieldsIgnore = array();
     $queryParts = array('SELECT' => '', 'FROM' => '', 'WHERE' => '', 'GROUPBY' => '', 'ORDERBY' => '', 'LIMIT' => '');
     $tsfe = $this->getTypoScriptFrontendController();
     $considerMovePlaceholders = $tsfe->sys_page->versioningPreview && $table !== 'pages' && !empty($GLOBALS['TCA'][$table]['ctrl']['versioningWS']);
     if (trim($conf['uidInList'])) {
         $listArr = GeneralUtility::intExplode(',', str_replace('this', $tsfe->contentPid, $conf['uidInList']));
         if (count($listArr) === 1) {
             $comparison = '=' . (int) $listArr[0];
         } else {
             $comparison = ' IN (' . implode(',', $this->getDatabaseConnection()->cleanIntArray($listArr)) . ')';
         }
         // If move placeholder shall be considered, select via t3ver_move_id
         if ($considerMovePlaceholders) {
             $movePlaceholderComparison = $table . '.t3ver_state=' . VersionState::cast(VersionState::MOVE_PLACEHOLDER) . ' AND ' . $table . '.t3ver_move_id' . $comparison;
             $query .= ' AND (' . $table . '.uid' . $comparison . ' OR ' . $movePlaceholderComparison . ')';
         } else {
             $query .= ' AND ' . $table . '.uid' . $comparison;
         }
         $pid_uid_flag++;
     }
     // Static_* tables are allowed to be fetched from root page
     if (substr($table, 0, 7) === 'static_') {
         $pid_uid_flag++;
     }
     if (trim($conf['pidInList'])) {
         $listArr = GeneralUtility::intExplode(',', str_replace('this', $tsfe->contentPid, $conf['pidInList']));
         // Removes all pages which are not visible for the user!
         $listArr = $this->checkPidArray($listArr);
         if (GeneralUtility::inList($conf['pidInList'], 'root')) {
             $listArr[] = 0;
         }
         if (GeneralUtility::inList($conf['pidInList'], '-1')) {
             $listArr[] = -1;
             $enableFieldsIgnore['pid'] = true;
         }
         if (!empty($listArr)) {
             $query .= ' AND ' . $table . '.pid IN (' . implode(',', array_map('intval', $listArr)) . ')';
             $pid_uid_flag++;
         } else {
             // If not uid and not pid then uid is set to 0 - which results in nothing!!
             $pid_uid_flag = 0;
         }
     }
     // If not uid and not pid then uid is set to 0 - which results in nothing!!
     if (!$pid_uid_flag) {
         $query .= ' AND ' . $table . '.uid=0';
     }
     $where = isset($conf['where.']) ? trim($this->stdWrap($conf['where'], $conf['where.'])) : trim($conf['where']);
     if ($where) {
         $query .= ' AND ' . $where;
     }
     // Check if the table is translatable, and set the language field by default from the TCA information
     $languageField = '';
     if (!empty($conf['languageField']) || !isset($conf['languageField'])) {
         if (isset($conf['languageField']) && !empty($GLOBALS['TCA'][$table]['columns'][$conf['languageField']])) {
             $languageField = $conf['languageField'];
         } elseif (!empty($GLOBALS['TCA'][$table]['ctrl']['languageField']) && !empty($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'])) {
             $languageField = $table . '.' . $GLOBALS['TCA'][$table]['ctrl']['languageField'];
         }
     }
     if (!empty($languageField)) {
         // The sys_language record UID of the content of the page
         $sys_language_content = (int) $tsfe->sys_language_content;
         if ($tsfe->sys_language_contentOL && !empty($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'])) {
             // Sys language content is set to zero/-1 - and it is expected that whatever routine processes the output will
             // OVERLAY the records with localized versions!
             $languageQuery = $languageField . ' IN (0,-1)';
             // Use this option to include records that don't have a default translation
             // (originalpointerfield is 0 and the language field contains the requested language)
             $includeRecordsWithoutDefaultTranslation = isset($conf['includeRecordsWithoutDefaultTranslation.']) ? $this->stdWrap($conf['includeRecordsWithoutDefaultTranslation'], $conf['includeRecordsWithoutDefaultTranslation.']) : $conf['includeRecordsWithoutDefaultTranslation'];
             if (!empty(trim($includeRecordsWithoutDefaultTranslation))) {
                 $languageQuery .= ' OR (' . $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] . ' = 0 AND ' . $languageField . ' = ' . $sys_language_content . ')';
             }
         } else {
             $languageQuery = $languageField . ' = ' . $sys_language_content;
         }
         $query .= ' AND (' . $languageQuery . ')';
     }
     // Enablefields
     if ($table === 'pages') {
         $query .= ' ' . $tsfe->sys_page->where_hid_del . $tsfe->sys_page->where_groupAccess;
     } else {
         $query .= $this->enableFields($table, false, $enableFieldsIgnore);
     }
     // MAKE WHERE:
//.........这里部分代码省略.........

作者:CDR    项目:TYPO3.CM   
/**
  * This creates the buttons for die modules
  *
  * @param string $function Identifier for function of module
  * @return void
  */
 protected function makeButtons($function = '')
 {
     $lang = $this->getLanguageService();
     // View page
     if (!VersionState::cast($this->pageinfo['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
         $viewButton = $this->buttonBar->makeLinkButton()->setOnClick(htmlspecialchars(BackendUtility::viewOnClick($this->pageinfo['uid'], '', BackendUtility::BEgetRootLine($this->pageinfo['uid']))))->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', true))->setIcon($this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL))->setHref('#');
         $this->buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, 3);
     }
     // Shortcut
     $shortcutButton = $this->buttonBar->makeShortcutButton()->setModuleName($this->moduleName)->setGetVariables(['id', 'M', 'edit_record', 'pointer', 'new_unique_uid', 'search_field', 'search_levels', 'showLimit'])->setSetVariables(array_keys($this->MOD_MENU));
     $this->buttonBar->addButton($shortcutButton);
     // Cache
     if (!$this->modTSconfig['properties']['disableAdvanced']) {
         $clearCacheButton = $this->buttonBar->makeLinkButton()->setHref(BackendUtility::getModuleUrl($this->moduleName, ['id' => $this->pageinfo['uid'], 'clear_cache' => '1']))->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.clear_cache', true))->setIcon($this->iconFactory->getIcon('actions-system-cache-clear', Icon::SIZE_SMALL));
         $this->buttonBar->addButton($clearCacheButton, ButtonBar::BUTTON_POSITION_RIGHT, 1);
     }
     if (!$this->modTSconfig['properties']['disableIconToolbar']) {
         // Move record
         if (MathUtility::canBeInterpretedAsInteger($this->eRParts[1])) {
             $urlParameters = ['table' => $this->eRParts[0], 'uid' => $this->eRParts[1], 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')];
             $moveButton = $this->buttonBar->makeLinkButton()->setHref(BackendUtility::getModuleUrl('move_element', $urlParameters))->setTitle($lang->getLL('move_' . ($this->eRParts[0] == 'tt_content' ? 'record' : 'page'), true))->setIcon($this->iconFactory->getIcon('actions-' . ($this->eRParts[0] == 'tt_content' ? 'document' : 'page') . '-move', Icon::SIZE_SMALL));
             $this->buttonBar->addButton($moveButton, ButtonBar::BUTTON_POSITION_LEFT, 2);
         }
         // Edit page properties and page language overlay icons
         if ($this->pageIsNotLockedForEditors() && $this->getBackendUser()->checkLanguageAccess(0)) {
             // Edit localized page_language_overlay only when one specific language is selected
             if ($this->MOD_SETTINGS['function'] == 1 && $this->current_sys_language > 0) {
                 $overlayRecord = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('uid', 'pages_language_overlay', 'pid = ' . (int) $this->id . ' ' . 'AND sys_language_uid = ' . (int) $this->current_sys_language . BackendUtility::deleteClause('pages_language_overlay') . BackendUtility::versioningPlaceholderClause('pages_language_overlay'), '', '', '');
                 $editLanguageButton = $this->buttonBar->makeLinkButton()->setHref('#')->setTitle($lang->getLL('editPageLanguageOverlayProperties', true))->setOnClick(htmlspecialchars(BackendUtility::editOnClick('&edit[pages_language_overlay][' . $overlayRecord['uid'] . ']=edit')))->setIcon($this->iconFactory->getIcon('mimetypes-x-content-page-language-overlay', Icon::SIZE_SMALL));
                 $this->buttonBar->addButton($editLanguageButton, ButtonBar::BUTTON_POSITION_LEFT, 3);
             }
             $editPageButton = $this->buttonBar->makeLinkButton()->setHref('#')->setTitle($lang->getLL('editPageProperties', true))->setOnClick(htmlspecialchars(BackendUtility::editOnClick('&edit[pages][' . $this->id . ']=edit')))->setIcon($this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL));
             $this->buttonBar->addButton($editPageButton, ButtonBar::BUTTON_POSITION_LEFT, 3);
         }
         // Add CSH (Context Sensitive Help) icon to tool bar
         $contextSensitiveHelpButton = $this->buttonBar->makeHelpButton()->setModuleName($this->descrTable)->setFieldName($function === 'quickEdit' ? 'quickEdit' : 'columns_' . $this->MOD_SETTINGS['function']);
         $this->buttonBar->addButton($contextSensitiveHelpButton);
         // QuickEdit
         if ($function == 'quickEdit') {
             // Close Record
             $closeButton = $this->buttonBar->makeLinkButton()->setHref('#')->setOnClick(htmlspecialchars('jumpToUrl(' . GeneralUtility::quoteJSvalue($this->closeUrl) . '); return false;'))->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.closeDoc', true))->setIcon($this->iconFactory->getIcon('actions-document-close', Icon::SIZE_SMALL));
             $this->buttonBar->addButton($closeButton, ButtonBar::BUTTON_POSITION_LEFT, 0);
             // Save Record
             $saveButtonDropdown = $this->buttonBar->makeSplitButton();
             $saveButton = $this->buttonBar->makeInputButton()->setName('_savedok')->setValue('1')->setForm('PageLayoutController')->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDoc', true))->setIcon($this->iconFactory->getIcon('actions-document-save', Icon::SIZE_SMALL));
             $saveButtonDropdown->addItem($saveButton);
             $saveAndCloseButton = $this->buttonBar->makeInputButton()->setName('_saveandclosedok')->setValue('1')->setForm('PageLayoutController')->setOnClick('document.editform.redirect.value=\'' . $this->closeUrl . '\';')->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveCloseDoc', true))->setIcon($this->iconFactory->getIcon('actions-document-save-close', Icon::SIZE_SMALL));
             $saveButtonDropdown->addItem($saveAndCloseButton);
             $saveAndShowPageButton = $this->buttonBar->makeInputButton()->setName('_savedokview')->setValue('1')->setForm('PageLayoutController')->setOnClick('document.editform.redirect.value+=\'&popView=1\';')->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDocShow', true))->setIcon($this->iconFactory->getIcon('actions-document-save-view', Icon::SIZE_SMALL));
             $saveButtonDropdown->addItem($saveAndShowPageButton);
             $this->buttonBar->addButton($saveButtonDropdown, ButtonBar::BUTTON_POSITION_LEFT, 1);
             // Delete record
             if ($this->deleteButton) {
                 $deleteButton = $this->buttonBar->makeLinkButton()->setHref('#')->setOnClick(htmlspecialchars('return deleteRecord(' . GeneralUtility::quoteJSvalue($this->eRParts[0]) . ',' . GeneralUtility::quoteJSvalue($this->eRParts[1]) . ',' . GeneralUtility::quoteJSvalue(GeneralUtility::getIndpEnv('SCRIPT_NAME') . '?id=' . $this->id) . ');'))->setTitle($lang->getLL('deleteItem', true))->setIcon($this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL));
                 $this->buttonBar->addButton($deleteButton, ButtonBar::BUTTON_POSITION_LEFT, 4);
             }
             // History
             if ($this->undoButton) {
                 $undoButton = $this->buttonBar->makeLinkButton()->setHref('#')->setOnClick(htmlspecialchars('window.location.href=' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('record_history', array('element' => $this->eRParts[0] . ':' . $this->eRParts[1], 'revert' => 'ALL_FIELDS', 'sumUp' => -1, 'returnUrl' => $this->R_URI))) . '; return false;'))->setTitle(htmlspecialchars(sprintf($lang->getLL('undoLastChange'), BackendUtility::calcAge($GLOBALS['EXEC_TIME'] - $this->undoButtonR['tstamp'], $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.minutesHoursDaysYears')))))->setIcon($this->iconFactory->getIcon('actions-edit-undo', Icon::SIZE_SMALL));
                 $this->buttonBar->addButton($undoButton, ButtonBar::BUTTON_POSITION_LEFT, 5);
                 $historyButton = $this->buttonBar->makeLinkButton()->setHref('#')->setOnClick(htmlspecialchars('jumpToUrl(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('record_history', array('element' => $this->eRParts[0] . ':' . $this->eRParts[1], 'returnUrl' => $this->R_URI)) . '#latest') . ');return false;'))->setTitle($lang->getLL('recordHistory', true))->setIcon($this->iconFactory->getIcon('actions-document-history-open', Icon::SIZE_SMALL));
                 $this->buttonBar->addButton($historyButton, ButtonBar::BUTTON_POSITION_LEFT, 3);
             }
         }
     }
 }

作者:plan2ne    项目:TYPO3.CM   
/**
  * Visualizes the deleted status for a versionized record.
  *
  * @param string $table Name of the table
  * @param array $row Record row containing the field values
  * @param array $status Status to be used for rendering the icon
  * @return void
  */
 public function overrideIconOverlay($table, array $row, array &$status)
 {
     if (isset($row['t3ver_state']) && VersionState::cast($row['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
         $status['deleted'] = TRUE;
     }
 }

作者:plan2ne    项目:TYPO3.CM   
/**
  * Get a single record row for a TCA table from the database.
  * \TYPO3\CMS\Backend\Form\DataPreprocessor is used for "upgrading" the
  * values, especially the relations.
  * Used in inline context
  *
  * @param string $table The table to fetch data from (= foreign_table)
  * @param string $uid The uid of the record to fetch, or the pid if a new record should be created
  * @param string $cmd The command to perform, empty or 'new'
  * @return array A record row from the database post-processed by \TYPO3\CMS\Backend\Form\DataPreprocessor
  * @internal
  */
 public function getRecord($table, $uid, $cmd = '')
 {
     $backendUser = $this->getBackendUserAuthentication();
     // Fetch workspace version of a record (if any):
     if ($cmd !== 'new' && $backendUser->workspace !== 0 && BackendUtility::isTableWorkspaceEnabled($table)) {
         $workspaceVersion = BackendUtility::getWorkspaceVersionOfRecord($backendUser->workspace, $table, $uid, 'uid,t3ver_state');
         if ($workspaceVersion !== FALSE) {
             $versionState = VersionState::cast($workspaceVersion['t3ver_state']);
             if ($versionState->equals(VersionState::DELETE_PLACEHOLDER)) {
                 return FALSE;
             }
             $uid = $workspaceVersion['uid'];
         }
     }
     /** @var $trData DataPreprocessor */
     $trData = GeneralUtility::makeInstance(DataPreprocessor::class);
     $trData->addRawData = TRUE;
     $trData->lockRecords = 1;
     // If a new record should be created
     $trData->fetchRecord($table, $uid, $cmd === 'new' ? 'new' : '');
     $rec = reset($trData->regTableItems_data);
     return $rec;
 }

作者:Torsten8    项目:TYPO3.CM   
/**
  * Substitute given list of uids in child table with workspace uid if needed
  *
  * @param array $connectedUids List of connected uids
  * @param string $childTableName Name of child table
  * @return array List of uids in workspace
  */
 protected function getWorkspacedUids(array $connectedUids, $childTableName)
 {
     $backendUser = $this->getBackendUser();
     $newConnectedUids = [];
     foreach ($connectedUids as $uid) {
         // Fetch workspace version of a record (if any):
         // @todo: Needs handling
         if ($backendUser->workspace !== 0 && BackendUtility::isTableWorkspaceEnabled($childTableName)) {
             $workspaceVersion = BackendUtility::getWorkspaceVersionOfRecord($backendUser->workspace, $childTableName, $uid, 'uid,t3ver_state');
             if ($workspaceVersion !== false) {
                 $versionState = VersionState::cast($workspaceVersion['t3ver_state']);
                 if ($versionState->equals(VersionState::DELETE_PLACEHOLDER)) {
                     return [];
                 }
                 $uid = $workspaceVersion['uid'];
             }
         }
         $newConnectedUids[] = $uid;
     }
     return $newConnectedUids;
 }

作者:rickymathe    项目:TYPO3.CM   
/**
  * Checks if record is a move-placeholder (t3ver_state==VersionState::MOVE_PLACEHOLDER) and if so
  * it will set $row to be the pointed-to live record (and return TRUE)
  *
  * @param string $table Table name
  * @param array $row Row (passed by reference) - must be online record!
  * @return bool TRUE if overlay is made.
  * @see PageRepository::movePlhOl()
  */
 public static function movePlhOL($table, &$row)
 {
     if (static::isTableWorkspaceEnabled($table)) {
         // If t3ver_move_id or t3ver_state is not found, then find it... (but we like best if it is here...)
         if (!isset($row['t3ver_move_id']) || !isset($row['t3ver_state'])) {
             $moveIDRec = self::getRecord($table, $row['uid'], 't3ver_move_id, t3ver_state');
             $moveID = $moveIDRec['t3ver_move_id'];
             $versionState = VersionState::cast($moveIDRec['t3ver_state']);
         } else {
             $moveID = $row['t3ver_move_id'];
             $versionState = VersionState::cast($row['t3ver_state']);
         }
         // Find pointed-to record.
         if ($versionState->equals(VersionState::MOVE_PLACEHOLDER) && $moveID) {
             if ($origRow = self::getRecord($table, $moveID, implode(',', array_keys($row)))) {
                 $row = $origRow;
                 return true;
             }
         }
     }
     return false;
 }

作者:khanhdeu    项目:typo3tes   
/**
  * Processes version overlays on the final result set.
  *
  * @param int[] $ids
  * @return int[]
  */
 protected function processVersionOverlays(array $ids)
 {
     if (empty($this->workspaceId) || !$this->isWorkspaceEnabled() || empty($ids)) {
         return $ids;
     }
     $ids = $this->processVersionMovePlaceholders($ids);
     $versions = $this->getDatabaseConnection()->exec_SELECTgetRows('uid,t3ver_oid,t3ver_state', $this->tableName, 'pid=-1 AND t3ver_oid IN (' . $this->intImplode(',', $ids) . ')' . ' AND t3ver_wsid=' . $this->workspaceId);
     if (!empty($versions)) {
         foreach ($versions as $version) {
             $liveReferenceId = $version['t3ver_oid'];
             $versionId = $version['uid'];
             if (isset($ids[$liveReferenceId])) {
                 if (!$this->keepDeletePlaceholder && VersionState::cast($version['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
                     unset($ids[$liveReferenceId]);
                 } else {
                     $ids[$liveReferenceId] = $versionId;
                 }
             }
         }
         $ids = $this->reindex($ids);
     }
     return $ids;
 }

作者:rickymathe    项目:TYPO3.CM   
/**
  * This helper functions checks if the DB record ($row) has any special status based on the TCA settings like hidden,
  * starttime etc, and then returns a specific icon overlay identifier for the overlay of this DB record
  * This method solely takes care of the overlay of this record, not any type
  *
  * @param string $table The TCA table
  * @param array $row The selected record
  * @return string The status with the highest priority
  */
 protected function mapRecordTypeToOverlayIdentifier($table, array $row)
 {
     $tcaCtrl = $GLOBALS['TCA'][$table]['ctrl'];
     // Calculate for a given record the actual visibility at the moment
     $status = array('hidden' => false, 'starttime' => false, 'endtime' => false, 'futureendtime' => false, 'fe_group' => false, 'deleted' => false, 'protectedSection' => false, 'nav_hide' => (bool) $row['nav_hide']);
     // Icon state based on "enableFields":
     if (is_array($tcaCtrl['enablecolumns'])) {
         $enableColumns = $tcaCtrl['enablecolumns'];
         // If "hidden" is enabled:
         if (isset($enableColumns['disabled']) && !empty($row[$enableColumns['disabled']])) {
             $status['hidden'] = true;
         }
         // If a "starttime" is set and higher than current time:
         if (!empty($enableColumns['starttime']) && $GLOBALS['EXEC_TIME'] < (int) $row[$enableColumns['starttime']]) {
             $status['starttime'] = true;
         }
         // If an "endtime" is set
         if (!empty($enableColumns['endtime'])) {
             if ((int) $row[$enableColumns['endtime']] > 0) {
                 if ((int) $row[$enableColumns['endtime']] < $GLOBALS['EXEC_TIME']) {
                     // End-timing applies at this point.
                     $status['endtime'] = true;
                 } else {
                     // End-timing WILL apply in the future for this element.
                     $status['futureendtime'] = true;
                 }
             }
         }
         // If a user-group field is set
         if (!empty($enableColumns['fe_group']) && $row[$enableColumns['fe_group']]) {
             $status['fe_group'] = true;
         }
     }
     // If "deleted" flag is set (only when listing records which are also deleted!)
     if (isset($tcaCtrl['delete']) && !empty($row[$tcaCtrl['delete']])) {
         $status['deleted'] = true;
     }
     // Detecting extendToSubpages (for pages only)
     if ($table === 'pages' && (int) $row['extendToSubpages'] > 0) {
         $status['protectedSection'] = true;
     }
     if (isset($row['t3ver_state']) && VersionState::cast($row['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
         $status['deleted'] = true;
     }
     // Now only show the status with the highest priority
     $iconName = '';
     foreach ($this->overlayPriorities as $priority) {
         if ($status[$priority]) {
             $iconName = $this->recordStatusMapping[$priority];
             break;
         }
     }
     return $iconName;
 }

作者:khanhdeu    项目:typo3tes   
/**
  * Checks if record is a move-placeholder
  * (t3ver_state==VersionState::MOVE_PLACEHOLDER) and if so it will set $row to be
  * the pointed-to live record (and return TRUE) Used from versionOL
  *
  * @param string $table Table name
  * @param array $row Row (passed by reference) - only online records...
  * @return boolean TRUE if overlay is made.
  * @see \TYPO3\CMS\Backend\Utility\BackendUtility::movePlhOl()
  * @todo Define visibility
  */
 public function movePlhOL($table, &$row)
 {
     if (($table == 'pages' || (int) $GLOBALS['TCA'][$table]['ctrl']['versioningWS'] >= 2) && (int) VersionState::cast($row['t3ver_state'])->equals(VersionState::MOVE_PLACEHOLDER)) {
         // Only for WS ver 2... (moving)
         // If t3ver_move_id is not found, then find it (but we like best if it is here)
         if (!isset($row['t3ver_move_id'])) {
             $moveIDRec = $this->getRawRecord($table, $row['uid'], 't3ver_move_id', TRUE);
             $moveID = $moveIDRec['t3ver_move_id'];
         } else {
             $moveID = $row['t3ver_move_id'];
         }
         // Find pointed-to record.
         if ($moveID) {
             $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(implode(',', array_keys($row)), $table, 'uid=' . (int) $moveID . $this->enableFields($table));
             $origRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
             $GLOBALS['TYPO3_DB']->sql_free_result($res);
             if ($origRow) {
                 $row = $origRow;
                 return TRUE;
             }
         }
     }
     return FALSE;
 }

作者:dachcom-digita    项目:TYPO3.CM   
/**
  * Find orphan records
  * VERY CPU and memory intensive since it will look up the whole page tree!
  *
  * @return array
  */
 public function main()
 {
     // Initialize result array:
     $resultArray = array('message' => $this->cli_help['name'] . LF . LF . $this->cli_help['description'], 'headers' => array('versions' => array('All versions', 'Showing all versions of records found', 0), 'versions_published' => array('All published versions', 'This is all records that has been published and can therefore be removed permanently', 1), 'versions_liveWS' => array('All versions in Live workspace', 'This is all records that are offline versions in the Live workspace. You may wish to flush these if you only use workspaces for versioning since then you might find lots of versions piling up in the live workspace which have simply been disconnected from the workspace before they were published.', 1), 'versions_lost_workspace' => array('Versions outside a workspace', 'Versions that has lost their connection to a workspace in TYPO3.', 3), 'versions_inside_versioned_page' => array('Versions in versions', 'Versions inside an already versioned page. Something that is confusing to users and therefore should not happen but is technically possible.', 2), 'versions_unused_placeholders' => array('Unused placeholder records', 'Placeholder records which are not used anymore by offline versions.', 2), 'versions_move_placeholders_ok' => array('Move placeholders', 'Move-to placeholder records which has good integrity', 0), 'versions_move_placeholders_bad' => array('Move placeholders with bad integrity', 'Move-to placeholder records which has bad integrity', 2), 'versions_move_id_check' => array('Checking if t3ver_move_id is correct', 't3ver_move_id must only be set with online records having t3ver_state=3.', 2)), 'versions' => array());
     $startingPoint = $this->cli_isArg('--pid') ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->cli_argValue('--pid'), 0) : 0;
     $depth = $this->cli_isArg('--depth') ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->cli_argValue('--depth'), 0) : 1000;
     $this->genTree($startingPoint, $depth, (int) $this->cli_argValue('--echotree'));
     $resultArray['versions'] = $this->recStats['versions'];
     $resultArray['versions_published'] = $this->recStats['versions_published'];
     $resultArray['versions_liveWS'] = $this->recStats['versions_liveWS'];
     $resultArray['versions_lost_workspace'] = $this->recStats['versions_lost_workspace'];
     $resultArray['versions_inside_versioned_page'] = $this->recStats['versions_inside_versioned_page'];
     // Finding all placeholders with no records attached!
     $resultArray['versions_unused_placeholders'] = array();
     foreach ($GLOBALS['TCA'] as $table => $cfg) {
         if ($cfg['ctrl']['versioningWS']) {
             $placeHolders = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,pid', $table, 't3ver_state=' . new VersionState(VersionState::NEW_PLACEHOLDER) . ' AND pid>=0' . BackendUtility::deleteClause($table));
             foreach ($placeHolders as $phrec) {
                 if (count(BackendUtility::selectVersionsOfRecord($table, $phrec['uid'], 'uid', '*', null)) <= 1) {
                     $resultArray['versions_unused_placeholders'][GeneralUtility::shortMD5($table . ':' . $phrec['uid'])] = $table . ':' . $phrec['uid'];
                 }
             }
         }
     }
     asort($resultArray['versions_unused_placeholders']);
     // Finding all move placeholders with inconsistencies:
     $resultArray['versions_move_placeholders_ok'] = array();
     $resultArray['versions_move_placeholders_bad'] = array();
     foreach ($GLOBALS['TCA'] as $table => $cfg) {
         if (BackendUtility::isTableWorkspaceEnabled($table)) {
             $placeHolders = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,pid,t3ver_move_id,t3ver_wsid,t3ver_state', $table, 't3ver_state=' . new VersionState(VersionState::MOVE_PLACEHOLDER) . ' AND pid>=0' . BackendUtility::deleteClause($table));
             foreach ($placeHolders as $phrec) {
                 $shortID = GeneralUtility::shortMD5($table . ':' . $phrec['uid']);
                 if ((int) $phrec['t3ver_wsid'] != 0) {
                     $phrecCopy = $phrec;
                     if (BackendUtility::movePlhOL($table, $phrec)) {
                         if ($wsAlt = BackendUtility::getWorkspaceVersionOfRecord($phrecCopy['t3ver_wsid'], $table, $phrec['uid'], 'uid,pid,t3ver_state')) {
                             if (!VersionState::cast($wsAlt['t3ver_state'])->equals(VersionState::MOVE_POINTER)) {
                                 $resultArray['versions_move_placeholders_bad'][$shortID] = array($table . ':' . $phrec['uid'], 'State for version was not "4" as it should be!', $phrecCopy);
                             } else {
                                 $resultArray['versions_move_placeholders_ok'][$shortID] = array($table . ':' . $phrec['uid'], 'PLH' => $phrecCopy, 'online' => $phrec, 'PNT' => $wsAlt);
                             }
                         } else {
                             $resultArray['versions_move_placeholders_bad'][$shortID] = array($table . ':' . $phrec['uid'], 'No version was found for online record to be moved. A version must exist.', $phrecCopy);
                         }
                     } else {
                         $resultArray['versions_move_placeholders_bad'][$shortID] = array($table . ':' . $phrec['uid'], 'Did not find online record for "t3ver_move_id" value ' . $phrec['t3ver_move_id'], $phrec);
                     }
                 } else {
                     $resultArray['versions_move_placeholders_bad'][$shortID] = array($table . ':' . $phrec['uid'], 'Placeholder was not assigned a workspace value in t3ver_wsid.', $phrec);
                 }
             }
         }
     }
     ksort($resultArray['versions_move_placeholders_ok']);
     ksort($resultArray['versions_move_placeholders_bad']);
     // Finding move_id_check inconsistencies:
     $resultArray['versions_move_id_check'] = array();
     foreach ($GLOBALS['TCA'] as $table => $cfg) {
         if (BackendUtility::isTableWorkspaceEnabled($table)) {
             $placeHolders = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,pid,t3ver_move_id,t3ver_wsid,t3ver_state', $table, 't3ver_move_id<>0' . BackendUtility::deleteClause($table));
             foreach ($placeHolders as $phrec) {
                 if (VersionState::cast($phrec['t3ver_state'])->equals(VersionState::MOVE_PLACEHOLDER)) {
                     if ($phrec['pid'] != -1) {
                     } else {
                         $resultArray['versions_move_id_check'][] = array($table . ':' . $phrec['uid'], 'Record was offline, must not be!', $phrec);
                     }
                 } else {
                     $resultArray['versions_move_id_check'][] = array($table . ':' . $phrec['uid'], 'Record had t3ver_move_id set to "' . $phrec['t3ver_move_id'] . '" while having t3ver_state=' . $phrec['t3ver_state'], $phrec);
                 }
             }
         }
     }
     return $resultArray;
 }

作者:rickymathe    项目:TYPO3.CM   
/**
  * Checks if record is a move-placeholder
  * (t3ver_state==VersionState::MOVE_PLACEHOLDER) and if so it will set $row to be
  * the pointed-to live record (and return TRUE) Used from versionOL
  *
  * @param string $table Table name
  * @param array $row Row (passed by reference) - only online records...
  * @return bool TRUE if overlay is made.
  * @see BackendUtility::movePlhOl()
  */
 public function movePlhOL($table, &$row)
 {
     if (!empty($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) && (int) VersionState::cast($row['t3ver_state'])->equals(VersionState::MOVE_PLACEHOLDER)) {
         // Only for WS ver 2... (moving) - enabled by default with CMS7
         // If t3ver_move_id is not found, then find it (but we like best if it is here)
         if (!isset($row['t3ver_move_id'])) {
             $moveIDRec = $this->getRawRecord($table, $row['uid'], 't3ver_move_id', true);
             $moveID = $moveIDRec['t3ver_move_id'];
         } else {
             $moveID = $row['t3ver_move_id'];
         }
         // Find pointed-to record.
         if ($moveID) {
             $res = $this->getDatabaseConnection()->exec_SELECTquery(implode(',', array_keys($row)), $table, 'uid=' . (int) $moveID . $this->enableFields($table));
             $origRow = $this->getDatabaseConnection()->sql_fetch_assoc($res);
             $this->getDatabaseConnection()->sql_free_result($res);
             if ($origRow) {
                 $row = $origRow;
                 return true;
             }
         }
     }
     return false;
 }

作者:Gregp    项目:TYPO3.CM   
/**
  * 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;
 }

作者:grauru    项目:testgit_t3   
/**
  * Callback to determine whether a new parent reference shall be considered in the dependency resolver utility.
  * Only elements that are a delete placeholder are considered.
  *
  * @param array $callerArguments
  * @param array $targetArgument
  * @param ElementEntity $caller
  * @param string $eventName
  * @return NULL|string Skip response (if required)
  */
 public function createClearDependentElementParentReferenceCallback(array $callerArguments, array $targetArgument, ElementEntity $caller, $eventName)
 {
     $response = $this->createNewDependentElementParentReferenceCallback($callerArguments, $targetArgument, $caller, $eventName);
     if (empty($response)) {
         $record = BackendUtility::getRecord($callerArguments['table'], $callerArguments['id']);
         if (!VersionState::cast($record['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
             $response = ElementEntity::RESPONSE_Skip;
         }
     }
     return $response;
 }

作者:allipierr    项目:Typo   
/**
     * Renders Content Elements from the tt_content table from page id
     *
     * @param integer $id Page id
     * @return string HTML for the listing
     * @todo Define visibility
     */
    public function getTable_tt_content($id)
    {
        $this->initializeLanguages();
        $this->initializeClipboard();
        // Initialize:
        $RTE = $this->getBackendUser()->isRTE();
        $lMarg = 1;
        $showHidden = $this->tt_contentConfig['showHidden'] ? '' : BackendUtility::BEenableFields('tt_content');
        $pageTitleParamForAltDoc = '&recTitle=' . rawurlencode(BackendUtility::getRecordTitle('pages', BackendUtility::getRecordWSOL('pages', $id), TRUE));
        /** @var $pageRenderer \TYPO3\CMS\Core\Page\PageRenderer */
        $pageRenderer = $this->getPageLayoutController()->doc->getPageRenderer();
        $pageRenderer->loadExtJs();
        $pageRenderer->addJsFile($GLOBALS['BACK_PATH'] . 'sysext/cms/layout/js/typo3pageModule.js');
        // Get labels for CTypes and tt_content element fields in general:
        $this->CType_labels = array();
        foreach ($GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'] as $val) {
            $this->CType_labels[$val[1]] = $this->getLanguageService()->sL($val[0]);
        }
        $this->itemLabels = array();
        foreach ($GLOBALS['TCA']['tt_content']['columns'] as $name => $val) {
            $this->itemLabels[$name] = $this->getLanguageService()->sL($val['label']);
        }
        $languageColumn = array();
        $out = '';
        // Select display mode:
        // MULTIPLE column display mode, side by side:
        if (!$this->tt_contentConfig['single']) {
            // Setting language list:
            $langList = $this->tt_contentConfig['sys_language_uid'];
            if ($this->tt_contentConfig['languageMode']) {
                if ($this->tt_contentConfig['languageColsPointer']) {
                    $langList = '0,' . $this->tt_contentConfig['languageColsPointer'];
                } else {
                    $langList = implode(',', array_keys($this->tt_contentConfig['languageCols']));
                }
                $languageColumn = array();
            }
            $langListArr = GeneralUtility::intExplode(',', $langList);
            $defLanguageCount = array();
            $defLangBinding = array();
            // For each languages... :
            // If not languageMode, then we'll only be through this once.
            foreach ($langListArr as $lP) {
                $lP = (int) $lP;
                if (count($langListArr) === 1 || $lP === 0) {
                    $showLanguage = ' AND sys_language_uid IN (' . $lP . ',-1)';
                } else {
                    $showLanguage = ' AND sys_language_uid=' . $lP;
                }
                $cList = explode(',', $this->tt_contentConfig['cols']);
                $content = array();
                $head = array();
                // Select content records per column
                $contentRecordsPerColumn = $this->getContentRecordsPerColumn('table', $id, array_values($cList), $showHidden . $showLanguage);
                // For each column, render the content into a variable:
                foreach ($cList as $key) {
                    if (!$lP) {
                        $defLanguageCount[$key] = array();
                    }
                    // Start wrapping div
                    $content[$key] .= '<div class="t3-page-ce-wrapper';
                    if (count($contentRecordsPerColumn[$key]) === 0) {
                        $content[$key] .= ' t3-page-ce-empty';
                    }
                    $content[$key] .= '">';
                    // Add new content at the top most position
                    $content[$key] .= '
					<div class="t3-page-ce" id="' . uniqid() . '">
						<div class="t3-page-ce-dropzone" id="colpos-' . $key . '-' . 'page-' . $id . '-' . uniqid() . '">
							<div class="t3-page-ce-wrapper-new-ce">
								<a href="#" onclick="' . htmlspecialchars($this->newContentElementOnClick($id, $key, $lP)) . '" title="' . $this->getLanguageService()->getLL('newRecordHere', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-new') . '</a>
							</div>
						</div>
					</div>
					';
                    $editUidList = '';
                    $rowArr = $contentRecordsPerColumn[$key];
                    $this->generateTtContentDataArray($rowArr);
                    foreach ((array) $rowArr as $rKey => $row) {
                        if ($this->tt_contentConfig['languageMode']) {
                            $languageColumn[$key][$lP] = $head[$key] . $content[$key];
                            if (!$this->defLangBinding) {
                                $languageColumn[$key][$lP] .= $this->newLanguageButton($this->getNonTranslatedTTcontentUids($defLanguageCount[$key], $id, $lP), $lP);
                            }
                        }
                        if (is_array($row) && !VersionState::cast($row['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
                            $singleElementHTML = '';
                            if (!$lP && ($this->defLangBinding || $row['sys_language_uid'] != -1)) {
                                $defLanguageCount[$key][] = $row['uid'];
                            }
                            $editUidList .= $row['uid'] . ',';
                            $disableMoveAndNewButtons = $this->defLangBinding && $lP > 0;
                            if (!$this->tt_contentConfig['languageMode']) {
//.........这里部分代码省略.........

作者:adroll    项目:TYPO3.CM   
/**
  * Release version from this workspace (and into "Live" workspace but as an offline version).
  *
  * @param string $table Table name
  * @param int $id Record UID
  * @param bool $flush If set, will completely delete element
  * @param DataHandler $tcemainObj TCEmain object
  * @return void
  */
 protected function version_clearWSID($table, $id, $flush = FALSE, DataHandler $tcemainObj)
 {
     if ($errorCode = $tcemainObj->BE_USER->workspaceCannotEditOfflineVersion($table, $id)) {
         $tcemainObj->newlog('Attempt to reset workspace for record failed: ' . $errorCode, 1);
         return;
     }
     if (!$tcemainObj->checkRecordUpdateAccess($table, $id)) {
         $tcemainObj->newlog('Attempt to reset workspace for record failed because you do not have edit access', 1);
         return;
     }
     $liveRec = BackendUtility::getLiveVersionOfRecord($table, $id, 'uid,t3ver_state');
     if (!$liveRec) {
         return;
     }
     // Clear workspace ID:
     $updateData = array('t3ver_wsid' => 0, 't3ver_tstamp' => $GLOBALS['EXEC_TIME']);
     $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . (int) $id, $updateData);
     // Clear workspace ID for live version AND DELETE IT as well because it is a new record!
     if (VersionState::cast($liveRec['t3ver_state'])->equals(VersionState::NEW_PLACEHOLDER) || VersionState::cast($liveRec['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
         $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . (int) $liveRec['uid'], $updateData);
         // THIS assumes that the record was placeholder ONLY for ONE record (namely $id)
         $tcemainObj->deleteEl($table, $liveRec['uid'], TRUE);
     }
     // If "deleted" flag is set for the version that got released
     // it doesn't make sense to keep that "placeholder" anymore and we delete it completly.
     $wsRec = BackendUtility::getRecord($table, $id);
     if ($flush || (VersionState::cast($wsRec['t3ver_state'])->equals(VersionState::NEW_PLACEHOLDER) || VersionState::cast($wsRec['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER))) {
         $tcemainObj->deleteEl($table, $id, TRUE, TRUE);
     }
     // Remove the move-placeholder if found for live record.
     if ((int) $GLOBALS['TCA'][$table]['ctrl']['versioningWS'] >= 2) {
         if ($plhRec = BackendUtility::getMovePlaceholder($table, $liveRec['uid'], 'uid')) {
             $tcemainObj->deleteEl($table, $plhRec['uid'], TRUE, TRUE);
         }
     }
 }

作者:rickymathe    项目:TYPO3.CM   
/**
  * Determines whether this node is deleted.
  *
  * @return bool
  */
 public function isDeleted()
 {
     return !empty($this->record['deleted']) || VersionState::cast($this->record['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER);
 }

作者:Mr-Robot    项目:TYPO3.CM   
/**
  * Get a single record row for a TCA table from the database.
  * \TYPO3\CMS\Backend\Form\DataPreprocessor is used for "upgrading" the
  * values, especially the relations.
  *
  * @param integer $pid The pid of the page the record should be stored (only relevant for NEW records)
  * @param string $table The table to fetch data from (= foreign_table)
  * @param string $uid The uid of the record to fetch, or the pid if a new record should be created
  * @param string $cmd The command to perform, empty or 'new'
  * @return array A record row from the database post-processed by \TYPO3\CMS\Backend\Form\DataPreprocessor
  * @todo Define visibility
  */
 public function getRecord($pid, $table, $uid, $cmd = '')
 {
     // Fetch workspace version of a record (if any):
     if ($cmd !== 'new' && $GLOBALS['BE_USER']->workspace !== 0 && BackendUtility::isTableWorkspaceEnabled($table)) {
         $workspaceVersion = BackendUtility::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $table, $uid, 'uid,t3ver_state');
         if ($workspaceVersion !== FALSE) {
             $versionState = VersionState::cast($workspaceVersion['t3ver_state']);
             if ($versionState->equals(VersionState::DELETE_PLACEHOLDER)) {
                 return FALSE;
             }
             $uid = $workspaceVersion['uid'];
         }
     }
     /** @var $trData \TYPO3\CMS\Backend\Form\DataPreprocessor */
     $trData = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\DataPreprocessor');
     $trData->addRawData = TRUE;
     $trData->lockRecords = 1;
     $trData->disableRTE = $GLOBALS['SOBE']->MOD_SETTINGS['disableRTE'];
     // If a new record should be created
     $trData->fetchRecord($table, $uid, $cmd === 'new' ? 'new' : '');
     $rec = reset($trData->regTableItems_data);
     return $rec;
 }


问题


面经


文章

微信
公众号

扫码关注公众号