/** * Get field names for deletion rules and the target key definition * * @param $obj * @return array */ public function getTargetFields($obj) { if (!$obj->activeRecord) { return array(); } $arrFields = InternalTable::getFieldList($obj->activeRecord, 'target'); foreach ($arrFields as $arrField) { $arrReturn[] = $arrField['name']; } return $arrReturn; }
/** * Get table names * * @return array */ public function getTables() { return InternalTable::getTables(); }
/** * Finalize the run * * @param $objRun */ public static function finalize($objRun) { // do not finalize the a child job run if ($objRun->id != $objRun->rootRun) { return; } Tracking::log($objRun->id, $objRun->rootRun, $GLOBALS['TL_LANG']['tl_convertx_job']['finalisation']); // ----------------------------------------- // kill tmp sources foreach ($objRun->sources as $source) { $strSource = str_replace('_source', '', str_replace('cvx_', '', $source)); // source is not an internal table if (is_numeric($strSource)) { // kill tmp source table if (ExternalData::deleteTmpTable($strSource, '_source')) { Tracking::log($objRun->id, $objRun->rootRun, sprintf($GLOBALS['TL_LANG']['tl_convertx_job']['temporarySourceRemoved'], $strSource), 'entry'); } } } // ----------------------------------------- // replace target tables by working tables foreach ($objRun->targets as $target) { $strTarget = str_replace('cvx_', '', $target); // target is not an internal table if (is_numeric($strTarget)) { $strClass = ExternalData::getClass($strTarget, 'targetType'); if ($strClass::finalize($strTarget, $objRun)) { Tracking::log($objRun->id, $objRun->rootRun, sprintf($GLOBALS['TL_LANG']['tl_convertx_job']['targetFileCreated'], $strTarget), 'entry'); // kill tmp target table if (ExternalData::deleteTmpTable($strTarget)) { Tracking::log($objRun->id, $objRun->rootRun, sprintf($GLOBALS['TL_LANG']['tl_convertx_job']['temporaryTargetRemoved'], $strTarget), 'entry'); } } else { Tracking::log($objRun->id, $objRun->rootRun, sprintf($GLOBALS['TL_LANG']['tl_convertx_job']['targetFileNotCreated'], $strTarget), 'entry', 'error'); // kill tmp target table if (ExternalData::deleteTmpTable($strTarget)) { Tracking::log($objRun->id, $objRun->rootRun, sprintf($GLOBALS['TL_LANG']['tl_convertx_job']['temporaryTargetRemoved'], $strTarget), 'entry'); } } } else { // finalize internal target table if (InternalTable::finalize($strTarget, $objRun)) { Tracking::log($objRun->id, $objRun->rootRun, sprintf($GLOBALS['TL_LANG']['tl_convertx_job']['targetUpdated'], $strTarget), 'entry'); } else { Tracking::log($objRun->id, $objRun->rootRun, sprintf($GLOBALS['TL_LANG']['tl_convertx_job']['targetNotUpdated'], $strTarget), 'entry', 'error'); } } } // close the run of the job $objRun->closed = '1'; $objRun->end = time(); // save the log summary $objRun->log = Tracking::showLog($objRun->id); // the run should be ok $objRun->status = 'ok'; // well, it didnt fail, but there maybe errors that didn't lead to an abortion $objLog = Database::getInstance()->prepare("SELECT id FROM tl_convertx_log WHERE pid=? AND status=?")->execute($objRun->id, 'error'); if ($objLog->numRows > 0) { $objRun->status = 'error'; } // look if we have to do something external before finishing the run if (isset($GLOBALS['TL_HOOKS']['convertx']['final']) && is_array($GLOBALS['TL_HOOKS']['convertx']['final'])) { foreach ($GLOBALS['TL_HOOKS']['convertx']['final'] as $callback) { $objRun = System::importStatic($callback[0])->{$callback}[1]($objRun); } } $objRun->save(); // fine, we're done :) return; }