/**
  * Clones all GridElements which are configured for "All languages" and creates a single GridElement
  * for each page translation. Also sets the language for the original GridElement to 0 (default language)
  *
  * @param int $pageUid
  * @return int Amount of cloned GridElements
  */
 public function cloneLangAllGEs($pageUid)
 {
     $cloned = 0;
     $pageLanguages = $this->sharedHelper->getAvailablePageTranslations($pageUid);
     $allLanguages = $this->sharedHelper->getAllLanguages();
     $nonPageLanguages = array_diff($allLanguages, $pageLanguages);
     $gridElements = $this->getCeGridElements($pageUid, -1);
     // All GridElements with language = all
     $this->langIsoCodes = $this->sharedHelper->getLanguagesIsoCodes();
     foreach ($gridElements as $contentElementUid) {
         $origContentElement = $this->sharedHelper->getContentElement($contentElementUid);
         foreach ($pageLanguages as $langUid) {
             $translationContentUid = $this->addTranslationContentElement($origContentElement, $langUid, $origContentElement['uid']);
             $this->updateShortcutElements($contentElementUid, $langUid, $translationContentUid);
             $cloned += 1;
         }
         // modify shortcuts for non non page translations (could be other languages available)
         if (!empty($nonPageLanguages)) {
             foreach ($nonPageLanguages as $pageLanguageUid) {
                 $this->updateShortcutElements($contentElementUid, $pageLanguageUid, $contentElementUid);
             }
         }
         $origContentElement['sys_language_uid'] = 0;
         $origUid = $origContentElement['uid'];
         unset($origContentElement['uid']);
         $tvTemplateUid = (int) $origContentElement['tx_templavoila_to'];
         if (!empty($origContentElement['tx_templavoila_flex'])) {
             $origContentElement['pi_flexform'] = $origContentElement['tx_templavoila_flex'];
         }
         $origContentElement['pi_flexform'] = $this->sharedHelper->cleanFlexform($origContentElement['pi_flexform'], $tvTemplateUid);
         $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tt_content', 'uid=' . $origUid, $origContentElement);
         $this->updateSysLanguageOfAllLanguageShortcuts($contentElementUid);
     }
     return $cloned;
 }