<?php
include_once($rel."libraries/BTPL_functions.inc.php");
require_once($path['cb'].$cbDirLib.'CB_pageSplit.class.php');
require_once($path['cb'].$cbDirLib.'CB_media.class.php');
/* Flaggen Workaround */
$art2LangFlagArr = $langFlagArr;
define("ART_OPTION_PRINT", 1 << 0);
define("ART_SORT_DATE", 1 << 0);
define("ART_SORT_NUMERIC", 1 << 1);
define("ART_SORT_MONTH_NUMERIC", 1 << 2);
define("ART_SORT_DAY_NUMERIC", 1 << 3);
if(!is_object($artOption)) {
//Ableitung des Article Option Objektes
$artOption = new CBOption();
$artOption->setModule("art");
$artOption->getOptionList();
}
/* Offset herausfinden */
$articleOffset = 0;
if($_REQUEST[articleOffset] != "") {
$articleOffset = $_REQUEST[articleOffset];
}
if($archive == 1) {
$artAmount = 10000;
} else {
$artAmount = 10;
if($cbOption->getSingleOption("artAmount")) {
$artAmount = $cbOption->getSingleOption("artAmount");
}
}
// Instantiate Media Class for Media Work (like replacements)
$myMedia = new MediaManagement();
$myMedia->setOptionObject($cbOption);
$myMedia->setBranchID($cbOption->getSingleOption("rpBranch"));
$rpBranch = $myMedia->getBranchDirectory();
$dlQuery = mysql_fetch_array(mysql_query("SELECT * FROM ".TABLE."_options WHERE name = 'default_lang' AND module = 'art'"));
$defaultLanguage = $dlQuery[value];
$pageDefaultLanguage = $dlQuery[value];
if(!empty($_COOKIE['main_language'])) {
if(ereg("^[0-9]*$", $_COOKIE['main_language'])) {
$defaultLanguage = $_COOKIE['main_language'];
}
}
/*
* SQL Language Statement, falls sich vom User eingestellte Sprache
* mit der in C*B definierten unterscheidet. Dadurch werden auch
* alle Artikel angezeigt, die nicht in der User Sprache vorliegen
*/
$languageStatement = "content.language = '$defaultLanguage'";
#if($pageDefaultLanguage != $defaultLanguage) {
# $languageStatement = "(content.language = '$defaultLanguage' OR content.language = '$pageDefaultLanguage')";
#}
$userQuery = mysql_query("SELECT userid, fullname, initial, email FROM ".TABLE."_user");
while($userRow = mysql_fetch_array($userQuery)) {
$userFull[$userRow[userid]] = $userRow[fullname];
$userInitial[$userRow[userid]] = $userRow[initial];
$userEmail[$userRow[userid]] = $userRow[email];
}
$folderRow = mysql_fetch_array(mysql_query("SELECT fname, fid FROM ".TABLE."_columns WHERE fid = '$openfolder'"));
/* Implementation of stage rules in module article2 */
$today = date( "YmdHis", time() );
if($cbOption->getSingleOption("timepost")) {
if(!$preview) {
$stageStatement = "AND general.stage = '3' AND general.publishfrom <= '".$today."' AND (general.publishto >= '".$today."' OR general.publishto = '00000000')";
} else {
$stageStatement = "";
}
} else {
$stageStatement = "AND general.stage = '3'";
}
/*
* Sortier Methode
*/
$sortMethod = $artOption->getSingleOption("sortMethod");
switch($sortMethod){
case ART_SORT_NUMERIC:
$sortMethodString = "ORDER BY general.order_num ASC";
break;
default:
$sortMethodString = "ORDER BY general.datetime DESC";
} // switch
$artTitle = array();
$author_id = array();
$artInitial = array();
$artFolder = array();
$artIntro = array();
$artIde = array();
$artAuthorFull = array();
$artDate = array();
$artTime = array();
$artEmail = array();
$artMore = array();
// Building the select Query for article 2
$query = "SELECT * FROM ".TABLE."_art_general AS general, ".TABLE."_art_content AS content LEFT JOIN ".TABLE."_art_folder AS relFolder
ON general.ide = relFolder.articleID
WHERE general.ide = content.ide
AND ((relFolder.folderID = '$openfolder' AND relFolder.articleID = general.ide) OR general.folderID = '$openfolder')
$stageStatement
AND $languageStatement
GROUP BY general.ide
$sortMethodString LIMIT $articleOffset,$artAmount";
$result = mysql_query($query);
// Building the Counter Select Query to get the amount of articles
$counterQuery = mysql_fetch_assoc(mysql_query("SELECT COUNT(general.ide) AS artCounter FROM ".TABLE."_art_general AS general, ".TABLE."_art_content AS content LEFT JOIN ".TABLE."_art_folder AS relFolder
ON general.ide = relFolder.articleID
WHERE general.ide = content.ide
AND ((relFolder.folderID = '$openfolder' AND relFolder.articleID = general.ide) OR general.folderID = '$openfolder')
$stageStatement
AND content.language = '$defaultLanguage'"));
$articleFullAmount = $counterQuery[artCounter];
$artPageLinkObject = new CB_pageSplit($artAmount, $articleOffset, $articleFullAmount);
/*
* Fetching the results of article Query.
* Generating of Array's with Informations for templates
*/
$counter = 0;
while($artData = mysql_fetch_object($result)) {
/*
* Template Finder
*/
$style = $artData->template;
if(($style)&&(is_dir($tplLocation."/$style"))) {
$thisStyle = $style;
} else {
$thisStyle = "default";
}
/**
* 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 {
if( is_file($location."/settings.inc.php" )) {
include($location."/settings.inc.php" );
}
}
/* End Load Article Settings */
$intro = $artData->intro;
$content_all = explode("[--PAGEBREAK--]", $artData->content);
$content = stripslashes($content_all[0]);
$ide = $artData->ide;
$title = substr($artData->title, 0, 24);
if(strlen($artData->title) > 24) {
$title .= "...";
}
unset($iconData);
$query = mysql_query("SELECT branchID, filename FROM ".TABLE."_mm_files WHERE fileID = '".$artData->iconID."'");
$a = mysql_fetch_array($query);
$bQuery = mysql_fetch_array(mysql_query("SELECT branchName FROM ".TABLE."_mm_folder WHERE branchID = '".$a[branchID]."'"));
if($a["filename"] != "") { $iconData[set] = 1; } else { $iconData[set] = 0; }
$iconData[name] = $a["filename"];
$iconData[branch] = $bQuery["branchName"];
##### getting page titles #####
if((count($content_all) > 0) AND ($content != '') AND ($content != 'n/a'))
{
$page_title = array();
$page_title['0'] = "Additional Info";
for($t = 1; $t < count($content_all); $t++)
{
$ptitle = explode("[--TITLE--]", $content_all[$t]);
$page_title[$t] = $ptitle[1];
}
}
############# end #############
if(($content != '') AND ($content != 'n/a') AND ($content != '<P> </P>')) {
$more = "1";
} else {
$more = "0";
}
/********* REPLACEMENT START **********/
$intro = str_replace('[REPLACEDIR]', $path["cb"].'uploads/files/'.$rpBranch.'/', $intro);
/********** REPLACEMENT END ***********/
if(preg_match("/^[0-9]*$/i", $introWordRestriction) && $introWordRestriction != "noRestriction") {
$intro = word_substr($intro, $introWordRestriction, "4", "3");
}
// 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);
$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);
$datum = substr($artData->datetime,0,10);
$d1 = substr($datum,0,4);
$d2 = substr($datum,5,2);
$d3 = substr($datum,8,2);
$date= $d3.".".$d2.".".$d1;
$article_initial[] = $userInitial[$artData->userID];
/*
* 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
*/
$tpl->assign("art2Oview",
array ( "FLAGS" => $flagContent,
"FOLDER_NAME" => $folderRow[fname],
"TITLE" => $title,
"INTRO" => stripslashes($intro),
"IDE" => $ide,
"ICON" => $iconData[name],
"ICONBRANCH" => $iconData[branch],
"ICONSET" => $iconData[set],
"AUTHOR_FULL" => $userFull[$artData->userID],
"DATE" => $date,
"TIME" => substr($artData->datetime,11,8),
"EMAIL" => unicode_encode($userEmail[$artData->userID]),
"AID" => $artData->userID,
"MORE" => $more,
"OPENFOLDER" => $openfolder
)
);
unset($langFlagSet);
unset($langIDArr);
$output[] = $tpl->fetch("$thisStyle/overview.template", null, "article2");
$BTPL_metaData['title'] .= " ".$title;
$BTPL_metaData['keywords'] .= ", ".$contentObject->x_keywords;
++$counter;
}
$tpl->assign("articlePageNavigation",
array ( "nextAvailable" => $artPageLinkObject->nextPageExists(),
"lastAvailable" => $artPageLinkObject->lastPageExists(),
"nextOffset" => $artPageLinkObject->getNextOffset(),
"lastOffset" => $artPageLinkObject->getNextOffset(),
"pageArray" => $artPageLinkObject->getPages(),
"actualPage" => $artPageLinkObject->getActualPage()
)
);
$tpl->assign("overviewContent", $output);
/*
* Man kann verschiedene Templates angeben
*/
if(!empty($article2_overviewContent_template)) {
$tpl->display($article2_overviewContent_template);
} else {
$tpl->display("overviewContent.template");
}
?>