Ejemplo n.º 1
0
 public function testGetMonthNameDefaultsEnglish()
 {
     $i = 1;
     foreach ($this->c->_lang_months as $k => $v) {
         $this->assertEquals($v, $this->c->getMonthName($i));
         $i++;
     }
     $this->assertEquals('January', $this->c->getMonthName());
 }
Ejemplo n.º 2
0
 public function testGetter()
 {
     $calendar = new Calendar(new \DateTime('2014-01-01 12:14:00'), new \DateTimeZone('UTC'));
     $this->assertEquals('2014-01-01 00:00:00', $calendar->getDate()->format('Y-m-d H:i:s'));
     $calendar->setDate(new \DateTime('2014-01-04 12:14:00'));
     $this->assertEquals('2014-01-04 00:00:00', $calendar->getDate()->format('Y-m-d H:i:s'));
     $tz = new \DateTimeZone('Europe/Berlin');
     $calendar->setTimezone($tz);
     $this->assertEquals($tz, $calendar->getTimezone());
     $this->assertEquals('01', $calendar->getWeekNumber());
     $this->assertEquals(4, $calendar->getDay());
     $this->assertEquals(1, $calendar->getMonth());
     $this->assertEquals(2014, $calendar->getYear());
     $this->assertEquals('January', $calendar->getMonthName());
 }
Ejemplo n.º 3
0
<td>
<?php 
if ($month == 1) {
    echo "<a href='?month=12&&year=", $year - 1, "'><<</a>";
} else {
    echo "<a href='?month=", $month - 1, "&&year={$year}'><<</a>";
}
?>
</td>
<td colspan="5">
<div>
<?php 
if ($printView) {
    echo Calendar::getMonthName($month) . " " . $year;
} else {
    echo "<h1>" . Calendar::getMonthName($month) . " " . $year . "<h1>";
}
?>
</div>
</td>
<td align="right">
<?php 
if ($month == 12) {
    echo "<a href='?month=1&&year=", $year + 1, "'>>></a>";
} else {
    echo "<a href='?month=", $month + 1, "&&year={$year}'>>></a>";
}
?>
</td>
</tr>
<tr>
Ejemplo n.º 4
0
      <td class='value'><?php 
echo $cal->getSecond();
?>
</td>
   </tr>
   <tr>
      <td class='name'>day name</td>
      <td class='value'><?php 
echo $cal->getDayName();
?>
</td>
   </tr>
   <tr>
      <td class='name'>Month name</td>
      <td class='value'><?php 
echo $cal->getMonthName();
?>
</td>
   </tr>
   <tr>
      <td class='name'>Count days in month <?php 
echo $cal->getMonthName();
?>
</td>
      <td class='value'><?php 
echo $cal->countDaysInMonth();
?>
</td>
   </tr>
   <tr>
      <td class='name'>First day name of the month</td>
Ejemplo n.º 5
0
 private function birthdaysCalendar()
 {
     // require the class
     require_once FRAMEWORK_PATH . 'lib/calendar/calendar.class.php';
     // set the default month and year, i.e. the current month and year
     $m = date('m');
     $y = date('Y');
     // check for a different Month / Year (i.e. user has moved to another month)
     if (isset($_GET['month'])) {
         $m = intval($_GET['month']);
         if ($m > 0 && $m < 13) {
         } else {
             $m = date('m');
         }
     }
     if (isset($_GET['year'])) {
         $y = intval($_GET['year']);
     }
     // Instantiate the calendar object
     $calendar = new Calendar('', $m, $y);
     // Get next and previous month / year
     $nm = $calendar->getNextMonth()->getMonth();
     $ny = $calendar->getNextMonth()->getYear();
     $pm = $calendar->getPreviousMonth()->getMonth();
     $py = $calendar->getPreviousMonth()->getYear();
     // send next / previous month data to the template
     $this->registry->getObject('template')->getPage()->addTag('nm', $nm);
     $this->registry->getObject('template')->getPage()->addTag('pm', $pm);
     $this->registry->getObject('template')->getPage()->addTag('ny', $ny);
     $this->registry->getObject('template')->getPage()->addTag('py', $py);
     // send the current month name and year to the template
     $this->registry->getObject('template')->getPage()->addTag('month_name', $calendar->getMonthName());
     $this->registry->getObject('template')->getPage()->addTag('the_year', $calendar->getYear());
     // Set the start day of the week
     $calendar->setStartDay(0);
     require_once FRAMEWORK_PATH . 'models/relationships.php';
     $relationships = new Relationships($this->registry);
     $idsSQL = $relationships->getIDsByUser($this->registry->getObject('authenticate')->getUser()->getUserID());
     $sql = "SELECT DATE_FORMAT(pr.user_dob, '%d' ) as profile_dob, pr.name as profile_name, pr.user_id as profile_id, ( ( YEAR( CURDATE() ) ) - ( DATE_FORMAT(pr.user_dob, '%Y' ) ) ) as profile_new_age FROM profile pr WHERE pr.user_id IN (" . $idsSQL . ") AND pr.user_dob LIKE '%-{$m}-%'";
     $this->registry->getObject('db')->executeQuery($sql);
     $dates = array();
     $data = array();
     if ($this->registry->getObject('db')->numRows() > 0) {
         while ($row = $this->registry->getObject('db')->getRows()) {
             $dates[] = $row['profile_dob'];
             $data[intval($row['profile_dob'])] = "<br />" . $row['profile_name'] . " (" . $row['profile_new_age'] . ")<br />";
         }
     }
     $calendar->setData($data);
     // tell the calendar which days should be highlighted
     $calendar->setDaysWithEvents($dates);
     $calendar->buildMonth();
     // days
     $this->registry->getObject('template')->dataToTags($calendar->getDaysInOrder(), 'cal_0_day_');
     // dates
     $this->registry->getObject('template')->dataToTags($calendar->getDates(), 'cal_0_dates_');
     // styles
     $this->registry->getObject('template')->dataToTags($calendar->getDateStyles(), 'cal_0_dates_style_');
     // data
     $this->registry->getObject('template')->dataToTags($calendar->getDateData(), 'cal_0_dates_data_');
     $this->registry->getObject('template')->buildFromTemplates('header.tpl.php', 'bd-calendar.tpl.php', 'footer.tpl.php');
 }