Location: PHPKode > projects > Content*Builder > contentbuilder/plugins/article2/artAdd3.inc.php
<?php
	// +----------------------------------------------------------------------+
	// | artAdd3.inc.php                                                      |
	// +----------------------------------------------------------------------+
	// | Copyright (c) 1997-2003 The C*B Development Group                    |
	// +----------------------------------------------------------------------+
	// | This source file is subject to version 1.0 of the CB license,        |
	// | that is bundled with this package in the file license.txt            |
	// | If you did not receive a copy of the PHP license please send a       |
	// | note to hide@address.com so we can mail you            |
	// | a copy immediately.                                                  |
	// +----------------------------------------------------------------------+
	// | Authors: Jörg Stöber <hide@address.com>                |
	// |          Michael Pfannkuchen <hide@address.com>                |
	// | $Id: artAdd3.inc.php,v 1.3 2004/09/19 19:33:10 cb_fog Exp $
	// +----------------------------------------------------------------------+

	/* 
	* Usage of this sub-plugin-file (sub='artadd3'):
	* Speichern der Daten nach dem Editieren in der Datenbank 
	*/
	
	if(isset($deleteNode)) {
		if($articlePerms->hasEditPermission($id)) {
			$delNodeInfo  = $nestedSet->getNode($deleteNode);
			if($delNodeInfo[ide] != $delNodeInfo[rootID]) {
				$deletedNodes = $nestedSet->deleteNode($deleteNode);
				foreach($deletedNodes as $v) {
					$dquery = mysql_query("DELETE FROM ".TABLE."_art_content WHERE ide = '$v'");
				}
			}
		}
	}
	
	$link1 = $PHP_SELF.'?load='.$config["urlIdent"].'&sub=artAdd&'.SID;
	$link2 = $PHP_SELF.'?load='.$config["urlIdent"].'&sub=artAdd2&id='.$id.'&'.SID;

	$tpl->assign("SUB", "artAdd");
	$tpl->assign("ID", $id);

	if(!ereg("(^[1-9]?[0-9]*$)", $id)) {
		unset($id);
	}
	
	if($articlePerms->hasEditPermission($id)) {
		if(!empty($artDeleteVersion) && ereg("(^[1-9]?[0-9]*$)", $artDeleteVersion)) {
			$check = mysql_fetch_object(mysql_query("SELECT * FROM ".TABLE."_art_general WHERE ide = '$id'"));
			$languages = $check->languages;
			$languages = intval($languages);
			$permission = true;
			if(!(MOD_ALL & $cbPerms) && !(ADMIN & $cbPerms)) {
				if($check->userID != $cbUserID) {
					$permission = false;
				}
			}
			if($permission != false) {
				$artDeleteVersion = intval($artDeleteVersion);
				$languages &= ~$artDeleteVersion;
				$query1 = mysql_query("UPDATE ".TABLE."_art_general SET languages = '$languages' WHERE ide = '$id'");
				$query2 = mysql_query("DELETE FROM ".TABLE."_art_content WHERE ide = '$id' AND language = '$artDeleteVersion'");
			}
		}
		
		if($_POST[artVersionModify] == "1") {
			if(! ereg("(^[1-9]?[0-9]*$)", $language)) {
				$errorList[] = $error_msg["no_content"];
			}
			if ((! $intro) && (! $content)) {
				$errorList[] = "Javascript error: no WYSIWYG content grabbed with on_Submit() event";
			}
			if(! (count($errorList) > 0)) {
				if($cbOption->getSingleOption("requireintro") == 1 AND $intro == "") {
					$intro = "intro required";
				}
				$query = mysql_query("SELECT * FROM ".TABLE."_art_general WHERE ide = '$id'");
				$fetch = mysql_fetch_array($query,MYSQL_ASSOC);
				$intro_temp   = $intro;
				$content_temp = $content;
				
				// 1st remove all references to local host (name of this current server host)
				$title        = removeLocalDomainname($title);
				$intro        = removeLocalDomainname($intro);
				$content      = removeLocalDomainname($content);
				$description  = addslashes($description);
				$keywords     = addslashes($keywords);
				$keywords     = strip_tags($keywords);
				$title        = htmlspecialchars($title);
	
	            // editor (parse) dependend replacements before data saving in DB ...
	            $intro=prepareForSave($fetch["parse"],$intro,$autoadd);
	            $content=prepareForSave($fetch["parse"],$content,$autoadd);
		
				/********* REPLACEMENT START **********/
				// getting replacement object
	            if (! isset($sext_rp)){
	                $sext_rp = new sext_rp();
	            }
	            // if there are replacements set up in CB simple extension plugin do ...
	            if ($sext_rp->count > 0){
	                $intro=$sext_rp->replaceImagesToValue($intro);
	                $content=$sext_rp->replaceImagesToValue($content);
	                $intro=$sext_rp->replaceTextToValue($intro);
	                $content=$sext_rp->replaceTextToValue($content);
	            }
				
				/********** REPLACEMENT END ***********/
				if($cbOption->getSingleOption("change_author")) {
					$usrUpdate = mysql_query("UPDATE ".TABLE."_art_general SET userid = '$cbUserID' WHERE ide = '$id'");
				}
				if(!empty($artTemplate)) {
					$template = mysql_query("UPDATE ".TABLE."_art_general SET template = '$artTemplate' WHERE ide = '$id'");
				}
				
				$sql = "UPDATE ".TABLE."_art_content SET title = '$title', intro = '$intro', content = '$content', keywords = '$keywords', description = '$description' WHERE ide = '$id' AND language = '$language'";
				$query = mysql_query($sql);
				cb_log(9);
	            /* now saving XML-Datafile - it's easy done by grabbing structured data back from database ...
	            * ok, poor performance, but this is the editors frontend ... */
	            // 1st getting articla-Data in array ...
				$query = mysql_query("SELECT * FROM ".TABLE."_art_content WHERE ide = '$id' AND language = '$language'");
				$articleData = mysql_fetch_array($query,MYSQL_ASSOC);
	            // 2nd getting MetaInfo-Data in array ...
				$query = mysql_query("SELECT * FROM ".TABLE."_art_general WHERE ide = '$id'");
				$metaInfo = mysql_fetch_array($query,MYSQL_ASSOC);
				
	
	            // save xml-backup ... 2 lines, easy done ...
	            //trigger_error("\$id=".$id." \$language=".$language);
	            $xmlDocument = new xmldocument($id."_".$language,$cbUserID,$metaInfo,$articleData);
	            $xmlDocument->saveXmlFile();
			} else {
				$errorList[] = $error_msg["no_content"];
			}
		}
		
		$artContentLangID = array();
		$artLangIDArr = array_flip($artLangArr);
		$query  = mysql_query("SELECT language, title FROM ".TABLE."_art_content WHERE ide = '$id'");
		while($artContentRow = mysql_fetch_object($query)) {
			$artContentLangShort[] = $artLangIDArr[$artContentRow->language];
			$artContentLangID[]    = $artContentRow->language;
			$artContentVersionSet  = true;
		}
		$artLangNotSetArr = array_diff($artLangArr, $artContentLangID);
		foreach($artLangNotSetArr as $k => $v) {
			$artContentLangNotSetShort[] = $k;
			$artContentLangNotSetID[]    = $v;
		}
		$fetch  = mysql_fetch_array($query);
		$query  = mysql_query("SELECT * FROM ".TABLE."_art_general WHERE ide = '$id'");
		$fetch2 = mysql_fetch_array($query);
		
		if($artOption->getSingleOption("chapterControl")) {
			/* 
			* Den ganzen Zweig fürs Webdossier bekommen
			* $dArt = dossierArticle
			*/
			$dossierBranch = $nestedSet->getBranch($fetch2[rootID]);
			if($dossierBranch != false) {
				foreach($dossierBranch as $v) {
					if($v[rootID] == $v[ide]) {
						$dArtHead[] = 1;
					} else {
						$dArtHead[] = 0;
					}
					if($v[ide] == $id) {
						$dArtActual[] = 1;
					} else {
						$dArtActual[] = 0;
					}
					$dArtTitle[] = $v[title];
					$dArtID[]    = $v[ide];
					$dArtParent[]= $v[parentID];
					$dArtLevel[] = $v[level];
					$dArtSpace[] = ($v[level] - 1) * 10;
				}
			}
			
			$tpl->assign("add3DossierRow",
				array ( "TITLE"  => $dArtTitle,
						"ID"     => $dArtID,
						"SPACE"  => $dArtSpace,
						"LEVEL"  => $dArtLevel,
						"MAIN"   => $dArtHead,
						"ACTUAL" => $dArtActual,
						"PARENT" => $dArtParent
				)
			);
			$tpl->assign("DOSSIER_DISPLAY", "1");
		} else {
			$tpl->assign("DOSSIER_DISPLAY", "0");
		}
		
		$tpl->assign("add3_overview",
			array ( "TITLE"           => $fetch2['title'],
					"DATE"            => $fetch2["datetime"],
					"ID"              => $id,
					"CLEAR"           => $amText["clearmessage"]
			)
		);
			
		if($artContentVersionSet) {
			$tpl->assign("artEditLang_set", "1");
		}
		$tpl->assign("artEditLangRow",
			array ( "LANGUAGE_SHORT"  => $artContentLangShort,
					"LANGUAGE_ID"     => $artContentLangID
			)
		);
		$tpl->assign("artAddLang",
			array ( "LANGUAGE_SHORT"  => $artContentLangNotSetShort,
					"LANGUAGE_ID"     => $artContentLangNotSetID
			)
		);
		$tpl->assign("add3_overview_set", "1");
		
		$mainPluginContent[]  = $tpl->fetch($config['templates']."scripts.template", null, "pluginArt2".$cbUserID);
		$mainPluginContent[]  = $tpl->fetch($config['templates']."add3.template", null, "pluginArt2".$cbUserID);
	} else {
	
	}
	
	/*
	* Fehler Liste ans Template senden, wenn vorhanden
	*/
	if(count($errorList) > 0) {
		$tpl->assign("errorSet", "1");
		$tpl->assign("errorList", $errorList);
	}
	
	$mainMessageContent[] = $tpl->fetch($config['templates']."messages.template", null, "pluginArt2".$cbUserID);
?>
Return current item: Content*Builder