"geändert Datum" beim Duplizieren auch kopieren

Gesperrt
stefkey
Beiträge: 556
Registriert: Mi 19. Okt 2005, 16:10
Wohnort: Heidelberg
Kontaktdaten:

"geändert Datum" beim Duplizieren auch kopieren

Beitrag von stefkey »

Hallo,

beim Duplizieren wird das Datum der letzten Änderung leider auf das aktuelle Datum gesetzt.
Weiß jemand welchen Codeschnipsel ich wo ergänzen muss damit das Datum mit kopiert wird?
Oldperl
Beiträge: 4316
Registriert: Do 30. Jun 2005, 22:56
Wohnort: Eltmann, Unterfranken, Bayern
Hat sich bedankt: 6 Mal
Danksagung erhalten: 4 Mal
Kontaktdaten:

Re: "geändert Datum" beim Duplizieren auch kopieren

Beitrag von Oldperl »

Hallo stefkey,

die Funktionen zum Kopieren/Duplizieren liegen normalerweise in der Datei contenido/includes/functions.con.php.

Gruß aus Franken

Ortwin
ConLite 3.0.0-dev, alternatives und stabiles Update von Contenido 4.8.x unter PHP 8.x - Download und Repo auf Gitport.de
phpBO Search Advanced - das Suchwort-Plugin für CONTENIDO 4.9
Mein Entwickler-Blog
stefkey
Beiträge: 556
Registriert: Mi 19. Okt 2005, 16:10
Wohnort: Heidelberg
Kontaktdaten:

Re: "geändert Datum" beim Duplizieren auch kopieren

Beitrag von stefkey »

ahja! :-)

Ich hab halt leider nicht so viel oder eher gesagt kaum Ahnung voin php. Ich dekne aber das wäre der richtige Teil:

Code: Alles auswählen

function conCopyArticle ($srcidart, $targetcat = 0, $newtitle = "")
{
	global $cfg, $_cecRegistry;
	
	$db = new DB_Contenido;
	$db2 = new DB_Contenido;
	
	$sql = "SELECT idclient FROM ".$cfg["tab"]["art"] ." WHERE idart = '".Contenido_Security::toInteger($srcidart)."'";
	
	$db->query($sql); 

	if (!$db->next_record())
	{
		return false;
	}
	
	$idclient = $db->f("idclient");
	$dstidart = $db->nextid($cfg["tab"]["art"]);
	
	$sql = "INSERT INTO ".$cfg["tab"]["art"]." (idart, idclient) VALUES ('".Contenido_Security::toInteger($dstidart)."', '".Contenido_Security::toInteger($idclient)."')";
	$db->query($sql);
	
	conCopyArtLang($srcidart, $dstidart, $newtitle);
	
	// Update category relationship
	$sql = "SELECT idcat, status FROM ".$cfg["tab"]["cat_art"]." WHERE idart = '".Contenido_Security::toInteger($srcidart)."'";
	$db->query($sql);
	
	while ($db->next_record())
	{
		$nextid = $db2->nextid($cfg["tab"]["cat_art"]);
		
		// These are the insert values
		$aFields = Array("idcatart" => Contenido_Security::toInteger($nextid),
						 "idcat" => ($targetcat != 0) ? Contenido_Security::toInteger($targetcat) : Contenido_Security::toInteger($db->f("idcat")),
						 "idart" => Contenido_Security::toInteger($dstidart),
						 "is_start" => 0,
						 "status" => ($db->f("status") != '') ? Contenido_Security::toInteger($db->f("status")) : 0,
						 "createcode" => 1);
						 
		$sql = "INSERT INTO ".$cfg["tab"]["cat_art"]." (".implode(", ", array_keys($aFields)).") VALUES (".implode(", ", array_values($aFields)).");";
		$db2->query($sql);
		
		if ($targetcat != 0) { // If true, exit while routine, only one category entry is needed
			break;
		}
	}
   	
	# Contenido Extension Chain
	# @see docs/techref/plugins/Contenido Extension Chainer.pdf
	#
	# Usage:
	# One could define the file contenido/includes/config.local.php
	# with following code.
	#
	# global $_cecRegistry;
	# cInclude("plugins", "extension/extenison.php");
	# $_cecRegistry->addChainFunction("Contenido.Content.CopyArticle", "AdditionalFunction1");
	# 
	# If function "AdditionalFunction1" is defined in file extension.php, it would be called via
	# $chainEntry->execute($srcidart, $dstidart);
	 
	$iterator = $_cecRegistry->getIterator("Contenido.Content.CopyArticle");
	
	while ($chainEntry = $iterator->next())
	{
		$chainEntry->execute($srcidart, $dstidart);
	}
	
	return $dstidart;
	 
}


hmmmm.. oder vielleicht doch eher das (da steht mehr drin) :oops: :

Code: Alles auswählen

function conCopyArtLang ($srcidart, $dstidart, $newtitle)
{
	global $cfg, $lang;
	
	$db = new DB_Contenido;
	$db2 = new DB_Contenido;
	
	$sql = "SELECT idartlang, idlang, idtplcfg, title, pagetitle, summary, 
			author, online, redirect, redirect, redirect_url,
			artsort, timemgmt, datestart, dateend, status, free_use_01,
			free_use_02, free_use_03, time_move_cat, time_target_cat,
			time_online_move, external_redirect, locked FROM
			".$cfg["tab"]["art_lang"]." WHERE idart = '".Contenido_Security::toInteger($srcidart)."' AND idlang='".Contenido_Security::toInteger($lang)."'";
	$db->query($sql);
		
	while ($db->next_record())
	{
		
		$nextid = $db2->nextid($cfg["tab"]["art_lang"]);
		/* Copy the template configuration */
		if ($db->f("idtplcfg") != 0)
		{
			$newidtplcfg = conCopyTemplateConfiguration($db->f("idtplcfg"));
		 	conCopyContainerConf($db->f("idtplcfg"), $newidtplcfg);	
		}
		
		conCopyContent($db->f("idartlang"), $nextid);		
		
		$idartlang = $nextid;
		$idart = $dstidart;
		$idlang = $db->f("idlang");
		$idtplcfg = $newidtplcfg;
		
		if ($newtitle != "")
		{
			$title = sprintf($newtitle, addslashes($db->f("title")));
		} else {
			$title = sprintf(i18n("%s (Copy)"), addslashes($db->f("title"))); 
		}
		$pagetitle = addslashes($db->f("pagetitle"));
		$summary = addslashes($db->f("summary"));
		$created = date("Y-m-d H:i:s");
		$author = $db->f("author");
		$online = 0;
		$redirect = $db->f("redirect");
		$redirecturl = $db->f("redirect_url");
		$artsort = $db->f("artsort");
		$timemgmt = $db->f("timemgmt");
		$datestart = $db->f("datestart");
		$dateend = $db->f("dateend");
		$status = $db->f("status");
		$freeuse01 = $db->f("free_use_01");
		$freeuse02 = $db->f("free_use_02");
		$freeuse03 = $db->f("free_use_03");
		$timemovecat = $db->f("time_move_cat");
		$timetargetcat = $db->f("time_target_cat");
		$timeonlinemove = $db->f("time_online_move");
		$externalredirect = $db->f("external_redirect");
		$locked = $db->f("locked");
		
		$sql = "INSERT INTO ".$cfg["tab"]["art_lang"]."
				(idartlang, idart, idlang, idtplcfg, title,
				pagetitle, summary, created, lastmodified,
				author, online, redirect, redirect_url,
				artsort, timemgmt, datestart, dateend, 
				status, free_use_01, free_use_02, free_use_03,
				time_move_cat, time_target_cat, time_online_move,
				external_redirect, locked) VALUES ('".Contenido_Security::toInteger($idartlang)."',
				'".Contenido_Security::toInteger($idart)."',
				'".Contenido_Security::toInteger($idlang)."',
				'".Contenido_Security::toInteger($idtplcfg)."',
				'".Contenido_Security::escapeDB($title, $db2)."',
				'".Contenido_Security::escapeDB($pagetitle, $db2)."',
				'".Contenido_Security::escapeDB($summary, $db2)."',
				'".Contenido_Security::escapeDB($created, $db2)."',
				'".Contenido_Security::escapeDB($created, $d2b)."',                
				'".Contenido_Security::escapeDB($author, $db2)."',
				'".Contenido_Security::toInteger($online)."',
				'".Contenido_Security::escapeDB($redirect, $db2)."',
				'".Contenido_Security::escapeDB($redirecturl, $db2)."',
				'".Contenido_Security::toInteger($artsort)."',
				'".Contenido_Security::toInteger($timemgmt)."',
				'".Contenido_Security::escapeDB($datestart, $db2)."',
				'".Contenido_Security::escapeDB($dateend, $db2)."',
				'".Contenido_Security::toInteger($status)."',
				'".Contenido_Security::toInteger($freeuse01)."',
				'".Contenido_Security::toInteger($freeuse02)."',
				'".Contenido_Security::toInteger($freeuse03)."',
				'".Contenido_Security::toInteger($timemovecat)."',
				'".Contenido_Security::toInteger($timetargetcat)."',
				'".Contenido_Security::toInteger($timeonlinemove)."',
				'".Contenido_Security::escapeDB($externalredirect, $db)."',
				'".Contenido_Security::toInteger($locked)."')";

		$db2->query($sql);
		
        // execute CEC hook
        $param = CEC_Hook::execute('Contenido.Article.conCopyArtLang_AfterInsert', array(
            'idartlang' => Contenido_Security::toInteger($idartlang), 
            'idart'     => Contenido_Security::toInteger($idart), 
            'idlang'    => Contenido_Security::toInteger($idlang),
            'idtplcfg'  => Contenido_Security::toInteger($idtplcfg), 
            'title'     => Contenido_Security::escapeDB($title, $db2)
        ));

		/* Copy meta tags */
		$sql = "SELECT idmetatype, metavalue FROM ".$cfg["tab"]["meta_tag"]." WHERE idartlang = '".Contenido_Security::toInteger($db->f("idartlang"))."'";
		$db->query($sql);
		
		while ($db->next_record())
		{
			$nextidmetatag = $db2->nextid($cfg["tab"]["meta_tag"]);
			$metatype = $db->f("idmetatype");
			$metavalue = $db->f("metavalue");
			$sql = "INSERT INTO ".$cfg["tab"]["meta_tag"]."
						(idmetatag, idartlang, idmetatype, metavalue)
						VALUES
						('".Contenido_Security::toInteger($nextidmetatag)."', '".Contenido_Security::toInteger($idartlang)."', '".Contenido_Security::toInteger($metatype)."', '".Contenido_Security::escapeDB($metavalue, $db2)."')";
			$db2->query($sql);
		}
		
		/* Update keyword list for new article */
		conMakeArticleIndex ($idartlang, $idart);
	}			
}


Vielleicht kann ja jemand drüberfliegen und mir ein paar Zeilen Code verraten... oder ist das doch ne größere Sache?



EDIT:

haha! Beim Duplizieren werden die META-Tags kopiert! Und im Code oben finde ich das:

Code: Alles auswählen

      /* Copy meta tags */
      $sql = "SELECT idmetatype, metavalue FROM ".$cfg["tab"]["meta_tag"]." WHERE idartlang = '".Contenido_Security::toInteger($db->f("idartlang"))."'";
      $db->query($sql);
      
      while ($db->next_record())
      {
         $nextidmetatag = $db2->nextid($cfg["tab"]["meta_tag"]);
         $metatype = $db->f("idmetatype");
         $metavalue = $db->f("metavalue");
         $sql = "INSERT INTO ".$cfg["tab"]["meta_tag"]."
                  (idmetatag, idartlang, idmetatype, metavalue)
                  VALUES
                  ('".Contenido_Security::toInteger($nextidmetatag)."', '".Contenido_Security::toInteger($idartlang)."', '".Contenido_Security::toInteger($metatype)."', '".Contenido_Security::escapeDB($metavalue, $db2)."')";
         $db2->query($sql);
      }
      
Wäre das ein Ansatz?

Und jetzt, jetzt komm ich sicher nicht mehr weiter :( Kann sich jemand mal opfern zu gucken?
stefkey
Beiträge: 556
Registriert: Mi 19. Okt 2005, 16:10
Wohnort: Heidelberg
Kontaktdaten:

Re: "geändert Datum" beim Duplizieren auch kopieren

Beitrag von stefkey »

Na und ob ich es wohl geschafft habe! Hier die Änderung in der function.con.php

Die Zeilen die ersetzt wurden sind mit /* auskommentiert, die Zeilen die stattdessen stehen sind mit /* + */ am Zeilenbeginn kommentiert.
Das braucht vermutlich nie jemand aber trotzdem hier der Code damit ich wenigstens auch mal etwas beitragen kann und nicht immer nur blöde Freagen habe...
Es werden folgende Artikel Eigenschaften mit kopiert: $created, $lastmodified, $author, $modifiedby, $published, $publishedby, $online,
Danke und viel Erfolg weiterhin!

Code: Alles auswählen

function conCopyArtLang ($srcidart, $dstidart, $newtitle)
{
	global $cfg, $lang;
	
	$db = new DB_Contenido;
	$db2 = new DB_Contenido;

/* SJ 	$sql = "SELECT idartlang, idlang, idtplcfg, title, pagetitle, summary, */
/* SJ			author, online, redirect, redirect, redirect_url, */
	$sql = "SELECT idartlang, idlang, idtplcfg, title, urlname, pagetitle, summary, created, lastmodified,
			author, modifiedby, published, publishedby, online, redirect, redirect_url,
			artsort, timemgmt, datestart, dateend, status, free_use_01,
			free_use_02, free_use_03, time_move_cat, time_target_cat,
			time_online_move, external_redirect, locked FROM
			".$cfg["tab"]["art_lang"]." WHERE idart = '".Contenido_Security::toInteger($srcidart)."' AND idlang='".Contenido_Security::toInteger($lang)."'";
	$db->query($sql);
		
	while ($db->next_record())
	{
		
		$nextid = $db2->nextid($cfg["tab"]["art_lang"]);
		/* Copy the template configuration */
		if ($db->f("idtplcfg") != 0)
		{
			$newidtplcfg = conCopyTemplateConfiguration($db->f("idtplcfg"));
		 	conCopyContainerConf($db->f("idtplcfg"), $newidtplcfg);	
		}
		
		conCopyContent($db->f("idartlang"), $nextid);		
		
		$idartlang = $nextid;
		$idart = $dstidart;
		$idlang = $db->f("idlang");
		$idtplcfg = $newidtplcfg;
		
		if ($newtitle != "")
		{
			$title = sprintf($newtitle, addslashes($db->f("title")));
		} else {
			$title = sprintf(i18n("%s (Copy)"), addslashes($db->f("title"))); 
		}
		$title = $db->f("title");
		$urlname = $db->f("urlname");
		$pagetitle = addslashes($db->f("pagetitle"));
		$summary = addslashes($db->f("summary"));
/* -		$created = date("Y-m-d H:i:s"); */
/* + */ 	$created = $db->f("created");
/* + */		$lastmodified = $db->f("lastmodified");
		$author = $db->f("author");
/* + */		$modifiedby = $db->f("modifiedby");
/* + */		$published = $db->f("published");
/* + */		$publishedby = $db->f("publishedby");
/* -		$online = 0; */
/* + */		$online = $db->f("online");
		$redirect = $db->f("redirect");
		$redirecturl = $db->f("redirect_url");
		$artsort = $db->f("artsort");
		$timemgmt = $db->f("timemgmt");
		$datestart = $db->f("datestart");
		$dateend = $db->f("dateend");
		$status = $db->f("status");
		$freeuse01 = $db->f("free_use_01");
		$freeuse02 = $db->f("free_use_02");
		$freeuse03 = $db->f("free_use_03");
		$timemovecat = $db->f("time_move_cat");
		$timetargetcat = $db->f("time_target_cat");
		$timeonlinemove = $db->f("time_online_move");
		$externalredirect = $db->f("external_redirect");
		$locked = $db->f("locked");
		
		$sql = "INSERT INTO ".$cfg["tab"]["art_lang"]."
				(idartlang, idart, idlang, idtplcfg, title, urlname,
				pagetitle, summary, created, lastmodified,
/* SJ				author, online, redirect, redirect_url, */
				author, modifiedby, published, publishedby, online, redirect, redirect_url,
				artsort, timemgmt, datestart, dateend,
				status, free_use_01, free_use_02, free_use_03,
				time_move_cat, time_target_cat, time_online_move,
				external_redirect, locked) VALUES ('".Contenido_Security::toInteger($idartlang)."',
				'".Contenido_Security::toInteger($idart)."',
				'".Contenido_Security::toInteger($idlang)."',
				'".Contenido_Security::toInteger($idtplcfg)."',
				'".Contenido_Security::escapeDB($title, $db2)."',
/* + */				'".Contenido_Security::escapeDB($urlname, $db2)."',
				'".Contenido_Security::escapeDB($pagetitle, $db2)."',
				'".Contenido_Security::escapeDB($summary, $db2)."',
				'".Contenido_Security::escapeDB($created, $db2)."',
				'".Contenido_Security::escapeDB($lastmodified, $d2b)."',                
				'".Contenido_Security::escapeDB($author, $db2)."',
/* + */				'".Contenido_Security::escapeDB($modifiedby, $db2)."',
/* + */				'".Contenido_Security::escapeDB($published, $db2)."',
/* + */				'".Contenido_Security::escapeDB($publishedby, $db2)."',
				'".Contenido_Security::toInteger($online)."',
				'".Contenido_Security::escapeDB($redirect, $db2)."',
				'".Contenido_Security::escapeDB($redirecturl, $db2)."',
				'".Contenido_Security::toInteger($artsort)."',
				'".Contenido_Security::toInteger($timemgmt)."',
				'".Contenido_Security::escapeDB($datestart, $db2)."',
				'".Contenido_Security::escapeDB($dateend, $db2)."',
				'".Contenido_Security::toInteger($status)."',
				'".Contenido_Security::toInteger($freeuse01)."',
				'".Contenido_Security::toInteger($freeuse02)."',
				'".Contenido_Security::toInteger($freeuse03)."',
				'".Contenido_Security::toInteger($timemovecat)."',
				'".Contenido_Security::toInteger($timetargetcat)."',
				'".Contenido_Security::toInteger($timeonlinemove)."',
				'".Contenido_Security::escapeDB($externalredirect, $db)."',
				'".Contenido_Security::toInteger($locked)."')";

		$db2->query($sql);
		
        // execute CEC hook
        $param = CEC_Hook::execute('Contenido.Article.conCopyArtLang_AfterInsert', array(
            'idartlang' => Contenido_Security::toInteger($idartlang), 
            'idart'     => Contenido_Security::toInteger($idart), 
            'idlang'    => Contenido_Security::toInteger($idlang),
            'idtplcfg'  => Contenido_Security::toInteger($idtplcfg), 
            'title'     => Contenido_Security::escapeDB($title, $db2)
        ));

		/* Copy meta tags */
		$sql = "SELECT idmetatype, metavalue FROM ".$cfg["tab"]["meta_tag"]." WHERE idartlang = '".Contenido_Security::toInteger($db->f("idartlang"))."'";
		$db->query($sql);
		
		while ($db->next_record())
		{
			$nextidmetatag = $db2->nextid($cfg["tab"]["meta_tag"]);
			$metatype = $db->f("idmetatype");
			$metavalue = $db->f("metavalue");
			$sql = "INSERT INTO ".$cfg["tab"]["meta_tag"]."
						(idmetatag, idartlang, idmetatype, metavalue)
						VALUES
						('".Contenido_Security::toInteger($nextidmetatag)."', '".Contenido_Security::toInteger($idartlang)."', '".Contenido_Security::toInteger($metatype)."', '".Contenido_Security::escapeDB($metavalue, $db2)."')";
			$db2->query($sql);
		}
		
		/* Update keyword list for new article */
		conMakeArticleIndex ($idartlang, $idart);
	}			
}
Gesperrt