- <?php
- /**
- * <b>Week Calendar : Calendar</b><br />
- * The week calendar page displays all of the events for the specified week.
- * Default page for the the calendar section.
- * This section is searchable.
- * @author Kristen O'Brien <kristen_paristemi-com>
- * @copyright Copyright 2004, Kristen O'Brien
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @link http://www.paristemi.com Paristemi Main Site
- * @package paristemi
- * @subpackage paristemi_business_logic
- * @since Build 0.1
- * @version Build 0.7
- * @filesource
- */
- /**
- * Include the constants file and all of the files in the include list
- */
- if(ltrim(dirname($_SERVER['SCRIPT_FILENAME'])) == "" || !file_exists($_SERVER['DOCUMENT_ROOT']."/constants.php")) {
- if(!file_exists("../constants.php")) { require_once("../public_html/constants.php"); }
- else { require_once("../constants.php"); }
- }
- else { require_once($_SERVER['DOCUMENT_ROOT']."/constants.php"); }
- foreach($INCLUDE_LIST as $includefile) { require_once $includefile; }
- require_once ($SERVER_DIRECTORY.$INCLUDE_PATH.$CALENDAR_INCLUDE);
-
- $smarty = UtilSmarty::createSmarty();
- $cal = new Calendar;
- $db = new Database();
- $db_cal = $db->GetClass('cal');
-
- $searchterm="";$stitle="";$sstitle="";$sdesc="";$scntflg=false;$searchflg=false;$lbegin=0;
- if(getenv("QUERY_STRING")) {
- $month="";$day="";$year="";
- if(isset($HTTP_GET_VARS['mon'])) {$month = $HTTP_GET_VARS['mon'];}
- if(isset($HTTP_GET_VARS['day'])) {$day = $HTTP_GET_VARS['day'];}
- if(isset($HTTP_GET_VARS['year'])) {$year = $HTTP_GET_VARS['year'];}
- $today = getdate(mktime(0,0,0,$month,$day,$year));
-
- if(isset($HTTP_GET_VARS['SearchTerm'])) {$searchterm = $HTTP_GET_VARS['SearchTerm'];$searchflg=true;}
- if(isset($HTTP_GET_VARS['Title'])) {$stitle = $HTTP_GET_VARS['Title'];}
- if(isset($HTTP_GET_VARS['Category'])) {$sstitle = $HTTP_GET_VARS['Category'];}
- if(isset($HTTP_GET_VARS['Description'])) {$sdesc = $HTTP_GET_VARS['Description'];}
- if(isset($HTTP_GET_VARS['lbegin'])) {$lbegin = $HTTP_GET_VARS['lbegin'];}
- if(isset($HTTP_GET_VARS['scount'])) {$scount = $HTTP_GET_VARS['scount'];$scntflg=true;}
- }
- else { $today = getdate(time()); }
- $begin_week =& $cal->beginWeek($today);
- $end_week =& $cal->endWeek($today);
- $next_week =& $cal->nextDay(7,$begin_week);
- $last_week =& $cal->previousDay(7,$begin_week);
- $data =& $db_cal->GetWeekData($begin_week, $end_week);
-
- if(getenv("QUERY_STRING") && $searchflg && $searchterm != "") {
- $pagesubtitle = $S_SEARCH." ".$S_CALENDAR." - ".$searchterm;
- }
- else {
- $pagesubtitle = $begin_week['month'] . " " . $begin_week['mday'] . ", " . $begin_week['year']
- . " - " . $end_week['month'] . " ". $end_week['mday'] . ", " . $end_week['year'];
- }
- require_once $HTTP_DOCUMENT_ROOT.$INCLUDE_PATH.$HEADER.
- "?pagetitle=".str_replace(" ","%20",htmlentities($S_WEEK)." ".htmlentities($S_CALENDAR)).
- "&pagesubtitle=".str_replace(" ","%20",htmlentities(stripslashes($pagesubtitle))).
- "&pagedesc=".str_replace(" ","%20",htmlentities($CHURCH_NAME." ".$S_DESC_CAL));
-
- $sidecal = $cal->calHeader();
- $smarty->assign('sidesections',array($sidecal['callinks']));
- $smarty->assign('icondescriptions',$sidecal['calicons']);
- $smarty = $cal->calSearchForm($smarty);
-
- if(getenv("QUERY_STRING") && $searchflg && $searchterm != "") {
- $sterm = $searchterm;
- $atype = array();
- if($sdesc != null) { $atype[] = "description"; }
- if($stitle != null) { $atype[] = "title"; }
- if($sstitle != null) { $atype[] = "stitle"; }
-
- $finalresults =& $db_cal->SearchCalType($searchterm,$atype,$LISTING_LIMIT,$lbegin);
- if(!$scntflg) {$scount = $db_cal->SearchCalCount($searchterm,$atype);}
- $smarty->assign('heading',$S_SEARCH." ".$S_RESULTS." (".$scount." ".$S_TOTAL.")");
-
- if($finalresults != null) {
- $listelements = array();
- $foundoldevent = false;
- foreach($finalresults as $result) {
- if($result->STitle != "" && $result->STitle != "No Series"
- && $result->Title != $result->STitle && $result->Type != $S_HOME_GROUP) {
- $series = " - ".stripslashes($result->STitle); }
- else { $series = ""; }
- if(!$foundoldevent && $result->Timestamp < time()) {
- $listelements[] = array('Title'=>'break');
- $foundoldevent = true;
- }
- $listelements[] = array('LinkPath'=>$HTTP_DOCUMENT_ROOT.$CALENDAR_PATH.$ITEM_CAL_FILE."?id=".$result->ID,
- 'Title'=>stripslashes($result->Title).$series,
- 'SubTitle'=>$result->Date,
- 'SubText'=>stripslashes($result->Description),
- 'ImageIcons'=>array(
- array('Link'=>$HTTP_DOCUMENT_ROOT.$CALENDAR_PATH.$ITEM_CAL_FILE."?id=".$result->ID,
- 'src'=>$HTTP_DOCUMENT_ROOT.$IMAGE_PATH.$cal->getImageSmall($result->Type),
- 'alt'=>stripslashes($result->Type))));
- }
- $smarty->assign('listelements',$listelements);
- $bottomlinks = array();
- if($scount >= $lbegin-$LISTING_LIMIT && $lbegin-$LISTING_LIMIT >= 0) {
- $bottomlinks[] = array('LinkPath'=>$HTTP_DOCUMENT_ROOT.$CALENDAR_PATH.
- $WEEK_CAL_FILE."?SearchTerm=".$sterm."&Title=".
- $stitle."&STitle=".$sstitle."&Description=".$sdesc
- ."&lbegin=".($lbegin-$LISTING_LIMIT).
- "&scount=".$scount,
- 'LinkText'=>"<< ".$S_PREVIOUS." ".$LISTING_LIMIT." ".$S_RESULTS);
- }
- if($lbegin+$LISTING_LIMIT < $scount) {
- if($scount-($lbegin+$LISTING_LIMIT) < $LISTING_LIMIT) {
- $linktext = $S_NEXT." ".($scount-($lbegin+$LISTING_LIMIT))." ".$S_RESULTS." >>";
- }
- else { $linktext = $S_NEXT." ".$LISTING_LIMIT." ".$S_RESULTS." >>"; }
- $bottomlinks[] = array('LinkPath'=>$HTTP_DOCUMENT_ROOT.$CALENDAR_PATH.
- $WEEK_CAL_FILE."?SearchTerm=".$sterm."&Title=".
- $stitle."&Topic=".$sstitle."&Description=".$sdesc
- ."&lbegin=".($lbegin+$LISTING_LIMIT)."&scount=".$scount,'LinkText'=>$linktext);
- }
- $smarty->assign('bottomlinks',$bottomlinks);
- }
- else {
- $smarty->assign('notice',$N_SEARCH_CAL_NONE);
- }
- }
- else {
- $tbldata = array();
- $tblclass = "weekcal";
- $tbltdclass = array("weekcal-date","weekcal-day","weekcal-event");
-
- $tblheader = "<a href=\"".$HTTP_DOCUMENT_ROOT.$CALENDAR_PATH.$WEEK_CAL_FILE.
- "?mon=".$last_week['mon']."&day=".$last_week['mday']."&year=".$last_week['year']."\"><<</a>";
- $tblheader .= " ";
- $tblheader .= $S_WEEK_OF." " . $begin_week['month'] . " " . $begin_week['mday'] . ", " . $begin_week['year']
- . " - " . $end_week['month'] . " ". $end_week['mday'] . ", " . $end_week['year'];
- $tblheader .= " ";
- $tblheader .= "<a href=\"".$HTTP_DOCUMENT_ROOT.$CALENDAR_PATH.$WEEK_CAL_FILE.
- "?mon=".$next_week['mon']."&day=".$next_week['mday']."&year=".$next_week['year']."\">>></a>";
- $tblhead = array($tblheader,array($S_DATE,$S_DAY,$S_EVENT));
-
- $this_day = $begin_week;
- for($i=0; $i < 7; $i++) {
- $iteminfo = " ";
- foreach ($data as $value) {
- if($value->Start['wday'] == $this_day['wday']) {
- $itemlink = "<a href=\"".$HTTP_DOCUMENT_ROOT.$CALENDAR_PATH.$ITEM_CAL_FILE."?id=".$value->ID."\">";
- $itemdata = $itemlink."<img src=\"".$HTTP_DOCUMENT_ROOT.$IMAGE_PATH;
- $image =& $cal->getImageSmall($value->Type);
- $itemdata .= $image."\" border=\"0\" alt=\"".$value->Type."\"></a>";
- $itemdata .= " ".$itemlink.stripslashes($value->Title);
- $iteminfo .= $itemdata;
- if($value->SShow){
- if($value->Type == $S_HOME_GROUP) {
- // do nothing
- }
- else if($value->Title != $value->STitle) {
- $iteminfo .= " - ".$value->STitle;
- }
- }
- else if($value->Type == $S_BIBLE_COLLEGE) { $iteminfo .= " - ".$S_BIBLE_COLLEGE; }
- if($value->SSubShow) {
- $iteminfo .= "<br />".$itemdata;
- if($value->Title != $value->SSubTitle) {$iteminfo .= " - ".$value->SSubTitle;}
- }
- $iteminfo .= "</a><br />";
- }
- }
- $iteminfo = substr($iteminfo,0,strlen($iteminfo)-6);
- $iteminfo .= " ";
- $dayinfo = array($this_day['month']." ".$this_day['mday'],
- $this_day['weekday'],$iteminfo);
- array_push($tbldata,$dayinfo);
-
- $old_day = $this_day;
- $this_day =& $cal->incDay($old_day);
- }
-
- echo "<br />";
- $next_week =& $cal->nextDay(7,$begin_week);
- $last_week =& $cal->previousDay(7,$begin_week);
- $tblfooter = "<a href=\"".$HTTP_DOCUMENT_ROOT.$CALENDAR_PATH.$WEEK_CAL_FILE.
- "?mon=".$last_week['mon']."&day=".$last_week['mday']."&year=".$last_week['year']."\"><< Previous Week</a>".
- " | ".
- "<a href=\"".$HTTP_DOCUMENT_ROOT.$CALENDAR_PATH.$WEEK_CAL_FILE.
- "?mon=".$next_week['mon']."&day=".$next_week['mday']."&year=".$next_week['year']."\">Next Week >></a>";
- $smarty->assign('printtable',
- UtilHtml::createTable($tbldata,$tblhead,$tblclass,$tblfooter,"",$tbltdclass));
- }
- UtilSmarty::displaySectionPage($smarty);
- ?>
- <?php require_once $SERVER_DIRECTORY.$INCLUDE_PATH.$FOOTER; ?>