Location: PHPKode > projects > Content*Builder > contentbuilder/plugins/article2/artOverview.inc.php
<?php
	$link1 = $PHP_SELF.'?load='.$config["urlIdent"].'&'.SID;
	
	if(isset($subf)) {
		$art2_oview_subf = $subf;
		session_register("art2_oview_subf");
		if($subf == "") {
			session_unregister("art2_oview_subf");
		}
	}
	
	/*
	* Lösch Funktion für Artikel
	*/
	if(isset($delbox)) {
		$mediaDelArray = array();
		
		$delbox2 = $delbox;
		unset($delbox);
		foreach($delbox2 as $k => $v) {
			if($articlePerms->hasEditPermission($v)) {
				$delbox[$k] = $v;
			}
		}
		
		$mediaDel = false;
		foreach($delbox as $k => $v) {
			$thisNode = $nestedSet->getNode($v);
			$deleteIDQuery = mysql_query("SELECT ide, mediaID FROM ".TABLE."_art_general WHERE leftID BETWEEN $thisNode[leftID] AND $thisNode[rightID] AND rootID = '$thisNode[rootID]'");
			while($deleteIDRow = mysql_fetch_array($deleteIDQuery)) {
				if(ereg("(^[1-9]?[0-9]*$)", $deleteIDRow[mediaID])) {
					$mediaDelArray[] = $deleteIDRow[mediaID];
					$mediaDel = true;
				}
			}
			
			$deletedNodes = $nestedSet->deleteNode($v);
			foreach($deletedNodes as $value) {
				$dquery = mysql_query("DELETE FROM ".TABLE."_art_content WHERE ide = '$value'");
				$dquery = mysql_query("DELETE FROM ".TABLE."_art_folder  WHERE articleID = '$value'");
			}
		}
		if($mediaDel) {	$myMedia->deleteBranch($mediaDelArray); }
		cb_log(7);
	}

	if($articlePerms->hasPublishPermission()) {	
		/*
		* Comment (ger)
		* Funktion, die alle Artikel dieser Seite online setzt.
		*/
		if(isset($onbox)) {
			foreach($onbox as $k => $v) {
				$dquery = mysql_query("UPDATE ".TABLE."_art_general SET stage = '3' WHERE ide = '$v'");
			}
		}
	
		/*
		* Comment (ger)
		* Funktion zum Offline-Schalten der Artikel - alle markierten Artikel
		* gehen damit offline.
		*/
		if(isset($offbox)) {
			foreach($offbox as $k => $v) {
				$dquery = mysql_query("UPDATE ".TABLE."_art_general SET stage = '4' WHERE ide = '$v'");
			}
			cb_log(16);
		}
	}
	
	include($cbDirLib."pageSplit.class.php");
	if (!$offset) $offset=0;
	$limit = 20;
	
	// Ordner ermitteln, um Eingrenzung auf bestimmte Rubriken zu erwirken
	$thisFolder = mysql_fetch_array(mysql_query("SELECT * FROM ".TABLE."_columns WHERE fid = '$art2_oview_subf' ORDER BY fname ASC"));
	if(empty($thisFolder)) {
		$thisFname = $amText["art_all"];
	} else {
		$thisFname  = $amText["art_of_this"].$thisFolder['fname'];
	}

	$folderUp = "&subf=".$thisFolder['mfolder'];
	
	$folderSubQuery = $nestedSet_folder->getChildren($art2_oview_subf, true);
	if($folderSubQuery != false) {
		$counter = 0;
		foreach($folderSubQuery as $v) {
			$folderFid[]  = $v['id'];
			$folderName[] = $v['name'];
			++$counter;
		}
	}

	$allFolderQuery = $nestedSet_folder->getAllNodes(true);
    if($allFolderQuery != false) {
		foreach($allFolderQuery as $v) {
			$allfid   = $v['id'];
			$allfname = $v['name'];
			$myArtFolderIDNameHash[$allfid]=$allfname;
		}
	}

	$tpl->assign("form_set", "1");
	
	/*
	* Comment (ger)
	* User Rechte aus DB laden
	*/
	$query  = mysql_query("SELECT * FROM ".TABLE."_user WHERE name = '$_SESSION[user]'");
	$result = mysql_fetch_assoc($query);
	$pref	= $result["initial"];
	$usern  = $result["name"];
	
	// Prüfung auf Userrechte
	if($articlePerms->hasAccess()) {
		if(isset($art2_oview_subf) && ($art2_oview_subf != "") && ($art2_oview_subf != "0")) {
			if(!$articlePerms->hasEditPermission($art2_oview_subf, array( "type" => "column" ))) {
				$query_where = "art.userID = '".$cbUserID."'";
	
				if(!empty($art2_oview_subf)) {
				  $query_where .= "AND art.folderID = '".$art2_oview_subf."'";
				}
			} else {
				$query_where = "";
	
				if(!empty($art2_oview_subf)) {
					$query_where = "art.folderID = '".$art2_oview_subf."'";
				}
			}
			$andQueryWhere   = "AND ".$query_where;
			$whereQueryWhere = "WHERE ".$query_where;
		}
		
		/*
		* Sortier Methode
		*/
		$sortMethod = $artOption->getSingleOption("sortMethod");
		switch($sortMethod){
			case ART_SORT_NUMERIC: 
				 $sortMethodString = "ORDER BY art.order_num ASC";
				 break;
			default:
				 $sortMethodString = "ORDER BY art.datetime DESC";
		} // switch
		
		$queryt = mysql_query("SELECT art.*, COUNT(comment.entryID) AS comments FROM ".TABLE."_art_general AS art LEFT JOIN ".TABLE."_comment AS comment ON comment.entryID = art.ide AND comment.type = 'article2' WHERE art.rootID = art.ide ".$andQueryWhere." GROUP BY art.rootID, comment.entryID $sortMethodString LIMIT ".$offset.",".$limit);

		$articleSet = false;
		if(!$queryt) {
			$errorList[] = $amText["no_user_article"];
			$tpl->assign("form_set", "0");
		} else {
			// Falls Artikel gefunden werden.
			// Abfrage nach Artikel-Anzahl

			$result = mysql_query("SELECT COUNT(*) FROM ".TABLE."_art_general AS art "
								 ."LEFT JOIN ".TABLE."_user AS user ON user.userid = art.userID $whereQueryWhere");
			list($numrec)	= mysql_fetch_row($result);
			$numpage		= intval($numrec/$limit);

			// Es wird aufgerundete wenn Teilrest übrig bleibt.

			if ($numrec%$limit) {
				++$numpage;
			}
			
            $myArticleFolderIDs   = array();
            $myArticleFolderNames = array();

			$counter = 0;
			while($getquery = mysql_fetch_array($queryt)) {
				$articleSet = true;
				if(!empty($art2_oview_subf)) {
					// Zwischenspeicher-Funktion einer Ordnerliste
					$tpl->assign("FOLDER_SUB", $art2_oview_subf);
					$tpl->assign("folder_sub_set", "1");
				}

				// Titel erzeugen
				$artTitle = substr($getquery["title"],0,17);
				if(strlen($getquery["title"]) > 17) {
					$artTitle .= "...";
				}

				// Datum erzeugen
				$firstsub				= substr($getquery["datetime"],0,10);
				$dt						= explode("-",$firstsub);
				$dat1					= $dt[2].".".$dt[1].".".$dt[0];
				$secondsub				= substr($getquery["datetime"],-8,5);
				$getquery["datetime"]	= $dat1."&nbsp;".$secondsub." Uhr";

				// Off Box checked
				if($getquery["stage"] == 4) {$thisBox = 'checked';} else {$thisBox = '';}
				
				$_myArticleFolderNameHash = $myArtFolderIDNameHash[$getquery["folderID"]];
				$_myArticleFolderName     = substr($_myArticleFolderNameHash,0,15);
				if(strlen($_myArticleFolderNameHash) > 15) {
					$_myArticleFolderName .= "...";
				}
				
                // hier werden die artikel-daten den array's zugeweisen
				$artCommentCounter[$counter]    = $getquery["comments"];
				$myArticleFolderIDs[$counter]   = $getquery["folderID"];
                $myArticleFolderNames[$counter] = $_myArticleFolderName;
				$artide[$counter] = $getquery["ide"];
				$titles[$counter] = $artTitle;
				$date[$counter]   = $getquery["datetime"];
				$author[$counter] = $getquery["fullname"].' ('.$getquery["initial"].')';
				$checked[$counter]= $thisBox;
				$artCounter = $getquery['artCounter'];
				++$counter;
			}
		}
	} else {
		$errorList[] = $amText["cannot_modify"];
		$tpl->assign("form_set", "0");
	}

	$navigation = new PageSplit($limit, $offset, $numpage);
	$pn = array();
	
	$urlVars = $link1.$fsub;
	$pn['back']  = $navigation->getBackLink($urlVars, $amLink["pnBack"]);
	$pn['fwd']   = $navigation->getNextLink($urlVars, $amLink["pnFwd"]);
	$pn['pages'] = $navigation->getPageLinks($urlVars);
		
    if (! $thisFolder['fname']) {
        $thisFolderName = 'Alle Rubriken / Anfang';
    } else {
        $thisFolderName = $thisFolder['fname'];
    }

	$tpl->assign("folders",
		array ( "CURRENT_FOLDER_NAME"   => $thisFolderName,
				"FUP_FID"	 => $folderUp
		)
	);

	if($folderName[0] != "") {
		$tpl->assign("folders_row_set", "1");
	}
	
	$tpl->assign("folders_row",
		array ( "FOLDER_SUB" => $folderFid,
				"FTITLE"     => $folderName
		)
	);


	$tpl->assign("form",
		array ( "FOLDER_NAME" => $thisFname,
				"SUBF"        => $subf,
				"PNBACK"      => $pn['back'],
				"PNPAGES"     => $pn['pages'],
				"PNFWD"       => $pn['fwd']
		)
	);

	if($articleSet) {
		$tpl->assign("form_row",
			array ( "IDE"       => $artide,
					"TITLE"     => $titles,
					"DATE"		=> $date,
					"AUTHOR"	=> $author,
					"SELECTED"  => $checked,
					"COMMENT_COUNTER" => $artCommentCounter,
    	            "MY_ARTICLE_FOLDER_ID"   => $myArticleFolderIDs,
        	        "MY_ARTICLE_FOLDER_NAME" => $myArticleFolderNames 
			)
		);
		$tpl->assign("form_row_set", "1");
	}
	$tpl->assign("overview_set", "1");
	
	if(count($errorList) > 0) {
		$tpl->assign("errorSet", "1");
		$tpl->assign("errorList", $errorList);
	}
	
	$mainPluginContent[]  = $tpl->fetch($config['templates']."overview.template", null, "pluginArt2".$cbUserID);
	$mainMessageContent[] = $tpl->fetch($config['templates']."messages.template", null, "pluginArt2".$cbUserID);
?>
Return current item: Content*Builder