aboutsummaryrefslogtreecommitdiff
path: root/lib/calendar/CalendarWeekView.class.php
blob: c1e0f24718ff2d9fb78b479fd045aa44fb3b2028 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
# Lifter010: TODO

/**
 * CalendarWeekView.class.php - a specialized calendar view for displaying weeks
 *
 * This class takes and checks all necessary parameters to display a calendar/schedule/time-table.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * @author      Till Glöggler <tgloeggl@uos.de> & Rasmus Fuhse <fuhse@data-quest.de>
 * @license     http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
 * @category    Stud.IP
 */

/**
 * Kind of bean class for the calendar view.
 *
 * @since      2.0
 *
 * @deprecated since Stud.IP 5.5
 */

class CalendarWeekView extends CalendarView
{
    protected $days = [1,2,3,4,5];
    protected $context;


    /**
     * You need to pass an instance of this class to the template. The constructor
     * expects an array of entries of the following type:
     *  array(
     *   $day_number => array(array (
     *    'color' => the color in hex (css-like, without the #)
     *    'start' => the (start hour * 100) + (start minute)
     *    'end'   => the (end hour * 100) + (end minute)
     *    //'day'   => day of week (0 = Sunday, ... , 6 = Saturday)
     *    'title' => the entry`s title
     *    'content' => whatever shall be the content of the entry as a string
     *   ) ...) ...
     *  )
     *
     * @param  mixed  $entries     an array of entries (see above)
     * @param  string $controller  the name of the controller. Used to create links.
     */
    public function __construct($entries, $controller)
    {
        parent::__construct($entries);
        $this->context = $controller;
    }

    /**
     * Call this function th enable/disable the grouping of entries with the same start and end.
     *
     * @param  bool  $group  optional, defaults to true
     */
    public function groupEntries($grouped = true)
    {
        $this->grouped = $grouped;
        foreach($this->entries as $entry_column) {
            $entry_column->groupEntries();
        }
    }

    /* * * * * * * * * * * * * * *
     * * *   G E T T E R S   * * *
     * * * * * * * * * * * * * * */

    /**
     * @return mixed the context
     */
    public function getContext()
    {
        return $this->context;
    }

    /**
     * @return mixed the days
     */
    public function getDays()
    {
        return $this->days;
    }

    /**
     * returns the previously set javasscript insert-function only
     * if read_only is not set.
     *
     * @return  string  name of js-function or anonymous js-function
     */
    public function getInsertFunction() {
        if (!$this->read_only) {
            return parent::getInsertFunction();
        }

        return false;
    }

    /**
     * returns all columns of the calendar-view nad removes the url if
     * read_only is set
     *
     * @return  array  of CalendarColumn
     */
    public function getColumns() {
        // remove links and urls if calendar-view is read-only
        if ($this->read_only) {
            foreach ($this->entries as $column) {
                $column->setURL(false);
                foreach ($column->entries as $key => $entry) {
                    unset($column->entries[$key]['url']);
                    unset($column->entries[$key]['onClick']);
                    unset($column->entries[$key]['icons']);
                }
            }
        }

        return parent::getColumns();
    }
}