/**
  * @param $dc
  */
 public static function deleteDataRecord($dc)
 {
     // If this is not the backend than return
     if (TL_MODE != 'BE') {
         return;
     }
     // Check if there is an active record
     if ($dc instanceof \DataContainer && $dc->activeRecord) {
         $intId = $dc->activeRecord->id;
         $strTable = $dc->table;
         $strModel = '\\' . \Model::getClassFromTable($strTable);
         $objTranslationController = new \TranslationController();
         // Return if the class does not exist (#9 thanks to tsarma)
         if (!class_exists($strModel)) {
             return;
         }
         // Get object from model
         $objModel = $strModel::findByPk($intId);
         if ($objModel !== null) {
             $arrData = $objModel->row();
             if (is_array($arrData) && count($arrData) > 0) {
                 // Load current data container
                 $objTranslationController->loadDataContainer($strTable);
                 // Get tl_undo data
                 $objUndo = \Database::getInstance()->prepare("SELECT * FROM tl_undo WHERE fromTable=? ORDER BY id DESC")->limit(1)->execute($dc->table);
                 $arrSet = $objUndo->row();
                 // Deserialize tl_undo data
                 $arrSet['data'] = deserialize($arrSet['data']);
                 foreach ($arrData as $strField => $varValue) {
                     switch ($GLOBALS['TL_DCA'][$strTable]['fields'][$strField]['inputType']) {
                         case 'TranslationInputUnit':
                         case 'TranslationTextArea':
                         case 'TranslationTextField':
                             // Get translation values
                             $objTranslation = \TranslationFieldsModel::findByFid($varValue);
                             if ($objTranslation !== null) {
                                 while ($objTranslation->next()) {
                                     $t = \TranslationFieldsModel::getTable();
                                     // Add cross table record to undo data
                                     $arrSet['data'][$t][] = $objTranslation->row();
                                     // Delete translation
                                     $objTranslation->delete();
                                 }
                             }
                             break;
                     }
                 }
                 // Serialize tl_undo data
                 $arrSet['data'] = serialize($arrSet['data']);
                 // Update tl_undo
                 \Database::getInstance()->prepare("UPDATE tl_undo %s WHERE id=?")->set($arrSet)->execute($objUndo->id);
             }
         }
     }
 }
 /**
  * @param \DataContainer $objDC
  * @return \DataContainer
  */
 public static function translateDCObject(\DataContainer $objDC)
 {
     // Get table
     $strTable = $objDC->current()->getTable();
     // Load current data container
     $objTranslationController = new \TranslationController();
     $objTranslationController->loadDataContainer($strTable);
     if (count($GLOBALS['TL_DCA'][$strTable]['fields']) > 0) {
         foreach ($GLOBALS['TL_DCA'][$strTable]['fields'] as $field => $arrValues) {
             $objDC->{$field} = self::translateField($arrValues['inputType'], $objDC->{$field});
         }
     }
     return $objDC;
 }