[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/data/ -> plogcalendar.class.php (source)

   1  <?php
   2      lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
   3      lt_include( PLOG_CLASS_PATH."class/dao/bloginfo.class.php" );
   4      lt_include( PLOG_CLASS_PATH."class/data/Date.class.php" );
   5      lt_include( PLOG_CLASS_PATH."class/data/htmlcalendar.class.php" );
   6      lt_include( PLOG_CLASS_PATH.'class/data/timestamp.class.php' );
   7      lt_include( PLOG_CLASS_PATH."class/locale/locale.class.php" );
   8      lt_include( PLOG_CLASS_PATH."class/locale/locales.class.php" );
   9      lt_include( PLOG_CLASS_PATH."class/net/requestgenerator.class.php" );
  10  
  11     /**    

  12      * \ingroup Data

  13      *

  14      * A derived class is required to reimplement some methods from the parent

  15      * Calendar class to add things like links to the days and so on.

  16      * This one also converts the original HtmlCalendar into Locale aware, respecting

  17      * things like the first day of the week and the abbreviations of the days of the week.

  18      *

  19      * User classes will rarely need to use this class.

  20      */
  21      class PlogCalendar extends Calendar 
  22      {
  23  
  24          var $_dayPosts;
  25          var $_blogInfo;
  26          var $rg;
  27  
  28          /**

  29           * Constructor.

  30           *

  31           * @param dayPosts An array indexed from 1 to as many days as the month where

  32           * every position tells how many posts were made that day.

  33           * @param localeCode A code specifying the locale we want to use. If empty, the default

  34           * one specified in the configuration file will be used.

  35           */
  36          function PlogCalendar( $dayPosts =  null, $blogInfo = null, $locale = null )
  37          {
  38              $this->Calendar();
  39  
  40              if( $locale == null ) {
  41                  $config = Config::getConfig();
  42                  //$locale = new Locale( $config->getValue( "default_locale" ));

  43                  $locale = Locales::getLocale( $config->getValue( "default_locale" ));
  44              }
  45  
  46              $this->_dayPosts = $dayPosts;
  47              $this->_blogInfo = $blogInfo;
  48  
  49              // set the first day of the week according to our blogsetting

  50              $blogSettings =  $this->_blogInfo->getSettings();
  51              $this->startDay = $blogSettings->getValue( 'first_day_of_week', $locale->firstDayOfWeek() );
  52              //array_push( $this->monthsNames, $locale->tr("January"));

  53              $this->monthNames = $locale->getMonthNames();
  54              // abbreviations of the days of the week

  55              $this->dayNamesShort = $locale->getDayNamesShort();
  56              // full names of the days of the week

  57              $this->dayNames = $locale->getDayNames();
  58  
  59              $this->rg = RequestGenerator::getRequestGenerator( $blogInfo );
  60          }
  61  
  62          /**

  63           * Function overwritten from the base one, so that we can display links for the

  64           * next month and the previous month         

  65           *        

  66           * @see Calendar::getCalendarLink()

  67           */
  68          function getCalendarLink( $month, $year )
  69          {
  70              if( $month < 10 ) $month = "0".$month;
  71              $date = "$year$month";
  72  
  73              $calendarLink = $this->rg->getArchiveLink( $date );
  74  
  75  
  76              return( $calendarLink );
  77          }
  78  
  79          /**

  80           * Function overwritten from the base one, so that we can display a link for the days

  81           * that have posts         

  82           *         

  83           * @see Calendar::getDateLink()

  84           */
  85          function getDateLink( $day, $month, $year )
  86          {
  87              if( $this->_dayPosts == null )
  88                  return "";
  89  
  90              if( array_key_exists( $day, $this->_dayPosts) && $this->_dayPosts[$day] > 0 ) {
  91                  if( $day < 10 ) $day = "0".$day;
  92                  $date = "$year$month$day";
  93  
  94                  $dateLink = $this->rg->getArchiveLink( $date );
  95  
  96                  return( $dateLink );
  97              }
  98  
  99              return "";
 100          }
 101          
 102          /**

 103           * Return the HTML for a specified month

 104           *         

 105           * @see Calendar::getMonthView()

 106           */
 107          function getMonthView($month, $year)
 108          {
 109          
 110              $t = Timestamp::getBlogDate( $this->_blogInfo );
 111              
 112              // getBlogDate sometimes returns the time without the time zone applied.  If it wasn't

 113              // We need to make sure that it is applied now

 114              $config =& Config::getConfig();
 115              if( $config->getValue( "time_difference_calculation" ) == TIME_DIFFERENCE_CALCULATION_DYNAMIC ) {
 116                  $blogSettings = $this->_blogInfo->getSettings();
 117                  $timeDifference = $blogSettings->getValue( "time_offset" );
 118                  $t->setDate( Timestamp::getDateWithOffset( $t->getDate(), $timeDifference ), DATE_FORMAT_TIMESTAMP );
 119              }
 120              
 121              return $this->getMonthHTML($month, $year, 1/*showYear*/, 
 122                                         $t->getTimestamp(DATE_FORMAT_UNIXTIME) );
 123          }
 124  
 125  
 126          
 127      }
 128  ?>


Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics