Location: PHPKode > projects > Content*Builder > modules/article2/fullarticle.inc.php
<?
	include_once($rel."libraries/BTPL_functions.inc.php");
	
	require_once($path['cb'].$cbDirLib.'CB_media.class.php');
	$myMedia  = new MediaManagement();
	$myMedia->setOptionObject($cbOption);
	$myMedia->setBranchID($cbOption->getSingleOption("rpBranch"));
	$rpBranch = $myMedia->getBranchDirectory();
	
	if(!isset($page)) $page = 0;
	if(!isset($openfolder)) {
		$article_res = mysql_query("SELECT ide, folderID FROM ".TABLE."_art_general WHERE ide = '$id'");
		$article_row = mysql_fetch_array($article_res);
		$openfolder = $article_row['folderID'];
	}
	
	if(!is_object($artOption)) {
		//Ableitung des Article Option Objektes
		$artOption = new CBOption();
		$artOption->setModule("art");
		$artOption->getOptionList();
	}
	
	$id = $_REQUEST['id'];
	$ide = $id;
	
	extract($HTTP_POST_VARS);
		
	if(empty($language)) {
		$dlQuery  = mysql_fetch_array(mysql_query("SELECT * FROM ".TABLE."_options WHERE name = 'default_lang' AND module = 'art'"));
		$language = $dlQuery[value];
	}
	
	$articleQuery = mysql_query("SELECT * FROM ".TABLE."_art_general AS general LEFT JOIN ".TABLE."_art_content AS content ON general.ide = content.ide WHERE general.ide = '$id' AND content.language = '$language'");
	$articleRow   = mysql_fetch_object($articleQuery);
	
	/*
	* Template Finder
	*/
	$style = $articleRow->template;
	if(($style)&&(is_dir($tplLocation."/$style"))) {
		$thisStyle = $style;
	} else {
		$thisStyle = "default";
	}
	
	if($page == 0) {
		$intro = $articleRow->intro;
	}
	$content_all = explode("[--PAGEBREAK--]", $articleRow->content);
	$content = $content_all[$page];
	$content = explode("[--title--]", $content);
	$content = implode(" ", $content);
	if(($page + 1) <= ( count($content_all) - 1 )) {
		$page_fwd = $page + 1;
	}
	if(($page - 1) >= 0) {
		$page_back = $page - 1;
	}
	
	if(isset($page_back)) { $link_back = $PHP_SELF.'?load='.$load.'&sub=full&id='.$ide.'&language='.$language.'&page='.$page_back;}
	$pageLinks = "";
	for($z = 1; $z <= count($content_all); $z++) {
		if($z == 1) {
			$pageLinks .= '[ ';
		}
		if(($page + 1) == $z) {
			$pageLinks .= ' '.$z.' ';
		} else {
			$pageLinks .= ' <a href="'.$PHP_SELF.'?load='.$load.'&sub=full&id='.$ide.'&language='.$language.'&page='.($z - 1).'">'.$z.'</a> ';
		}
		
		if($z != count($content_all)) {
			$pageLinks .= '|';
		} else {
			$pageLinks .= ' ]';
		}
	}
	if(isset($page_fwd)) { $link_fwd = $PHP_SELF.'?load='.$load.'&sub=full&id='.$ide.'&language='.$language.'&page='.$page_fwd;}
	
	$userQuery = mysql_fetch_array(mysql_query("SELECT userid, fullname, initial, email FROM ".TABLE."_user WHERE userid = '".$articleRow->userID."'"));
	$userFull    = $userQuery[fullname];
	$userInitial = $userQuery[initial];
	$userEmail   = unicode_encode($userQuery[email]);
	
	if((count($content_all) - 1) == $page) {
		$initial = '('.$userInitial.')';
	}
	
	if(!$showall) {
		if(empty($limit)) { $limit = 30; }
		$limit = "LIMIT ".$limit;
	}
	
	$datum = substr($articleRow->datetime,0,10);
	$d1 = substr($datum,0,4);
	$d2 = substr($datum,5,2);
	$d3 = substr($datum,8,2);
	$date= $d3.".".$d2.".".$d1;
	
	if(1 & $articleRow->options) {
		$print = 1;
	} else {
		$print = 0;
	}
	
	/********* REPLACEMENT START **********/
	$intro	 = str_replace('[REPLACEDIR]', $path["cb"].'uploads/files/'.$rpBranch.'/', $intro);
	$content = str_replace('[REPLACEDIR]', $path["cb"].'uploads/files/'.$rpBranch.'/', $content);
	/********** REPLACEMENT END ***********/
	
	$intro	 = str_replace('[CBDIR]', $path["cb"], $intro);
	$content = str_replace('[CBDIR]', $path["cb"], $content);
	
	// CB Article Link ... Internal Link Hack
	$intro   = preg_replace("/\[CBLINK articleID=([0-9a-f-]*)\](.*)\[\/CBLINK]/i", "<a href=".$PHP_SELF."?load=".$load."&sub=full&id=$1&openfolder=".$openfolder.">$2</a>", $intro);
	$content = preg_replace("/\[CBLINK articleID=([0-9a-f-]*)\](.*)\[\/CBLINK]/i", "<a href=".$PHP_SELF."?load=".$load."&sub=full&id=$1&openfolder=".$openfolder.">$2</a>", $content);
	//$intro   = preg_replace("/\[CBLINK module=([0-9a-zA-Z-]*) id=([0-9a-f-]*)\](.*)\[\/CBLINK]/i", "<a href=\"".$PHP_SELF."?load=$1&sub=full&id=$2\">$3</a>", $intro);
	//$content = preg_replace("/\[CBLINK module=([0-9a-zA-Z-]*) id=([0-9a-f-]*)\](.*)\[\/CBLINK]/i", "<a href=\"".$PHP_SELF."?load=$1&sub=full&id=$2\">$3</a>", $content);
	$intro   = preg_replace("/\[CBLINK module=([0-9a-zA-Z-]*) id=([0-9a-f-]*) fid=([0-9a-f-]*)\](.*)\[\/CBLINK]/i", "<a href=\"".$PHP_SELF."?load=$1&sub=full&id=$2&openfolder=$3\">$4</a>", $intro);
	$intro   = preg_replace("/\[CBLINK module=([0-9a-zA-Z-]*) id=([0-9a-f-]*)\](.*)\[\/CBLINK]/i", "<a href=\"".$PHP_SELF."?load=$1&sub=full&id=$2\">$3</a>", $intro);
	$content = preg_replace("/\[CBLINK module=([0-9a-zA-Z-]*) id=([0-9a-f-]*) fid=([0-9a-f-]*)\](.*)\[\/CBLINK]/i", "<a href=\"".$PHP_SELF."?load=$1&sub=full&id=$2&openfolder=$3\">$4</a>", $content);
	$content = preg_replace("/\[CBLINK module=([0-9a-zA-Z-]*) id=([0-9a-f-]*)\](.*)\[\/CBLINK]/i", "<a href=\"".$PHP_SELF."?load=$1&sub=full&id=$2\">$3</a>", $content);

	/**
	*  Load Article settings 
	*  Try to load individual settings for article template 
	*  or general if there is no individual setting file
	*/
	if(is_file($tplLocation."/".$thisStyle."/settings.inc.php")) {
		include($tplLocation."/".$thisStyle."/settings.inc.php");
	} else {
		include($location."/settings.inc.php");
	}
	/* End Load Article Settings */
	
	/*
	* meikel new: Language Flag Build 
	*/
	foreach($langFlagArr as $k => $v) {
		if($k & $artData->languages) {
			$langFlagSet[] = $v;
			$langIDArr[]   = $k;
		}
	}
	$tpl->assign("languageFlagData", 
		array ( "LOCATION"     => $location,
				"FLAG"         => $langFlagSet,
				"LANGID"       => $langIDArr,
				"OPENFOLDER"   => $openfolder,
				"IDE"          => $ide
		)
	);
	
	/* 
	* end language Flag Builder 
	*/

	
	
	
	$introSet = 0;
	if($intro != "") {
		$introSet = 1;
	}
	
	$fullarticle =	array(
		"FULL_INTRO"	=> stripslashes($intro),
		"FULL_INTRO_SET"=> $introSet,
		"FULL_CONTENT"	=> stripslashes($content),
		"FULL_TITLE"	=> stripslashes($articleRow->title),
		"FULL_TIME"		=> substr($articleRow->datetime,11,8),
		"FULL_DATE"		=> getGermanDate($articleRow->datetime),
		"FULL_PRINT"    => $print,
		"EMAIL"			=> $userEmail,
		"FULL_A_NAME"	=> $userFull,
		"FULL_INITIAL"	=> $initial,
		"FULL_IDE"		=> $id,
		"FULL_OPENFOLDER" => $openfolder,
		"PAGE_LINKS"	=> $pageLinks,
		"FWD_LINK"		=> $link_fwd,
		"BACK_LINK"	    => $link_back,
		"LANGUAGE"      => $language
	);
	
	$tpl->assign("fullarticle", $fullarticle);
	
	if($link_back != "") {
		$tpl->assign("back_link_set", "1");
	}
	if($link_fwd != "") {
		$tpl->assign("fwd_link_set", "1");
	}
	
	/*
	* Kapitel Kontrolle
	*/
	if($artOption->getSingleOption("chapterControl")) {
		/* 
		* Initialisierung der NeSet Array's für das 
		* Article Nested Set Objekt 
		*/
		$params = array (
			'table'  => TABLE.'_art_general',
			'id'     => 'ide',
			'parent' => 'parentID',
			'root'   => 'rootID',
			'l'      => 'leftID',
			'r'      => 'rightID',
			'level'  => 'level',
			'norder' => 'order_num'
		);
		
		$additional = array (
			'fid'      => 'folderID',
			'user'     => 'userID',
			'media'    => 'mediaID',
			'icon'     => 'iconID',
			'title'    => 'title',
			'datetime' => 'datetime',
			'pFrom'    => 'publishFrom',
			'pTo'      => 'publishTo',
			'stage'    => 'stage',
			'parse'    => 'parse',
			'options'  => 'options',
			'lang'     => 'languages'
		);
		
		$artNestedSet = CB_NestedSet::factory($params, $additional);
		
		/* 
		* Den ganzen Zweig fürs Webdossier bekommen
		* $dArt = dossierArticle
		*/
		$dossierBranch = $artNestedSet->getBranch($articleRow->rootID);
		if($dossierBranch != false) {
			foreach($dossierBranch as $v) {
				if($v[ide] == $id) {
					$dArtActual[] = 1;
				} else {
					$dArtActual[] = 0;
				}
				
				if($v[ide] == $v[rootID]) {
					$dArtLeft  = $v[leftID];
					$dArtRight = $v[rightID];
				}
				
				$dArtTitle[] = $v[title];
				$dArtID[]    = $v[ide];
				$dArtParent[]= $v[parentID];
				$dArtLevel[] = $v[level];
				$dArtSpace[] = ($v[level] - 1) * 10;
			}
		}
		
		$dossierDisplay = 0;
		if(($dArtRight - $dArtLeft) > 1) {
			$dossierDisplay = 1;
		}
		
		$tpl->assign("artDossier",
			array ( "TITLE"  => $dArtTitle,
					"ID"     => $dArtID,
					"SPACE"  => $dArtSpace,
					"LEVEL"  => $dArtLevel,
					"ACTUAL" => $dArtActual,
					"PARENT" => $dArtParent,
					"DOSSIER_DISPLAY" => $dossierDisplay
			)
		);
	} else {
		$tpl->assign("artDossier", "DOSSIER_DISPLAY", "0");
	}
	
		
	/**
	* Comment Ausgabe
	*/
	$type = "article2";
	$entryID = $id;
	$idLabel = "id";
	$submitLabel = "ART2_submit";
	$outputOrder = "ORDER BY datetime ASC";
	$outputLimit = "";
		
	if($cbOption->getSingleOption("comment")) {
		include($rel."libraries/comment/insertComment.php");
		include($rel."libraries/comment/displayComments.php");
		$tpl->assign("commentLink", "1");
	} else {
		$tpl->assign("commentLink", "0");
	}
	
	$tpl->display("$thisStyle/fullarticle.template");
	$tpl->display("comments.template");
?>
Return current item: Content*Builder