[ Index ]
 

Code source de e107 0.7.8

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/e107_plugins/calendar_menu/ -> next_event_menu.php (source)

   1  <?php
   2  /*
   3  + ----------------------------------------------------------------------------+
   4  |     e107 website system
   5  |
   6  |     ©Steve Dunstan 2001-2002
   7  |     http://e107.org
   8  |     jalist@e107.org
   9  |
  10  |     Released under the terms and conditions of the
  11  |     GNU General Public License (http://gnu.org).
  12  |
  13  |     $Source: /cvsroot/e107/e107_0.7/e107_plugins/calendar_menu/next_event_menu.php,v $
  14  |     $Revision: 1.3 $
  15  |     $Date: 2006/11/16 10:24:14 $
  16  |     $Author: e107coders $
  17  |
  18  | 09.11.06 - Cache support added, templating/shortcode tweaks
  19  +----------------------------------------------------------------------------+
  20  */
  21  
  22  
  23  if (!defined('e107_INIT')) { exit; }
  24  
  25  global $ecal_dir, $tp;
  26  $ecal_dir    = e_PLUGIN . "calendar_menu/";
  27  
  28  global $ecal_class;
  29  require_once ($ecal_dir."ecal_class.php");
  30  $ecal_class = new ecal_class;
  31  
  32      $cache_tag = "nq_event_cal_next";
  33  
  34  // See if the page is already in the cache
  35      if($cacheData = $e107cache->retrieve($cache_tag, $ecal_class->max_cache_time))
  36      {
  37          echo $cacheData;
  38          return;
  39      }
  40  
  41  include_lan(e_PLUGIN."calendar_menu/languages/".e_LANGUAGE.".php");
  42  
  43  // Values defined through admin pages
  44  $menu_title = $pref['eventpost_menuheading'];
  45  $days_ahead = $pref['eventpost_daysforward'];
  46  $show_count = $pref['eventpost_numevents'];
  47  $show_recurring = $pref['eventpost_checkrecur'];
  48  $link_in_heading = $pref['eventpost_linkheader'];
  49  
  50  // Now set defaults for anything not defined
  51  if (!$menu_title) $menu_title = EC_LAN_140;
  52  if (!$days_ahead) $days_ahead = 30;        // Number of days ahead to go
  53  if (!$show_count) $show_count = 3;        // Number of events to show
  54  if (!$show_recurring) $show_recurring = 1;    // Zero to exclude recurring events
  55  if (!$link_in_heading) $link_in_heading = 0;    // Zero for simple heading, 1 to have clickable link
  56  
  57  
  58  require ($ecal_dir."calendar_shortcodes.php");
  59  if (is_readable(THEME."calendar_template.php")) 
  60  {  // Needs to be require in case second
  61    require (THEME."calendar_template.php");
  62  }
  63  else 
  64  {
  65    require ($ecal_dir."calendar_template.php");
  66  }
  67  
  68  $site_time = $ecal_class->cal_timedate;
  69  $end_time = $site_time + (86400 * $days_ahead);
  70  
  71  
  72  // Build up query bit by bit
  73      $cal_qry = "SELECT e.event_id, e.event_rec_m, e.event_rec_y, e.event_start, e.event_thread, e.event_title, e.event_recurring, e.event_allday, ec.*
  74      FROM #event as e LEFT JOIN #event_cat as ec ON e.event_category = ec.event_cat_id
  75      WHERE (((e.event_start >= {$site_time} AND e.event_start < {$end_time}))";
  76  
  77  if ($show_recurring > 0)
  78  {  // This won't work properly under some circumstances if $days_ahead is greater than the number of days in the current month plus next month.
  79     // If that matters, need another test on event_rec_y (which is actually the month) - plus the calculation to generate the values
  80      $cal_datearray        = $ecal_class->cal_date;
  81      $first_day            = $cal_datearray['mday'];
  82      $first_month        = $cal_datearray['mon'];
  83  
  84      $end_date    = mktime(0,0,0,$first_month,$first_day,0) + (86400 * $days_ahead);
  85      $end_datearray = getdate($end_date);
  86      $last_month = $end_datearray['mon'];
  87      $last_day    = $end_datearray['mday'];
  88      $cal_qry .= " OR ((e.event_recurring = '1') 
  89                   AND ";
  90      if ($first_month == $last_month)
  91      {   // All dates within current month
  92        $cal_qry .= "(((e.event_rec_y = {$first_month})    
  93                   AND  (e.event_rec_m >= {$first_day}) AND (e.event_rec_m < {$last_day})  ) ))";
  94      }
  95      else
  96      {    // Dates overlap one or more months
  97      $cal_qry .= "(((e.event_rec_y = {$first_month})    AND  (e.event_rec_m >= {$first_day})) 
  98                    OR ((e.event_rec_y  = {$last_month}) AND  (e.event_rec_m < {$last_day}))";
  99      $first_month++;
 100      if ($first_month > 12) $first_month = 1;
 101      if ($first_month <> $last_month)
 102      {  // Add a whole month in the middle
 103        $cal_qry .= " OR (e.event_rec_y = {$first_month}) ";
 104      }
 105      $cal_qry .= "))";
 106      }
 107  }
 108  
 109  $cal_qry .= ')'.$ecal_class->extra_query;       // Puts in class filter if not calendar admin
 110  
 111  if (isset($pref['eventpost_fe_set']))
 112  {
 113     $cal_qry .= " AND find_in_set(ec.event_cat_id,'".$pref['eventpost_fe_set']."')";
 114  }
 115      
 116  $cal_qry .= " order by e.event_start LIMIT {$show_count}";
 117  
 118  
 119  $cal_totev = 0;
 120  $cal_text = '';
 121  $cal_row = array();
 122  global $cal_row, $cal_totev;
 123  
 124  $cal_totev = $sql->db_Select_gen($cal_qry);
 125  
 126  
 127  if ($cal_totev > 0)
 128  {
 129      while ($cal_row = $sql->db_Fetch())
 130      {
 131        $cal_totev --;    // Can use this to modify inter-event gap
 132        $cal_text .= $tp->parseTemplate($EVENT_CAL_FE_LINE,FALSE,$calendar_shortcodes);
 133      }
 134  }
 135  else
 136  {
 137    $cal_text.= EC_LAN_141;
 138  }
 139  
 140  $calendar_title = $menu_title;
 141  if ($link_in_heading == 1)
 142  {
 143    $calendar_title = "<a class='forumlink' href='" . e_PLUGIN . "calendar_menu/event.php' >" . $menu_title . "</a>";
 144  }
 145  
 146  // Now handle the data, cache as well
 147  ob_start();                    // Set up a new output buffer
 148  $ns->tablerender($calendar_title, $cal_text, 'next_event_menu');
 149  $cache_data = ob_get_flush();            // Get the page content, and display it
 150  $e107cache->set($cache_tag, $cache_data);    // Save to cache
 151      
 152  
 153  ?>


Généré le : Sun Apr 1 01:23:32 2007 par Balluche grâce à PHPXref 0.7