Location: PHPKode > projects > Content*Builder > contentbuilder/plugins/article2/artMove.inc.php
<?php
	require_once("Date.php");

	$tpl->assign("id", $id);
		
	$sortMethod = $artOption->getSingleOption("sortMethod");
	if(($sortMethod == ART_SORT_DATE) || ($sortMethod == "")) {
		$error[] = "Datum als Sortiermethode angegeben";
	}
	
	$articleCheck = mysql_query("SELECT datetime, order_num, folderID, ide, title FROM ".TABLE."_art_general WHERE ide = '".$_REQUEST[id]."'");
	$moveArtRow   = mysql_fetch_object($articleCheck);
	
	if(!($sortMethod == ART_SORT_DATE) && !($sortMethod == "")) {
		/*
		* Nur wenn Sortier Methode nicht nur nach Datum geht, ist eine 
		* Verschiebung per Nested Sets möglich / sinnhaft
		*/
		if(isset($_POST[moveArtTarget])) {
			$targetCheck  = mysql_query("SELECT ide FROM ".TABLE."_art_general WHERE ide = '".$_POST[moveArtTarget]."'");
			
			if($articleCheck && $targetCheck) {
				switch($_POST[moveArtAction]) {
					case "after":
						 $moveMethod = CB_NESE_MOVEAFTER;
						 break;
					default:
						 $moveMethod = CB_NESE_MOVEBEFORE;
				}
				
				$result = $nestedSet->moveBranch($_REQUEST[id], $_POST[moveArtTarget], $moveMethod);
			
				if($result != 0) {
					// DISPLAY TEMPLATE
					if($result == 2) {
						$error[] = $error_msg["branchIsChild"];
					}
					if($result == 1) {
						$error[] = $error_msg["fNotExists"];
					}
				}
			}
		}
		
		/*
		* Abfrage der Artikel ohne BerĂĽcksichtigung des Datums
		*/
		$articleQuery = mysql_query("SELECT ide, title FROM ".TABLE."_art_general WHERE ide != '$id' AND ide = rootID AND folderID = '".$moveArtRow->folderID."' ORDER BY order_num ASC");
		while($articleRow = mysql_fetch_object($articleQuery)) {
			$artTitle[] = $articleRow->title;
			$artIDE[]   = $articleRow->ide;
		}
		
		$moveMethodValue[] = CB_NESE_MOVEAFTER;
		$moveMethodText[]  = $amText["moveArtAfter"];
		$moveMethodValue[] = CB_NESE_MOVEBEFORE;
		$moveMethodText[]  = $amText["moveArtBefore"];
		
		$tpl->assign("move_order_method_select", 
			array ( "value" => $moveMethodValue,
					"text"  => $moveMethodText
			)
		);
		
		$tpl->assign("move_order_target_select", 
			array ( "title" => $artTitle,
					"ide"   => $artIDE
			)
		);
		
		$tpl->assign("move_order_set", "1");
	} else {
		$moveArtDate = new Date($moveArtRow->datetime);
		
		if(isset($_POST[artTargetDay]) && isset($_POST[artTargetMonth]) && isset($_POST[artTargetYear])) {
			$moveArtDate->setDay($_POST[artTargetDay]);
			$moveArtDate->setMonth($_POST[artTargetMonth]);
			$moveArtDate->setYear($_POST[artTargetYear]);
			
			$newDatetime  = $moveArtDate->getDate( DATE_FORMAT_ISO_EXTENDED );
			
			mysql_query("UPDATE ".TABLE."_art_general SET datetime = '$newDatetime' WHERE ide = '$id'");
		}
		
		$moveArtDay   = $moveArtDate->getDay();
		$moveArtMonth = $moveArtDate->getMonth();
		$moveArtYear  = $moveArtDate->getYear();
		$moveArtTitle = $moveArtRow->title;
		
		/*
		* Abfrage der Artikel mit Sortierung nach Datum
		*/
		$articleQuery = mysql_query("SELECT ide, title, datetime FROM ".TABLE."_art_general WHERE ide = rootID AND folderID = '".$moveArtRow->folderID."' ORDER BY datetime DESC");
		while($articleRow = mysql_fetch_object($articleQuery)) {
			$articleDate = new Date($articleRow->datetime);
			
			$artDay[]   = $articleDate->getDay();
			$artMonth[] = $articleDate->getMonth();
			$artYear[]  = $articleDate->getYear();
			$artTitle[] = $articleRow->title;
			$artIDE[]   = $articleRow->ide;
		}
		
		$tpl->assign("move_date_artList",
			array ( "DAY"   => $artDay,
					"MONTH" => $artMonth,
					"YEAR"  => $artYear,
					"TITLE" => $artTitle,
					"IDE"   => $artIDE
			)
		);
		
		$tpl->assign("move_date_data",
			array ( "DAY"   => $moveArtDay,
					"MONTH" => $moveArtMonth,
					"YEAR"  => $moveArtYear,
					"TITLE" => $moveArtTitle,
					"IDE"   => $id
			)
		);
		
		$tpl->assign("move_date_set", "1");
	}
	
	/* 
	* Fehler ausgeben
	*/
	if(is_array($error)) {
		$tpl->assign("errorSet", "1");
		$tpl->assign("errorList", $error);
	}
	
	/*
	* Template ausgeben
	*/
	$mainPluginContent[]  = $tpl->fetch($config['templates']."artMove.template", null, "pluginArt2".$cbUserID);
	$mainMessageContent[] = $tpl->fetch($config['templates']."messages.template", null, "pluginArt2".$cbUserID);
?>
Return current item: Content*Builder