1: <?php
2: /**
3: * Kronolith_Calendar_Holiday defines an API for single holiday calendars.
4: *
5: * Copyright 2010-2012 Horde LLC (http://www.horde.org/)
6: *
7: * See the enclosed file COPYING for license information (GPL). If you
8: * did not receive this file, see http://www.horde.org/licenses/gpl.
9: *
10: * @author Jan Schneider <jan@horde.org>
11: * @package Kronolith
12: */
13: class Kronolith_Calendar_Holiday extends Kronolith_Calendar
14: {
15: /**
16: * The Date_Holidays driver information.
17: *
18: * @var array
19: */
20: protected $_driver;
21:
22: /**
23: * Constructor.
24: *
25: * @param array $params A hash with any parameters that this calendar
26: * might need.
27: * Required parameters:
28: * - share: The share of this calendar.
29: */
30: public function __construct($params = array())
31: {
32: if (!isset($params['driver'])) {
33: throw new BadMethodCallException('driver parameter is missing');
34: }
35: parent::__construct($params);
36: }
37:
38: /**
39: * Returns the name of this calendar.
40: *
41: * @return string This calendar's name.
42: */
43: public function name()
44: {
45: return $this->_driver['title'];
46: }
47:
48: /**
49: * Whether this calendar is supposed to be displayed in lists.
50: *
51: * @return boolean True if this calendar should be displayed.
52: */
53: public function display()
54: {
55: return in_array($this->_driver['id'], $GLOBALS['display_holidays']);
56: }
57:
58: /**
59: * Returns a hash representing this calendar.
60: *
61: * @return array A simple hash.
62: */
63: public function toHash()
64: {
65: $hash = parent::toHash();
66: $hash['show'] = in_array($this->_driver['id'], $GLOBALS['display_holidays']);
67: return $hash;
68: }
69: }
70: