foregroundColor() public static method

Returns the foreground color for a calendar or a background color.
public static foregroundColor ( array | Horde_Share_Object | string $calendar ) : string
$calendar array | Horde_Share_Object | string A color string, a calendar share or a hash from a remote calender definition.
return string A HTML color code.
Esempio n. 1
0
 /**
  * Returns a hash representing this calendar.
  *
  * @return array  A simple hash.
  */
 public function toHash()
 {
     global $calendar_manager, $conf, $injector, $registry;
     $owner = $registry->getAuth() && $this->_share->get('owner') == $registry->getAuth();
     $hash = parent::toHash();
     $hash['name'] = Kronolith::getLabel($this->_share);
     $hash['desc'] = (string) $this->_share->get('desc');
     $hash['owner'] = $owner;
     $hash['users'] = Kronolith::listShareUsers($this->_share);
     $hash['fg'] = Kronolith::foregroundColor($this->_share);
     $hash['bg'] = Kronolith::backgroundColor($this->_share);
     $hash['show'] = in_array('tasks/' . $this->_share->getName(), $calendar_manager->get(Kronolith::DISPLAY_EXTERNAL_CALENDARS));
     $hash['edit'] = $this->_share->hasPermission($registry->getAuth(), Horde_Perms::EDIT);
     $hash['caldav'] = $this->caldavUrl();
     $hash['sub'] = Horde::url($registry->get('webroot', 'horde') . ($conf['urls']['pretty'] == 'rewrite' ? '/rpc/nag/' : '/rpc.php/nag/'), true, -1) . ($this->_share->get('owner') ? $registry->convertUsername($this->_share->get('owner'), false) : '-system-') . '/' . $this->_share->getName() . '.ics';
     if ($owner) {
         $hash['perms'] = Kronolith::permissionToJson($this->_share->getPermission(), is_null($this->_share->get('owner')));
     }
     return $hash;
 }
Esempio n. 2
0
 /**
  * Returns the colors of the current calendar.
  *
  * @return array  The calendar background and foreground color.
  */
 public function colors()
 {
     $color = $this->backgroundColor();
     return array($color, Kronolith::foregroundColor($color));
 }
Esempio n. 3
0
        $owner = $GLOBALS['registry']->getAuth() && $calendar->owner() == $GLOBALS['registry']->getAuth();
        if ($my && $owner || !$my && !$owner) {
            $code['conf']['calendars']['internal'][$id] = array('name' => ($owner || !$calendar->owner() ? '' : '[' . $GLOBALS['registry']->convertUsername($calendar->owner(), false) . '] ') . $calendar->name(), 'desc' => $calendar->description(), 'owner' => $owner, 'fg' => $calendar->foreground(), 'bg' => $calendar->background(), 'show' => in_array($id, $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_CALENDARS)), 'edit' => $calendar->hasPermission(Horde_Perms::EDIT), 'feed' => (string) Kronolith::feedUrl($id), 'embed' => Kronolith::embedCode($id));
            if ($owner) {
                $code['conf']['calendars']['internal'][$id]['perms'] = Kronolith::permissionToJson($calendar->share()->getPermission());
            }
        }
    }
    // Tasklists
    if (!$has_tasks) {
        continue;
    }
    foreach ($registry->tasks->listTasklists($my, Horde_Perms::SHOW) as $id => $tasklist) {
        $owner = $GLOBALS['registry']->getAuth() && $tasklist->get('owner') == $GLOBALS['registry']->getAuth();
        if ($my && $owner || !$my && !$owner) {
            $code['conf']['calendars']['tasklists']['tasks/' . $id] = array('name' => Kronolith::getLabel($tasklist), 'desc' => $tasklist->get('desc'), 'owner' => $owner, 'fg' => Kronolith::foregroundColor($tasklist), 'bg' => Kronolith::backgroundColor($tasklist), 'show' => in_array('tasks/' . $id, $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_EXTERNAL_CALENDARS)), 'edit' => $tasklist->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT));
            if ($owner) {
                $code['conf']['calendars']['tasklists']['tasks/' . $id]['perms'] = Kronolith::permissionToJson($tasklist->getPermission());
            }
        }
    }
}
// Timeobjects
foreach ($GLOBALS['calendar_manager']->get(Kronolith::ALL_EXTERNAL_CALENDARS) as $id => $calendar) {
    if ($calendar->api() == 'tasks') {
        continue;
    }
    if (!$calendar->display()) {
        continue;
    }
    $code['conf']['calendars']['external'][$id] = array('name' => $calendar->name(), 'fg' => $calendar->foreground(), 'bg' => $calendar->background(), 'api' => $registry->get('name', $registry->hasInterface($calendar->api())), 'show' => in_array($id, $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_EXTERNAL_CALENDARS)));
Esempio n. 4
0
 /**
  * Imports a backend specific event object.
  *
  * @param mixed $event  Backend specific event object that this object
  *                      will represent.
  */
 public function fromDriver($event)
 {
     $this->id = '_' . $this->_api . $event['id'];
     $this->icon = !empty($event['icon']) ? $event['icon'] : null;
     $this->title = $event['title'];
     $this->description = isset($event['description']) ? $event['description'] : '';
     if (isset($event['location'])) {
         $this->location = $event['location'];
     }
     try {
         $this->start = new Horde_Date($event['start']);
         $this->end = new Horde_Date($event['end']);
     } catch (Horde_Date_Exception $e) {
         throw new Kronolith_Exception($e);
     }
     if (isset($event['status'])) {
         switch ($event['status']) {
             case 'confirmed':
                 $this->status = Kronolith::STATUS_CONFIRMED;
                 break;
             case 'tentative':
                 $this->status = Kronolith::STATUS_TENTATIVE;
                 break;
             default:
                 $this->status = Kronolith::STATUS_FREE;
         }
     } else {
         $this->status = Kronolith::STATUS_FREE;
     }
     if (isset($event['private'])) {
         $this->private = $event['private'];
     }
     $this->_params = $event['params'];
     $this->_link = !empty($event['link']) ? $event['link'] : null;
     $this->url = !empty($event['url']) ? (string) $event['url'] : null;
     $this->_editLink = !empty($event['edit_link']) ? $event['edit_link'] : null;
     $this->_deleteLink = !empty($event['delete_link']) ? $event['delete_link'] : null;
     $this->_ajaxLink = !empty($event['ajax_link']) ? $event['ajax_link'] : null;
     $this->_backgroundColor = Kronolith::backgroundColor($event);
     $this->_foregroundColor = Kronolith::foregroundColor($event);
     if (isset($event['recurrence'])) {
         $recurrence = new Horde_Date_Recurrence($this->start);
         $recurrence->setRecurType($event['recurrence']['type']);
         if (isset($event['recurrence']['end'])) {
             $recurrence->setRecurEnd(new Horde_Date($event['recurrence']['end']));
         }
         if (isset($event['recurrence']['interval'])) {
             $recurrence->setRecurInterval($event['recurrence']['interval']);
         }
         if (isset($event['recurrence']['count'])) {
             $recurrence->setRecurCount($event['recurrence']['count']);
         }
         if (isset($event['recurrence']['days'])) {
             $recurrence->setRecurOnDay($event['recurrence']['days']);
         }
         if (isset($event['recurrence']['exceptions'])) {
             foreach ($event['recurrence']['exceptions'] as $exception) {
                 $recurrence->addException(substr($exception, 0, 4), substr($exception, 4, 2), substr($exception, 6, 2));
             }
         }
         if (isset($event['recurrence']['completions'])) {
             foreach ($event['recurrence']['completions'] as $completion) {
                 $recurrence->addCompletion(substr($completion, 0, 4), substr($completion, 4, 2), substr($completion, 6, 2));
             }
         }
         $this->recurrence = $recurrence;
     }
     if (isset($event['owner'])) {
         $this->_owner = $event['owner'];
     }
     if (isset($event['permissions'])) {
         $this->_permissions = $event['permissions'];
     }
     if (isset($event['variable_length'])) {
         $this->_variableLength = $event['variable_length'];
     }
     $this->initialized = true;
     $this->stored = true;
 }