Location: PHPKode > projects > Content*Builder > contentbuilder/plugins/article2/artAdd2.inc.php
<?
	$link1 = $PHP_SELF.'?load='.$config["urlIdent"].'&sub=artAdd&'.SID;

	$noDisplay = true;
	
	if(!(ADMIN & $cbPerms)) {
		if(!(ADD_ART & $cbPerms)) {
			echo $error_msg["permission-denied"];
			exit();
		}
	}

	extract($HTTP_POST_VARS);

	if(empty($id)) {
		header("Location: ".$link1);
		exit();
	} else {
		
		if(empty($language) || !ereg("(^[1-9]?[0-9]*$)", $language)) {
			echo "test";
			header("Location: ".$link1);
			exit();
		}
		
        if($loadfrom == "xml"){ // lade Artikel-Daten aus XML anstelle aus der Mysql-DB ...
            // if xmlfile is not set in QUERY_STRING ... ; empty string means latest version ...
            if (! $xmlfile) { $xmlfile=""; }
            // Anlegen des Objektes per Referenz ( notify '&' header )
            $xmlDocument = & new xmldocument($id."_".$language,$cbUserID,"","");
            // if called without filename, request latest xml-data ..
            if ($xmlDocument->loadXmlFile($xmlfile)){
               // getting data structure from object ...
               $data=$xmlDocument->get_xmldata();
               // never never use xmldocument object members directly from stdout routines ...

               // assign xml-nodenames / xml-values to CB-article vars ....
               foreach ($data[3] as $keys => $values){
                   $$values["name"]=$values["value"];
                   //trigger_error("\$".$values['name']."=".$$values['name']);
               }
            }
        } else {  // alternativ lade Artikel-Daten aus Mysql-DB (Standard)
		//  Reading Article General Data
		    $select = mysql_query("SELECT mediaID, folderID, userID, title AS workingTitle, datetime, stage, parse, options, languages FROM ".TABLE."_art_general WHERE ide = '$id'");
		    $values = mysql_fetch_array($select);
		    foreach($values as $k => $value) {
                ${$k} = $value;
            }
			
			$folderQuery = mysql_fetch_array(mysql_query("SELECT fname FROM ".TABLE."_columns WHERE fid = '$folderID'"));
			$folderName  = $folderQuery[fname];
			
		    $authorQuery = mysql_fetch_array(mysql_query("SELECT * FROM ".TABLE."_user AS user WHERE user.userid = '$cbUserID'"));
		    if(($values['userID'] != $authorQuery['userid']) && !(MOD_ALL & $cbPerms) && !(ADMIN & $cbPerms)) {
                $cancel = true;
			    $modError['wrongUser'] = true;
		     }
		     if(empty($values)) {
			     $cancel = true;
			     $modError['wrongID'] = true;
             }
		
		     //  Reading Article Content
		     $select2 = mysql_query("SELECT * FROM ".TABLE."_art_content WHERE ide = '$id' AND language = '$language'");
		     $values  = mysql_fetch_array($select2);
		     if(!is_array($values)) {
                $languages |= $language;
			    mysql_query("UPDATE ".TABLE."_art_general SET languages = '$languages' WHERE ide = '$id'");
			    mysql_query("INSERT INTO ".TABLE."_art_content (ide, language) VALUES ('$id', '$language')");
				
				$content     = "";
				$intro       = "";
				$title       = "";
				$keywords    = "";
				$description = "";
		     } else {
                foreach($values as $k => $value) {
				   ${$k} = $value;
			    }
             }
         }   // end of data grab routines ... (from db or xml ...)
         
		/********* 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->replaceImagesToKey($intro);
			$content=$sext_rp->replaceImagesToKey($content);
			$intro=$sext_rp->replaceTextToKey($intro);
			$content=$sext_rp->replaceTextToKey($content);
		}
		/********** REPLACEMENT END ***********/
		
		// the following much longer code was stripped out to file prepareFunctions.php
		// providing more straightforward reading ...
        $intro=prepareDisplay($parse,$intro,$autoadd);
        $content=prepareDisplay($parse,$content,$autoadd);
   	}

	# ab hier wieder Standard ...		
	
	if(!$cancel) {
		$BTPL_location = $cbOption->getSingleOption("BTPL_location");
			
		$fetchFolder = mysql_fetch_object(mysql_query("SELECT * FROM ".TABLE."_columns WHERE fid = '$folderID'"));
	
		/* BTPL Skin Selector */
		$BTPL_skinSelected = "default";
		if($fetchFolder->skin != "") {
			if(is_dir($BTPL_location."templates/".$fetchFolder->skin)) {
				$BTPL_skinSelected = $fetchFolder->skin;
			}
		}
		/* BTPL Skin Selector Ende */
			
		if(!empty($BTPL_location) && is_file($BTPL_location."index.php") && is_dir($BTPL_location."templates")) {
			$artTemplate = $template;
			/* Skin Finder */
			$artTplDirArray  = array();
			$artTplCounter   = 0;
			
			if(is_dir($BTPL_location."templates/".$BTPL_skinSelected."/modules/article2/")) {
				$dir2scan = $BTPL_location."templates/".$BTPL_skinSelected."/modules/article2/";
			} else {
				$dir2scan = $BTPL_location."modules/article2/templates/";
			}
			 
			$artTplDir = dir($dir2scan);
			while($artTplDirEntry = $artTplDir->read()) {
				$noInclude = false;
				if(is_dir($dir2scan.$artTplDirEntry) && ($artTplDirEntry != ".") && ($artTplDirEntry != "..")) {
					if(file_exists($dir2scan.$artTplDirEntry."/overview.template")) {
						if($artTemplate == $artTplDirEntry) {
							$artTplSelected[] = "selected";
						} else {
							$artTplSelected[] = "";
						}
						$artTplDirArray[] = $artTplDirEntry;
						++$artTplCounter;
					}
				}
			}
			$artTplDir->close();
				
			$tpl->assign("style_option", 
				array ( "TPLNAME"      => $artTplDirArray,
						"SELECTED"     => $artTplSelected
				)
			);
			$tpl->assign("style_set", "1");
		}
		
		$tpl->assign( "articleData",
			array ( "parse"        => $parse,
					"id"           => $id,
					"mediaID"      => $mediaID,
					"workingTitle" => stripslashes($workingTitle),
					"folderName"   => stripslashes($folderName),
					"title"        => stripslashes($title),
					"keywords"     => $keywords,
					"description"  => $description,
					"intro"        => stripslashes($intro),
					"content"      => stripslashes($content),
					"lang"         => $lang_pf,
					"languageID"   => $language
			)
		);
		
		$tpl->assign( "back_form_set", "1" );

		// meikelator 2002-11-24: adding mediaID-Info for DHTML-Editor intro-path
		
		$tpl->assign("add2_form",
			array ( 
					"MODIFY_ICON"     => $amText["modify_icon"]
			)
		);

		if($parse == HTML_PLAIN) {
			$tpl->assign("parseData", 
				array ( "parseType"  => "HTML_PLAIN",
						"br_box"      => "1"
				)
			);
		} else if ($parse == DHTML_MS) {
			$tpl->assign("parseData", 
				array ( "parseType"   => "DHTML_MS",
						"DHTML_MS_URL" => $editorConfig[DHTML_MS]["edit_url"]
				)
			);
   		} else {
			$tpl->assign("parseData", 
				array ( "parseType"   => "OTHER")
			);
		}

		$tpl->assign("add2_form_set", "1");
	} else {
		if($modError['wrongUser'] == true) { 
			$errorList[] = $amError['wrongUser']; 
		}
		if($modError['wrongID'] == true)	{ 
			$errorList[] = $amError['wrongID']; 
		}
	}
	
	$tpl->assign("article_set", "1");
	
	# alle bestehenden Editoren ausser der DHTML-Editor verwenden eine Standard-Template-Datei
	# fuer die Formular-Anzeige ...
	# written by Deka
	# --> falsch 
	# In der Editors.config.php wird festgelegt, welcher Editor welches Template nutzt
	# by F.o.G.
	$mainPluginContent[]  = $tpl->fetch($config['templates']."scripts.template", null, "pluginArticle2".$cbUserID);
	$mainPluginContent[]  = $tpl->fetch($config['templates'].$editorConfig[$parse]['edit_tpl'], null, "pluginArticle2".$cbUserID);
	
	if(count($errorList) > 0) {
		$tpl->assign("errorSet", "1");
		$tpl->assign("errorList", $errorList);
	}
	
	$mainMessageContent[] = $tpl->fetch($config['templates']."messages.template", null, "pluginArticle2".$cbUserID);
?>
Return current item: Content*Builder