[ 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/ -> calendar_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/calendar_menu.php,v $
  14  |     $Revision: 1.25 $
  15  |     $Date: 2006/11/24 22:27:18 $
  16  |     $Author: e107coders $
  17  |
  18  | 22.10.06 steved - Various tidying up, additional options supported
  19  | 24.10.06 steved - templated, various cleaning up
  20  | 06.11.06 steved - template file integrated with other calendar files
  21  | 09.11.06 steved - Caching added, other mods to templates etc
  22  +----------------------------------------------------------------------------+
  23  */
  24  
  25  
  26  if (!defined('e107_INIT')) { exit; }
  27  
  28  $ecal_dir    = e_PLUGIN . "calendar_menu/";
  29  require_once ($ecal_dir.'ecal_class.php');
  30  $ecal_class = new ecal_class;
  31  
  32  $cache_tag = "nq_event_cal_cal";
  33  
  34  
  35  // See if the page is already in the cache
  36      if($cacheData = $e107cache->retrieve($cache_tag, $ecal_class->max_cache_time))
  37      {
  38          echo $cacheData;
  39          return;
  40      }
  41  
  42  include_lan($ecal_dir."languages/".e_LANGUAGE.".php");
  43  
  44  global $ecal_dir, $tp;
  45  
  46  
  47  if (is_readable(THEME."calendar_template.php"))
  48  {
  49    require (THEME."calendar_template.php");
  50  }
  51  else
  52  {  // Needs to be require - otherwise not loaded if two menus use it
  53    require ($ecal_dir."calendar_template.php");
  54  }
  55  
  56  $cal_datearray        = $ecal_class->cal_date;
  57  $cal_current_month    = $cal_datearray['mon'];
  58  $cal_current_year    = $cal_datearray['year'];
  59  $numberdays    = date("t", $ecal_class->cal_date); // number of days in this month
  60  
  61  
  62  $cal_monthstart        = mktime(0, 0, 0, $cal_current_month, 1, $cal_current_year);            // Time stamp for first day of month
  63  $cal_firstdayarray    = getdate($cal_monthstart);
  64  $cal_monthend        = mktime(0, 0, 0, $cal_current_month + 1, 1, $cal_current_year) -1;        // Time stamp for last day of month
  65  
  66  
  67      $cal_qry = "SELECT e.event_rec_m, e.event_rec_y, e.event_start, e.event_end, e.event_datestamp, ec.*
  68      FROM #event as e LEFT JOIN #event_cat as ec ON e.event_category = ec.event_cat_id
  69      WHERE ((e.event_start >= {$cal_monthstart} AND e.event_start <= {$cal_monthend}) OR (e.event_rec_y = {$cal_current_month}))
  70      {$ecal_class->extra_query} order by e.event_start";
  71  
  72  
  73  $cal_events = array();
  74  $cal_totev = 0;
  75  if ($cal_totev = $sql->db_Select_gen($cal_qry))
  76  {
  77    while ($cal_row = $sql->db_Fetch())
  78    {
  79      if ($cal_row['event_rec_y'] == $cal_current_month)
  80      {    // Recurring events
  81        $cal_start_day = $cal_row['event_rec_m'];
  82      }
  83      else
  84      {    // 'normal' events
  85        $cal_tmp = getdate($cal_row['event_start']);
  86        if ($cal_tmp['mon'] == $cal_current_month)
  87        {
  88          $cal_start_day = $cal_tmp['mday'];
  89        }
  90        else
  91        {
  92          $cal_start_day = 1;
  93        }
  94      }
  95      // Mark start day of each event
  96      $cal_events[$cal_start_day][] = $cal_row['event_cat_icon'];    // Will be overwritten if several events on same day
  97      if ((($ecal_class->max_recent_show != 0) && (time() - $cal_row['event_datestamp']) <= $ecal_class->max_recent_show)) $cal_events[$cal_start_day]['is_recent'] = TRUE;
  98    }
  99  }
 100  
 101  
 102  if ($pref['eventpost_weekstart'] == 'sun')
 103  {
 104    $cal_week    = array(EC_LAN_25, EC_LAN_19, EC_LAN_20, EC_LAN_21, EC_LAN_22, EC_LAN_23, EC_LAN_24);
 105  }
 106  else
 107  {
 108    $cal_week    = array(EC_LAN_19, EC_LAN_20, EC_LAN_21, EC_LAN_22, EC_LAN_23, EC_LAN_24, EC_LAN_25);
 109  }
 110  
 111  $cal_months    = array(EC_LAN_0, EC_LAN_1, EC_LAN_2, EC_LAN_3, EC_LAN_4, EC_LAN_5, EC_LAN_6, EC_LAN_7, EC_LAN_8, EC_LAN_9, EC_LAN_10, EC_LAN_11);
 112  
 113  
 114  $calendar_title = "<a class='forumlink' href='".e_PLUGIN."calendar_menu/";
 115  if ($pref['eventpost_menulink'] == 1)
 116  {
 117    $calendar_title .= "calendar.php' >";
 118  }
 119  else
 120  {
 121    $calendar_title .= "event.php' >";
 122  }
 123  if ($pref['eventpost_dateformat'] == 'my')
 124  {
 125      $calendar_title .= $cal_months[$cal_datearray['mon']-1] ." ". $cal_current_year . "</a>";
 126  }
 127  else
 128  {
 129      $calendar_title .= $cal_current_year ." ". $cal_months[$cal_datearray['mon']-1] . "</a>";
 130  }
 131  
 132  
 133  $cal_text = $CALENDAR_MENU_START;
 134  
 135  
 136  if ($pref['eventpost_showeventcount']=='1')
 137  {
 138    if ($cal_totev)
 139    {
 140      $cal_text .= EC_LAN_26 . ": " . $cal_totev;
 141    }
 142    else
 143    {
 144      $cal_text .= EC_LAN_27;
 145    }
 146    $cal_text .= "<br /><br />";
 147  }
 148  
 149  $cal_start    = $cal_monthstart;        // First day of month as time stamp
 150  
 151  
 152  // Start the table
 153  $cal_text .= $CALENDAR_MENU_TABLE_START;
 154  // Open header row
 155  $cal_text .= $CALENDAR_MENU_HEADER_START;
 156  // Now do the headings
 157  
 158  foreach($cal_week as $cal_day)
 159  {
 160      $cal_text .= $CALENDAR_MENU_HEADER_FRONT;
 161      $cal_text .= substr($cal_day, 0, $pref['eventpost_lenday']);
 162      $cal_text .= $CALENDAR_MENU_HEADER_BACK;
 163  }
 164  $cal_text .= $CALENDAR_MENU_HEADER_END;  // Close off header row, open first date row
 165  
 166  
 167  $cal_thismonth    = $cal_datearray['mon'];
 168  $cal_thisday    = $cal_datearray['mday'];    // Today
 169  
 170  
 171  if ($pref['eventpost_weekstart'] == 'mon')
 172  {
 173      $firstdayoffset = ($cal_firstdayarray['wday'] == 0 ? $cal_firstdayarray['wday'] + 6 : $cal_firstdayarray['wday']-1);
 174  }
 175  else
 176  {
 177      $firstdayoffset = $cal_firstdayarray['wday'];
 178  }
 179  
 180  
 181  for ($cal_c = 0; $cal_c < $firstdayoffset; $cal_c++)
 182  {
 183      $cal_text .= $CALENDAR_MENU_DAY_NON;
 184  }
 185  $cal_loop = $firstdayoffset;
 186  
 187  // Now do the days of the month
 188  for($cal_c = 1; $cal_c <= 31; $cal_c++)
 189  {   // Four cases to decode:
 190      //         1 - Today, no events
 191      //        2 - Some other day, no events (or no icon defined)
 192      //        3 - Today with events (and icon defined)
 193      //        4 - Some other day with events (and icon defined)
 194      $cal_dayarray = getdate($cal_start + (($cal_c-1) * 86400));
 195      $cal_css = 2;        // The default - not today, no events
 196      if ($cal_dayarray['mon'] == $cal_thismonth)
 197      {  // Dates match for this month
 198        $cal_img = $cal_c;        // Default 'image' is the day of the month
 199        $cal_event_count = 0;
 200        $title = "";
 201        if ($cal_thisday == $cal_c) $cal_css = 1;
 202          $cal_linkut = mktime(0 , 0 , 0 , $cal_dayarray['mon'], $cal_c, $cal_datearray['year']).".one";  // ALways need "one"
 203          if (array_key_exists($cal_c, $cal_events))
 204          {
 205              $cal_event_icon = e_PLUGIN . "calendar_menu/images/" . $cal_events[$cal_c]['0'];
 206              $cal_event_count = count($cal_events[$cal_c]);        // See how many events today
 207              if (!empty($cal_events[$cal_c]) && is_file($cal_event_icon))
 208              {   // Show icon if it exists
 209                $cal_css += 2;        // Gives 3 for today, 4 for other day
 210                if ($cal_event_count == 1)
 211                {
 212                  $title = " title='1 ".EC_LAN_135."' ";
 213                }
 214                else
 215                {
 216                  $title = " title='{$cal_event_count} " . EC_LAN_106 . "' ";
 217                }
 218                $cal_img = "<img style='border:0' src='{$cal_event_icon}' alt='' />";
 219                  //height='10' width='10'
 220                if (isset($cal_events[$cal_c]['is_recent']) && $cal_events[$cal_c]['is_recent'])
 221                {
 222                  $cal_css += 2;
 223                }
 224              }
 225          }
 226          $cal_text .= $CALENDAR_MENU_DAY_START[$cal_css]."<a {$title} href='" . e_PLUGIN . "calendar_menu/event.php?{$cal_linkut}'>{$cal_img}</a>";
 227          $cal_text .= $CALENDAR_MENU_DAY_END[$cal_css];
 228          $cal_loop++;
 229          if ($cal_loop == 7)
 230          {  // Start next row
 231              $cal_loop = 0;
 232              if ($cal_c != $numberdays)
 233              {
 234                $cal_text .= $CALENDAR_MENU_WEEKSWITCH;
 235              }
 236          }
 237      }
 238  }
 239  
 240  if ($cal_loop != 0)
 241  {
 242  for($cal_a = ($cal_loop + 1); $cal_a <= 7; $cal_a++)
 243  {
 244      $cal_text .= $CALENDAR_MENU_DAY_NON;
 245  }
 246  }
 247  // Close table
 248  $cal_text .= $CALENDAR_MENU_END;
 249  
 250  // Now handle the data, cache as well
 251  ob_start();                    // Set up a new output buffer
 252  $ns->tablerender($calendar_title, $cal_text, 'calendar_menu');
 253  $cache_data = ob_get_flush();            // Get the page content, and display it
 254  $e107cache->set($cache_tag, $cache_data);    // Save to cache
 255  
 256  
 257  ?>


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