public function Render()
 {
     require_once 'Calendar/Day.php';
     require_once 'Calendar/Month/Weekdays.php';
     $this->month = new Calendar_Month_Weekdays($this->y, $this->m, $this->phpa->config['week_start']);
     $this->tpl->assign('title_string', date('F Y', $this->ts));
     // to be used between the <title></title> tags
     $this->tpl->assign('cur_month', $this->month);
     // asigns a Calendar_Month_Weekday object *as reference*
     $this->tpl->assign('prev_month', $this->month->prevMonth(TRUE));
     // assigns a timestamp
     $this->tpl->assign('next_month', $this->month->nextMonth(TRUE));
     // assigns a timestamp
     // get list of weekdays like sun...sat. Weekday starts as per $phpa->config['week_start']
     $this->tpl->assign('weekdays', Calendar_Util_Textual::weekdayNames('short', $this->phpa->config['week_start']));
     // ...
     $hash = new MonthHasher($this->phpa->DB, $this->y, $this->m);
     $selection = array();
     while ($row = $hash->fetch()) {
         $selection[] = new Calendar_Day($this->y, $this->m, $row['d']);
     }
     $this->month->build($selection);
     $this->tpl->assign('hash', $hash);
     $this->tpl->display('month_view.tpl.php');
 }
 public function __construct($phpa)
 {
     require_once 'Calendar/Util/Textual.php';
     $this->phpa = $phpa;
     $this->DB = $phpa->DB;
     $this->tpl = $phpa->tpl;
     $this->d = isset($_GET['d']) ? intval($_GET['d']) : date('d');
     $this->m = isset($_GET['m']) ? intval($_GET['m']) : date('m');
     $this->y = isset($_GET['y']) ? intval($_GET['y']) : date('Y');
     if (FALSE === checkdate($this->m, $this->d, $this->y)) {
         $this->d = date('d');
         $this->m = date('m');
         $this->y = date('Y');
     }
     $this->ts = mktime(0, 0, 0, $this->m, $this->d, $this->y);
     $this->tpl->assign('ts', $this->ts);
     // unix timestamp
     $this->tpl->assignRef('d', $this->d);
     $this->tpl->assignRef('m', $this->m);
     $this->tpl->assignRef('y', $this->y);
     // dropdown boxes data
     // crange() is just like range() except works with strings. see libs/functions.lib.php
     $this->tpl->assign('month_select', array_combine(crange('01', '12'), Calendar_Util_Textual::monthNames('short')));
     $this->tpl->assign('year_select', range($this->y - 1, $this->y + 5));
 }
 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);
     }
     $this->assertEqual($weekdayNames, Calendar_Util_Textual::orderedWeekdays($this->mockcal, 'short'));
 }
Example #4
0
 /**
  * Returns the days of the week using the order defined in the decorated
  * calendar object. Only useful for Calendar_Month_Weekdays, Calendar_Month_Weeks
  * and Calendar_Week. Otherwise the returned array will begin on Sunday
  * @param object subclass of Calendar e.g. Calendar_Month
  * @param string (optional) format of returned months (one,two,short or long)
  * @return array ordered array of week day names
  * @access public
  * @static
  */
 function orderedWeekdays($Calendar, $format = 'long')
 {
     $days = Calendar_Util_Textual::weekdayNames($format);
     // Not so good - need methods to access this information perhaps...
     if (isset($Calendar->tableHelper)) {
         $ordereddays = $Calendar->tableHelper->daysOfWeek;
     } else {
         $ordereddays = array(0, 1, 2, 3, 4, 5, 6);
     }
     $ordereddays = array_flip($ordereddays);
     $i = 0;
     $returndays = array();
     foreach ($ordereddays as $key => $value) {
         $returndays[$i] = $days[$key];
         $i++;
     }
     return $returndays;
 }
Example #5
0
 /**
  * Returns the days of the week using the order defined in the decorated
  * calendar object. Only useful for Calendar_Month_Weekdays, Calendar_Month_Weeks
  * and Calendar_Week. Otherwise the returned array will begin on Sunday
  * @param string (optional) format of returned months (one,two,short or long)
  * @return array ordered array of week day names
  * @access public
  */
 function orderedWeekdays($format = 'long')
 {
     return Calendar_Util_Textual::orderedWeekdays($this->calendar, $format);
 }
Example #6
0
 /**
  * Returns the days of the week using the order defined in the decorated
  * calendar object. Only useful for Calendar_Month_Weekdays, Calendar_Month_Weeks
  * and Calendar_Week. Otherwise the returned array will begin on Sunday
  *
  * @param object $Calendar subclass of Calendar e.g. Calendar_Month
  * @param string $format   (optional) format of returned months (one,two,short or long)
  *
  * @return array ordered array of week day names
  * @access public
  * @static
  */
 function orderedWeekdays($Calendar, $format = 'long')
 {
     $days = Calendar_Util_Textual::weekdayNames($format);
     if (isset($Calendar->tableHelper)) {
         $ordereddays = $Calendar->tableHelper->getDaysOfWeek();
     } else {
         //default: start from Sunday
         $firstDay = 0;
         //check if defined / set
         if (defined('CALENDAR_FIRST_DAY_OF_WEEK')) {
             $firstDay = CALENDAR_FIRST_DAY_OF_WEEK;
         } elseif (isset($Calendar->firstDay)) {
             $firstDay = $Calendar->firstDay;
         }
         $ordereddays = array();
         for ($i = $firstDay; $i < 7; $i++) {
             $ordereddays[] = $i;
         }
         for ($i = 0; $i < $firstDay; $i++) {
             $ordereddays[] = $i;
         }
     }
     $ordereddays = array_flip($ordereddays);
     $i = 0;
     $returndays = array();
     foreach ($ordereddays as $key => $value) {
         $returndays[$i] = $days[$key];
         $i++;
     }
     return $returndays;
 }
Example #7
0
echo 'Next month is: ' . Calendar_Util_Textual::nextMonthName($Calendar) . '<br /><hr />';
echo 'Previous day is: ' . Calendar_Util_Textual::prevDayName($Calendar) . '<br />';
echo 'This day is: ' . Calendar_Util_Textual::thisDayName($Calendar, 'short') . '<br />';
echo 'Next day is: ' . Calendar_Util_Textual::nextDayName($Calendar, '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);
?>
<p>Rendering calendar....</p>
<table>
<caption><?php 
echo Calendar_Util_Textual::thisMonthName($Calendar) . ' ' . $Calendar->thisYear();
?>
</caption>
<tr>
<?php 
$dayheaders = Calendar_Util_Textual::orderedWeekdays($Calendar, 'short');
foreach ($dayheaders as $dayheader) {
    echo '<th>' . $dayheader . '</th>';
}
?>
</tr>
<?php 
$Calendar->build();
while ($Day = $Calendar->fetch()) {
    if ($Day->isFirst()) {
        echo "<tr>\n";
    }
    if ($Day->isEmpty()) {
        echo '<td>&nbsp;</td>';
    } else {
        echo '<td>' . $Day->thisDay() . '</td>';
Example #8
0
 function testOrderedWeekdaysShort()
 {
     $weekdayNames = array(0 => 'Sun', 1 => 'Mon', 2 => 'Tue', 3 => 'Wed', 4 => 'Thu', 5 => 'Fri', 6 => 'Sat');
     $this->assertEqual($weekdayNames, Calendar_Util_Textual::orderedWeekdays($this->mockcal, 'short'));
 }
Example #9
0
        $cellId++;
    }
    $cellId = 0;
    $rowId++;
}
// Assigning events to the template
$xoopsTpl->assign('tableRows', $tableRows);
// Retriving categories
$cats = $catHandler->objectToArray($catHandler->getAllCat($xoopsUser));
// Assigning categories to the template
$xoopsTpl->assign('cats', $cats);
// Retriving weekdayNames
$weekdayNames = Calendar_Util_Textual::weekdayNames();
for ($i = 0; $i < $xoopsModuleConfig['week_start_day']; $i++) {
    $weekdayName = array_shift($weekdayNames);
    $weekdayNames[] = $weekdayName;
}
// Assigning weekdayNames to the template
$xoopsTpl->assign('weekdayNames', $weekdayNames);
// Retriving monthNames
$monthNames = Calendar_Util_Textual::monthNames();
// Making navig data
$navig = array('prev' => array('uri' => 'year=' . $pMonthCalObj->thisYear() . '&amp;month=' . $pMonthCalObj->thisMonth(), 'name' => $extcalTimeHandler->getFormatedDate($xoopsModuleConfig['nav_date_month'], $pMonthCalObj->getTimestamp())), 'this' => array('uri' => 'year=' . $monthCalObj->thisYear() . '&amp;month=' . $monthCalObj->thisMonth(), 'name' => $extcalTimeHandler->getFormatedDate($xoopsModuleConfig['nav_date_month'], $monthCalObj->getTimestamp())), 'next' => array('uri' => 'year=' . $nMonthCalObj->thisYear() . '&amp;month=' . $nMonthCalObj->thisMonth(), 'name' => $extcalTimeHandler->getFormatedDate($xoopsModuleConfig['nav_date_month'], $nMonthCalObj->getTimestamp())));
// Assigning navig data to the template
$xoopsTpl->assign('navig', $navig);
// Assigning current form navig data to the template
$xoopsTpl->assign('selectedCat', $cat);
$xoopsTpl->assign('year', $year);
$xoopsTpl->assign('month', $month);
$xoopsTpl->assign('view', "calmonth");
include XOOPS_ROOT_PATH . '/footer.php';
Example #10
0
function bExtcalMinicalShow($options)
{
    define('CALENDAR_ROOT', XOOPS_ROOT_PATH . '/modules/extcal/class/pear/Calendar/');
    include_once XOOPS_ROOT_PATH . '/modules/extcal/class/config.php';
    require_once CALENDAR_ROOT . 'Util/Textual.php';
    require_once CALENDAR_ROOT . 'Month/Weeks.php';
    require_once CALENDAR_ROOT . 'Day.php';
    // Retriving Image for block if enabled
    if ($options[0] == 1) {
        $imageHandler =& xoops_gethandler('image');
        $criteria = new Criteria('imgcat_id', $options[1]);
        $criteria->setSort('image_id');
        $criteria->setOrder('RAND()');
        $criteria->setLimit(1);
        $image = $imageHandler->getObjects($criteria);
        if (isset($image[0])) {
            $imageArray = array('displayImage' => true, 'image_name' => $image[0]->getVar('image_name'), 'image_nicename' => $image[0]->getVar('image_nicename'));
        } else {
            $imageArray = array('displayImage' => false);
        }
    } else {
        $imageArray = array('displayImage' => false);
    }
    // Retriving module config
    $extcalConfig = ExtcalConfig::getHandler();
    $xoopsModuleConfig = $extcalConfig->getModuleConfig();
    // Getting eXtCal object's handler
    $catHandler = xoops_getmodulehandler('cat', 'extcal');
    $eventHandler = xoops_getmodulehandler('event', 'extcal');
    $extcalTimeHandler = ExtcalTime::getHandler();
    // Retriving month and year value according to block options
    $month = date('n');
    $year = date('Y');
    if ($options[2] == -1) {
        $month--;
        if ($month == 0) {
            $month = 12;
            $year--;
        }
    } else {
        if ($options[2] == 1) {
            $month++;
            if ($month == 13) {
                $month = 1;
                $year++;
            }
        }
    }
    // Saving display link preference
    $displayLink = $options[3];
    // Delete options to keep only categorie data
    array_shift($options);
    array_shift($options);
    array_shift($options);
    array_shift($options);
    // Retriving events and formatting them
    $events = $eventHandler->objectToArray($eventHandler->getEventCalendarMonth($month, $year, $options));
    //$eventHandler->formatEventDate($events, "l dS \of F Y h:i:s A");
    // Calculating timestamp for the begin and the end of the month
    $startMonth = mktime(0, 0, 0, $month, 1, $year);
    $endMonth = mktime(23, 59, 59, $month + 1, 0, $year);
    /*
     *  Adding all event occuring during this month to an array indexed by day number
     */
    $eventsArray = array();
    foreach ($events as $event) {
        if (!$event['event_isrecur']) {
            bExtcalMinicalAddEventToArray($event, $eventsArray, $extcalTimeHandler, $startMonth, $endMonth);
        } else {
            $recurEvents = $eventHandler->getRecurEventToDisplay($event, $startMonth, $endMonth);
            foreach ($recurEvents as $recurEvent) {
                bExtcalMinicalAddEventToArray($recurEvent, $eventsArray, $extcalTimeHandler, $startMonth, $endMonth);
            }
        }
    }
    /*
     *  Making an array to create tabbed output on the template
     */
    // Flag current day
    $selectedDays = array(new Calendar_Day(date('Y', xoops_getUserTimestamp(time(), $extcalTimeHandler->_getUserTimeZone($GLOBALS['xoopsUser']))), date('n', xoops_getUserTimestamp(time(), $extcalTimeHandler->_getUserTimeZone($GLOBALS['xoopsUser']))), date('j', xoops_getUserTimestamp(time(), $extcalTimeHandler->_getUserTimeZone($GLOBALS['xoopsUser'])))));
    // Build calendar object
    $monthCalObj = new Calendar_Month_Weeks($year, $month, $xoopsModuleConfig['week_start_day']);
    $monthCalObj->build();
    $tableRows = array();
    $rowId = 0;
    $cellId = 0;
    while ($weekCalObj = $monthCalObj->fetch()) {
        $weekCalObj->build($selectedDays);
        $tableRows[$rowId]['weekInfo'] = array('week' => $weekCalObj->thisWeek('n_in_year'), 'day' => $weekCalObj->thisDay(), 'month' => $weekCalObj->thisMonth(), 'year' => $weekCalObj->thisYear());
        while ($dayCalObj = $weekCalObj->fetch()) {
            $tableRows[$rowId]['week'][$cellId] = array('isEmpty' => $dayCalObj->isEmpty(), 'number' => $dayCalObj->thisDay(), 'isSelected' => $dayCalObj->isSelected());
            if (isset($eventsArray[$dayCalObj->thisDay()]) && !$dayCalObj->isEmpty()) {
                $tableRows[$rowId]['week'][$cellId]['haveEvents'] = true;
            } else {
                $tableRows[$rowId]['week'][$cellId]['haveEvents'] = false;
            }
            $cellId++;
        }
        $cellId = 0;
        $rowId++;
    }
    // Retriving weekdayNames
    $weekdayNames = Calendar_Util_Textual::weekdayNames('one');
    for ($i = 0; $i < $xoopsModuleConfig['week_start_day']; $i++) {
        $weekdayName = array_shift($weekdayNames);
        $weekdayNames[] = $weekdayName;
    }
    // Making navig data
    $navig = array('uri' => 'year=' . $monthCalObj->thisYear() . '&amp;month=' . $monthCalObj->thisMonth(), 'name' => $extcalTimeHandler->getFormatedDate($xoopsModuleConfig['nav_date_month'], $monthCalObj->getTimestamp()));
    $ret = array('image' => $imageArray, 'displayLink' => $displayLink, 'submitText' => _MB_EXTCAL_SUBMIT_LINK_TEXT, 'tableRows' => $tableRows, 'weekdayNames' => $weekdayNames, 'navig' => $navig);
    return $ret;
}