irgendwie wird da immer als kategoriename -> a zugewiesen
templates werden diesen neuen kategorien ebenso nicht zugewiesen...
das artikel kopieren sieht hingegen gut aus...
in der function.str.php anstelle von
function strCopyCategory
folgende funktion verwenden...
Code: Alles auswählen
function strCopyCategory ($idcat, $destidcat, $remakeTree = true)
{
global $cfg, $client, $lang;
$newidcat = strNewCategory($destidcat, "a", $remakeTree);
/* Selectors */
$_oldcatlang = new cApiCategoryLanguageCollection;
$_newcatlang = new cApiCategoryLanguageCollection;
$_oldcatlang->select("idcat = '$idcat' AND idlang = '$lang'");
$oldcatlang = $_oldcatlang->next();
$_newcatlang->select("idcat = '$newidcat' AND idlang = '$lang'");
$newcatlang = $_newcatlang->next();
/* Worker objects */
$newcat = new cApiCategory($newidcat);
$oldcat = new cApiCategory($idcat);
/* Copy properties */
$newcatlang->set("name", sprintf(i18n("Copy of %s"), $oldcatlang->get("name")));
$newcatlang->set("public", $oldcatlang->get("public"));
$newcatlang->set("visible", 0);
$newcatlang->store();
/* Copy template configuration */
if ($oldcatlang->get("idtplcfg") != 0)
{
/* Create new template configuration */
$newcatlang->assignTemplate($oldcatlang->getTemplate());
/* Copy the container configuration */
$c_cconf = new cApiContainerConfigurationCollection;
$m_cconf = new cApiContainerConfigurationCollection;
$c_cconf->select("idtplcfg = '".$oldcatlang->get("idtplcfg")."'");
while ($i_cconf = $c_cconf->next())
{
$m_cconf->create($newcatlang->get("idtplcfg"), $i_cconf->get("number"), $i_cconf->get("container"));
}
}
$db = new DB_Contenido;
$db2 = new DB_Contenido;
/* Copy all articles */
$sql = "SELECT A.idart, B.idartlang FROM ".$cfg["tab"]["cat_art"]." AS A, ".$cfg["tab"]["art_lang"]." AS B WHERE A.idcat = '$idcat' AND B.idart = A.idart AND B.idlang = '$lang'";
$db->query($sql);
while ($db->next_record())
{
$newidart = conCopyArticle($db->f("idart"), $newidcat);
if ($db->f("idartlang") == $oldcatlang->get("startidartlang"))
{
$sql = "SELECT idcatart FROM ".$cfg["tab"]["cat_art"]." WHERE idcat = '$newidcat' AND idart = '$newidart'";
$db2->query($sql);
if ($db2->next_record())
{
conMakeStart($db2->f("idcatart"), 1);
}
}
}
return ($newidcat);
}
bei einer kopierten kategorie wird nun auch das Copy of ergänzt..