Location: PHPKode > projects > Content*Builder > contentbuilder/plugins/article2/preview.inc.php
<?php
	if(empty($rel) && empty($cbrel)) { $cbrel = "../../"; };

	$width = "450";
	$path["cb"] = $cbrel;
	$preview = "true";
	
	require_once($path['cb'].'root.inc');
	require_once($path['cb'].$cbDirInclude.'config.ini');
	require_once($path['cb'].$cbDirInclude.'db.php');
	require_once($path['cb'].$cbDirLib.'patTemplate.php');
	require_once($path['cb'].$cbDirLib.'CB_option.class.php');
	
	include_once("../../".$cbDirLib."CB_plugin.class.php" );
	
	/* 
	* Ableiten des Plugin Objekts zum verwalten der Plugins 
	*/
	$cbPlugins  = new CB_plugin();
	
	include_once("plugin.config" );
	
	$actualPlugin = $cbPlugins->getPluginByIdent("art2");
	
	$cbOption = new CBOption();
	$cbOption->setModule("system");
	$cbOption->getOptionList();

	$BTPL_location = $cbOption->getSingleOption("BTPL_location");
	if(!$BTPL_location) {
		$error[] = "Der Pfad zum BTPL wurde noch nicht gesetzt.";
	}
	
	$rel = $cbrel.$BTPL_location;
	
	require_once($cbrel.$BTPL_location."libraries/logInfo.class.php");
	require_once($cbrel.$BTPL_location."libraries/BTPL_module.class.php");
	require_once($cbrel.$BTPL_location."libraries/smarty/Smarty.class.php");
	require_once($cbrel.$BTPL_location."languages.inc.php");
	
	$BTPL_module = new BTPL_module();
	if(isset($rel)) {
		$BTPL_module->setRelPath($rel);
	}
	$BTPL_log = new CB_statistic();
	
	if(empty($openfolder)) { 
		$openfolder = $cbOption->getSingleOption("COLUMN_mainFolder"); 
		if(!$openfolder) {
			$error[] = "Keine Hauptrubrik gesetzt und keine spezielle Rubrik ausgewählt.";
		}
	}
	
	if(!$cbOption->getSingleOption("skinDir")) {
		$templateDir = $cbrel."templates/default/";
	} else {
		$templateDir = $cbrel.$cbOption->getSingleOption("skinDir");
	}
	define("CB_TEMPLATE_DIR", $templateDir);
	
	
	### Starting the template output ###
	$tpl = new patTemplate;
	$tpl->setBaseDir(CB_TEMPLATE_DIR.$actualPlugin->getValue("templates"));
	
	
	$tpl->readTemplatesFromFile("preview.template");
	$tpl->addGlobalVar("TEMPLATE_DIR", CB_TEMPLATE_DIR);
	$tpl->addGlobalVar("WIDTH", $width);
		
	ob_start();
		$tpl->displayParsedTemplate("head");
		$head = ob_get_contents();
	ob_end_clean();
		
	ob_start();
		$tpl->displayParsedTemplate("foot");
		$foot = ob_get_contents();
	ob_end_clean();
	
	$tpl2 = $tpl;
	
	if(!$error) {
		$path['cb'] = $cbrel;
		$CB_path = $path['cb'];
		$load = "article2";
		global $location;
		$location = $rel."modules/".$load."/";
	
		######## Don't modify from here ##########
		function loadModule($name, $position, $directory, $startFile, $main = false) {
			global $BTPL_module;
			if($main) {
				$mainSet = true;
			} else {
				$mainSet = false;
			}
			$BTPL_module->setModule(
				array ( "name"      => $name,
						"position"  => $position,
						"directory" => $directory,
						"file"      => $startFile,
						"main"      => $mainSet
				)
			);
		}
		
		function displayModule($name) {
			global $BTPL_module;
			$BTPL_module->displayModule($name);
		}
		
		$preview = TRUE;
		
		if(!isset($openfolder)) { $openfolder = $cbOption->getSingleOption("COLUMN_mainFolder"); };
	
		$fetchFolder = mysql_fetch_object(mysql_query("SELECT * FROM ".TABLE."_columns WHERE fid = '$openfolder'"));
		
		/* 
		* Skin Selector 
		*/
		if(empty($BTPL_skinSelected)) { $BTPL_skinSelected = "default/"; }
		if(empty($BTPL_skinModule  )) { $BTPL_skinModule   = "default/"; }
		if($fetchFolder->skin != "") {
			$folderTemp = explode(":", $fetchFolder->skin);
			if(count($folderTemp) == 1) {
				if(is_dir($rel."templates/".$folderTemp[0])) {
					$BTPL_skinSelected = $folderTemp[0]."/";
					$BTPL_skinModule   = $folderTemp[0]."/";
					$BTPL_skinModulePart = "";
				}
			} elseif(count($folderTemp) == 2) {
				if(is_dir($rel."templates/".$folderTemp[0]."/sub/".$folderTemp[1])) {
					$BTPL_skinSelected = $folderTemp[0]."/";
					$BTPL_skinModule   = $folderTemp[0]."/sub/".$folderTemp[1]."/";
					$BTPL_skinModulePart = "/sub/".$folderTemp[1]."/";
				}
			}
		}
		/* Skin Selector Ende */
		
		$path = array( "cb" => "../../");
		$BTPL_module->CB_path = $path['cb'];
		
		### Starting the template output ###
		$t_basedir = $rel."templates/".$BTPL_skinSelected;
		$t_images  = $rel."templates/".$BTPL_skinSelected."images/";
	
		$tpl = new Smarty;
		$tpl->template_dir = $t_basedir;
		$tpl->compile_dir  = $t_basedir."compiled/";
		$tpl->assign("CB_VERSION", $version);
		
		/* --Sub Template Checker--
		*  Wenn im sub Verzeichnis ein Sub Template liegt und dabei auch 
		*  eine contentbuilder.template vorhanden ist, dann soll diese auch
		*  eingebunden werden. Ansonsten wird das default contentbuilder.template
		*  aus dem Skin Verzeichnis geladen
		*/
		$BTPL_mainTemplate = "defaultMainTpl";
		if($BTPL_skinModule != $BTPL_skinSelected) {
			if(is_file($rel."templates/".$BTPL_skinModule."contentbuilder.template")) {
				$BTPL_mainTemplate = "subMainTpl";
			}
		}
		
		$tpl->assign("IMAGEDIR", $t_images);
		$tpl->assign("TEMPLATE_DIR", $t_basedir);
		$tpl->assign("OPENFOLDER", $openfolder);
		$tpl->assign("PHP_SELF",	basename($PHP_SELF));
		$tpl->assign("CBPATH",	$path["cb"]);
		$tpl->assign("RELPATH",	$rel);
		
		$tpl->assign("LOAD", $load);
		
		loadModule("article", "c", $load, "dummy", true);
		displayModule("article");
		
		ob_start();
			include($t_basedir."style.css");
			$BTPL_module->displayParsedModules();
			$BTPL_tplArrays = $BTPL_module->getArrayList();
			echo ${$BTPL_tplArrays[0]}[0];
			$content = ob_get_contents();
		ob_end_clean();	
	} else {
		$tpl->readTemplatesFromFile("messages.template");
		ob_start();
			$tpl->addVar("error", "MESSAGE", $error);
			$tpl->setAttribute("error", "visibility", "visible");
			$tpl->displayParsedTemplate("messages");
			$content = ob_get_contents();
		ob_end_clean();
	}
	
	echo $head;
	echo $content;
	echo $foot;
?>
Return current item: Content*Builder