コード例 #1
0
 /**
  * Does the content migration recursive for all pages
  *
  * @param array $formdata
  * @return void
  */
 public function migrateContentAction($formdata)
 {
     $this->sharedHelper->setUnlimitedTimeout();
     $uidTvTemplate = (int) $formdata['tvtemplate'];
     $uidBeLayout = (int) $formdata['belayout'];
     $contentElementsUpdated = 0;
     $pageTemplatesUpdated = 0;
     if ($uidTvTemplate > 0 && $uidBeLayout > 0) {
         $pageUids = $this->sharedHelper->getPageIds();
         foreach ($pageUids as $pageUid) {
             if ($this->sharedHelper->getTvPageTemplateUid($pageUid) == $uidTvTemplate) {
                 $contentElementsUpdated += $this->migrateContentHelper->migrateContentForPage($formdata, $pageUid);
                 $this->migrateContentHelper->migrateTvFlexformForPage($formdata, $pageUid);
             }
             // Update page template (must be called for every page, since to and next_to must be checked
             $pageTemplatesUpdated += $this->migrateContentHelper->updatePageTemplate($pageUid, $uidTvTemplate, $uidBeLayout);
         }
         if ($formdata['markdeleted']) {
             $this->migrateContentHelper->markTvTemplateDeleted($uidTvTemplate);
         }
     }
     $this->view->assign('contentElementsUpdated', $contentElementsUpdated);
     $this->view->assign('pageTemplatesUpdated', $pageTemplatesUpdated);
 }
コード例 #2
0
 /**
  * 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);
 }