/**
  * @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);
                     }
                 }
             }
         }
     }
 }
 /**
  * Migrates templavoila flexform of page to db fields with the given pageUid to the selected column positions
  *
  * @param array $formdata
  * @param int $pageUid
  * @return int Number of Content elements updated
  */
 public function migrateTvFlexformForPage($formdata, $pageUid)
 {
     $pageUid = (int) $pageUid;
     $localizationDiffSourceFields = array();
     $flexformConversionOption = $formdata['convertflexformoption'];
     $flexformFieldPrefix = $formdata['flexformfieldprefix'];
     $pageRecord = $this->sharedHelper->getPage($pageUid);
     $tvTemplateUid = (int) $this->sharedHelper->getTvPageTemplateUid($pageUid);
     $isTvDataLangDisabled = $this->sharedHelper->isTvDataLangDisabled($tvTemplateUid);
     $pageFlexformString = $pageRecord['tx_templavoila_flex'];
     if (!empty($pageFlexformString)) {
         $langIsoCodes = $this->sharedHelper->getLanguagesIsoCodes();
         $allAvailableLanguages = $this->sharedHelper->getAvailablePageTranslations($pageUid);
         if (empty($allAvailableLanguages)) {
             $allAvailableLanguages = array();
         }
         array_unshift($allAvailableLanguages, 0);
         foreach ($allAvailableLanguages as $langUid) {
             $flexformString = $pageFlexformString;
             $langUid = (int) $langUid;
             if ($flexformConversionOption !== 'exclude') {
                 if (t3lib_extMgm::isLoaded('static_info_tables')) {
                     if ($langUid > 0) {
                         $forceLanguage = $flexformConversionOption === 'forceLanguage';
                         if (!$isTvDataLangDisabled) {
                             $flexformString = $this->sharedHelper->convertFlexformForTranslation($flexformString, $langIsoCodes[$langUid], $forceLanguage);
                         }
                     }
                 }
             }
             $flexformString = $this->sharedHelper->cleanFlexform($flexformString, $tvTemplateUid);
             if (!empty($flexformString)) {
                 $flexformArray = t3lib_div::xml2array($flexformString);
                 if (is_array($flexformArray['data'])) {
                     foreach ($flexformArray['data'] as $sheetData) {
                         if (is_array($sheetData['lDEF'])) {
                             foreach ($sheetData['lDEF'] as $fieldName => $fieldData) {
                                 if (isset($fieldData['vDEF'])) {
                                     $fieldValue = (string) $fieldData['vDEF'];
                                     $fullFieldName = $flexformFieldPrefix . $fieldName;
                                     if ($langUid === 0) {
                                         $fields = $GLOBALS['TYPO3_DB']->admin_get_fields('pages');
                                         if (!empty($fields[$fullFieldName])) {
                                             if ($GLOBALS['TYPO3_DB']->quoteStr($fullFieldName, 'pages') === $fullFieldName) {
                                                 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('pages', 'uid=' . intval($pageUid), array($fullFieldName => $fieldValue));
                                             }
                                         }
                                     } elseif ($langUid > 0) {
                                         $fields = $GLOBALS['TYPO3_DB']->admin_get_fields('pages_language_overlay');
                                         if (!empty($fields[$fullFieldName])) {
                                             if ($GLOBALS['TYPO3_DB']->quoteStr($fullFieldName, 'pages_language_overlay') === $fullFieldName) {
                                                 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('pages_language_overlay', '(pid=' . intval($pageUid) . ')' . ' AND (sys_language_uid = ' . $langUid . ')' . t3lib_BEfunc::deleteClause('pages_language_overlay'), array($fullFieldName => $fieldValue));
                                             }
                                             $localizationDiffSourceFields[] = $fullFieldName;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $this->sharedHelper->fixPageLocalizationDiffSources($pageUid, $localizationDiffSourceFields);
 }