$notification->displayNotification("error",i18n("Could not set the language-ID in the file 'config.php'. Please set the language manually."));
}
}
/**
*Renamealanguage
*
*@authorJanLengowski<Jan.Lengowski@4fb.de>
*@authorOlafNiemann<Olaf.Niemann@4fb.de>
*@copyrightfourforbusinessAG<www.4fb.de>
*/
functionlangRenameLanguage($idlang,$name){
global$db;
global$cfg;
$sql="UPDATE ".$cfg["tab"]["lang"]." SET name='".Contenido_Security::escapeDB($name,$db)."' WHERE idlang='".Contenido_Security::toInteger($idlang)."'";
$sql="SELECT * FROM ".$cfg["tab"]["clients_lang"]." WHERE idclient='".Contenido_Security::toInteger($client)."' ORDER BY idlang ASC";
$db->query($sql);
if($db->next_record()){//***********if there is already a language copy from it
$firstlang=$db->f("idlang");
//***********duplicate entries in 'art_lang'-table*************
$sql="SELECT * FROM ".$cfg["tab"]["art_lang"]." AS A, ".$cfg["tab"]["art"]." AS B WHERE A.idart=B.idart AND B.idclient='".Contenido_Security::toInteger($client)."' AND idlang!='0'
//********* make changes to new entry*************
$date=date("Y-m-d H:i:s");
$sql="SELECT * FROM ".$cfg["tab"]["art_lang"]." AS A, ".$cfg["tab"]["art"]." AS B WHERE A.idart=B.idart AND B.idclient='".Contenido_Security::toInteger($client)."' AND idlang='".Contenido_Security::toInteger($idlang)."'";
$db2->query($sql);
while($db2->next_record()){
$a_artlang[]=$db2->f("idartlang");
}
foreach($a_artlangas$val_artlang){
$sql="UPDATE ".$cfg["tab"]["art_lang"]." SET created='".Contenido_Security::escapeDB($date,$db2)."', lastmodified='0', online='0', author='' WHERE idartlang='".Contenido_Security::toInteger($val_artlang)."'";
$db2->query($sql);
}
}
fakeheader(time());
/* Duplicate all entries in the 'cat_lang' table */
//********* duplicates entry in DB ****************
$sql="INSERT INTO ".$cfg["tab"]["cat_lang"]." (idcatlang, ".Contenido_Security::escapeDB($keystring,$db2).") VALUES ('".Contenido_Security::toInteger($nextid)."', ".Contenido_Security::escapeDB($valuestring,$db2).")";
$db2->query($sql);
//********* make changes to new entry*************
$sql="SELECT * FROM ".$cfg["tab"]["cat_lang"]." AS A, ".$cfg["tab"]["cat"]." AS B WHERE A.idcat=B.idcat AND B.idclient='".Contenido_Security::toInteger($client)."' AND idlang='".Contenido_Security::toInteger($idlang)."'";
$db2->query($sql);
while($db2->next_record()){
$a_catlang[]=$db2->f("idcatlang");
}
foreach($a_catlangas$val_catlang){
$sql="UPDATE ".$cfg["tab"]["cat_lang"]." SET visible='0' WHERE idcatlang='".Contenido_Security::toInteger($val_catlang)."'";
$db2->query($sql);
}
}
//***********duplicate entries in 'stat'-table*************
$sql="SELECT * FROM ".$cfg["tab"]["stat"]." WHERE idclient='".Contenido_Security::toInteger($client)."' AND idlang='".Contenido_Security::toInteger($firstlang)."'";
//********* duplicates entry in DB ****************
$sql="INSERT INTO ".$cfg["tab"]["stat"]." (idstat, ".Contenido_Security::escapeDB($keystring,$db2).") VALUES ('".Contenido_Security::toInteger($db->nextid($cfg["tab"]["stat"]))."', ".Contenido_Security::escapeDB($valuestring,$db2).")";
$db2->query($sql);
//********* make changes to new entry*************
$sql="UPDATE ".$cfg["tab"]["stat"]." SET visited='0' WHERE idclient='".Contenido_Security::toInteger($client)."' AND idlang='".Contenido_Security::toInteger($idlang)."'";
$db2->query($sql);
}
fakeheader(time());
//***********duplicate entries in 'tpl_conf'-table*************
$sql="SELECT * FROM ".$cfg["tab"]["tpl_conf"];
$db->query($sql);
/* Array storing the category->template allocations fot later reallocation */
$cfg_old_new=array();
while($db->next_record()){
$nextid=$db2->nextid($cfg["tab"]["tpl_conf"]);
/* Array storing the category->template allocations fot later reallocation */
//********* duplicates entry in DB ****************
$sql="INSERT INTO ".$cfg["tab"]["tpl_conf"]." (idtplcfg, ".Contenido_Security::escapeDB($keystring,$db2).") VALUES ('".Contenido_Security::toInteger($nextid)."', ".Contenido_Security::escapeDB($valuestring,$db2).")";
$db2->query($sql);
}
/*
-REMARK-JL-15.07.03
Availabletpl-cfgallocationarraysare:
$cfg_cat=array('idcatlang'=>n,
'idtplcfg'=>n);
$cfg_art=array('idartlang'=>n,
'idtplcfg'=>n);
$cfg_old_new=array('oldidtplcfg'=>n,
'newidtplcfg'=>n);
*/
/* Copy the template configuration data */
if(is_array($cfg_old_new)){
foreach($cfg_old_newas$data){
$oldidtplcfg=$data['oldidtplcfg'];
$newidtplcfg=$data['newidtplcfg'];
$sql="SELECT number, container FROM ".$cfg["tab"]["container_conf"]." WHERE idtplcfg = '".Contenido_Security::toInteger($oldidtplcfg)."' ORDER BY number ASC";
/* Reallocate the category -> templatecfg allocations */
if(is_array($cfg_cat)){
foreach($cfg_catas$data){
if($data['idtplcfg']!=0){
// Category has a configuration
foreach($cfg_old_newas$arr){
if($data['idtplcfg']==$arr['oldidtplcfg']){
$sql="UPDATE ".$cfg["tab"]["cat_lang"]." SET idtplcfg = '".Contenido_Security::toInteger($arr['newidtplcfg'])."' WHERE idcatlang = '".Contenido_Security::toInteger($data['idcatlang'])."'";
$db->query($sql);
}
}
}
}
}
/* Reallocate the article -> templatecfg allocations */
if(is_array($cfg_art)){
foreach($cfg_artas$data){
if($data['idtplcfg']!=0){
// Category has a configuration
foreach($cfg_old_newas$arr){
if($data['idtplcfg']==$arr['oldidtplcfg']){
// We have a match :)
$sql="UPDATE ".$cfg["tab"]["art_lang"]." SET idtplcfg = '".Contenido_Security::toInteger($arr['newidtplcfg'])."' WHERE idartlang = '".Contenido_Security::toInteger($data['idartlang'])."'";
//************ check if there are still arts online
$sql="SELECT * FROM ".$cfg["tab"]["art_lang"]." AS A, ".$cfg["tab"]["art"]." AS B WHERE A.idart=B.idart AND B.idclient='".Contenido_Security::toInteger($idclient)."'
//************ check if there are visible categories
$sql="SELECT * FROM ".$cfg["tab"]["cat_lang"]." AS A, ".$cfg["tab"]["cat"]." AS B WHERE A.idcat=B.idcat AND B.idclient='".Contenido_Security::toInteger($idclient)."'
//********* check if this is the clients last language to be deleted, if yes delete from art, cat, and cat_art as well *******
$lastlanguage=0;
$sql="SELECT COUNT(*) FROM ".$cfg["tab"]["clients_lang"]." WHERE idclient='".Contenido_Security::toInteger($idclient)."'";
$db->query($sql);
$db->next_record();
if($db->f(0)==1){
$lastlanguage=1;
}
//********** delete from 'art_lang'-table *************
$sql="SELECT A.idtplcfg AS idtplcfg, idartlang, A.idart FROM ".$cfg["tab"]["art_lang"]." AS A, ".$cfg["tab"]["art"]." AS B WHERE A.idart=B.idart AND B.idclient='".Contenido_Security::toInteger($idclient)."'
$sql="DELETE FROM ".$cfg["tab"]["art_lang"]." WHERE idartlang='".Contenido_Security::escapeDB($value,$db)."'";
$db->query($sql);
$sql="DELETE FROM ".$cfg["tab"]["content"]." WHERE idartlang='".Contenido_Security::escapeDB($value,$db)."'";
$db->query($sql);
$sql="DELETE FROM ".$cfg["tab"]["link"]." WHERE idartlang='".Contenido_Security::escapeDB($value,$db)."'";
$db->query($sql);
}
}
if($lastlanguage==1){
if(is_array($a_idart)){
foreach($a_idartas$value){
$sql="DELETE FROM ".$cfg["tab"]["art"]." WHERE idart='".Contenido_Security::escapeDB($value,$db)."'";
$db->query($sql);
$sql="DELETE FROM ".$cfg["tab"]["cat_art"]." WHERE idart='".Contenido_Security::escapeDB($value,$db)."'";
$db->query($sql);
}
}
}
//********** delete from 'cat_lang'-table *************
$sql="SELECT A.idtplcfg AS idtplcfg, idcatlang, A.idcat FROM ".$cfg["tab"]["cat_lang"]." AS A, ".$cfg["tab"]["cat"]." AS B WHERE A.idcat=B.idcat AND B.idclient='".Contenido_Security::toInteger($idclient)."'
$sql="DELETE FROM ".$cfg["tab"]["cat_lang"]." WHERE idcatlang='".Contenido_Security::escapeDB($value,$db)."'";
$db->query($sql);
}
}
if($lastlanguage==1){
if(is_array($a_idcat)){
foreach($a_idcatas$value){
$sql="DELETE FROM ".$cfg["tab"]["cat"]." WHERE idcat='".Contenido_Security::escapeDB($value,$db)."'";
$db->query($sql);
$sql="DELETE FROM ".$cfg["tab"]["cat_tree"]." WHERE idcat='".Contenido_Security::escapeDB($value,$db)."'";
$db->query($sql);
}
}
}
//********** delete from 'stat'-table *************
$sql="DELETE FROM ".$cfg["tab"]["stat"]." WHERE idlang='".Contenido_Security::toInteger($idlang)."' AND idclient='".Contenido_Security::toInteger($idclient)."'";
$db->query($sql);
//********** delete from 'code'-table *************
$sql="DELETE FROM ".$cfg["tab"]["code"]." WHERE idlang='".Contenido_Security::toInteger($idlang)."' AND idclient='".Contenido_Security::toInteger($idclient)."'";
$db->query($sql);
if(is_array($a_idtplcfg)){
foreach($a_idtplcfgas$tplcfg){
if($tplcfg!=0){
//********** delete from 'tpl_conf'-table *************
$sql="DELETE FROM ".$cfg["tab"]["tpl_conf"]." WHERE idtplcfg='".Contenido_Security::toInteger($tplcfg)."'";
$db->query($sql);
//********** delete from 'container_conf'-table *************
$sql="DELETE FROM ".$cfg["tab"]["container_conf"]." WHERE idtplcfg='".Contenido_Security::toInteger($tplcfg)."'";
$db->query($sql);
}
}
}
//*********** delete from 'clients_lang'-table*************
$sql="DELETE FROM ".$cfg["tab"]["clients_lang"]." WHERE idclient='".Contenido_Security::toInteger($idclient)."' AND idlang='".Contenido_Security::toInteger($idlang)."'";
$db->query($sql);
//*********** delete from 'lang'-table*************
$sql="DELETE FROM ".$cfg["tab"]["lang"]." WHERE idlang='".Contenido_Security::toInteger($idlang)."'";
$db->query($sql);
}else{
return$notification->messageBox("error",i18n("Could not delete language"),0);
$sql="UPDATE ".$cfg["tab"]["lang"]." SET active='".Contenido_Security::toInteger($active)."' WHERE idlang='".Contenido_Security::toInteger($idlang)."'";
$db->query($sql);
}
functionlangGetTextDirection($idlang,$db=null){
global$cfg;
if($db==null||!is_object($db)){
$db=newDB_ConLite;
}
$sql="SELECT direction FROM ".$cfg["tab"]["lang"]." WHERE idlang='".Contenido_Security::toInteger($idlang)."'";