<?php
###########################################
###### Content Builder Base Template ######
###########################################
# to modify the html of this template, go to the template folder and modify the
# templates in default. Please don't modify the <patTemplate ...> tags, cause they
# are neccessary for correct view
######## Don't modify from here ##########
$debug_time_start = microtime();
include_once("prepend.php");
$CB_path = $path['cb'];
session_name("webfrontend");
@session_start();
/*
* $opennfolder finden und Rubrik Daten auslesen
*/
if(!empty($_REQUEST[openfolder])) {
$openfolder = $_REQUEST[openfolder];
}
/*
* Wenn openfolder leer und Artikel gewählt, hole ID aus Artikel
*/
if($openfolder == "" && $load == "article2" && isset($id)) {
$articleFolderQuery = mysql_fetch_assoc(mysql_query("SELECT folderID FROM ".TABLE."_art_general WHERE ide = '$id'"));
$openfolder = $articleFolderQuery[folderID];
}
if(!isset($openfolder)) {
$openfolder = $cbOption->getSingleOption("COLUMN_mainFolder");
}
$openfolderData = mysql_fetch_assoc(mysql_query("SELECT loadurl, rootID AS root, leftID AS l, rightID AS r, level, fname AS name, order_num AS norder, skin, mfolder, describt FROM ".TABLE."_columns WHERE fid = '$openfolder'"));
$GLOBALS[openfolderData] = $openfolderData;
/*
* Bei leerem $load Feld load aus der Rubrik herauslesen
*/
if(!empty($_REQUEST[load])) { $load = $_REQUEST[load]; } else {
$load = "article2";
/*
* $load aus loadurl Feld herausparsen, wenn da was drin steht
*/
if(($openfolderData[loadurl] != "") && !preg_match("/^http:\/\//i", $openfolderData[loadurl])) {
$loadurlArr = explode("&", $openfolderData[loadurl]);
$load = $loadurlArr[0];
}
}
$fetchFolder = $openfolderData;
/* Community Feature */
if ($community_logout == 1) {
/*
* letzten Besuch loggen
*/
mysql_query("UPDATE ".TABLE."_community_user SET lastLogin = NOW() WHERE userID = ".$community_data->userID."");
unset($_SESSION[community_name]);
unset($_COOKIE['communityData']);
session_destroy();
setcookie("communityData", false);
$community_check = 0;
}
if($_SESSION['community_name'] == "" && $_COOKIE['communityData'] != false) {
$communityData = explode(":", $_COOKIE['communityData']);
$community_login = 1;
$login_password = $communityData[1];
$login_name = $communityData[0];
$communityRememberMe = 1;
}
if(!empty($community_login)) {
setcookie("communityData", false);
$c_password = md5($login_password);
$login_check = mysql_fetch_object(mysql_query("SELECT * FROM ".TABLE."_community_user WHERE name = '$login_name' AND password = '$c_password'"));
$community_check = 0;
if(!empty($login_check->name) && (1 & $login_check->options)) {
$community_data = $login_check;
$community_check = 1;
$_SESSION[community_name] = $community_data->name;
$_SESSION[community_data] = $login_check;
$_SESSION[community_uid] = $community_data->userID;
if($communityRememberMe == 1) {
$communityString = $login_name .":". $login_password;
setcookie("communityData", $communityString, time() + 604800);
}
/*
* letzten Login loggen
*/
mysql_query("UPDATE ".TABLE."_community_user SET lastLogin = NOW() WHERE userID = ".$community_data->userID."");
}
}
if(!$community_check && !empty($_SESSION[community_name])) {
$community_name = $_SESSION[community_name];
$check = mysql_fetch_object(mysql_query("SELECT * FROM ".TABLE."_community_user WHERE name = '$community_name'"));
if(!empty($check->name)) {
$community_check = 1;
} else {
session_destroy();
$community_check = 0;
}
}
/* Community Feature End */
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);
}
function setModuleValue($name, $valueName, $valueContent) {
global $BTPL_module;
if(is_object($BTPL_module->modules[$name])) {
$BTPL_module->modules[$name]->values[$valueName] = $valueContent;
}
}
function setModuleValues($name, $valueArray) {
global $BTPL_module;
if(is_object($BTPL_module->modules[$name]) && is_array($valueArray)) {
foreach($valueArray as $k => $v) {
$BTPL_module->modules[$name]->values[$k] = $v;
}
}
}
$preview = FALSE;
/*
* Skin Selector
* This feature selects the skin or set a default skin. Furthermore
* it selects the subElements that are set. subElements are pieces of
* a skin (modules.php & module_arrayTplRelation.inc.php), that lies in
* an own directory under sub.
* Is there no subElement, the 'subElement' is now the skin directory. If
* there not the required files for a subElement, 'subElement' is now the root
* where the default modules.php lies.
*/
$BTPL_skinSelected = $path['defaultSkin'] ? $path['defaultSkin'] : "default/";
$BTPL_skinModule = $path['defaultSkin'] ? $path['defaultSkin'] : "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 */
### 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->config_dir = $t_basedir."config/";
$tpl->assign("CB_VERSION", $version);
/*
* Standard OpenfolderDaten an Smarty senden
*/
$tpl->assign("openfolderData", $openfolderData);
/* --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);
/* Load individual module.php of selected Skin */
if(file_exists($rel."templates/".$BTPL_skinModule."modules.php") && file_exists("templates/".$BTPL_skinModule."module_arrayTplRelation.inc.php")) {
include($rel."templates/".$BTPL_skinModule."modules.php");
include($rel."templates/".$BTPL_skinModule."module_arrayTplRelation.inc.php");
} else {
$check = 0;
if($BTPL_skinModule != $BTPL_skinSelected) {
if(file_exists($rel."templates/".$BTPL_skinSelected."modules.php") && file_exists("templates/".$BTPL_skinSelected."module_arrayTplRelation.inc.php")) {
$check = 1;
}
}
if($check == 1) {
include($rel."templates/".$BTPL_skinSelected."modules.php");
include($rel."templates/".$BTPL_skinSelected."module_arrayTplRelation.inc.php");
} else {
include($rel."modules.php");
include($rel."module_arrayTplRelation.inc.php");
}
}
/* Default Title und Keywords setzen */
$BTPL_module->setMetaData(
array ( "title" => $cbOption->getSingleOption("BTPL_defaultTitle"),
"keywords" => $cbOption->getSingleOption("BTPL_defaultKeywords")
)
);
$BTPL_module->setTemplate($tpl);
$BTPL_module->displayParsedModules();
$BTPL_tplArrays = $BTPL_module->getArrayList();
#$tpl->debugging = true;
/* MetaDaten abrufen und dem Template btpl:head zuordnen */
$metaData = $BTPL_module->getMetaData();
$tpl->assign(
array ( "TITLE" => $metaData[title],
"KEYWORDS" => $metaData[keywords]
)
);
$currentSection = "";
foreach($BTPL_tplArrays as $k => $v) {
$currentSection = $BTPL_arrayTplRelation[$v];
if(!empty($currentSection)) {
$tempVar = $currentSection."Set";
$tpl->assign($tempVar, "1");
$tpl->assign($currentSection, $$v);
}
}
$debug_time_end = microtime();
$start = explode(" ", $debug_time_start);
$end = explode(" ", $debug_time_end);
$elapsed = ($end[0] - $start[0]) + ($end[1] - $start[1]);
$mtime=number_format( $elapsed, 3, ".", ",");
$tpl->assign("debug_data",
array ( "creationTime" => $mtime )
);
#include('counter.inc.php');
/* Einbinden des Sub- oder DefaultMainTemplates */
if($BTPL_mainTemplate == "subMainTpl") {
$tpl->display($BTPL_skinModulePart."contentbuilder.template");
} else {
$tpl->display("contentbuilder.template");
}
/* --Sub Template Checker End-- */
$BTPL_log->setStatInfo("btpl:folder:view", $openfolder);
$BTPL_log->logInfo();
?>