Ejemplo n.º 1
0
 /**
  * Retourne le jour du mois
  * @param string $format 'long' ou 'short'
  * @return string
  * @access public
  */
 public function thisDayName($format = 'long')
 {
     $day = Calendar_Decorator_Textual::thisDayName();
     $dayArray = Calendar_Decorator_Textual::weekdayNames();
     $d = array_keys($dayArray, $day);
     switch ($format) {
         case 'long':
             return $this->longWeekDayNames[$d[0]];
             break;
         case 'short':
             return $this->shortWeekDayNames[$d[0]];
     }
 }
Ejemplo n.º 2
0
* Description: demonstrates using the Textual decorator
*/
if (!@(include 'Calendar' . DIRECTORY_SEPARATOR . 'Calendar.php')) {
    define('CALENDAR_ROOT', '../../');
}
require_once CALENDAR_ROOT . 'Day.php';
require_once CALENDAR_ROOT . 'Month' . DIRECTORY_SEPARATOR . 'Weekdays.php';
require_once CALENDAR_ROOT . 'Decorator' . DIRECTORY_SEPARATOR . 'Textual.php';
// Could change language like this
// setlocale (LC_TIME, "de_DE"); // Unix based (probably)
// setlocale (LC_TIME, "ge"); // Windows
echo "<hr>Calling: Calendar_Decorator_Textual::monthNames('long');<pre>";
print_r(Calendar_Decorator_Textual::monthNames('long'));
echo '</pre>';
echo "<hr>Calling: Calendar_Decorator_Textual::weekdayNames('two');<pre>";
print_r(Calendar_Decorator_Textual::weekdayNames('two'));
echo '</pre>';
echo "<hr>Creating: new Calendar_Day(date('Y'), date('n'), date('d'));<br />";
$Calendar = new Calendar_Day(date('Y'), date('n'), date('d'));
// Decorate
$Textual =& new Calendar_Decorator_Textual($Calendar);
echo '<hr>Previous month is: ' . $Textual->prevMonthName('two') . '<br />';
echo 'This month is: ' . $Textual->thisMonthName('short') . '<br />';
echo 'Next month is: ' . $Textual->nextMonthName() . '<br /><hr />';
echo 'Previous day is: ' . $Textual->prevDayName() . '<br />';
echo 'This day is: ' . $Textual->thisDayName('short') . '<br />';
echo 'Next day is: ' . $Textual->nextDayName('one') . '<br /><hr />';
echo "Creating: new Calendar_Month_Weekdays(date('Y'), date('n'), 6); - Saturday is first day of week<br />";
$Calendar = new Calendar_Month_Weekdays(date('Y'), date('n'), 6);
// Decorate
$Textual =& new Calendar_Decorator_Textual($Calendar);
Ejemplo n.º 3
0
 /**
  * Computes the data nececssary for the welcome screen. Automatically put into the request
  * data array.
  *
  * @access private
  */
 function _compute_welcome_data()
 {
     setlocale(LC_ALL, 'fi_FI@UTF-8');
     // First step of request data: Overall info
     $year_data = array();
     $first_month = $this->_compute_first_month();
     $last_month = $this->_compute_last_month();
     $this->_request_data['first_month'] =& $first_month;
     $this->_request_data['last_month'] =& $last_month;
     $this->_request_data['total_count'] = $this->_compute_events_count_total();
     $this->_request_data['year_data'] =& $year_data;
     if (!$first_month) {
         return;
     }
     // Second step of request data: Years and months.
     $first_year = $first_month->thisYear();
     $last_year = $last_month->thisYear();
     for ($year_nr = $first_year; $year_nr <= $last_year; $year_nr++) {
         $year = new Calendar_Year($year_nr);
         $year->build();
         $year_url = $this->_get_calendar_yearlink($year);
         $year_count = $this->_compute_events_count_between($year->thisYear('timestamp'), $year->nextYear('timestamp'));
         $month_data = array();
         // Loop over the months, start month is either first posting month
         // or January in all other cases.
         $month = null;
         if ($year_nr == $first_year) {
             for ($i = 1; $i < $first_month->thisMonth(); $i++) {
                 $month = $year->fetch();
             }
         }
         while ($month = $year->fetch()) {
             $month_textual = new Calendar_Decorator_Textual($month);
             $month_url = $this->_get_calendar_monthlink($month);
             $month_count = $this->_compute_events_count_between($month->thisMonth('timestamp'), $month->nextMonth('timestamp'));
             $month_data[$month->thisMonth()] = array('month' => $month_textual, 'name' => $month_textual->thisMonthName(), 'url' => $month_url, 'count' => $month_count);
             // Check for end month in end year
             if ($year_nr == $last_year && $month->thisMonth() >= $last_month->thisMonth()) {
                 break;
             }
         }
         $year_data[$year_nr] = array('year' => $year_nr, 'url' => $year_url, 'count' => $year_count, 'month_data' => $month_data);
     }
 }
Ejemplo n.º 4
0
 function testOrderedWeekdaysShort()
 {
     $weekdayNames = array(0 => 'Sun', 1 => 'Mon', 2 => 'Tue', 3 => 'Wed', 4 => 'Thu', 5 => 'Fri', 6 => 'Sat');
     $Textual = new Calendar_Decorator_Textual($this->mockcal);
     $this->assertEqual($weekdayNames, $Textual->orderedWeekdays('short'));
 }
 function testOrderedWeekdaysShort()
 {
     $weekdayNames = array(0 => 'Sun', 1 => 'Mon', 2 => 'Tue', 3 => 'Wed', 4 => 'Thu', 5 => 'Fri', 6 => 'Sat');
     $nShifts = CALENDAR_FIRST_DAY_OF_WEEK;
     while ($nShifts-- > 0) {
         $day = array_shift($weekdayNames);
         array_push($weekdayNames, $day);
     }
     $Textual = new Calendar_Decorator_Textual($this->mockcal);
     $this->assertEqual($weekdayNames, $Textual->orderedWeekdays('short'));
 }