[ Index ]
 

Code source de e107 0.7.8

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

title

Body

[fermer]

/e107_plugins/blogcalendar_menu/ -> archive.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/blogcalendar_menu/archive.php,v $
  14  |     $Revision: 1.4 $
  15  |     $Date: 2006/06/12 09:07:10 $
  16  |     $Author: lisa_ $
  17  +----------------------------------------------------------------------------+
  18  | Based on code by: Thomas Bouve (crahan@gmx.net)
  19  */
  20      
  21  require_once ("../../class2.php");
  22  require_once(e_HANDLER."userclass_class.php");
  23      
  24  $lan_file = e_PLUGIN."blogcalendar_menu/languages/".e_LANGUAGE.".php";
  25  if (file_exists($lan_file)) {
  26      require_once($lan_file);
  27  } else {
  28      require_once(e_PLUGIN."blogcalendar_menu/languages/English.php");
  29  };
  30  require_once ("calendar.php");
  31  require_once ("functions.php");
  32  require_once(HEADERF);
  33      
  34  // ---------------------
  35  // initialize some cruft
  36  // ---------------------
  37  $sql = new db;
  38  $prefix = e_PLUGIN."blogcalendar_menu";
  39  $marray = array(BLOGCAL_M1, BLOGCAL_M2, BLOGCAL_M3, BLOGCAL_M4,
  40      BLOGCAL_M5, BLOGCAL_M6, BLOGCAL_M7, BLOGCAL_M8,
  41      BLOGCAL_M9, BLOGCAL_M10, BLOGCAL_M11, BLOGCAL_M12);
  42  // if nr of rows per month is not set, default to 3
  43  $months_per_row = $pref['blogcal_mpr']?$pref['blogcal_mpr']:
  44  "3";
  45  $pref['blogcal_ws'] = "monday";
  46      
  47  // -------------------------------------
  48  // what year are we supposed to display?
  49  // -------------------------------------
  50  $cur_year = date("Y");
  51  $cur_month = date("n");
  52  $cur_day = date("j");
  53  if (strstr(e_QUERY, "year")) {
  54      $tmp = explode(".", e_QUERY);
  55      $req_year = $tmp[1];
  56  } else {
  57      $req_year = $cur_year;
  58  }
  59      
  60      
  61  // --------------------------------
  62  // look for the first and last year
  63  // --------------------------------
  64  $sql->db_Select_gen("SELECT news_id, news_datestamp from ".MPREFIX."news ORDER BY news_datestamp LIMIT 0,1");
  65  $first_post = $sql->db_Fetch();
  66  $start_year = date("Y", $first_post['news_datestamp']);
  67  $end_year = $cur_year;
  68      
  69      
  70  // ----------------------
  71  // build the yearselector
  72  // ----------------------
  73  $year_selector = "<div class='forumheader' style='text-align: center; margin-bottom: 2px;'>";
  74  $year_selector .= "".BLOGCAL_ARCHIV1.": <select name='activate' onChange='urljump(this.options[selectedIndex].value)' class='tbox'>";
  75  
  76  for($i = $start_year; $i <= $end_year; $i++) {
  77      $start = mktime(0, 0, 0, 1, 1, intval($req_year));
  78      $end = mktime(23, 59, 59, 12, 31, intval($req_year));
  79      // create the option entry
  80      $year_link = $prefix."/archive.php?year.".$i;
  81      $year_selector .= "<option value='".$year_link."'";
  82      if ($i == $req_year) {
  83          $year_selector .= " selected";
  84      }
  85      if ($sql->db_Select("news", "news_id, news_datestamp, news_class", "news_datestamp > $start AND news_datestamp < $end")) {
  86          while ($news = $sql->db_Fetch()) {
  87              if (check_class($news['news_class'])) {
  88                  list($xmonth, $xday) = explode(" ", date("n j", $news['news_datestamp']));
  89                  if (!$day_links[$xmonth][$xday]) {
  90                      $day_links[$xmonth][$xday] = e_BASE."news.php?day.".formatdate($req_year, $xmonth, $xday);
  91                  }
  92              }
  93          }
  94      }
  95      $year_selector .= ">".$i."</option>";
  96  }
  97      
  98  $year_selector .= "</select>";
  99      
 100      
 101  // --------------------------
 102  // create the archive display
 103  // --------------------------
 104  $newline = 0;
 105  $archive = "<div style='text-align:center'><table border='0' cellspacing='7'><tr>";
 106  $archive .= "<td colspan='$months_per_row'><div>$year_selector</div></td></tr><tr>";
 107  for($i = 1; $i <= 12; $i++) {
 108      if (++$newline == $months_per_row+1) {
 109          $archive .= "</tr><tr>";
 110          $newline = 1;
 111      }
 112      $archive .= "<td style='vertical-align:top'>";
 113      $archive .= "<div class='fcaption' style='text-align:center; margin-bottom:2px;'>";
 114       
 115      // href the current month regardless of newsposts or any month with news
 116      if (($req_year == $cur_year && $i == $cur_month) || $day_links[$i]) {
 117          $archive .= "<a class='forumlink' href='".e_BASE."news.php?month.".formatDate($req_year, $i)."'>".$marray[$i-1]."</a>";
 118      } else {
 119          $archive .= $marray[$i-1];
 120      }
 121       
 122      $archive .= "</div>";
 123      if (($req_year == $cur_year) && ($i == $cur_month)) {
 124          $req_day = $cur_day;
 125      } else {
 126          $req_day = "";
 127      }
 128      $archive .= "<div>".calendar($req_day, $i, $req_year, $day_links[$i], $pref['blogcal_ws'])."</div></td>\n";
 129  }
 130  $archive .= "</tr></table></div>";
 131  $ns->tablerender(BLOGCAL_L2 ."&nbsp;$req_year", $archive);
 132      
 133  require_once(FOOTERF);
 134  ?>


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