[ Index ]

PHP Cross Reference of phpwcms V1.4.7 _r403 (01.11.10)

title

Body

[close]

/include/inc_front/ -> calendar.func.inc.php (source)

   1  <?php
   2  /*************************************************************************************
   3     Copyright notice
   4     
   5     (c) 2002-2010 Oliver Georgi (oliver@phpwcms.de) // All rights reserved.
   6   
   7     This script is part of PHPWCMS. The PHPWCMS web content management system is
   8     free software; you can redistribute it and/or modify it under the terms of
   9     the GNU General Public License as published by the Free Software Foundation;
  10     either version 2 of the License, or (at your option) any later version.
  11    
  12     The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
  13     A copy is found in the textfile GPL.txt and important notices to the license 
  14     from the author is found in LICENSE.txt distributed with these scripts.
  15    
  16     This script is distributed in the hope that it will be useful, but WITHOUT ANY 
  17     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  18     PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  19   
  20     This copyright notice MUST APPEAR in all copies of the script!
  21  *************************************************************************************/
  22  
  23  //calendar specific functions
  24  //PHPWCMS_TEMPLATE.'calendar/calendar.ini'
  25  
  26  function initializeCalendar($ini='') {
  27      $_baseCalVal = getCurrentCalendarDate();
  28      $_calDates = ($ini && file_exists($ini)) ? parse_ini_file($ini, true) : array();
  29      $_baseCalVal['days'] = array();
  30      if(isset($_calDates[ $_baseCalVal['current_month'] ]) && is_array($_calDates[ $_baseCalVal['current_month'] ])) {
  31          foreach($_calDates[ $_baseCalVal['current_month'] ] as $_calDay => $calLink) {
  32              $_baseCalVal['days'][ strval($_baseCalVal['current_month'].substr('0'.$_calDay, -2)) ] = array($calLink, NULL, NULL);
  33          }
  34      }
  35      return $_baseCalVal;
  36  }
  37  
  38  
  39  function buildCalendarLink($date_value='') {
  40      global $_getVar;
  41      $_oldCalValue = '';
  42      if(!empty($_getVar['calendardate'])) $_oldCalValue = $_getVar['calendardate']; //save old value
  43      if(!empty($date_value)) $_getVar['calendardate'] = $date_value; //set new value
  44      $link = 'index.php' . returnGlobalGET_QueryString('urlencode'); //build Link
  45      if($_oldCalValue) $_getVar['calendardate'] = $_oldCalValue; //restore old value
  46      return $link;
  47  }
  48  
  49  
  50  function buildCalendarGETValue($value=array(), $spacer='-') {
  51      if(!is_array($value) || !count($value)) {
  52          $value = array('year'=>date('Y'), 'month'=>date('n'), 'day'=>date('j'));
  53      }
  54      return $value['year'].$spacer.$value['month'].$spacer.$value['day'];
  55  }
  56  
  57  
  58  function getCurrentCalendarDate() {
  59  
  60      global $_getVar;
  61      
  62      $_date = array();
  63      
  64      $_date['year']    = date('Y');
  65      $_date['month']    = date('n');
  66      $_date['day']    = date('j');
  67      
  68      if(!empty($_getVar['calendardate'])) {
  69          $d = explode('-', $_getVar['calendardate']);
  70          if(!empty($d[0]) && intval($d[0]))    $_date['year']    = intval($d[0]);
  71          if(!empty($d[1]) && intval($d[1]))    $_date['month']    = intval($d[1]);
  72          if(!empty($d[2]) && intval($d[2]))    $_date['day']    = intval($d[2]);
  73          if (($int_time = strtotime($_date['year'].'/'.$_date['month'].'/'.$_date['day'])) === -1) {
  74                 $_date['year']    = date('Y');
  75              $_date['month']    = date('n');
  76              $_date['day']    = date('j');
  77          } else {
  78                 $_date['year']    = date('Y', $int_time);
  79              $_date['month']    = date('n', $int_time);
  80              $_date['day']    = date('j', $int_time);
  81          }
  82      }
  83          
  84      define('THIS_YEAR',        $_date['year']);
  85      define('THIS_MONTH',    $_date['month']);
  86      define('THIS_DAY',        $_date['day']);
  87      
  88  
  89      $_date['next_month']['month']    = ($_date['month'] == 12)                ? 1                        : $_date['month'] + 1;
  90      $_date['prev_month']['month']    = ($_date['month'] == 1)                ? 12                    : $_date['month'] - 1;
  91      $_date['next_month']['year']    = ($_date['next_month']['month'] == 1)    ? $_date['year'] + 1    : $_date['year'];
  92      $_date['prev_month']['year']    = ($_date['prev_month']['month'] == 12)    ? $_date['year'] - 1    : $_date['year'];
  93      
  94      $_date['next_year']['month']    = $_date['month'];
  95      $_date['prev_year']['month']    = $_date['month'];
  96      $_date['next_year']['year']        = $_date['year'] + 1;
  97      $_date['prev_year']['year']        = $_date['year'] - 1;
  98      
  99      $_date['next_month']['day']        = $_date['day'];
 100      $_date['prev_month']['day']        = $_date['day'];
 101      $_date['next_year']['day']        = $_date['day'];
 102      $_date['prev_year']['day']        = $_date['day'];
 103      
 104      $_date['next_link']    = buildCalendarLink( buildCalendarGETValue($_date['next_month']) );
 105      $_date['prev_link']    = buildCalendarLink( buildCalendarGETValue($_date['prev_month']) );
 106      
 107      $_date['current_month'] = THIS_YEAR.substr('0'.THIS_MONTH, -2);
 108      
 109      return $_date;
 110  
 111  }
 112  
 113  
 114  
 115  
 116  ?>


Generated: Tue Nov 16 22:51:00 2010 Cross-referenced by PHPXref 0.7