Changeset 874 for trunk/www/macros/macro_calendar.php
- Timestamp:
- 12/25/07 13:58:40 (4 years ago)
- File:
-
- 1 edited
-
trunk/www/macros/macro_calendar.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/macros/macro_calendar.php
r869 r874 1 1 <?php 2 require_once(IA_ROOT_DIR.'www/url.php'); 2 3 3 require_once(IA_ROOT_DIR.'www/macros/macro_remotebox.php'); 4 function macro_calendar($args) { 5 $max_events = getattr($args, 'limit', 7); 6 $forumurl = url_forum(); 4 7 5 function macro_calendar() { 6 $args = array( 7 'url' => IA_SMF_URL.'/ia_calendar.php' 8 ); 9 return macro_remotebox($args, true); 8 // Find all events which are happening in the near future that the member can see. 9 $result = db_fetch_all(" 10 SELECT 11 cal.ID_EVENT, cal.startDate, cal.endDate, cal.title, cal.ID_MEMBER, cal.ID_TOPIC, 12 cal.ID_BOARD, t.ID_FIRST_MSG 13 FROM ia_smf_calendar AS cal 14 LEFT JOIN ia_smf_boards AS b ON (b.ID_BOARD = cal.ID_BOARD) 15 LEFT JOIN ia_smf_topics AS t ON (t.ID_TOPIC = cal.ID_TOPIC) 16 WHERE cal.endDate >= '" . strftime('%Y-%m-%d', time()) . "' 17 ORDER BY cal.startDate 18 LIMIT $max_events"); 19 $return = array(); 20 $duplicates = array(); 21 foreach ($result as $row) 22 { 23 // Check if we've already come by an event linked to this same topic with the same title... and don't display it if we have. 24 if (!empty($duplicates[$row['title'] . $row['ID_TOPIC']])) 25 continue; 26 27 if ($row['startDate'] < strftime('%Y-%m-%d', time())) 28 $date = strftime('%Y-%m-%d', time()); 29 else 30 $date = $row['startDate']; 31 32 $return[$date][] = array( 33 'id' => $row['ID_EVENT'], 34 'title' => $row['title'], 35 'modify_href' => $forumurl . '?action=' . ($row['ID_BOARD'] == 0 ? 'calendar;sa=post;' : 'post;msg=' . $row['ID_FIRST_MSG'] . ';topic=' . $row['ID_TOPIC'] . '.0;calendar;') . 'eventid=' . $row['ID_EVENT'], 36 'href' => $row['ID_BOARD'] == 0 ? '' : $forumurl . '?topic=' . $row['ID_TOPIC'] . '.0', 37 'link' => $row['ID_BOARD'] == 0 ? $row['title'] : '<a href="' . $forumurl . '?topic=' . $row['ID_TOPIC'] . '.0">' . $row['title'] . '</a>', 38 'start_date' => $row['startDate'], 39 'end_date' => $row['endDate'], 40 'is_last' => false 41 ); 42 43 // Let's not show this one again, huh? 44 $duplicates[$row['title'] . $row['ID_TOPIC']] = true; 45 } 46 47 foreach ($return as $mday => $array) 48 $return[$mday][count($array) - 1]['is_last'] = true; 49 50 $html = '<div class="calendar">'; 51 $html .= '<div class="header">'; 52 $html .= '<a href="'.IA_URL.'/forum?action=calendar">In curand..</a></div>'; 53 foreach ($return as $mday => $array) 54 { 55 $html .= '<div class="date">'.strftime("%A, %d %b %Y", strtotime($mday)).'</div>'; 56 foreach ($array as $event) 57 { 58 $html .= '<div class="event">'; 59 $html .= '»'; 60 $html .= $event['link'] . (!$event['is_last'] ? ', ' : ''); 61 $html .= '</div>'; 62 } 63 } 64 $html .= '</div>'; 65 66 return $html; 10 67 } 11 68
Note: See TracChangeset
for help on using the changeset viewer.
![[infoarena] development](/chrome/site/logo.png)