}
$vars->set('name', $calendar->get('name'));
+$vars->set('color', $calendar->get('color'));
$vars->set('description', $calendar->get('desc'));
$tags = new Kronolith_Tagger();
$vars->set('tags', implode(',', array_values($tags->getTags($calendar->getName(), 'calendar'))));
v3.0-git
--------
+[jan] Set colors per calendar (Request #7480).
[jan] Add individual notification methods for single events (Alfonso Marín
Marín <almarin@um.es>).
[jan] Add Ajax interface.
var $_calendar;
/**
+ * The HTML background color to be used for this event.
+ *
+ * @var string
+ */
+ var $_backgroundColor;
+
+ /**
+ * The HTML foreground color to be used for this event.
+ *
+ * @var string
+ */
+ var $_foregroundColor;
+
+ /**
* The VarRenderer class to use for printing select elements.
*
* @var Horde_UI_VarRenderer
$this->alarm = $alarm;
$this->_calendar = $driver->getCalendar();
+ if (!empty($this->_calendar)) {
+ $share = $GLOBALS['all_calendars'][$this->_calendar];
+ $this->_backgroundColor = $share->get('color');
+ if (empty($this->_backgroundColor)) {
+ $this->_backgroundColor = '#dddddd';
+ }
+ $this->_foregroundColor = Horde_Image::brightness($this->_backgroundColor) < 128 ? '#f6f6f6' : '#000';
+ }
+
if ($eventObject !== null) {
$this->fromDriver($eventObject);
}
$link = Horde::linkTooltip($this->getViewUrl(array('datetime' => $datetime->strftime('%Y%m%d%H%M%S'), 'url' => $from_url), $full),
$event_title,
$this->getStatusClass(), '', '',
- $this->getTooltip());
+ $this->getTooltip(),
+ '',
+ array('style' => $this->getCSSColors(false)));
}
$link .= @htmlspecialchars($event_title, ENT_QUOTES, NLS::getCharset());
}
if ($icons && $prefs->getValue('show_icons')) {
- $icon_color = isset($GLOBALS['cManager_fgColors'][$this->category]) ?
- ($GLOBALS['cManager_fgColors'][$this->category] == '#000' ? '000' : 'fff') :
- ($GLOBALS['cManager_fgColors']['_default_'] == '#000' ? '000' : 'fff');
-
+ $icon_color = $this->_foregroundColor == '#000' ? '000' : 'fff';
$status = '';
if ($this->alarm) {
if ($this->alarm % 10080 == 0) {
}
/**
+ * Returns the CSS color definition for this event.
+ *
+ * @param boolean $with_attribute Whether to wrap the colors inside a
+ * "style" attribute.
+ *
+ * @return string A CSS string with color definitions.
+ */
+ function getCSSColors($with_attribute = true)
+ {
+ $css = 'background-color:' . $this->_backgroundColor . ';color:' . $this->_foregroundColor;
+ if ($with_attribute) {
+ $css = ' style="' . $css . '"';
+ }
+ return $css;
+ }
+
+ /**
* @return string A tooltip for quick descriptions of this event.
*/
function getTooltip()
parent::Horde_Form($vars, _("Create Calendar"));
$this->addVariable(_("Name"), 'name', 'text', true);
+ $this->addVariable(_("Color"), 'color', 'colorpicker', false);
$this->addVariable(_("Description"), 'description', 'longtext', false, false, null, array(4, 60));
$this->addVariable(_("Tags"), 'tags', 'text', false);
$this->setButtons(array(_("Create")));
return $calendar;
}
$calendar->set('name', $this->_vars->get('name'));
+ $calendar->set('color', $this->_vars->get('color'));
$calendar->set('desc', $this->_vars->get('description'));
$tagger = new Kronolith_Tagger();
$tagger->tag($calendar->getName(), $this->_vars->get('tags'), 'calendar');
$this->addHidden('', 'c', 'text', true);
$this->addVariable(_("Name"), 'name', 'text', true);
+ $this->addVariable(_("Color"), 'color', 'colorpicker', false);
$this->addVariable(_("Description"), 'description', 'longtext', false, false, null, array(4, 60));
$this->addVariable(_("Tags"), 'tags', 'text', false);
$this->setButtons(array(_("Save")));
$original_name = $this->_calendar->get('name');
$new_name = $this->_vars->get('name');
$this->_calendar->set('name', $new_name);
+ $this->_calendar->set('color', $this->_vars->get('color'));
$this->_calendar->set('desc', $this->_vars->get('description'));
if ($original_name != $new_name) {
$result = $GLOBALS['kronolith_driver']->rename($original_name, $new_name);
}
/**
+ * Returns the CSS color definition for a calendar.
+ *
+ * @param array|Horde_Share_Object $calendar A calendar share or a hash
+ * from a remote calender
+ * definition.
+ * @param boolean $with_attribute Whether to wrap the colors
+ * inside a "style" attribute.
+ *
+ * @return string A CSS string with color definitions.
+ */
+ function getCSSColors($calendar, $with_attribute = true)
+ {
+ $css = 'background-color:' . Kronolith::backgroundColor($calendar) . ';color:' . Kronolith::foregroundColor($calendar);
+ if ($with_attribute) {
+ $css = ' style="' . $css . '"';
+ }
+ return $css;
+ }
+
+ /**
* Builds Kronolith's list of menu items.
*/
function getMenu($returnType = 'object')
$eventCategories[$event->getCategory()] = true;
}
- $row .= '<td class="day-eventbox category' . hash('md5', $event->getCategory()) . '" '
+ $row .= '<td class="day-eventbox"'
+ . $event->getCSSColors()
. 'width="' . round(90 / count($this->_currentCalendars)) . '%" '
. 'valign="top" colspan="' . $this->_span[$cid] . '">'
. $event->getLink($this, true, $this->link(0, true));
}
}
- $row .= '<td class="day-eventbox category' . hash('md5', $event->getCategory()) . '" '
+ $row .= '<td class="day-eventbox"'
+ . $event->getCSSColors()
. '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 ($event->hasPermission(PERMS_READ)) {
$eventCategories[$event->getCategory()] = true;
}
- $html .= '<div class="month-eventbox category' . hash('md5', $event->getCategory()) . '">'
+ $html .= '<div class="month-eventbox"' . $event->getCSSColors() . '>'
. $event->getLink($date, true, $this->link(0, true));
if ($showTime) {
$html .= '<div class="event-time">' . htmlspecialchars($event->getTimeRange()) . '</div>';
$eventCategories[$event->getCategory()] = true;
}
- $row .= '<td class="week-eventbox category' . hash('md5', $event->getCategory()) . '" '
+ $row .= '<td class="week-eventbox"'
+ . $event->getCSSColors()
. 'width="' . round(99 / count($this->days[$j]->_currentCalendars)) . '%" '
. 'valign="top">'
. $event->getLink($this->days[$j], true, $this->link(0, true));
}
}
- $row .= '<td class="week-eventbox category' . hash('md5', $event->getCategory()) . '" '
+ $row .= '<td class="week-eventbox"'
+ . $event->getCSSColors()
. 'valign="top" '
. 'width="' . floor(((90 / count($this->days)) / count($this->_currentCalendars)) * ($span / $this->days[$j]->_span[$cid])) . '%" '
. 'colspan="' . $span . '" rowspan="' . $event->rowspan . '">'
<h4><?php echo _("My Calendars:") ?></h4>
<ul id="mycalendars">
<?php foreach ($my_calendars as $id => $cal): ?>
- <li><label><input type="checkbox" class="checkbox" name="display_cal[]" value="<?php echo htmlspecialchars($id) ?>"<?php echo (in_array($id, $display_calendars) ? ' checked="checked"' : '') . ' /> ' . htmlspecialchars($cal->get('name')) ?></label> <?php echo $info_img ?>
+ <li<?php echo Kronolith::getCSSColors($cal) ?>><label><input type="checkbox" class="checkbox" name="display_cal[]" value="<?php echo htmlspecialchars($id) ?>"<?php echo (in_array($id, $display_calendars) ? ' checked="checked"' : '') . ' /> ' . htmlspecialchars($cal->get('name')) ?></label> <?php echo $info_img ?>
<div class="panel-tags">
<?php $tags = $tagger->getTags($id, 'calendar'); ?>
<span style="cursor:pointer;" id="tag-show_<?php echo $id?>" onclick="toggleTags('<?php echo $id?>');" title="<?php echo _("Add new tags")?>">+</span><span id="tag-hide_<?php echo $id?>" style="display:none;cursor:pointer;" onclick="toggleTags('<?php echo $id?>');">-</span>
<h4><?php echo _("Shared Calendars:") ?></h4>
<ul id="sharedcalendars">
<?php foreach ($shared_calendars as $id => $cal): ?>
- <li><label><input type="checkbox" class="checkbox" name="display_cal[]" value="<?php echo htmlspecialchars($id) ?>"<?php echo (in_array($id, $display_calendars) ? ' checked="checked"' : '') . ' /> [' . htmlspecialchars(Auth::removeHook($cal->get('owner'))) . '] ' . htmlspecialchars($cal->get('name')) ?></label> <?php echo $info_img ?></li>
+ <li<?php echo Kronolith::getCSSColors($cal) ?>><label><input type="checkbox" class="checkbox" name="display_cal[]" value="<?php echo htmlspecialchars($id) ?>"<?php echo (in_array($id, $display_calendars) ? ' checked="checked"' : '') . ' /> [' . htmlspecialchars(Auth::removeHook($cal->get('owner'))) . '] ' . htmlspecialchars($cal->get('name')) ?></label> <?php echo $info_img ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<h4><?php echo _("Remote Calendars:") ?></h4>
<ul id="remotecalendars">
<?php foreach ($remote_calendars as $id => $cal): ?>
- <li><label><input type="checkbox" class="checkbox" name="display_cal[]" value="remote_<?php echo htmlspecialchars($cal['url']) ?>"<?php echo (in_array($cal['url'], $display_remote_calendars) ? ' checked="checked"' : '') . ' /> ' . htmlspecialchars($cal['name']) ?></label> <?php echo $info_img ?></li>
+ <li<?php echo Kronolith::getCSSColors($cal) ?>><label><input type="checkbox" class="checkbox" name="display_cal[]" value="remote_<?php echo htmlspecialchars($cal['url']) ?>"<?php echo (in_array($cal['url'], $display_remote_calendars) ? ' checked="checked"' : '') . ' /> ' . htmlspecialchars($cal['name']) ?></label> <?php echo $info_img ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>