/** * @param int $pageUid * @param int $geElementUid * @param array $childElement */ protected function updateInGeAllLangElements($pageUid, $geElementUid, $childElement) { $pageUid = (int) $pageUid; $geElementUid = (int) $geElementUid; $childElementUid = (int) $childElement['uid']; if ($childElement['sys_language_uid'] < 0 && $this->allLanguageRecordsInGeToShortcut) { $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tt_content', 'uid=' . $childElementUid, array('sys_language_uid' => 0)); $pageLanguages = $this->sharedHelper->getAvailablePageTranslations($pageUid); foreach ($pageLanguages as $langUid) { $langUid = (int) $langUid; if ($langUid > 0) { $localizedGridElement = $this->getLocalizedGridElement($geElementUid, $langUid); $localizedGridElementUid = (int) $localizedGridElement['uid']; if ($localizedGridElementUid > 0) { $translationContentElement = $childElement; $translationContentElement['tx_gridelements_container'] = $localizedGridElementUid; $translationContentElement['CType'] = 'shortcut'; $translationContentElement['records'] = 'tt_content_' . $childElementUid; $newUid = (int) $this->addTranslationContentElement($translationContentElement, $langUid, $childElementUid); if ($newUid > 0) { $this->refIndex->updateRefIndexTable('tt_content', $newUid); } } } } } }
/** * updates sys_refindex for translation content elements * * @param $contentUid */ protected function updateRefIndexTranslations($contentUid) { $updateRefIndexTranslations = $this->sharedHelper->getTranslationsForContentElement($contentUid); if (!empty($updateRefIndexTranslations)) { foreach ($updateRefIndexTranslations as $updateRefIndexTranslation) { $updateRefIndexTranslationUid = (int) $updateRefIndexTranslation['uid']; if ($updateRefIndexTranslationUid > 0) { $this->refIndex->updateRefIndexTable('tt_content', $updateRefIndexTranslationUid); } } } }
/** * Deletes an object * * @param Tx_Extbase_DomainObject_DomainObjectInterface $object The object to be insterted in the storage * @param Tx_Extbase_DomainObject_AbstractEntity|NULL $parentObject The parent object (if any) * @param string|NULL $parentPropertyName The name of the property * @param bool $markAsDeleted Shold we only mark the row as deleted instead of deleting (TRUE by default)? * @return void */ protected function removeObject(Tx_Extbase_DomainObject_DomainObjectInterface $object, $markAsDeleted = TRUE) { $dataMap = $this->dataMapper->getDataMap(get_class($object)); $tableName = $dataMap->getTableName(); if ($markAsDeleted === TRUE && $dataMap->getDeletedFlagColumnName() !== NULL) { $deletedColumnName = $dataMap->getDeletedFlagColumnName(); $res = $this->storageBackend->updateRow($tableName, array('uid' => $object->getUid(), $deletedColumnName => 1)); } else { $res = $this->storageBackend->removeRow($tableName, array('uid' => $object->getUid())); } $this->removeRelatedObjects($object); if ($this->extbaseSettings['persistence']['updateReferenceIndex'] === '1') { $this->referenceIndex->updateRefIndexTable($tableName, $object->getUid()); } }
/** * Deletes an object * * @param Tx_Extbase_DomainObject_DomainObjectInterface $object The object to be insterted in the storage * @param Tx_Extbase_DomainObject_AbstractEntity|NULL $parentObject The parent object (if any) * @param string|NULL $parentPropertyName The name of the property * @param bool $markAsDeleted Shold we only mark the row as deleted instead of deleting (TRUE by default)? * @return void */ protected function removeObject(Tx_Extbase_DomainObject_DomainObjectInterface $object, $markAsDeleted = TRUE) { $dataMap = $this->dataMapper->getDataMap(get_class($object)); $tableName = $dataMap->getTableName(); if ($markAsDeleted === TRUE && $dataMap->getDeletedFlagColumnName() !== NULL) { $deletedColumnName = $dataMap->getDeletedFlagColumnName(); $res = $this->storageBackend->updateRow($tableName, array('uid' => $object->getUid(), $deletedColumnName => 1)); } else { $res = $this->storageBackend->removeRow($tableName, array('uid' => $object->getUid())); } $this->removeRelatedObjects($object); $frameworkConfiguration = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); if ($frameworkConfiguration['persistence']['updateReferenceIndex'] === '1') { $this->referenceIndex->updateRefIndexTable($tableName, $object->getUid()); } }
/** * Migrates all content elements for the FCE with the given uid to the selected column positions * * @param array $contentElement * @param array $formdata * @return int Number of Content elements updated */ public function migrateContentElementsForFce($contentElement, $formdata) { $fieldMapping = $this->sharedHelper->getFieldMappingArray($formdata, 'tv_col_', 'ge_col_'); $tvContentArray = $this->sharedHelper->getTvContentArrayForContent($contentElement['uid']); $translationParentUid = (int) $contentElement['l18n_parent']; $sysLanguageUid = (int) $contentElement['sys_language_uid']; $pageUid = (int) $contentElement['pid']; $count = 0; $sorting = 0; foreach ($tvContentArray as $key => $contentUidString) { if (array_key_exists($key, $fieldMapping) && $contentUidString != '') { $contentUids = explode(',', $contentUidString); foreach ($contentUids as $contentUid) { $contentUid = (int) $contentUid; $myContentElement = NULL; $myContentElement = $this->sharedHelper->getContentElement($contentUid); $containerUid = (int) $contentElement['uid']; if ($translationParentUid > 0 && $sysLanguageUid > 0) { $myCeTranslationParentUid = (int) $myContentElement['uid']; if ($myCeTranslationParentUid > 0) { $tmpMyContentElement = $this->sharedHelper->getTranslationForContentElementAndLanguage($myCeTranslationParentUid, $sysLanguageUid); $tmpMyContentUid = (int) $tmpMyContentElement['uid']; if ($tmpMyContentUid > 0) { $contentUid = $tmpMyContentUid; $myContentElement = $tmpMyContentElement; } else { $containerUid = $translationParentUid; } } else { $containerUid = $translationParentUid; } } else { $myContentElement = $this->sharedHelper->getContentElement($contentUid); } if (intval($myContentElement['pid']) === $pageUid) { $this->sharedHelper->updateContentElementForGe($contentUid, $containerUid, $fieldMapping[$key], $sorting); } $sorting += 25; $count++; $this->sharedHelper->fixContentElementLocalizationDiffSources($contentUid); $this->refIndex->updateRefIndexTable('tt_content', $contentUid); } } } return $count; }
/** * @param array $contentArray * @param int $pageUid * @param int $sorting * @return array */ protected function fixSortingForContentArray($contentArray, $pageUid, &$sorting) { $pageUid = (int) $pageUid; $modifiedSortingCeUids = array(); if (is_array($contentArray)) { $contentElementUids = $this->getContentElementUids($contentArray); foreach ($contentElementUids as $ceUid) { $contentElement = $this->sharedHelper->getContentElement($ceUid); $contentTvFlexform = NULL; $contentElementPageUid = (int) $contentElement['pid']; if ($contentElementPageUid === $pageUid) { $contentTvFlexform = $contentElement['tx_templavoila_flex']; $contentElementUid = (int) $contentElement['uid']; if ($contentElementUid > 0) { $sorting += self::SORTING_OFFSET; $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tt_content', 'uid=' . $contentElementUid, array('sorting' => $sorting)); $modifiedSortingCeUids[] = $contentElementUid; $translations = $this->sharedHelper->getTranslationsForContentElement($contentElementUid); if (!empty($translations)) { foreach ($translations as $translation) { $translationUid = $translation['uid']; if ($translationUid > 0) { $sorting += self::SORTING_OFFSET; $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tt_content', 'uid=' . $translationUid, array('sorting' => $sorting)); $modifiedSortingCeUids[] = $translationUid; $this->refIndex->updateRefIndexTable('tt_content', $translationUid); } } } $this->refIndex->updateRefIndexTable('tt_content', $contentElementUid); $this->sharedHelper->fixContentElementLocalizationDiffSources($contentElementUid); if (!empty($contentTvFlexform)) { $contentArrayForFce = $this->sharedHelper->getTvContentArrayForContent($contentElementUid); $fceModifiedCeUids = $this->fixSortingForContentArray($contentArrayForFce, $pageUid, $sorting); $modifiedSortingCeUids = array_merge($modifiedSortingCeUids, $fceModifiedCeUids); } } } } } return $modifiedSortingCeUids; }