/** * Kopiert die Inhalte eines Artikels in einen anderen Artikel * * @param $from_id ArtikelId des Artikels, aus dem kopiert werden (Quell ArtikelId) * @param $to_id ArtikelId des Artikel, in den kopiert werden sollen (Ziel ArtikelId) * @param [$from_clang] ClangId des Artikels, aus dem kopiert werden soll (Quell ClangId) * @param [$to_clang] ClangId des Artikels, in den kopiert werden soll (Ziel ClangId) * @param [$from_re_sliceid] Id des Slices, bei dem begonnen werden soll */ function rex_copyContent($from_id, $to_id, $from_clang = 0, $to_clang = 0, $from_re_sliceid = 0) { global $REX, $REX_USER; if ($from_id == $to_id && $from_clang == $to_clang) { return false; } $gc = new rex_sql(); $gc->setQuery("select * from " . $REX['TABLE_PREFIX'] . "article_slice where re_article_slice_id='{$from_re_sliceid}' and article_id='{$from_id}' and clang='{$from_clang}'"); if ($gc->getRows() == 1) { // letzt slice_id des ziels holen .. $glid = new rex_sql(); $glid->setQuery("select r1.id, r1.re_article_slice_id\n from " . $REX['TABLE_PREFIX'] . "article_slice as r1\n left join " . $REX['TABLE_PREFIX'] . "article_slice as r2 on r1.id=r2.re_article_slice_id\n where r1.article_id={$to_id} and r1.clang={$to_clang} and r2.id is NULL;"); if ($glid->getRows() == 1) { $to_last_slice_id = $glid->getValue("r1.id"); } else { $to_last_slice_id = 0; } $ins = new rex_sql(); // $ins->debugsql = 1; $ins->setTable($REX['TABLE_PREFIX'] . "article_slice"); $cols = new rex_sql(); // $cols->debugsql = 1; $cols->setquery("SHOW COLUMNS FROM " . $REX['TABLE_PREFIX'] . "article_slice"); for ($j = 0; $j < $cols->rows; $j++, $cols->next()) { $colname = $cols->getvalue("Field"); if ($colname == "clang") { $value = $to_clang; } elseif ($colname == "re_article_slice_id") { $value = $to_last_slice_id; } elseif ($colname == "article_id") { $value = $to_id; } elseif ($colname == "createdate") { $value = time(); } elseif ($colname == "updatedate") { $value = time(); } elseif ($colname == "createuser") { $value = $REX_USER->getValue("login"); } elseif ($colname == "updateuser") { $value = $REX_USER->getValue("login"); } else { $value = addslashes($gc->getValue("{$colname}")); } if ($colname != "id") { $ins->setValue($colname, $value); } } $ins->insert(); // id holen und als re setzen und weitermachen.. rex_copyContent($from_id, $to_id, $from_clang, $to_clang, $gc->getValue("id")); return true; } rex_generateArticle($to_id); return true; }