Location: PHPKode > projects > Content*Builder > contentbuilder/plugins/article2/artAdd1.inc.php
<?php
// +----------------------------------------------------------------------+
// | artAdd1.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: artAdd1.inc.php,v 1.5 2004/09/29 17:18:17 cb_fog Exp $
// +----------------------------------------------------------------------+

$articleType = $articleType or $articleType = 'rootArticle';

$link1 = $PHP_SELF.'?load='.$config["urlIdent"].'&sub=artAdd&'.SID;
$link2 = $PHP_SELF.'?load='.$config["urlIdent"].'&sub=artAdd2&id='.$id.'&'.SID;

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

$errorSet = 0;
$error    = array();
/*
* Zugangsberechtigung testen
*/
if($articlePerms->hasAccess()) {
	$showAdd1Form = 1;
	
	if(empty($step2) AND ($_POST[artAddNewArticle] == 1)) {
		$cancel = false;
		$artCheck = mysql_fetch_array(mysql_query("SELECT ide, mediaID FROM ".TABLE."_art_general WHERE ide = '$id'"));
		//
		// Inserting global article directives into database.
		//
		if(empty($title)) {
			$error[] = $error_msg['not_all_set'];
			$errorSet = 1;
			$cancel = true;
		}
		
		$folder = trim($folder);
		$queryfolder = mysql_query("SELECT * FROM ".TABLE."_columns WHERE fid = '$folder'");
		if(mysql_num_rows($queryfolder) > 0) {
			$queryf = mysql_fetch_array($queryfolder);
		} else {
			$error[] = $error_msg["define_folder"];
			$errorSet = 1;
			$cancel = true;
		}
		
		/* Keine Zugriffsbeschränkung für Admins */
		if(!(ADMIN & $cbPerms)) {
			if($queryf["writestatus"] == "c") {
				$error[] = $error_msg["folder_closed"];
				$errorSet = 1;
				$cancel = true;
			}
		}

		/* 
		* Zeitabhängiges Veröffentlichen 
		*/
		if($from != "von" && $to != "bis" && !empty($from) && !empty($to)) {
			$from = trim($from);
			$to = trim($to);
			if(isset($from) AND isset($to)) {
				if(ereg("^[0-9]{2}.[0-9]{2}.[0-9]{4}$",$from)) {
					if(isset($from)) {
						$from = explode(".",$from);
						$from = $from[2]."".$from[1]."".$from[0]."000000";
						$from = trim($from);
					}
				}
				if(ereg("^[0-9]{2}.[0-9]{2}.[0-9]{4}$",$to)) {
					if(isset($to)) {
						$to = explode(".",$to);
						$to = $to[2]."".$to[1]."".$to[0]."000000";
						$to = trim($to);
					}
				}
				/*
				} else {
					$error[] = $error_msg['w_date_format'];
					$errorSet = 1;
					$cancel = true;
				}
				*/
			}
		}
		
		/* 
		* Optionen sind nun in einem Bitfeld kodiert 0. Bit = Print
		*/
		if($artChk[options] == "") { 
			$options = 0; 
		} else { 
			$options = $artChk[options]; 
		}
		
		$options &= ~ART_OPTION_PRINT; 
		if($print == 1) {
			$options |= ART_OPTION_PRINT;
		}

		/* Vordefiniert: Artikel ist offline */
		if(!$stage) { 
			$stage = 4;
		}
		
		if(count($error) == 0) {
			$mediaID = $artOption->getSingleOption("generalMedia");
			$title = trim($title);
			$title = strip_tags($title);
			$title = addslashes($title);
			$content = "n/a";
			
			/* aktuelles Datum ermitteln */
			$datum = date("Y-m-d H:i:s");

			if($articleType == 'rootArticle') {
				
				if($articlePerms->hasEditPermission($folder, array( "type" => "column"))) {
					/* 
					* NeSe Array setzen, dass die Daten enthält, die 
					* sich naturgemäß nicht aus der NeSe Logik ergeben
					* (zB. Name und UserID *G* )
					*/
					$ns_values = array (
						'fid'      => $folder,
						'user'     => $cbUserID,
						'title'    => $title,
						'datetime' => $datum,
						'pFrom'    => $from,
						'pTo'      => $to,
						'stage'    => $stage,
						'parse'    => $format,
						'options'  => $options
					);
					$id = $nestedSet->createRootNode($ns_values);
				}
			} elseif ($articleType == 'subArticle' && isset($parentID)) {
				if($articlePerms->hasEditPermission($parentID)) {
					/* 
					* NeSe Array setzen, dass die Daten enthält
					* Dabei sollen bestimmte Daten immer von den Eltern 
					* übernommen werden
					*/
					$parentData = $nestedSet->getNode($parentID);
					if($parentData != false) {
						$ns_values = array (
							'fid'      => $parentData[folderID],
							'user'     => $cbUserID,
							'title'    => $title,
							'datetime' => $datum,
							'pFrom'    => $parentData[publishFrom],
							'pTo'      => $parentData[publishTo],
							'stage'    => $stage,
							'parse'    => $format,
							'options'  => $parentData[options]
						);
						$id = $nestedSet->createSubNode($parentID, $ns_values);
					}
				}
			}
			cb_log(8);
			$showAdd1Form = 0;
		}
	}

	if((empty($id) OR isset($cancel)) && $showAdd1Form != 0) {
		$defaultEditorSelected[$cbOption->getSingleOption("defaultEditor")] = "selected";
		## setting arrays for format HTML select template
		// Row1
		$format_value[]	 = 0;
		$format_text[]   = "HTML";
		$format_selected[] = $defaultEditorSelected[0];
		// Row 2
		$format_value[]	 = 1;
		$format_text[]   = "Extended Text (TAG-System)";
		$format_selected[] = $defaultEditorSelected[1];
		// Row 3
		$format_value[]	 = 2;
		$format_text[]   = "Text-Only";
		$format_selected[] = $defaultEditorSelected[2];
		// Row4
		$format_value[]	 = 3;
		$format_text[]   = "DHTML Editor";
		$format_selected[] = $defaultEditorSelected[3];
		// Row5
		$format_value[]	 = 4;
		$format_text[]   = "HTML Area";
		$format_selected[] = $defaultEditorSelected[4];
			
		if($options & ART_OPTION_PRINT) { 
			$printChk = "checked"; 
		}
		
		/* 
		* Folder should only be visible to root Nodes 
		*/
		if($articleType == "rootArticle") {
			$artAdd_template = "add1Root";
			/* Collecting the Folder Tree Data */
			$folderTree = $nestedSet_folder->getAllNodes(true);
			if($folderTree != false) {
				foreach($folderTree as $v) {
					$folderListID[]    = $v[id];
					$folderListName[]  = $v[name];
					$folderListSpace[] = ($v[level] - 1) * 20;
				}
			}
			
			$tpl->assign($artAdd_template."FolderTreeRow",
				array ( "FNAME"		=> $folderListName,
						"ID"		=> $folderListID,
						"SPACE"		=> $folderListSpace,
						"SELECTED"	=> $folderListSelect
				)
			);
			$tpl->assign($artAdd_template."FolderTree_set", "1");
		} else {
			$artAdd_template = "add1Sub";
			$tpl->assign($artAdd_template."FolderTree_set", "0");
		}
		
		$tpl->assign("articleType", $articleType);
		
		$tpl->assign($artAdd_template."Form",
			array ( "TXT_ICON"	 => $amText["article_icon"],
					"VAL_PRINT"  => "1",
					"CHK_PRINT"  => $printChk,
					"ID"		 => $id,
					"LANG"		 => $lang_pf,
					"TITLE"		 => $title, 
					"ARTTYPE"    => $articleType,
					"PARENTID"   => $parentID
			)
		);
		
		$tpl->assign($artAdd_template."Format",
			array ( "VALUE"		=> $format_value,
					"SELECTED"	=> $format_selected,
					"TEXT"		=> $format_text
			)
		);

		if($cbOption->getSingleOption("timepost") == 1) {
			$tpl->assign($artAdd_template."Timepost",
				array ( "VAL_FROM"	   => date("d.m.Y"),
						"VAL_TO"	   => date("d.m.Y")
				)
			);
			$tpl->assign($artAdd_template."Timepost_set", "1");
		}

		if($cbOption->getSingleOption("artstatus") == 1) {
			for($z = 1; $z < 4; $z++) {
				if($stage == $z) {
					$stages[($z-1)] = 'selected';
				}
			}
			## setting arrays for icon HTML select template
			// Row1
				$stage_value[]	 = "1";
				$stage_text[]	 = $amText["stage_development"];
			// Row 2
				$stage_value[]	 = "2";
				$stage_text[]	 = $amText["stage_review"];
			// Row 3
				$stage_value[]	 = "3";
				$stage_text[]	 = $amText["stage_published"];
			// Row 4
				$stage_value[]	 = "4";
				$stage_text[]	 = $amText["stage_invisible"];
				$stages[3]		 = 'selected';

			$tpl->assign($artAdd_template."Stage_set", "1");
			$tpl->assign($artAdd_template."StageRow",
				array ( "VALUE"		=> $stage_value,
						"SELECTED"	=> $stages,
						"TEXT"		=> $stage_text
				)
			);
		}
		$tpl->assign("STAGE", $stage);
		$tpl->assign($artAdd_template."Form_set", "1");

		if(count($error) > 0) {
			$tpl->assign("errorSet", "1");
			$tpl->assign("errorList", $error);
		}
		
		$mainPluginContent[]  = $tpl->fetch($config['templates']."add1.template", null, "pluginArt2".$cbUserID);
		$mainMessageContent[] = $tpl->fetch($config['templates']."messages.template", null, "pluginArt2".$cbUserID);
	} else {
		include($pluginLocation."/artAdd3.inc.php");
	}
}
?>
Return current item: Content*Builder