ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilCalendarWeekGUI Class Reference
+ Collaboration diagram for ilCalendarWeekGUI:

Public Member Functions

 __construct (ilDate $seed_date)
 Constructor.
 executeCommand ()
 Execute command.
 show ()
 fill data section

Protected Member Functions

 showFulldayAppointment ($a_app)
 show fullday appointment
 showAppointment ($a_app)
 show appointment
 parseHourInfo ($daily_apps, $date, $num_day, $hours=null, $morning_aggr=7, $evening_aggr=20)
 calculate overlapping hours
 calculateColspans ($hours)
 calculate colspan

Protected Attributes

 $num_appointments = 1
 $seed = null
 $user_settings = null
 $weekdays = array()
 $lng
 $ctrl
 $tabs_gui
 $tpl
 $timezone = 'UTC'

Detailed Description

Constructor & Destructor Documentation

ilCalendarWeekGUI::__construct ( ilDate  $seed_date)

Constructor.

public

Parameters

Definition at line 62 of file class.ilCalendarWeekGUI.php.

References $ilCtrl, $lng, $tpl, ilCalendarUserSettings\_getInstanceByUserId(), ilDate\get(), and IL_CAL_FKT_GETDATE.

{
global $ilCtrl, $lng, $ilUser,$ilTabs,$tpl;
$this->seed = $seed_date;
$this->seed_info = $this->seed->get(IL_CAL_FKT_GETDATE,'','UTC');
$this->tpl = $tpl;
$this->lng = $lng;
$this->ctrl = $ilCtrl;
$this->tabs_gui = $ilTabs;
$this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
$this->app_colors = new ilCalendarAppointmentColors($ilUser->getId());
$this->timezone = $ilUser->getTimeZone();
}

+ Here is the call graph for this function:

Member Function Documentation

ilCalendarWeekGUI::calculateColspans (   $hours)
protected

calculate colspan

protected

Parameters
@return

Definition at line 656 of file class.ilCalendarWeekGUI.php.

Referenced by show().

{
global $ilUser;
foreach($hours as $hour_num => $hours_per_day)
{
foreach($hours_per_day as $num_day => $hour)
{
$colspans[$num_day] = max($colspans[$num_day],$hour['apps_num']);
// screen reader: always one col
if ($ilUser->prefs["screen_reader_optimization"])
{
$colspans[$num_day] = 1;
}
}
}
return $colspans;
}

+ Here is the caller graph for this function:

ilCalendarWeekGUI::executeCommand ( )

Execute command.

public

Definition at line 86 of file class.ilCalendarWeekGUI.php.

References $_GET, $_REQUEST, $_SESSION, $cmd, $ilCtrl, $tpl, and IL_CAL_DATE.

{
global $ilCtrl,$tpl;
$this->ctrl->saveParameter($this,'seed');
$next_class = $ilCtrl->getNextClass();
switch($next_class)
{
case 'ilcalendarappointmentgui':
$this->ctrl->setReturn($this,'');
$this->tabs_gui->setSubTabActive($_SESSION['cal_last_tab']);
// initial date for new calendar appointments
$idate = new ilDate($_REQUEST['idate'], IL_CAL_DATE);
include_once('./Services/Calendar/classes/class.ilCalendarAppointmentGUI.php');
$app = new ilCalendarAppointmentGUI($this->seed,$idate,(int) $_GET['app_id']);
$this->ctrl->forwardCommand($app);
break;
default:
$time = microtime(true);
$cmd = $this->ctrl->getCmd("show");
$this->$cmd();
$tpl->setContent($this->tpl->get());
#echo "Zeit: ".(microtime(true) - $time);
break;
}
return true;
}
ilCalendarWeekGUI::parseHourInfo (   $daily_apps,
  $date,
  $num_day,
  $hours = null,
  $morning_aggr = 7,
  $evening_aggr = 20 
)
protected

calculate overlapping hours

protected

Returns
array hours

Definition at line 529 of file class.ilCalendarWeekGUI.php.

References IL_CAL_FKT_GETDATE, ilCalendarSettings\TIME_FORMAT_12, and ilCalendarSettings\TIME_FORMAT_24.

Referenced by show().

{
global $ilUser;
for($i = $morning_aggr;$i <= $evening_aggr;$i++)
{
$hours[$i][$num_day]['apps_start'] = array();
$hours[$i][$num_day]['apps_num'] = 0;
switch($this->user_settings->getTimeFormat())
{
if ($morning_aggr > 0 && $i == $morning_aggr)
{
$hours[$i][$num_day]['txt'] = sprintf('%02d:00',0)."-";
}
$hours[$i][$num_day]['txt'].= sprintf('%02d:00',$i);
if ($evening_aggr < 23 && $i == $evening_aggr)
{
$hours[$i][$num_day]['txt'].= "-".sprintf('%02d:00',23);
}
break;
if ($morning_aggr > 0 && $i == $morning_aggr)
{
$hours[$i][$num_day]['txt'] = date('h a',mktime(0,0,0,1,1,2000))."-";
}
$hours[$i][$num_day]['txt'].= date('h a',mktime($i,0,0,1,1,2000));
if ($evening_aggr < 23 && $i == $evening_aggr)
{
$hours[$i][$num_day]['txt'].= "-".date('h a',mktime(23,0,0,1,1,2000));
}
break;
}
}
$date_info = $date->get(IL_CAL_FKT_GETDATE,'','UTC');
foreach($daily_apps as $app)
{
// fullday appointment are not relavant
if($app['fullday'])
{
continue;
}
// start hour for this day
if($app['start_info']['mday'] != $date_info['mday'])
{
$start = 0;
}
else
{
$start = $app['start_info']['hours'];
}
// end hour for this day
if($app['end_info']['mday'] != $date_info['mday'])
{
$end = 23;
}
elseif($app['start_info']['hours'] == $app['end_info']['hours'])
{
$end = $start +1;
}
else
{
$end = $app['end_info']['hours'];
}
// set end to next hour for screen readers
if ($ilUser->prefs["screen_reader_optimization"])
{
$end = $start +1;
}
if ($start < $morning_aggr)
{
$start = $morning_aggr;
}
if ($end <= $morning_aggr)
{
$end = $morning_aggr+1;
}
if ($start > $evening_aggr)
{
$start = $evening_aggr;
}
if ($end > $evening_aggr+1)
{
$end = $evening_aggr+1;
}
if ($end <= $start)
{
$end = $start + 1;
}
$first = true;
for($i = $start;$i < $end;$i++)
{
if($first)
{
if (!$ilUser->prefs["screen_reader_optimization"])
{
$app['rowspan'] = $end - $start;
}
else // screen readers get always a rowspan of 1
{
$app['rowspan'] = 1;
}
$hours[$i][$num_day]['apps_start'][] = $app;
$first = false;
}
$hours[$i][$num_day]['apps_num']++;
}
}
return $hours;
}

+ Here is the caller graph for this function:

ilCalendarWeekGUI::show ( )

fill data section

public

Definition at line 126 of file class.ilCalendarWeekGUI.php.

References $_GET, $lng, ilCalendarUtil\_buildWeekDayList(), ilCalendarSettings\_getInstance(), ilCalendarUtil\_numericDayToString(), ilCalendarUtil\_numericMonthToString(), calculateColspans(), ilUtil\getImagePath(), IL_CAL_DATE, IL_CAL_FKT_DATE, IL_CAL_FKT_GETDATE, ilYuiUtil\initDragDrop(), ilYuiUtil\initPanel(), parseHourInfo(), showAppointment(), showFulldayAppointment(), ilCalendarSchedule\TYPE_WEEK, and ilDateTime\WEEK.

{
global $ilUser, $lng;
$this->tpl = new ilTemplate('tpl.week_view.html',true,true,'Services/Calendar');
include_once('./Services/YUI/classes/class.ilYuiUtil.php');
$navigation = new ilCalendarHeaderNavigationGUI($this,$this->seed,ilDateTime::WEEK);
$this->tpl->setVariable('NAVIGATION',$navigation->getHTML());
if(isset($_GET["bkid"]))
{
$user_id = $_GET["bkid"];
$disable_empty = true;
$no_add = true;
}
else
{
$user_id = $ilUser->getId();
$disable_empty = false;
$no_add = false;
}
include_once('Services/Calendar/classes/class.ilCalendarSchedule.php');
$this->scheduler = new ilCalendarSchedule($this->seed,ilCalendarSchedule::TYPE_WEEK,$user_id,$disable_empty);
$this->scheduler->addSubitemCalendars(true);
$this->scheduler->calculate();
$counter = 0;
$hours = null;
$all_fullday = array();
foreach(ilCalendarUtil::_buildWeekDayList($this->seed,$this->user_settings->getWeekStart())->get() as $date)
{
$daily_apps = $this->scheduler->getByDay($date,$this->timezone);
$hours = $this->parseHourInfo($daily_apps,$date,$counter,$hours,
$this->user_settings->getDayStart(),
$this->user_settings->getDayEnd()
);
$this->weekdays[] = $date;
$num_apps[$date->get(IL_CAL_DATE)] = count($daily_apps);
$all_fullday[] = $daily_apps;
$counter++;
}
$colspans = $this->calculateColspans($hours);
include_once('Services/Calendar/classes/class.ilCalendarSettings.php');
// Table header
$counter = 0;
foreach(ilCalendarUtil::_buildWeekDayList($this->seed,$this->user_settings->getWeekStart())->get() as $date)
{
$date_info = $date->get(IL_CAL_FKT_GETDATE,'','UTC');
$this->ctrl->setParameterByClass('ilcalendarappointmentgui','seed',$date->get(IL_CAL_DATE));
$this->ctrl->setParameterByClass('ilcalendarappointmentgui','idate',$date->get(IL_CAL_DATE));
$this->ctrl->setParameterByClass('ilcalendardaygui','seed',$date->get(IL_CAL_DATE));
if(!$no_add)
{
if ($settings->getEnableGroupMilestones())
{
$this->tpl->setCurrentBlock("new_ms");
$this->tpl->setVariable('H_NEW_MS_SRC', ilUtil::getImagePath('ms_add.gif'));
$this->tpl->setVariable('H_NEW_MS_ALT', $this->lng->txt('cal_new_ms'));
$this->tpl->setVariable('NEW_MS_LINK', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui','addMilestone'));
$this->tpl->parseCurrentBlock();
}
$this->tpl->setCurrentBlock("new_app");
$this->tpl->setVariable('NEW_APP_LINK',$this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui','add'));
$this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
$this->tpl->setVariable('NEW_APP_SRC',ilUtil::getImagePath('date_add.gif'));
$this->tpl->setVariable('NEW_APP_ALT',$this->lng->txt('cal_new_app'));
$this->tpl->parseCurrentBlock();
}
$dayname = ilCalendarUtil::_numericDayToString($date->get(IL_CAL_FKT_DATE,'w'),true);
$daydate = $date_info['mday'].' '.ilCalendarUtil::_numericMonthToString($date_info['mon'],false);
if(!$disable_empty || $num_apps[$date->get(IL_CAL_DATE)] > 0)
{
$link = $this->ctrl->getLinkTargetByClass('ilcalendardaygui','');
$this->ctrl->clearParametersByClass('ilcalendardaygui');
$this->tpl->setCurrentBlock("day_view1_link");
$this->tpl->setVariable('HEADER_DATE',$daydate);
$this->tpl->setVariable('DAY_VIEW_LINK',$link);
$this->tpl->parseCurrentBlock();
$this->tpl->setCurrentBlock("day_view2_link");
$this->tpl->setVariable('DAYNAME',$dayname);
$this->tpl->setVariable('DAY_VIEW_LINK',$link);
$this->tpl->parseCurrentBlock();
}
else
{
$this->tpl->setCurrentBlock("day_view1_no_link");
$this->tpl->setVariable('HEADER_DATE',$daydate);
$this->tpl->parseCurrentBlock();
$this->tpl->setCurrentBlock("day_view2_no_link");
$this->tpl->setVariable('DAYNAME',$dayname);
$this->tpl->parseCurrentBlock();
}
$this->tpl->setCurrentBlock('day_header_row');
$this->tpl->setVariable('DAY_COLSPAN',max($colspans[$counter],1));
$this->tpl->parseCurrentBlock();
$counter++;
}
// show fullday events
$counter = 0;
foreach($all_fullday as $daily_apps)
{
foreach($daily_apps as $event)
{
if($event['fullday'])
{
$this->showFulldayAppointment($event);
}
}
$this->tpl->setCurrentBlock('f_day_row');
$this->tpl->setVariable('COLSPAN',max($colspans[$counter],1));
$this->tpl->parseCurrentBlock();
$counter++;
}
$this->tpl->setCurrentBlock('fullday_apps');
$this->tpl->setVariable('TXT_F_DAY', $lng->txt("cal_all_day"));
$this->tpl->parseCurrentBlock();
$new_link_counter = 0;
foreach($hours as $num_hour => $hours_per_day)
{
foreach($hours_per_day as $num_day => $hour)
{
foreach($hour['apps_start'] as $app)
{
$this->showAppointment($app);
}
// screen reader: appointments are divs, now output cell
if ($ilUser->prefs["screen_reader_optimization"])
{
$this->tpl->setCurrentBlock('scrd_day_cell');
$this->tpl->setVariable('TD_CLASS','calstd');
$this->tpl->parseCurrentBlock();
}
#echo "NUMDAY: ".$num_day;
#echo "COLAPANS: ".max($colspans[$num_day],1).'<br />';
$num_apps = $hour['apps_num'];
$colspan = max($colspans[$num_day],1);
// Show new apointment link
if(!$hour['apps_num'] && !$ilUser->prefs["screen_reader_optimization"] && !$no_add)
{
$this->tpl->setCurrentBlock('new_app_link');
$this->ctrl->setParameterByClass('ilcalendarappointmentgui','idate',$this->weekdays[$num_day]->get(IL_CAL_DATE));
$this->ctrl->setParameterByClass('ilcalendarappointmentgui','seed',$this->seed->get(IL_CAL_DATE));
$this->ctrl->setParameterByClass('ilcalendarappointmentgui','hour',$num_hour);
$this->tpl->setVariable('DAY_NEW_APP_LINK',$this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui','add'));
$this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
$this->tpl->setVariable('DAY_NEW_APP_SRC',ilUtil::getImagePath('date_add.gif'));
$this->tpl->setVariable('DAY_NEW_APP_ALT',$this->lng->txt('cal_new_app'));
$this->tpl->setVariable('DAY_NEW_ID',++$new_link_counter);
$this->tpl->parseCurrentBlock();
}
for($i = $colspan;$i > $hour['apps_num'];$i--)
{
if ($ilUser->prefs["screen_reader_optimization"])
{
continue;
}
$this->tpl->setCurrentBlock('day_cell');
if($i == ($hour['apps_num'] + 1))
{
$this->tpl->setVariable('TD_CLASS','calempty calrightborder');
#$this->tpl->setVariable('TD_STYLE',$add_style);
}
else
{
$this->tpl->setVariable('TD_CLASS','calempty');
#$this->tpl->setVariable('TD_STYLE',$add_style);
}
if(!$hour['apps_num'])
{
$this->tpl->setVariable('DAY_ID',$new_link_counter);
}
$this->tpl->setVariable('TD_ROWSPAN',1);
$this->tpl->parseCurrentBlock();
}
}
$this->tpl->setCurrentBlock('time_row');
$this->tpl->setVariable('TIME',$hour['txt']);
$this->tpl->parseCurrentBlock();
}
$this->tpl->setVariable("TXT_TIME", $lng->txt("time"));
}

+ Here is the call graph for this function:

ilCalendarWeekGUI::showAppointment (   $a_app)
protected

show appointment

protected

Parameters
arrayappointment

Definition at line 395 of file class.ilCalendarWeekGUI.php.

References $title, ilCalendarAppointmentPanelGUI\_getInstance(), IL_CAL_FKT_DATE, ilCalendarSettings\TIME_FORMAT_12, ilCalendarSettings\TIME_FORMAT_24, and ilCalendarCategory\TYPE_CH.

Referenced by show().

{
global $ilUser;
$this->tpl->setCurrentBlock('panel_code');
$this->tpl->setVariable('NUM',$this->num_appointments);
$this->tpl->parseCurrentBlock();
if (!$ilUser->prefs["screen_reader_optimization"])
{
$this->tpl->setCurrentBLock('not_empty');
}
else
{
$this->tpl->setCurrentBLock('scrd_not_empty');
}
include_once('./Services/Calendar/classes/class.ilCalendarAppointmentPanelGUI.php');
$this->tpl->setVariable('PANEL_DATA',ilCalendarAppointmentPanelGUI::_getInstance($this->seed)->getHTML($a_app));
$this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
$this->ctrl->setParameterByClass('ilcalendarappointmentgui','app_id',$a_app['event']->getEntryId());
$this->tpl->setVariable('APP_EDIT_LINK',$this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui','edit'));
if($a_app['event']->isFullDay())
{
$title = $a_app['event']->getPresentationTitle();
}
else
{
switch($this->user_settings->getTimeFormat())
{
$title = $a_app['event']->getStart()->get(IL_CAL_FKT_DATE,'H:i',$this->timezone);
break;
$title = $a_app['event']->getStart()->get(IL_CAL_FKT_DATE,'h:ia',$this->timezone);
break;
}
// add end time for screen readers
if ($ilUser->prefs["screen_reader_optimization"])
{
switch($this->user_settings->getTimeFormat())
{
$title.= "-".$a_app['event']->getEnd()->get(IL_CAL_FKT_DATE,'H:i',$this->timezone);
break;
$title.= "-".$a_app['event']->getEnd()->get(IL_CAL_FKT_DATE,'h:ia',$this->timezone);
break;
}
}
// booking
if($a_app['category_type'] == ilCalendarCategory::TYPE_CH)
{
include_once 'Services/Booking/classes/class.ilBookingEntry.php';
$entry = new ilBookingEntry($a_app['event']->getContextId());
if($entry)
{
$title .= ' '.$a_app['event']->getTitle();
if($entry->isOwner())
{
$max = (int)$entry->getNumberOfBookings();
$current = (int)$entry->getCurrentNumberOfBookings($a_app['event']->getEntryId());
if($max > 1)
{
$title .= ' ('.$current.'/'.$max.')';
}
else if($current == $max)
{
$title .= ' ('.$this->lng->txt('cal_booked_out').')';
}
else
{
$title .= ' ('.$this->lng->txt('cal_book_free').')';
}
}
else if($entry->hasBooked($a_app['event']->getEntryId()))
{
$title .= ' ('.$this->lng->txt('cal_date_booked').')';
}
}
}
else
{
$title .= (' '.$a_app['event']->getPresentationTitle());
}
}
$this->tpl->setVariable('APP_TITLE',$title);
$this->tpl->setVariable('LINK_NUM',$this->num_appointments);
$color = $this->app_colors->getColorByAppointment($a_app['event']->getEntryId());
$style = 'background-color: '.$color.';';
$style .= ('color:'.ilCalendarUtil::calculateFontColor($color));
$this->tpl->setVariable('LINK_STYLE',$style);
if (!$ilUser->prefs["screen_reader_optimization"])
{
// provide table cell attributes
$this->tpl->parseCurrentBlock();
$this->tpl->setCurrentBlock('day_cell');
$this->tpl->setVariable('DAY_CELL_NUM',$this->num_appointments);
$this->tpl->setVariable('TD_ROWSPAN',$a_app['rowspan']);
$this->tpl->setVariable('TD_STYLE',$style);
$this->tpl->setVariable('TD_CLASS','calevent');
$this->tpl->parseCurrentBlock();
}
else
{
// screen reader: work on div attributes
$this->tpl->setVariable('DIV_STYLE',$style);
$this->tpl->parseCurrentBlock();
}
$this->num_appointments++;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCalendarWeekGUI::showFulldayAppointment (   $a_app)
protected

show fullday appointment

protected

Parameters
arrayappointment
Returns

Definition at line 349 of file class.ilCalendarWeekGUI.php.

References ilCalendarAppointmentPanelGUI\_getInstance(), ilCalendarUtil\calculateFontColor(), and ilUtil\getImagePath().

Referenced by show().

{
$this->tpl->setCurrentBlock('panel_code');
$this->tpl->setVariable('NUM',$this->num_appointments);
$this->tpl->parseCurrentBlock();
// milestone icon
if ($a_app['event']->isMilestone())
{
$this->tpl->setCurrentBlock('fullday_ms_icon');
$this->tpl->setVariable('ALT_FD_MS', $this->lng->txt("cal_milestone"));
$this->tpl->setVariable('SRC_FD_MS', ilUtil::getImagePath("icon_ms_s.gif"));
$this->tpl->parseCurrentBlock();
}
$this->tpl->setCurrentBlock('fullday_app');
include_once('./Services/Calendar/classes/class.ilCalendarAppointmentPanelGUI.php');
$this->tpl->setVariable('PANEL_F_DAY_DATA',ilCalendarAppointmentPanelGUI::_getInstance($this->seed)->getHTML($a_app));
$this->tpl->setVariable('F_DAY_ID',$this->num_appointments);
$compl = ($a_app['event']->isMilestone() && $a_app['event']->getCompletion() > 0)
? " (".$a_app['event']->getCompletion()."%)"
: "";
$this->tpl->setVariable('F_APP_TITLE',$a_app['event']->getPresentationTitle().$compl);
$color = $this->app_colors->getColorByAppointment($a_app['event']->getEntryId());
$this->tpl->setVariable('F_APP_BGCOLOR',$color);
$this->tpl->setVariable('F_APP_FONTCOLOR',ilCalendarUtil::calculateFontColor($color));
$this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
$this->ctrl->setParameterByClass('ilcalendarappointmentgui','app_id',$a_app['event']->getEntryId());
$this->tpl->setVariable('F_APP_EDIT_LINK',$this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui','edit'));
$this->tpl->parseCurrentBlock();
$this->num_appointments++;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilCalendarWeekGUI::$ctrl
protected

Definition at line 49 of file class.ilCalendarWeekGUI.php.

ilCalendarWeekGUI::$lng
protected

Definition at line 48 of file class.ilCalendarWeekGUI.php.

Referenced by __construct(), and show().

ilCalendarWeekGUI::$num_appointments = 1
protected

Definition at line 43 of file class.ilCalendarWeekGUI.php.

ilCalendarWeekGUI::$seed = null
protected

Definition at line 44 of file class.ilCalendarWeekGUI.php.

ilCalendarWeekGUI::$tabs_gui
protected

Definition at line 50 of file class.ilCalendarWeekGUI.php.

ilCalendarWeekGUI::$timezone = 'UTC'
protected

Definition at line 53 of file class.ilCalendarWeekGUI.php.

ilCalendarWeekGUI::$tpl
protected

Definition at line 51 of file class.ilCalendarWeekGUI.php.

Referenced by __construct(), and executeCommand().

ilCalendarWeekGUI::$user_settings = null
protected

Definition at line 45 of file class.ilCalendarWeekGUI.php.

ilCalendarWeekGUI::$weekdays = array()
protected

Definition at line 46 of file class.ilCalendarWeekGUI.php.


The documentation for this class was generated from the following file: