* @author Chuck Hagenbuch <chuck@horde.org>
* @package Kronolith
*/
-class Kronolith_Day extends Horde_Date {
-
+class Kronolith_Day extends Horde_Date
+{
/**
* How many time slots are we dividing each hour into? Set from user
* preferences.
*
* @var integer
*/
- var $_slotsPerHour;
+ public $slotsPerHour;
/**
* How many slots do we have per day? Calculated from $_slotsPerHour.
* @see $_slotsPerHour
* @var integer
*/
- var $_slotsPerDay;
+ public $slotsPerDay;
/**
* How many minutes are in each slot? Calculated from $_slotsPerHour.
* @see $_slotsPerHour
* @var integer
*/
- var $_slotLength;
+ public $slotLength;
/**
* Array of slots holding hours and minutes for each piece of this day.
*
* @var array
*/
- var $slots = array();
+ public $slots = array();
/**
* Constructor.
* @param integer $day
* @param integer $year
*/
- function Kronolith_Day($month = null, $day = null, $year = null)
+ public function __construct($month = null, $day = null, $year = null)
{
if (is_null($month)) {
$month = date('n');
}
parent::__construct(array('year' => $year, 'month' => $month, 'mday' => $day));
- $this->_slotsPerHour = $GLOBALS['prefs']->getValue('slots_per_hour');
- if (!$this->_slotsPerHour) {
- $this->_slotsPerHour = 1;
+ $this->slotsPerHour = $GLOBALS['prefs']->getValue('slots_per_hour');
+ if (!$this->slotsPerHour) {
+ $this->slotsPerHour = 1;
}
- $this->_slotsPerDay = $this->_slotsPerHour * 24;
- $this->_slotLength = 60 / $this->_slotsPerHour;
+ $this->slotsPerDay = $this->slotsPerHour * 24;
+ $this->slotLength = 60 / $this->slotsPerHour;
- for ($i = 0; $i < $this->_slotsPerDay; $i++) {
- $minutes = $i * $this->_slotLength;
+ for ($i = 0; $i < $this->slotsPerDay; $i++) {
+ $minutes = $i * $this->slotLength;
$this->slots[$i]['hour'] = (int)($minutes / 60);
$this->slots[$i]['min'] = $minutes % 60;
}
}
- function getTime($format, $offset = 0)
+ public function getTime($format, $offset = 0)
{
$date = new Horde_Date(array('month' => $this->month,
'mday' => $this->mday + $offset,
return $date->strftime($format);
}
- function getTomorrow()
+ public function getTomorrow()
{
$date = new Horde_Date(array('month' => $this->month,
'mday' => $this->mday + 1,
return $date;
}
- function getYesterday()
+ public function getYesterday()
{
$date = new Horde_Date(array('month' => $this->month,
'mday' => $this->mday - 1,
return $date;
}
- function isToday()
+ public function isToday()
{
return $this->compareDate(new Horde_Date(mktime(0, 0, 0))) == 0;
}
- function isTomorrow()
+ public function isTomorrow()
{
$date = new Horde_Date(array('month' => $this->month,
'mday' => $this->mday - 1,
return $date->compareDate(new Horde_Date(mktime(0, 0, 0))) == 0;
}
- function diff()
+ public function diff()
{
$day2 = new Kronolith_Day();
return Date_Calc::dateDiff($this->mday, $this->month, $this->year,
* Just stores the $params in our newly-created object. All other work is
* done by {@link initialize()}.
*
- * @param array $params Any parameters needed for this driver.
+ * @param array $params Any parameters needed for this driver.
+ * @param string $errormsg A custom error message to use.
*/
- public function __construct($params = array(), $errormsg = null)
+ public function __construct(array $params = array(), $errormsg = null)
{
$this->_params = $params;
if ($errormsg === null) {
{
protected $_params = array();
- function __construct($user, $params = array())
+ public function __construct($user, array $params = array())
{
$this->_user = $user;
$this->_params = $params;
/**
* Constructs a new Kronolith_Storage SQL instance.
*
+ * @param string $user The user the fb info belongs to.
* @param array $params A hash containing connection parameters.
+ *
+ * @return Kronolith_Storage_Sql
*/
- public function __construct($user, $params = array())
+ public function __construct($user, array $params = array())
{
$this->_user = $user;
if (empty($params['db'])) {
* @author Jan Schneider <jan@horde.org>
* @package Kronolith
*/
-class Kronolith_View_Day extends Kronolith_Day {
-
- var $_events = array();
- var $_all_day_events = array();
- var $_all_day_rowspan = array();
- var $_all_day_maxrowspan = 0;
- var $_event_matrix = array();
- var $_parsed = false;
- var $_span = array();
- var $_totalspan = 0;
- var $_sidebyside = false;
- var $_currentCalendars = array();
- var $_first;
- var $_last;
-
- function Kronolith_View_Day($date, $events = null)
+class Kronolith_View_Day extends Kronolith_Day
+{
+ public $all_day_events = array();
+ public $all_day_rowspan = array();
+ public $all_day_maxrowspan = 0;
+ public $span = array();
+ public $totalspan = 0;
+ public $sidebyside = false;
+ protected $_events = array();
+ protected $_event_matrix = array();
+ protected $_parsed = false;
+ protected $_currentCalendars = array();
+ protected $_first;
+ protected $_last;
+
+ /**
+ *
+ * @param Horde_Date $date The day for this view
+ * @param array $events An array of Kronolith_Event objects
+ *
+ * @return Kronolith_View_Day
+ */
+ public function __construct(Horde_Date $date, array $events = null)
{
- parent::Kronolith_Day($date->month, $date->mday, $date->year);
+ parent::__construct($date->month, $date->mday, $date->year);
- $this->_sidebyside = $GLOBALS['prefs']->getValue('show_shared_side_by_side');
- if ($this->_sidebyside) {
+ $this->sidebyside = $GLOBALS['prefs']->getValue('show_shared_side_by_side');
+ if ($this->sidebyside) {
$allCalendars = Kronolith::listInternalCalendars();
foreach ($GLOBALS['display_calendars'] as $cid) {
$this->_currentCalendars[$cid] = $allCalendars[$cid];
- $this->_all_day_events[$cid] = array();
+ $this->all_day_events[$cid] = array();
}
} else {
$this->_currentCalendars = array(0);
}
}
- function setEvents($events)
+ /**
+ * Setter for events array
+ *
+ * @param array $events
+ */
+ public function setEvents(array $events)
{
$this->_events = $events;
}
- function html()
+ public function html()
{
global $prefs;
$showTime = Kronolith::viewShowTime();
require KRONOLITH_TEMPLATES . '/day/head.inc';
- if ($this->_sidebyside) {
+ if ($this->sidebyside) {
require KRONOLITH_TEMPLATES . '/day/head_side_by_side.inc';
}
echo '<tbody>';
* with no rowspan. We put in a rowspan in the row after the last
* event to fill all remaining rows. */
$row = '';
- $rowspan = ($this->_all_day_maxrowspan) ? ' rowspan="' . $this->_all_day_maxrowspan . '"' : '';
- for ($k = 0; $k < $this->_all_day_maxrowspan; ++$k) {
+ $rowspan = ($this->all_day_maxrowspan) ? ' rowspan="' . $this->all_day_maxrowspan . '"' : '';
+ for ($k = 0; $k < $this->all_day_maxrowspan; ++$k) {
$row = '';
foreach (array_keys($this->_currentCalendars) as $cid) {
- if (count($this->_all_day_events[$cid]) === $k) {
+ if (count($this->all_day_events[$cid]) === $k) {
// There are no events or all events for this calendar
// have already been printed.
- $row .= '<td class="allday" width="1%" rowspan="' . ($this->_all_day_maxrowspan - $k) . '" colspan="'. $this->_span[$cid] . '"> </td>';
- } elseif (count($this->_all_day_events[$cid]) > $k) {
+ $row .= '<td class="allday" width="1%" rowspan="' . ($this->all_day_maxrowspan - $k) . '" colspan="'. $this->span[$cid] . '"> </td>';
+ } elseif (count($this->all_day_events[$cid]) > $k) {
// We have not printed every all day event yet. Put one
// into this row.
- $event = $this->_all_day_events[$cid][$k];
+ $event = $this->all_day_events[$cid][$k];
$row .= '<td class="day-eventbox"'
. $event->getCSSColors()
. 'width="' . round(90 / count($this->_currentCalendars)) . '%" '
- . 'valign="top" colspan="' . $this->_span[$cid] . '">'
+ . 'valign="top" colspan="' . $this->span[$cid] . '">'
. $event->getLink($this, true, $this->link(0, true));
if ($showLocation) {
$row .= '<div class="event-location">' . htmlspecialchars($event->location) . '</div>';
}
if ($first_row) {
- $row .= '<td colspan="' . $this->_totalspan . '" width="100%"> </td>';
+ $row .= '<td colspan="' . $this->totalspan . '" width="100%"> </td>';
require KRONOLITH_TEMPLATES . '/day/all_day.inc';
}
$day_hour_force = $prefs->getValue('day_hour_force');
- $day_hour_start = $prefs->getValue('day_hour_start') / 2 * $this->_slotsPerHour;
- $day_hour_end = $prefs->getValue('day_hour_end') / 2 * $this->_slotsPerHour;
+ $day_hour_start = $prefs->getValue('day_hour_start') / 2 * $this->slotsPerHour;
+ $day_hour_end = $prefs->getValue('day_hour_end') / 2 * $this->slotsPerHour;
$rows = array();
$covered = array();
- for ($i = 0; $i < $this->_slotsPerDay; ++$i) {
+ for ($i = 0; $i < $this->slotsPerDay; ++$i) {
if ($i >= $day_hour_end && $i > $this->_last) {
break;
}
}
$row = '';
- if (($m = $i % $this->_slotsPerHour) != 0) {
- $time = ':' . $m * $this->_slotLength;
+ if (($m = $i % $this->slotsPerHour) != 0) {
+ $time = ':' . $m * $this->slotLength;
$hourclass = 'halfhour';
} else {
$time = Kronolith_View_Day::prefHourFormat($this->slots[$i]['hour']);
// factor of the total span, we get this event's
// individual span by dividing the total span by this
// event's overlap.
- $span = $this->_span[$cid] / $event->overlap;
+ $span = $this->span[$cid] / $event->overlap;
// Store the indent we're starting this event at
// for future use.
$hspan += $span;
$start = new Horde_Date(array(
- 'hour' => floor($i / $this->_slotsPerHour),
- 'min' => ($i % $this->_slotsPerHour) * $this->_slotLength,
+ 'hour' => floor($i / $this->slotsPerHour),
+ 'min' => ($i % $this->slotsPerHour) * $this->slotLength,
'month' => $this->month,
'mday' => $this->mday,
'year' => $this->year));
$end_slot = new Horde_Date($start);
- $end_slot->min += $this->_slotLength;
+ $end_slot->min += $this->slotLength;
if (((!$day_hour_force || $i >= $day_hour_start) &&
$event->start->compareDateTime($start) >= 0 &&
$event->start->compareDateTime($end_slot) < 0 ||
$row .= '<td class="day-eventbox"'
. $event->getCSSColors()
- . 'width="' . round((90 / count($this->_currentCalendars)) * ($span / $this->_span[$cid])) . '%" '
+ . 'width="' . round((90 / count($this->_currentCalendars)) * ($span / $this->span[$cid])) . '%" '
. 'valign="top" colspan="' . $span . '" rowspan="' . $event->rowspan . '">'
. $event->getLink($this, true, $this->link(0, true));
if ($showTime) {
}
}
- $diff = $this->_span[$cid] - $hspan;
+ $diff = $this->span[$cid] - $hspan;
if ($diff > 0) {
$row .= str_repeat('<td> </td>', $diff);
}
}
$template = $GLOBALS['injector']->createInstance('Horde_Template');
- $template->set('row_height', round(20 / $this->_slotsPerHour));
+ $template->set('row_height', round(20 / $this->slotsPerHour));
$template->set('rows', $rows);
$template->set('show_slots', true, true);
echo $template->fetch(KRONOLITH_TEMPLATES . '/day/rows.html')
* what should be on each line of the output table. This is a
* little tricky.
*/
- function parse()
+ public function parse()
{
global $prefs;
$tmp = array();
- $this->_all_day_maxrowspan = 0;
+ $this->all_day_maxrowspan = 0;
$day_hour_force = $prefs->getValue('day_hour_force');
- $day_hour_start = $prefs->getValue('day_hour_start') / 2 * $this->_slotsPerHour;
- $day_hour_end = $prefs->getValue('day_hour_end') / 2 * $this->_slotsPerHour;
+ $day_hour_start = $prefs->getValue('day_hour_start') / 2 * $this->slotsPerHour;
+ $day_hour_end = $prefs->getValue('day_hour_end') / 2 * $this->slotsPerHour;
// Separate out all day events and do some initialization/prep
// for parsing.
foreach (array_keys($this->_currentCalendars) as $cid) {
- $this->_all_day_events[$cid] = array();
- $this->_all_day_rowspan[$cid] = 0;
+ $this->all_day_events[$cid] = array();
+ $this->all_day_rowspan[$cid] = 0;
}
foreach ($this->_events as $key => $event) {
// If we have side_by_side we only want to include the
// event in the proper calendar.
- if ($this->_sidebyside) {
+ if ($this->sidebyside) {
$cid = $event->calendar;
} else {
$cid = 0;
// All day events are easy; store them seperately.
if ($event->isAllDay()) {
- $this->_all_day_events[$cid][] = clone $event;
- ++$this->_all_day_rowspan[$cid];
- $this->_all_day_maxrowspan = max($this->_all_day_maxrowspan, $this->_all_day_rowspan[$cid]);
+ $this->all_day_events[$cid][] = clone $event;
+ ++$this->all_day_rowspan[$cid];
+ $this->all_day_maxrowspan = max($this->all_day_maxrowspan, $this->all_day_rowspan[$cid]);
} else {
// Initialize the number of events that this event
// overlaps with.
// Track the first and last slots in which we have an event
// (they each start at the other end of the day and move
// towards/past each other as we find events).
- $this->_first = $this->_slotsPerDay;
+ $this->_first = $this->slotsPerDay;
$this->_last = 0;
// Run through every slot, adding in entries for every event
// that we have here.
- for ($i = 0; $i < $this->_slotsPerDay; ++$i) {
+ for ($i = 0; $i < $this->slotsPerDay; ++$i) {
// Initialize this slot in the event matrix.
foreach (array_keys($this->_currentCalendars) as $cid) {
$this->_event_matrix[$cid][$i] = array();
// Calculate the start and end times for this slot.
$start = new Horde_Date(array(
- 'hour' => floor($i / $this->_slotsPerHour),
- 'min' => ($i % $this->_slotsPerHour) * $this->_slotLength,
+ 'hour' => floor($i / $this->slotsPerHour),
+ 'min' => ($i % $this->slotsPerHour) * $this->slotLength,
'month' => $this->month,
'mday' => $this->mday,
'year' => $this->year));
$end = clone $start;
- $end->min += $this->_slotLength;
+ $end->min += $this->slotLength;
// Search through our events.
foreach ($this->_events as $key => $event) {
// If we have side_by_side we only want to include the
// event in the proper calendar.
- if ($this->_sidebyside) {
+ if ($this->sidebyside) {
$cid = $event->calendar;
} else {
$cid = 0;
$span[$cid] *= $s;
}
}
- $this->_totalspan += $span[$cid];
+ $this->totalspan += $span[$cid];
}
// Set the final span.
if (isset($span)) {
- $this->_span = $span;
+ $this->span = $span;
} else {
- $this->_totalspan = 1;
+ $this->totalspan = 1;
}
// We're now parsed and ready to go.
$this->_parsed = true;
}
- function link($offset = 0, $full = false)
+ public function link($offset = 0, $full = false)
{
return Horde::url('day.php', $full)
->add('date', $this->getTime('%Y%m%d', $offset));
}
- function getName()
+ public function getName()
{
return 'Day';
}
- function prefHourFormat($hour)
+ public function prefHourFormat($hour)
{
$hour = $hour % 24;
if ($GLOBALS['prefs']->getValue('twentyFour')) {
. ($hour < 12 ? 'am' : 'pm');
}
- function _sortByStart($evA, $evB)
+ protected function _sortByStart($evA, $evB)
{
$sA = $this->_events[$evA]->start;
$sB = $this->_events[$evB]->start;
* @author Chuck Hagenbuch <chuck@horde.org>
* @package Kronolith
*/
-class Kronolith_View_DeleteEvent {
-
- var $event;
+class Kronolith_View_DeleteEvent
+{
+ /**
+ * @var Kronolith_Event
+ */
+ protected $_event;
/**
* @param Kronolith_Event $event
*/
- function Kronolith_View_DeleteEvent($event)
+ public function __construct(Kronolith_Event $event)
{
- $this->event = $event;
+ $this->_event = $event;
+ }
+
+ public function __get($property)
+ {
+ switch ($property) {
+ case 'event':
+ return $this->_event;
+ default:
+ throw new Exception(_("Property does not exist."));
+ }
}
- function getTitle()
+ public function getTitle()
{
- if (!$this->event) {
+ if (!$this->_event) {
return _("Not Found");
}
- if (is_string($this->event)) {
- return $this->event;
+ if (is_string($this->_event)) {
+ return $this->_event;
}
- return sprintf(_("Delete %s"), $this->event->getTitle());
+ return sprintf(_("Delete %s"), $this->_event->getTitle());
}
- function link()
+ public function link()
{
- return $this->event->getDeleteUrl();
+ return $this->_event->getDeleteUrl();
}
- function html($active = true)
+ public function html($active = true)
{
- if (!$this->event) {
+ if (!$this->_event) {
echo '<h3>' . _("Event not found") . '</h3>';
exit;
}
- if (is_string($this->event)) {
- echo '<h3>' . $this->event . '</h3>';
+ if (is_string($this->_event)) {
+ echo '<h3>' . $this->_event . '</h3>';
exit;
}
$url = Horde_Util::getFormData('url');
echo '<div id="DeleteEvent"' . ($active ? '' : ' style="display:none"') . '>';
- if (!$this->event->recurs()) {
+ if (!$this->_event->recurs()) {
require KRONOLITH_TEMPLATES . '/delete/one.inc';
} else {
require KRONOLITH_TEMPLATES . '/delete/delete.inc';
echo '</div>';
if ($active && $GLOBALS['browser']->hasFeature('dom')) {
- if ($this->event->hasPermission(Horde_Perms::READ)) {
- $view = new Kronolith_View_Event($this->event);
+ if ($this->_event->hasPermission(Horde_Perms::READ)) {
+ $view = new Kronolith_View_Event($this->_event);
$view->html(false);
}
- if ($this->event->hasPermission(Horde_Perms::EDIT)) {
- $edit = new Kronolith_View_EditEvent($this->event);
+ if ($this->_event->hasPermission(Horde_Perms::EDIT)) {
+ $edit = new Kronolith_View_EditEvent($this->_event);
$edit->html(false);
}
}
}
- function getName()
+ public function getName()
{
return 'DeleteEvent';
}
* @author Chuck Hagenbuch <chuck@horde.org>
* @package Kronolith
*/
-class Kronolith_View_EditEvent {
-
- var $event;
+class Kronolith_View_EditEvent
+{
+ /**
+ *
+ * @var Kronolith_Event
+ */
+ protected $_event;
/**
* @param Kronolith_Event $event
*/
- function Kronolith_View_EditEvent($event)
+ public function __construct(Kronolith_Event $event)
{
- $this->event = $event;
+ $this->_event = $event;
+ }
+
+ public function __get($property)
+ {
+ switch ($property) {
+ case 'event':
+ return $this->_event;
+ default:
+ throw new Exception(_("Property does not exist."));
+ }
}
- function getTitle()
+ public function getTitle()
{
- if (!$this->event) {
+ if (!$this->_event) {
return _("Not Found");
}
- if (is_string($this->event)) {
- return $this->event;
+ if (is_string($this->_event)) {
+ return $this->_event;
}
- return sprintf(_("Edit %s"), $this->event->getTitle());
+ return sprintf(_("Edit %s"), $this->_event->getTitle());
}
- function link()
+ public function link()
{
- return $this->event->getEditUrl();
+ return $this->_event->getEditUrl();
}
- function html($active = true)
+ public function html($active = true)
{
- if (!$this->event) {
+ if (!$this->_event) {
echo '<h3>' . _("Event not found") . '</h3>';
exit;
}
- if (is_string($this->event)) {
- echo '<h3>' . $this->event . '</h3>';
+ if (is_string($this->_event)) {
+ echo '<h3>' . $this->_event . '</h3>';
exit;
}
$identity = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create();
- if ($this->event->hasPermission(Horde_Perms::EDIT)) {
- $calendar_id = $this->event->calendarType . '_' . $this->event->calendar;
+ if ($this->_event->hasPermission(Horde_Perms::EDIT)) {
+ $calendar_id = $this->_event->calendarType . '_' . $this->_event->calendar;
} else {
$calendar_id = 'internal_' . Kronolith::getDefaultCalendar(Horde_Perms::EDIT);
}
- if (!$this->event->hasPermission(Horde_Perms::EDIT)) {
+ if (!$this->_event->hasPermission(Horde_Perms::EDIT)) {
try {
- $calendar_id .= ':' . $this->event->getShare()->get('owner');
+ $calendar_id .= ':' . $this->_event->getShare()->get('owner');
} catch (Exception $e) {
}
}
- $GLOBALS['session']->set('kronolith', 'attendees', $this->event->attendees);
- $GLOBALS['session']->set('kronolith', 'resources', $this->event->getResources());
+ $GLOBALS['session']->set('kronolith', 'attendees', $this->_event->attendees);
+ $GLOBALS['session']->set('kronolith', 'resources', $this->_event->getResources());
if ($datetime = Horde_Util::getFormData('datetime')) {
$datetime = new Horde_Date($datetime);
$month = $datetime->month;
$url = Horde_Util::getFormData('url');
$perms = Horde_Perms::EDIT;
- if ($this->event->creator == $GLOBALS['registry']->getAuth()) {
+ if ($this->_event->creator == $GLOBALS['registry']->getAuth()) {
$perms |= Kronolith::PERMS_DELEGATE;
}
$calendars = Kronolith::listCalendars($perms, true);
$buttons = array();
- if (!$this->event->hasPermission(Horde_Perms::EDIT) &&
+ if (!$this->_event->hasPermission(Horde_Perms::EDIT) &&
($GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_events') === true ||
$GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_events') > Kronolith::countEvents())) {
$buttons[] = '<input type="submit" class="button" name="saveAsNew" value="' . _("Save As New") . '" />';
} else {
- if ($this->event->hasPermission(Horde_Perms::EDIT)) {
+ if ($this->_event->hasPermission(Horde_Perms::EDIT)) {
$buttons[] = '<input type="submit" class="button" name="save" value="' . _("Save Event") . '" />';
}
- if ($this->event->initialized) {
- if (!$this->event->recurs() &&
+ if ($this->_event->initialized) {
+ if (!$this->_event->recurs() &&
($GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_events') === true ||
$GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_events') > Kronolith::countEvents())) {
$buttons[] = '<input type="submit" class="button" name="saveAsNew" value="' . _("Save As New") . '" />';
->add(array('month' => $month, 'year' => $year));
}
- $event = &$this->event;
+ $event = &$this->_event;
$tags = implode(',', array_values($event->tags));
Horde_Core_Ui_JsCalendar::init(array(
echo '</div>';
if ($active && $GLOBALS['browser']->hasFeature('dom')) {
- if ($this->event->hasPermission(Horde_Perms::READ)) {
- $view = new Kronolith_View_Event($this->event);
+ if ($this->_event->hasPermission(Horde_Perms::READ)) {
+ $view = new Kronolith_View_Event($this->_event);
$view->html(false);
}
- if ($this->event->hasPermission(Horde_Perms::DELETE)) {
- $delete = new Kronolith_View_DeleteEvent($this->event);
+ if ($this->_event->hasPermission(Horde_Perms::DELETE)) {
+ $delete = new Kronolith_View_DeleteEvent($this->_event);
$delete->html(false);
}
}
}
- function getName()
+ public function getName()
{
return 'EditEvent';
}
* @author Chuck Hagenbuch <chuck@horde.org>
* @package Kronolith
*/
-class Kronolith_View_Event {
-
- var $event;
+class Kronolith_View_Event
+{
+ /**
+ *
+ * @var Kronolith_Event
+ */
+ protected $_event;
/**
* @param Kronolith_Event $event
*/
- function Kronolith_View_Event($event)
+ public function __construct(Kronolith_Event $event)
{
- $this->event = $event;
+ $this->_event = $event;
+ }
+
+ public function __get($property)
+ {
+ switch ($property) {
+ case 'event':
+ return $this->_event;
+ default:
+ throw new Exception(_("Property does not exist."));
+ }
}
- function getTitle()
+ public function getTitle()
{
- if (!$this->event) {
+ if (!$this->_event) {
return _("Not Found");
}
- if (is_string($this->event)) {
- return $this->event;
+ if (is_string($this->_event)) {
+ return $this->_event;
}
- return $this->event->getTitle();
+ return $this->_event->getTitle();
}
- function link()
+ public function link()
{
- return $this->event->getViewUrl();
+ return $this->_event->getViewUrl();
}
- function html($active = true)
+ public function html($active = true)
{
- if (!$this->event) {
+ if (!$this->_event) {
echo '<h3>' . _("Event not found") . '</h3>';
exit;
}
- if (is_string($this->event)) {
- echo '<h3>' . $this->event . '</h3>';
+ if (is_string($this->_event)) {
+ echo '<h3>' . $this->_event . '</h3>';
exit;
}
$createdby = '';
$modifiedby = '';
$userId = $GLOBALS['registry']->getAuth();
- if ($this->event->uid) {
+ if ($this->_event->uid) {
/* Get the event's history. */
try {
$log = $GLOBALS['injector']->getInstance('Horde_History')
- ->getHistory('kronolith:' . $this->event->calendar . ':' . $this->event->uid);
+ ->getHistory('kronolith:' . $this->_event->calendar . ':' . $this->_event->uid);
foreach ($log as $entry) {
switch ($entry['action']) {
case 'add':
} catch (Exception $e) {}
}
- $creatorId = $this->event->creator;
- $description = $this->event->description;
- $location = $this->event->location;
- $eventurl = $this->event->url;
- $private = $this->event->private && $creatorId != $GLOBALS['registry']->getAuth();
+ $creatorId = $this->_event->creator;
+ $description = $this->_event->description;
+ $location = $this->_event->location;
+ $eventurl = $this->_event->url;
+ $private = $this->_event->private && $creatorId != $GLOBALS['registry']->getAuth();
$owner = Kronolith::getUserName($creatorId);
- $status = Kronolith::statusToString($this->event->status);
- $attendees = $this->event->attendees;
- $resources = $this->event->getResources();
+ $status = Kronolith::statusToString($this->_event->status);
+ $attendees = $this->_event->attendees;
+ $resources = $this->_event->getResources();
if ($datetime = Horde_Util::getFormData('datetime')) {
$datetime = new Horde_Date($datetime);
$month = $datetime->month;
$timeFormat = $prefs->getValue('twentyFour') ? 'G:i' : 'g:ia';
// Tags
- $tags = implode(', ', $this->event->tags);
+ $tags = implode(', ', $this->_event->tags);
echo '<div id="Event"' . ($active ? '' : ' style="display:none"') . '>';
if ($active && $GLOBALS['browser']->hasFeature('dom')) {
/* We check for read permissions, because we can always save a
* copy if we can read the event. */
- if ($this->event->hasPermission(Horde_Perms::READ)) {
- $edit = new Kronolith_View_EditEvent($this->event);
+ if ($this->_event->hasPermission(Horde_Perms::READ)) {
+ $edit = new Kronolith_View_EditEvent($this->_event);
$edit->html(false);
}
- if ($this->event->hasPermission(Horde_Perms::DELETE)) {
- $delete = new Kronolith_View_DeleteEvent($this->event);
+ if ($this->_event->hasPermission(Horde_Perms::DELETE)) {
+ $delete = new Kronolith_View_DeleteEvent($this->_event);
$delete->html(false);
}
}
}
- function getName()
+ public function getName()
{
return 'Event';
}
* @author Jan Schneider <chuck@horde.org>
* @package Kronolith
*/
-class Kronolith_View_ExportEvent {
-
+class Kronolith_View_ExportEvent
+{
/**
* @param Kronolith_Event $event
*/
- function Kronolith_View_ExportEvent($event)
+ public function __construct(Kronolith_Event $event)
{
if (!$event) {
echo '<h3>' . _("Event not found") . '</h3>';
* @author Jan Schneider <jan@horde.org>
* @package Kronolith
*/
-class Kronolith_View_Month {
-
+class Kronolith_View_Month
+{
/**
* @var integer
*/
- var $month;
+ public $month;
/**
* @var integer
*/
- var $year;
+ public $year;
/**
* @var Horde_Date
*/
- var $date;
+ public $date;
/**
* @var array
*/
- var $_events = array();
+ protected $_events = array();
/**
* @var array
*/
- var $_currentCalendars = array();
+ protected $_currentCalendars = array();
/**
* @var integer
*/
- var $_daysInView;
+ protected $_daysInView;
/**
* @var integer
*/
- var $_startOfView;
+ protected $_startOfView;
/**
* @var integer
*/
- var $_startday;
+ protected $_startday;
- function Kronolith_View_Month($date)
+ /**
+ *
+ * @global Horde_Prefs $prefs
+ * @param Horde_Date $date
+ *
+ * @return Kronolith_View_Month
+ */
+ public function __construct(Horde_Date $date)
{
global $prefs;
}
}
- function html()
+ public function html()
{
global $prefs;
echo $html . '</tbody></table>';
}
- function getMonth($offset = 0)
+ public function getMonth($offset = 0)
{
$month = new Horde_Date($this->date);
$month->month += $offset;
return $month;
}
- function link($offset = 0, $full = false)
+ public function link($offset = 0, $full = false)
{
$month = $this->getMonth($offset);
return Horde::url('month.php', $full)
->add('date', $month->dateString());
}
- function getName()
+ public function getName()
{
return 'Month';
}
* @author Jan Schneider <jan@horde.org>
* @package Kronolith
*/
-class Kronolith_View_Week {
-
- var $parsed = false;
- var $days = array();
- var $week = null;
- var $year = null;
- var $startDay = null;
- var $endDay = null;
- var $startDate = null;
- var $_controller = 'week.php';
- var $_sidebyside = false;
- var $_currentCalendars = array();
+class Kronolith_View_Week
+{
+ public $parsed = false;
+ public $days = array();
+ public $week = null;
+ public $year = null;
+ public $startDay = null;
+ public $endDay = null;
+ public $startDate = null;
+ protected $_controller = 'week.php';
+ public $sidebyside = false;
+ public $_currentCalendars = array();
/**
* How many time slots are we dividing each hour into?
*
* @var integer
*/
- var $_slotsPerHour = 2;
+ public $_slotsPerHour = 2;
/**
* How many slots do we have per day? Calculated from $_slotsPerHour.
* @see $_slotsPerHour
* @var integer
*/
- var $_slotsPerDay;
+ public $_slotsPerDay;
- function Kronolith_View_Week($date)
+ public function __construct(Horde_Date $date)
{
$week = $date->weekOfYear();
$year = $date->year;
? $allevents[$date_stamp]
: array());
}
- $this->_sidebyside = $this->days[$this->startDay]->_sidebyside;
- $this->_currentCalendars = $this->days[$this->startDay]->_currentCalendars;
- $this->_slotsPerHour = $this->days[$this->startDay]->_slotsPerHour;
- $this->_slotsPerDay = $this->days[$this->startDay]->_slotsPerDay;
- $this->_slotLength = $this->days[$this->startDay]->_slotLength;
+ $this->sidebyside = $this->days[$this->startDay]->sidebyside;
+ $this->_currentCalendars = $this->days[$this->startDay]->currentCalendars;
+ $this->slotsPerHour = $this->days[$this->startDay]->slotsPerHour;
+ $this->slotsPerDay = $this->days[$this->startDay]->slotsPerDay;
+ $this->slotLength = $this->days[$this->startDay]->slotLength;
}
- function html()
+ public function html()
{
global $prefs;
$slots = $this->days[$this->startDay]->slots;
$cid = 0;
require KRONOLITH_TEMPLATES . '/week/head.inc';
- if ($this->_sidebyside) {
+ if ($this->sidebyside) {
require KRONOLITH_TEMPLATES . '/week/head_side_by_side.inc';
}
echo '</thead><tbody>';
$event_count = 0;
for ($j = $this->startDay; $j <= $this->endDay; ++$j) {
foreach (array_keys($this->_currentCalendars) as $cid) {
- $event_count = max($event_count, count($this->days[$j]->_all_day_events[$cid]));
- reset($this->days[$j]->_all_day_events[$cid]);
+ $event_count = max($event_count, count($this->days[$j]->all_day_events[$cid]));
+ reset($this->days[$j]->all_day_events[$cid]);
}
}
$row = '';
for ($j = $this->startDay; $j <= $this->endDay; ++$j) {
$row .= '<td class="hour rightAlign daySpacer">' . ($more_timeslots ? _("All day") : ' ') . '</td>' .
- '<td colspan="' . $this->days[$j]->_totalspan . '" valign="top"><table width="100%" cellspacing="0">';
- if ($this->days[$j]->_all_day_maxrowspan > 0) {
- for ($k = 0; $k < $this->days[$j]->_all_day_maxrowspan; ++$k) {
+ '<td colspan="' . $this->days[$j]->totalspan . '" valign="top"><table width="100%" cellspacing="0">';
+ if ($this->days[$j]->all_day_maxrowspan > 0) {
+ for ($k = 0; $k < $this->days[$j]->all_day_maxrowspan; ++$k) {
$row .= '<tr>';
- foreach (array_keys($this->days[$j]->_currentCalendars) as $cid) {
- if (count($this->days[$j]->_all_day_events[$cid]) === $k) {
- $row .= '<td rowspan="' . ($this->days[$j]->_all_day_maxrowspan - $k) . '" width="'. round(99 / count($this->days[$j]->_currentCalendars)) . '%"> </td>';
- } elseif (count($this->days[$j]->_all_day_events[$cid]) > $k) {
- $event = $this->days[$j]->_all_day_events[$cid][$k];
+ foreach (array_keys($this->days[$j]->currentCalendars) as $cid) {
+ if (count($this->days[$j]->all_day_events[$cid]) === $k) {
+ $row .= '<td rowspan="' . ($this->days[$j]->all_day_maxrowspan - $k) . '" width="'. round(99 / count($this->days[$j]->currentCalendars)) . '%"> </td>';
+ } elseif (count($this->days[$j]->all_day_events[$cid]) > $k) {
+ $event = $this->days[$j]->all_day_events[$cid][$k];
$row .= '<td class="week-eventbox"'
. $event->getCSSColors()
- . 'width="' . round(99 / count($this->days[$j]->_currentCalendars)) . '%" '
+ . 'width="' . round(99 / count($this->days[$j]->currentCalendars)) . '%" '
. 'valign="top">'
. $event->getLink($this->days[$j], true, $this->link(0, true));
if ($showLocation) {
require KRONOLITH_TEMPLATES . '/day/all_day.inc';
$day_hour_force = $prefs->getValue('day_hour_force');
- $day_hour_start = $prefs->getValue('day_hour_start') / 2 * $this->_slotsPerHour;
- $day_hour_end = $prefs->getValue('day_hour_end') / 2 * $this->_slotsPerHour;
+ $day_hour_start = $prefs->getValue('day_hour_start') / 2 * $this->slotsPerHour;
+ $day_hour_end = $prefs->getValue('day_hour_end') / 2 * $this->slotsPerHour;
$rows = array();
$covered = array();
- for ($i = 0; $i < $this->_slotsPerDay; ++$i) {
+ for ($i = 0; $i < $this->slotsPerDay; ++$i) {
if ($i >= $day_hour_end && $i > $this->last) {
break;
}
continue;
}
- if (($m = $i % $this->_slotsPerHour) != 0) {
- $time = ':' . $m * $this->_slotLength;
+ if (($m = $i % $this->slotsPerHour) != 0) {
+ $time = ':' . $m * $this->slotLength;
$hourclass = 'halfhour';
} else {
$time = Kronolith_View_Day::prefHourFormat($slots[$i]['hour']);
// first available cell of the day.
for (; isset($covered[$j][$i][$current_indent]); ++$current_indent);
- foreach ($this->days[$j]->_event_matrix[$cid][$i] as $key) {
- $event = &$this->days[$j]->_events[$key];
+ foreach ($this->days[$j]->event_matrix[$cid][$i] as $key) {
+ $event = &$this->days[$j]->events[$key];
if ($include_all_events || $event->calendar == $cid) {
// Since we've made sure that this event's
// overlap is a factor of the total span,
// we get this event's individual span by
// dividing the total span by this event's
// overlap.
- $span = $this->days[$j]->_span[$cid] / $event->overlap;
+ $span = $this->days[$j]->span[$cid] / $event->overlap;
// Store the indent we're starting this event at
// for future use.
$current_indent += $event->span;
$start = new Horde_Date(array(
- 'hour' => floor($i / $this->_slotsPerHour),
- 'min' => ($i % $this->_slotsPerHour) * $this->_slotLength,
+ 'hour' => floor($i / $this->slotsPerHour),
+ 'min' => ($i % $this->slotsPerHour) * $this->slotLength,
'month' => $this->days[$j]->month,
'mday' => $this->days[$j]->mday,
'year' => $this->days[$j]->year));
$slot_end = new Horde_Date($start);
- $slot_end->min += $this->_slotLength;
+ $slot_end->min += $this->slotLength;
if (((!$day_hour_force || $i >= $day_hour_start) &&
$event->start->compareDateTime($start) >= 0 &&
$event->start->compareDateTime($slot_end) < 0 ||
$row .= '<td class="week-eventbox"'
. $event->getCSSColors()
. 'valign="top" '
- . 'width="' . floor(((90 / count($this->days)) / count($this->_currentCalendars)) * ($span / $this->days[$j]->_span[$cid])) . '%" '
+ . 'width="' . floor(((90 / count($this->days)) / count($this->_currentCalendars)) * ($span / $this->days[$j]->span[$cid])) . '%" '
. 'colspan="' . $event->span . '" rowspan="' . $event->rowspan . '">'
. $event->getLink($this->days[$j], true, $this->link(0, true));
if ($showTime) {
}
}
- $diff = $this->days[$j]->_span[$cid] - $hspan;
+ $diff = $this->days[$j]->span[$cid] - $hspan;
if ($diff > 0) {
$row .= str_repeat('<td> </td>', $diff);
}
}
$template = $GLOBALS['injector']->createInstance('Horde_Template');
- $template->set('row_height', round(20 / $this->_slotsPerHour));
+ $template->set('row_height', round(20 / $this->slotsPerHour));
$template->set('rows', $rows);
$template->set('show_slots', !$more_timeslots, true);
echo $template->fetch(KRONOLITH_TEMPLATES . '/day/rows.html')
* run through the results to get the total horizontal span for
* the week, and the latest event of the week.
*/
- function parse()
+ public function parse()
{
for ($i = $this->startDay; $i <= $this->endDay; ++$i) {
$this->days[$i]->parse();
$this->totalspan = 0;
$this->span = array();
for ($i = $this->startDay; $i <= $this->endDay; ++$i) {
- $this->totalspan += $this->days[$i]->_totalspan;
+ $this->totalspan += $this->days[$i]->totalspan;
foreach (array_keys($this->_currentCalendars) as $cid) {
if (isset($this->span[$cid])) {
- $this->span[$cid] += $this->days[$i]->_span[$cid];
+ $this->span[$cid] += $this->days[$i]->span[$cid];
} else {
- $this->span[$cid] = $this->days[$i]->_span[$cid];
+ $this->span[$cid] = $this->days[$i]->span[$cid];
}
}
}
$this->last = 0;
- $this->first = $this->_slotsPerDay;
+ $this->first = $this->slotsPerDay;
for ($i = $this->startDay; $i <= $this->endDay; ++$i) {
if ($this->days[$i]->last > $this->last) {
$this->last = $this->days[$i]->last;
}
}
- function getWeek($offset = 0)
+ public function getWeek($offset = 0)
{
$week = new Horde_Date($this->startDate);
$week->mday += $offset * 7;
return $week;
}
- function link($offset = 0, $full = false)
+ public function link($offset = 0, $full = false)
{
$week = $this->getWeek($offset);
return Horde::url($this->_controller, $full)
->add('date', $week->dateString());
}
- function getName()
+ public function getName()
{
return 'Week';
}
* @author Chuck Hagenbuch <chuck@horde.org>
* @package Kronolith
*/
-class Kronolith_View_WorkWeek extends Kronolith_View_Week {
+class Kronolith_View_WorkWeek extends Kronolith_View_Week
+{
+ public $startDay = Horde_Date::DATE_MONDAY;
+ public $endDay = Horde_Date::DATE_FRIDAY;
+ protected $_controller = 'workweek.php';
- var $startDay = Horde_Date::DATE_MONDAY;
- var $endDay = Horde_Date::DATE_FRIDAY;
- var $_controller = 'workweek.php';
-
- function getName()
+ public function getName()
{
return 'WorkWeek';
}
* @author Jan Schneider <jan@horde.org>
* @package Kronolith
*/
-class Kronolith_View_Year {
-
- var $year;
- var $_events = array();
-
- function Kronolith_View_Year($date)
+class Kronolith_View_Year
+{
+ public $year;
+ protected $_events = array();
+
+ /**
+ *
+ * @param Horde_Date $date
+ *
+ * @return Kronolith_View_Year
+ */
+ public function __construct(Horde_Date $date)
{
$this->year = $date->year;
$startDate = new Horde_Date(array('year' => $this->year,
}
}
- function html()
+ public function html()
{
global $prefs;
echo $html . '</tr></table>';
}
- function link($offset = 0, $full = false)
+ public function link($offset = 0, $full = false)
{
return Horde::url('year.php', $full)
->add('date', ($this->year + $offset) . '0101');
}
- function getName()
+ public function getName()
{
return 'Year';
}
<tr>
<?php if ($first_row): ?>
<td class="nowrap rightAlignt"<?php echo $rowspan ?>><strong><?php echo $newEventUrl ?></strong></td>
- <td<?php echo $rowspan ?> style="height:<?php echo round(20 / $this->_slotsPerHour) ?>px"> </td>
+ <td<?php echo $rowspan ?> style="height:<?php echo round(20 / $this->slotsPerHour) ?>px"> </td>
<td<?php echo $rowspan ?>> </td>
<?php endif; ?>
<?php echo $row ?>
<th class="control" width="90%"> </th>
<?php endif; ?>
<?php $i = 0; foreach ($this->_currentCalendars as $cid => $cal): ?>
- <th class="control" width="<?php echo round(90 / count($this->_currentCalendars)) ?>%" colspan="<?php echo $this->_span[$cid] ?>">
+ <th class="control" width="<?php echo round(90 / count($this->_currentCalendars)) ?>%" colspan="<?php echo $this->span[$cid] ?>">
<strong><?php echo htmlspecialchars($cal->get('name')) ?></strong>
</th>
<?php endforeach; ?>
<?php $colwidth = round((100 - count($this->days) - 1) / count($this->days)); foreach ($this->days as $day): ?>
<th class="control" width="1%"> </th>
- <th class="nowrap <?php echo ($day->isToday() ? 'selected-control' : 'control') ?>" width="<?php echo $colwidth ?>%" colspan="<?php echo $day->_totalspan ?>">
+ <th class="nowrap <?php echo ($day->isToday() ? 'selected-control' : 'control') ?>" width="<?php echo $colwidth ?>%" colspan="<?php echo $day->totalspan ?>">
<?php
if (Kronolith::getDefaultCalendar(Horde_Perms::EDIT) &&
($GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_events') === true ||
<th width="<?php echo $colwidth ?>%" class="<?php echo ($day->isToday() ? 'selected-control' : 'control') ?>"> </th>
<?php endif; ?>
<?php foreach ($this->_currentCalendars as $cid => $cal): ?>
- <th class="<?php echo ($day->isToday() ? 'selected-control' : 'control') ?>" width="<?php echo floor((90 / count($this->days)) / count($this->_currentCalendars)) ?>%" colspan="<?php echo $day->_span[$cid] ?>">
+ <th class="<?php echo ($day->isToday() ? 'selected-control' : 'control') ?>" width="<?php echo floor((90 / count($this->days)) / count($this->_currentCalendars)) ?>%" colspan="<?php echo $day->span[$cid] ?>">
<strong><?php echo htmlspecialchars($cal->get('name')) ?></strong>
</th>
<?php endforeach; endforeach; ?>