<?php // $Id: block-Calendar_centerlist.php,v 20.10 2004/01/11 10:45:02 EllselAn Exp $
/************************************************************************/
/* KalenderMx v1.3                                                      */
/* ===================                                                  */
/*  Calendar Module for vkpMx 2.x & phpNuke 5.5-7.0                     */
/*  Copyright (c) 2004 by A.Ellsel (kalender@pragmamx.org)              */
/*  http://www.pragmamx.org & http://ww.shiba-design.de                 */
/* -------------------------------------------------------------------- */
/* KalenderMx is based on EventCalendar 2.0                             */
/*  Copyright (c) 2001 Originally by Rob Sutton                         */
/*  http://smart.xnettech.net (Nuke Site)                               */
/*  Development continued by Aleks A.-Lessmann                          */
/* Included some ideas and changes by:                                  */
/*  flobee, bulli-frank, kicks, kochloeffel, FrankySz, Jubilee          */
/* -------------------------------------------------------------------- */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 or a newer version.   */
/************************************************************************/
### !!!! don't change this 3 lines !!!! #########################################
$thisfile=basename(__file__);
if (eregi($thisfile, $_SERVER["PHP_SELF"])) die ("classement: You can't access this file directly...");
global $bgcolor1,$bgcolor2,$bgcolor3,$bgcolor4,$bgcolor5,$textcolor1,$textcolor2, $dbi;
#################################################################################

$mxblockcache = FALSE;

######  Einstellungen fuer den Block  ###################################################
if (!defined("CAL_MODULE_NAME")) define("CAL_MODULE_NAME","Kalender");  // CHANGE THIS IF YOU CHANGE THE CALENDAR-MODULES FOLDER NAME
#########################################################################################
$sort = "asc";						# Sortierung der Liste:  asc =aufsteigend / desc =absteigend
$scrolling = 0; 					# Eintraege seitlich scrollen
$scrolltype = "scroll" ;	# Art des Scrollens: scroll / alternate
$scrolldelay = 150 ;			# Scrollgeschwindigkeit: grosser Wert = langsamer / kleiner Wert = schneller
$listcount = 10 ;	 				# count of entries in the List-Block
$listStarttime = 0 ;			# display the starting Time in List-View: 0=nein / 1=ja
$listEndtime = 0 ;				# display the ending Time in List-View: 0=nein / 1=ja
$listtimebreak = 0 ;  		# Start/Endezeit nach Datum umbrechen:  0=nein / 1=ja   (erhoeht die Zeile!)
$eventwidth = 250	;				# Breite des einzelnen Events bei scrolling
$showTitle = 1 ;					# Blockueberschrift anzeigen: 0=nein / 1=ja
$scrolltopmargin = -2 ;		# Abstand des scrollenden Teils von oben: beliebiger integer Wert in px 
$showHeader = 1 ;					# Tabellenkopf anzeigen: 0=nein / 1=ja
$showLegend = 1 ;					# Farblegende anzeigen: 0=nein / 1=ja
$showNewlink = 1 ;				# Link Event vorschlagen anzeigen: 0=nein / 1=ja
$showalldot = 1 ;					# Link (stern) fuer alle Ereignisse 0=nein / 1=ja
######### Definition der Farben und Rahmen ###############################################################
$listheadbgcolor = $bgcolor2;				# Hintergrund Listen-Kopf
$listheadtxtcolor = $textcolor2;		# Text Listen-Kopf
$listbgcolor1 = $bgcolor1;					# Hintergrund erste Zeile
$listtxtcolor1 = $textcolor1;				# Text erste Zeile
$listbgcolor2 = $bgcolor2;					# Hintergrund naechste Zeile
$listtxtcolor2 = $textcolor2;				# Text naechste Zeile
$listbordercolor = $bgcolor3;				# Rahmenfarbe um Liste
$scrollbgcolor = $bgcolor1;					# Hintergrundfarbe des Marquee-Tags (Zwischenraum Scrollinhalte)
$listtableborder = 0;								# html Rahmen um Liste
$listtablecellspacing = 1;					# abstand zwischen Events (auch Rahmenbreite)
$listtablecellpadding = 2;    			# this will make the Events lines larger or smaller depending on value
$listheadbold = 1;									# Ueberschriften der Liste in Fettschrift: 0=nein / 1=ja
###### Ende der Einstellungen, ab hier nichts veraendern !! ###############################################

$listheadbold1 = ($listheadbold) ? "<b>" : "";
$listheadbold2 = ($listheadbold) ? "</b>" : "";
$timebreak    = ($listtimebreak) ? "<br>\n" : "";

$conftest =  @include("modules/".CAL_MODULE_NAME."/config/config.php");
if (!$conftest){
	$content = "<b>Error!</b><br>You must change the constant '\"CAL_MODULE_NAME\"' in file: <br>".__file__."";
	return;
	}
get_lang(CAL_MODULE_NAME);
if (!defined("CAL_MODULE_PATH"))  define("CAL_MODULE_PATH","modules/".CAL_MODULE_NAME."/");
if (!defined("CAL_TABLE_EVENTS")) @include_once(CAL_MODULE_PATH."includes/functions.php");

$showNewlink = (calIsPostAllowed() && $showNewlink) ? 1 : 0;

if (!calDetectGoodBrowser ()) {$scrolling=0;}
$whereoption= " categorie in(".calGetSqlEventpoints().") AND activ=1";
$d = (int)Date("d"); 
$m = (int)Date("m"); 
$y = (int)Date("Y");
$qrydate = "$y-$m-$d";
$qry="SELECT count(eid) FROM ".CAL_TABLE_EVENTS." 
WHERE (startDate>= '$qrydate' or endDate>= '$qrydate') 
and ($whereoption)";
list($icount) = sql_fetch_row(sql_query($qry, $dbi), $dbi);
if ($icount>$listcount) $icount=$listcount;
$content = "\n<!-- $thisfile output start -->\n<center>";
$i = 0;
if ($icount) {
	setlocale (LC_TIME, _CALLOCALE);
	$imgprops= "align=\"absmiddle\" hspace=\"6\" vspace=\"4\" width=\"9\" height=\"9\" border=\"0\" alt=\"\"";
	if ($scrolling) {
		$content.="<div style=\"position: relative; top: $scrolltopmargin;\">
		<marquee behavior='$scrolltype' direction='left' hspace='0' vspace='0' scrolldelay='$scrolldelay' loop='' truespeed dir='ltr' onmouseover='this.stop()' onmouseout='this.start()'>
		<table cellspacing=\"$listtablecellspacing\" cellpadding=\"$listtablecellpadding\" bgcolor=\"$listbordercolor\" bordercolor=\"$listbordercolor\" border=\"$listtableborder\">
		<tr>";
		}
	else {
		$content.="<table width=\"100%\" border=\"$listtableborder\" cellspacing=\"$listtablecellspacing\" cellpadding=\"$listtablecellpadding\" bgcolor=\"$listbordercolor\" bordercolor=\"$listbordercolor\">";
		if ($showHeader){
			$content.="<tr bgcolor=\"$listheadbgcolor\"><td colspan=\"3\" width=\"25%\"><font color=\"$listheadtxtcolor\" class=\"boxcontent\">$listheadbold1"._CALEVENTDATETEXT."$listheadbold2</font></td>\n<td width=\"75%\"><font color=\"$listheadtxtcolor\" class=\"boxcontent\">$listheadbold1"._CALSUBTITLE."$listheadbold2</font></td>\n</tr>\n";
			}
		#$content.="<tr bgcolor=\"$listbgcolor2\"><td width=\"10%\" height=\"1\"></td><td width=\"5%\"></td><td width=\"10%\"></td><td width=\"75%\"></td></tr>\n";
		}
	$content.="";
	$qry="SELECT eid, title, hometext, posteddate, topic, informant, year(startDate), month(startDate), dayofmonth(startDate), hour(startTime), minute(startTime), year(endDate), month(endDate), dayofmonth(endDate), hour(endTime), minute(endTime), alldayevent, categorie FROM ".CAL_TABLE_EVENTS." 
	WHERE (startDate>= '$qrydate' or endDate>= '$qrydate') 
	and ($whereoption) 
	order by startDate $sort, endDate $sort 
	limit 0,$icount";
	$result=sql_query($qry, $dbi);
	while(list($eid, $title, $hometext, $posteddate, $topic, $informant, $y1, $m1, $d1, $h1, $mi1, $y2, $m2, $d2, $h2, $mi2, $alldayevent, $categorie) = sql_fetch_row($result, $dbi)) {
		$title = htmlspecialchars(strip_tags(stripslashes($title)), ENT_QUOTES);
		$fontstyle = ($listStarttime) ? "tiny" : "content";
		$dateStart = strftime(_CALSHORTDATEFORMAT, mktime(0, 0, 0, $m1, $d1, $y1));
		if ($listStarttime && !$alldayevent) {
			$dateStart.= "$timebreak ".strftime(_CALTIMEFORMAT, mktime($h1, $mi1, 0, $m1, $d1, $y1));
			}
		$dateEnd = strftime(_CALSHORTDATEFORMAT, mktime(0, 0, 0, $m2, $d2, $y2));
		if ($listEndtime && !$alldayevent) {
			$dateEnd.= "$timebreak ".strftime(_CALTIMEFORMAT, mktime($h2, $mi2, 0, $m2, $d2, $y2));
			}
		$bgcolornew = ($i==0) ? $listbgcolor1 : $listbgcolor2;
		$txtcolornew = ($i==0) ? $listtxtcolor1 : $listtxtcolor2;
		$i = ($i==0) ? 1 : 0;
		if ($scrolling) {
			$content.="<td bgcolor=\"$bgcolornew\" nowrap width=\"$eventwidth\" align=\"center\"><font color=\"$txtcolornew\" class=\"tiny\">
			<img src=\"".calGetBarImage("ball",$categorie)."\" $imgprops>$dateStart "._CALLISTRANGE." $dateEnd</font><br>\n
			<font color=\"$txtcolornew\" class=\"boxcontent\">&nbsp;<a href=\"".CAL_MODULE_LINK."&op=view&eid=$eid\">$title</a></font></td>\n";
			}
		else {
			$alttext = ($hometext) ? strip_tags(htmlentities(stripslashes($hometext))) : "";
			$content.="<tr bgcolor=\"$bgcolornew\">
			<td nowrap width=\"10%\"><font color=\"$txtcolornew\" class=\"$fontstyle\">$dateStart</font></td>\n
			<td align=\"center\" width=\"5%\"><font color=\"$txtcolornew\" class=\"tiny\">"._CALLISTRANGE."</font></td>\n
			<td nowrap width=\"10%\"><font color=\"$txtcolornew\" class=\"$fontstyle\">$dateEnd</font></td>\n
			<td width=\"75%\"><font color=\"$txtcolornew\" class=\"boxcontent\"><img src=\"".calGetBarImage("ball",$categorie)."\" $imgprops>&nbsp;<a href=\"".CAL_MODULE_LINK."&op=view&eid=$eid\" title=\"$alttext\">$title</a></font></td>\n
			</tr>\n";
			}
		}
	$content.= ($scrolling) ? "</tr>\n</table></marquee></div>" : "</table>";
	setlocale (LC_TIME, $GLOBALS["locale"]);
	}
else {
	$content.= _CAL0EVENTSBLOCK."<br>\n";
	}
if ($showLegend) {
	$link = CAL_MODULE_LINK."&op=list";
	$content.=calBuildColorLegend("centerblock",$showalldot,$showNewlink);
	}
$content.="</center>";
$content .= "\n<!-- $thisfile output end -->\n<!-- XCalenderMx © by XyberSYSTEM Intelligent Network -->\n";
$content=ereg_replace("\t","",$content);

$blockfiletitle = ($showTitle) ? ""._CALLISTDESCRIPTION1." $icount "._CALLISTDESCRIPTION2."." : "";

?>
