<?php
include_once($rel."libraries/BTPL_functions.inc.php");
require_once($path['cb'].$cbDirLib.'CB_media.class.php');
$BTPL_log->setStatInfo("btpl:article:view", $openfolder);
$BTPL_log->logInfo();
$myMedia = new MediaManagement();
$myMedia->setOptionObject($cbOption);
$myMedia->setBranchID($cbOption->getSingleOption("rpBranch"));
$rpBranch = $myMedia->getBranchDirectory();
$id = $_REQUEST['id'];
$ide = $id;
if(!empty($id)) {
// get article
$articleQuery = mysql_query("SELECT * FROM ".TABLE."_article WHERE ide = '$id'");
}
if($articleQuery) {
$article = mysql_fetch_object($articleQuery);
$userInfo = mysql_fetch_array(mysql_query("SELECT * FROM ".TABLE."_user WHERE userid = '".$article->userid."'"));
if(is_array($userInfo)) {
foreach($userInfo as $k => $v) {
$article->{$k} = $v;
}
}
if(!isset($openfolder)) {
$openfolder = $article->folder;
}
extract($HTTP_POST_VARS);
// nur auf der ersten Seite steht das Intro
if(!isset($page)) $page = 0;
if($page == 0) {
$intro = $article->intro;
}
/*
* Template Finder
*/
$style = $article->template;
if(($style)&&(is_dir($tplLocation."/$style"))) {
$thisStyle = &$style;
} else {
$thisStyle = "default";
}
// Content der aktuellen Seite bekommen
$content_all = explode("[--PAGEBREAK--]", $article->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.'&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.'&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.'&page='.$page_fwd;}
// Author Namen und Initialen
$author = $article->fullname;
if((count($content_all) - 1) == $page) {
$initial = '('.$article->initial.')';
}
// Limit für Comments
if(!$showall) {
if(empty($limit)) { $limit = 30; }
$limit = "LIMIT ".$limit;
}
if($link_back != "") {
$tpl->assign("back_link_set", "1");
}
if($link_fwd != "") {
$tpl->assign("fwd_link_set", "1");
}
/********* 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-]*) 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 */
/* Implementation of stage rules in module article */
$full_date = ($cbOption->getSingleOption("timepost")) ? getGermanDate($article->publishfrom) : getGermanDate($article->datum);
$fullarticle = array(
"FULL_INTRO" => stripslashes($intro),
"FULL_CONTENT" => stripslashes($content),
"FULL_TITLE" => $article->title,
"FULL_TIME" => substr($article->datum,11,8),
"FULL_DATE" => $full_date,
"FULL_PRINT" => $article->print,
"EMAIL" => unicode_encode($article->email),
"FULL_A_NAME" => $article->fullname,
"FULL_INITIAL" => $initial,
"FULL_IDE" => $id,
"FULL_OPENFOLDER" => $openfolder,
"PAGE_LINKS" => $pageLinks,
"FWD_LINK" => $link_fwd,
"BACK_LINK" => $link_back
);
$tpl->assign("fullarticle", $fullarticle);
/**
* Comment Ausgabe
*/
$type = "article";
$entryID = $id;
$idLabel = "id";
$submitLabel = "ART_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");
}
?>