paristemi
[ class tree: paristemi ] [ index: paristemi ] [ all elements ]

Source for file index.php

Documentation is available at index.php

  1. <?php
  2. /**
  3. * <b>Week Calendar : Calendar</b><br />
  4. * The week calendar page displays all of the events for the specified week.
  5. * Default page for the the calendar section.
  6. * This section is searchable.
  7. * @author Kristen O'Brien <kristen_paristemi-com>
  8. * @copyright Copyright 2004, Kristen O'Brien
  9. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  10. * @link http://www.paristemi.com Paristemi Main Site
  11. * @package paristemi
  12. * @subpackage paristemi_business_logic
  13. * @since Build 0.1
  14. * @version Build 0.7
  15. * @filesource
  16. */
  17. /**
  18. * Include the constants file and all of the files in the include list
  19. */
  20. if(ltrim(dirname($_SERVER['SCRIPT_FILENAME'])) == "" || !file_exists($_SERVER['DOCUMENT_ROOT']."/constants.php")) {
  21. if(!file_exists("../constants.php")) { require_once("../public_html/constants.php"); }
  22. else { require_once("../constants.php"); }
  23. }
  24. else { require_once($_SERVER['DOCUMENT_ROOT']."/constants.php"); }
  25. foreach($INCLUDE_LIST as $includefile) { require_once $includefile; }
  26. require_once ($SERVER_DIRECTORY.$INCLUDE_PATH.$CALENDAR_INCLUDE);
  27.  
  28. $smarty = UtilSmarty::createSmarty();
  29. $cal = new Calendar;
  30. $db = new Database();
  31. $db_cal = $db->GetClass('cal');
  32. $searchterm="";$stitle="";$sstitle="";$sdesc="";$scntflg=false;$searchflg=false;$lbegin=0;
  33. if(getenv("QUERY_STRING")) {
  34. $month="";$day="";$year="";
  35. if(isset($HTTP_GET_VARS['mon'])) {$month = $HTTP_GET_VARS['mon'];}
  36. if(isset($HTTP_GET_VARS['day'])) {$day = $HTTP_GET_VARS['day'];}
  37. if(isset($HTTP_GET_VARS['year'])) {$year = $HTTP_GET_VARS['year'];}
  38. $today = getdate(mktime(0,0,0,$month,$day,$year));
  39.  
  40. if(isset($HTTP_GET_VARS['SearchTerm'])) {$searchterm = $HTTP_GET_VARS['SearchTerm'];$searchflg=true;}
  41. if(isset($HTTP_GET_VARS['Title'])) {$stitle = $HTTP_GET_VARS['Title'];}
  42. if(isset($HTTP_GET_VARS['Category'])) {$sstitle = $HTTP_GET_VARS['Category'];}
  43. if(isset($HTTP_GET_VARS['Description'])) {$sdesc = $HTTP_GET_VARS['Description'];}
  44. if(isset($HTTP_GET_VARS['lbegin'])) {$lbegin = $HTTP_GET_VARS['lbegin'];}
  45. if(isset($HTTP_GET_VARS['scount'])) {$scount = $HTTP_GET_VARS['scount'];$scntflg=true;}
  46. }
  47. else { $today = getdate(time()); }
  48. $begin_week =& $cal->beginWeek($today);
  49. $end_week =& $cal->endWeek($today);
  50. $next_week =& $cal->nextDay(7,$begin_week);
  51. $last_week =& $cal->previousDay(7,$begin_week);
  52. $data =& $db_cal->GetWeekData($begin_week, $end_week);
  53. if(getenv("QUERY_STRING") && $searchflg && $searchterm != "") {
  54. $pagesubtitle = $S_SEARCH." ".$S_CALENDAR." - ".$searchterm;
  55. }
  56. else {
  57. $pagesubtitle = $begin_week['month'] . " " . $begin_week['mday'] . ", " . $begin_week['year']
  58. . " - " . $end_week['month'] . " ". $end_week['mday'] . ", " . $end_week['year'];
  59. }
  60. require_once $HTTP_DOCUMENT_ROOT.$INCLUDE_PATH.$HEADER.
  61. "?pagetitle=".str_replace(" ","%20",htmlentities($S_WEEK)." ".htmlentities($S_CALENDAR)).
  62. "&pagesubtitle=".str_replace(" ","%20",htmlentities(stripslashes($pagesubtitle))).
  63. "&pagedesc=".str_replace(" ","%20",htmlentities($CHURCH_NAME." ".$S_DESC_CAL));
  64. $sidecal = $cal->calHeader();
  65. $smarty->assign('sidesections',array($sidecal['callinks']));
  66. $smarty->assign('icondescriptions',$sidecal['calicons']);
  67. $smarty = $cal->calSearchForm($smarty);
  68. if(getenv("QUERY_STRING") && $searchflg && $searchterm != "") {
  69. $sterm = $searchterm;
  70. $atype = array();
  71. if($sdesc != null) { $atype[] = "description"; }
  72. if($stitle != null) { $atype[] = "title"; }
  73. if($sstitle != null) { $atype[] = "stitle"; }
  74. $finalresults =& $db_cal->SearchCalType($searchterm,$atype,$LISTING_LIMIT,$lbegin);
  75. if(!$scntflg) {$scount = $db_cal->SearchCalCount($searchterm,$atype);}
  76. $smarty->assign('heading',$S_SEARCH." ".$S_RESULTS." (".$scount." ".$S_TOTAL.")");
  77. if($finalresults != null) {
  78. $listelements = array();
  79. $foundoldevent = false;
  80. foreach($finalresults as $result) {
  81. if($result->STitle != "" && $result->STitle != "No Series"
  82. && $result->Title != $result->STitle && $result->Type != $S_HOME_GROUP) {
  83. $series = " - ".stripslashes($result->STitle); }
  84. else { $series = ""; }
  85. if(!$foundoldevent && $result->Timestamp < time()) {
  86. $listelements[] = array('Title'=>'break');
  87. $foundoldevent = true;
  88. }
  89. $listelements[] = array('LinkPath'=>$HTTP_DOCUMENT_ROOT.$CALENDAR_PATH.$ITEM_CAL_FILE."?id=".$result->ID,
  90. 'Title'=>stripslashes($result->Title).$series,
  91. 'SubTitle'=>$result->Date,
  92. 'SubText'=>stripslashes($result->Description),
  93. 'ImageIcons'=>array(
  94. array('Link'=>$HTTP_DOCUMENT_ROOT.$CALENDAR_PATH.$ITEM_CAL_FILE."?id=".$result->ID,
  95. 'src'=>$HTTP_DOCUMENT_ROOT.$IMAGE_PATH.$cal->getImageSmall($result->Type),
  96. 'alt'=>stripslashes($result->Type))));
  97. }
  98. $smarty->assign('listelements',$listelements);
  99. $bottomlinks = array();
  100. if($scount >= $lbegin-$LISTING_LIMIT && $lbegin-$LISTING_LIMIT >= 0) {
  101. $bottomlinks[] = array('LinkPath'=>$HTTP_DOCUMENT_ROOT.$CALENDAR_PATH.
  102. $WEEK_CAL_FILE."?SearchTerm=".$sterm."&amp;Title=".
  103. $stitle."&amp;STitle=".$sstitle."&amp;Description=".$sdesc
  104. ."&amp;lbegin=".($lbegin-$LISTING_LIMIT).
  105. "&amp;scount=".$scount,
  106. 'LinkText'=>"<< ".$S_PREVIOUS." ".$LISTING_LIMIT." ".$S_RESULTS);
  107. }
  108. if($lbegin+$LISTING_LIMIT < $scount) {
  109. if($scount-($lbegin+$LISTING_LIMIT) < $LISTING_LIMIT) {
  110. $linktext = $S_NEXT." ".($scount-($lbegin+$LISTING_LIMIT))." ".$S_RESULTS." >>";
  111. }
  112. else { $linktext = $S_NEXT." ".$LISTING_LIMIT." ".$S_RESULTS." >>"; }
  113. $bottomlinks[] = array('LinkPath'=>$HTTP_DOCUMENT_ROOT.$CALENDAR_PATH.
  114. $WEEK_CAL_FILE."?SearchTerm=".$sterm."&amp;Title=".
  115. $stitle."&amp;Topic=".$sstitle."&amp;Description=".$sdesc
  116. ."&amp;lbegin=".($lbegin+$LISTING_LIMIT)."&amp;scount=".$scount,'LinkText'=>$linktext);
  117. }
  118. $smarty->assign('bottomlinks',$bottomlinks);
  119. }
  120. else {
  121. $smarty->assign('notice',$N_SEARCH_CAL_NONE);
  122. }
  123. }
  124. else {
  125. $tbldata = array();
  126. $tblclass = "weekcal";
  127. $tbltdclass = array("weekcal-date","weekcal-day","weekcal-event");
  128. $tblheader = "<a href=\"".$HTTP_DOCUMENT_ROOT.$CALENDAR_PATH.$WEEK_CAL_FILE.
  129. "?mon=".$last_week['mon']."&amp;day=".$last_week['mday']."&amp;year=".$last_week['year']."\">&lt;&lt;</a>";
  130. $tblheader .= "&nbsp; &nbsp; &nbsp;";
  131. $tblheader .= $S_WEEK_OF." " . $begin_week['month'] . " " . $begin_week['mday'] . ", " . $begin_week['year']
  132. . " - " . $end_week['month'] . " ". $end_week['mday'] . ", " . $end_week['year'];
  133. $tblheader .= "&nbsp; &nbsp; &nbsp;";
  134. $tblheader .= "<a href=\"".$HTTP_DOCUMENT_ROOT.$CALENDAR_PATH.$WEEK_CAL_FILE.
  135. "?mon=".$next_week['mon']."&amp;day=".$next_week['mday']."&amp;year=".$next_week['year']."\">&gt;&gt;</a>";
  136. $tblhead = array($tblheader,array($S_DATE,$S_DAY,$S_EVENT));
  137. $this_day = $begin_week;
  138. for($i=0; $i < 7; $i++) {
  139. $iteminfo = "&nbsp;";
  140. foreach ($data as $value) {
  141. if($value->Start['wday'] == $this_day['wday']) {
  142. $itemlink = "<a href=\"".$HTTP_DOCUMENT_ROOT.$CALENDAR_PATH.$ITEM_CAL_FILE."?id=".$value->ID."\">";
  143. $itemdata = $itemlink."<img src=\"".$HTTP_DOCUMENT_ROOT.$IMAGE_PATH;
  144. $image =& $cal->getImageSmall($value->Type);
  145. $itemdata .= $image."\" border=\"0\" alt=\"".$value->Type."\"></a>";
  146. $itemdata .= "&nbsp;".$itemlink.stripslashes($value->Title);
  147. $iteminfo .= $itemdata;
  148. if($value->SShow){
  149. if($value->Type == $S_HOME_GROUP) {
  150. // do nothing
  151. }
  152. else if($value->Title != $value->STitle) {
  153. $iteminfo .= " - ".$value->STitle;
  154. }
  155. }
  156. else if($value->Type == $S_BIBLE_COLLEGE) { $iteminfo .= " - ".$S_BIBLE_COLLEGE; }
  157. if($value->SSubShow) {
  158. $iteminfo .= "<br />".$itemdata;
  159. if($value->Title != $value->SSubTitle) {$iteminfo .= " - ".$value->SSubTitle;}
  160. }
  161. $iteminfo .= "</a><br />";
  162. }
  163. }
  164. $iteminfo = substr($iteminfo,0,strlen($iteminfo)-6);
  165. $iteminfo .= "&nbsp;";
  166. $dayinfo = array($this_day['month']." ".$this_day['mday'],
  167. $this_day['weekday'],$iteminfo);
  168. array_push($tbldata,$dayinfo);
  169. $old_day = $this_day;
  170. $this_day =& $cal->incDay($old_day);
  171. }
  172. echo "<br />";
  173. $next_week =& $cal->nextDay(7,$begin_week);
  174. $last_week =& $cal->previousDay(7,$begin_week);
  175. $tblfooter = "<a href=\"".$HTTP_DOCUMENT_ROOT.$CALENDAR_PATH.$WEEK_CAL_FILE.
  176. "?mon=".$last_week['mon']."&amp;day=".$last_week['mday']."&amp;year=".$last_week['year']."\">&lt;&lt; Previous Week</a>".
  177. "&nbsp;&nbsp;|&nbsp;&nbsp;".
  178. "<a href=\"".$HTTP_DOCUMENT_ROOT.$CALENDAR_PATH.$WEEK_CAL_FILE.
  179. "?mon=".$next_week['mon']."&amp;day=".$next_week['mday']."&amp;year=".$next_week['year']."\">Next Week &gt;&gt;</a>";
  180. $smarty->assign('printtable',
  181. UtilHtml::createTable($tbldata,$tblhead,$tblclass,$tblfooter,"",$tbltdclass));
  182. }
  183. UtilSmarty::displaySectionPage($smarty);
  184. ?>
  185. <?php require_once $SERVER_DIRECTORY.$INCLUDE_PATH.$FOOTER; ?>

Documentation generated on Mon, 10 May 2004 12:10:01 -0700 by phpDocumentor 1.3.0RC3