Proyectos de Subversion Moodle

Rev

Rev 11 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 11 Rev 1441
Línea 1... Línea 1...
1
<?php
1
<?php
2
 
-
 
3
// This file is part of Moodle - http://moodle.org/
2
// This file is part of Moodle - http://moodle.org/
4
//
3
//
5
// Moodle is free software: you can redistribute it and/or modify
4
// Moodle is free software: you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
5
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation, either version 3 of the License, or
6
// the Free Software Foundation, either version 3 of the License, or
Línea 49... Línea 48...
49
    public function complete_layout() {
48
    public function complete_layout() {
50
        return html_writer::end_tag('div');
49
        return html_writer::end_tag('div');
51
    }
50
    }
Línea 52... Línea 51...
52
 
51
 
53
    /**
-
 
54
     * @deprecated since 4.0 MDL-72810.
-
 
55
     */
-
 
56
    public function fake_block_threemonths() {
-
 
57
        throw new coding_exception(__FUNCTION__ . '() has been removed.');
-
 
58
    }
-
 
59
 
-
 
60
    /**
52
    /**
61
     * Adds a pretent calendar block
53
     * Adds a pretent calendar block
62
     *
54
     *
63
     * @param block_contents $bc
55
     * @param block_contents $bc
64
     * @param mixed $pos BLOCK_POS_RIGHT | BLOCK_POS_LEFT
56
     * @param mixed $pos BLOCK_POS_RIGHT | BLOCK_POS_LEFT
Línea 83... Línea 75...
83
        ];
75
        ];
84
        return $this->render_from_template('core_calendar/add_event_button', $data);
76
        return $this->render_from_template('core_calendar/add_event_button', $data);
85
    }
77
    }
Línea 86... Línea 78...
86
 
78
 
87
    /**
-
 
88
     * Displays an event
-
 
89
     *
79
    /**
90
     * @deprecated since 3.9
-
 
91
     *
-
 
92
     * @param calendar_event $event
-
 
93
     * @param bool $showactions
-
 
94
     * @return string
80
     * @deprecated 3.9
95
     */
-
 
96
    public function event(calendar_event $event, $showactions=true) {
-
 
97
        global $CFG;
-
 
98
        debugging('This function is no longer used', DEBUG_DEVELOPER);
-
 
99
 
-
 
100
        $event = calendar_add_event_metadata($event);
81
     */
101
        $context = $event->context;
-
 
102
        $output = '';
-
 
103
 
-
 
104
        $output .= $this->output->box_start('card-header clearfix');
-
 
105
        if (calendar_edit_event_allowed($event) && $showactions) {
-
 
106
            if (calendar_delete_event_allowed($event)) {
-
 
107
                $editlink = new moodle_url(CALENDAR_URL.'event.php', array('action' => 'edit', 'id' => $event->id));
-
 
108
                $deletelink = new moodle_url(CALENDAR_URL.'delete.php', array('id' => $event->id));
-
 
109
                if (!empty($event->calendarcourseid)) {
-
 
110
                    $editlink->param('course', $event->calendarcourseid);
-
 
111
                    $deletelink->param('course', $event->calendarcourseid);
-
 
112
                }
-
 
113
            } else {
-
 
114
                $params = array('update' => $event->cmid, 'return' => true, 'sesskey' => sesskey());
-
 
115
                $editlink = new moodle_url('/course/mod.php', $params);
-
 
116
                $deletelink = null;
-
 
117
            }
-
 
118
 
-
 
119
            $commands  = html_writer::start_tag('div', array('class' => 'commands float-sm-right'));
-
 
120
            $commands .= html_writer::start_tag('a', array('href' => $editlink));
-
 
121
            $str = get_string('tt_editevent', 'calendar');
-
 
122
            $commands .= $this->output->pix_icon('t/edit', $str);
-
 
123
            $commands .= html_writer::end_tag('a');
-
 
124
            if ($deletelink != null) {
-
 
125
                $commands .= html_writer::start_tag('a', array('href' => $deletelink));
-
 
126
                $str = get_string('tt_deleteevent', 'calendar');
-
 
127
                $commands .= $this->output->pix_icon('t/delete', $str);
-
 
128
                $commands .= html_writer::end_tag('a');
-
 
129
            }
-
 
130
            $commands .= html_writer::end_tag('div');
-
 
131
            $output .= $commands;
-
 
132
        }
82
    #[\core\attribute\deprecated(
133
        if (!empty($event->icon)) {
-
 
134
            $output .= $event->icon;
-
 
135
        } else {
-
 
136
            $output .= $this->output->spacer(array('height' => 16, 'width' => 16));
-
 
137
        }
-
 
138
 
-
 
139
        if (!empty($event->referer)) {
-
 
140
            $output .= $this->output->heading($event->referer, 3, array('class' => 'referer'));
-
 
141
        } else {
-
 
142
            $output .= $this->output->heading(
-
 
143
                format_string($event->name, false, array('context' => $context)),
83
        replacement: 'event no longer used',
144
                3,
-
 
145
                array('class' => 'name d-inline-block')
84
        since: '3.9',
146
            );
-
 
147
        }
-
 
148
        // Show subscription source if needed.
-
 
149
        if (!empty($event->subscription) && $CFG->calendar_showicalsource) {
-
 
150
            if (!empty($event->subscription->url)) {
-
 
151
                $source = html_writer::link($event->subscription->url,
-
 
152
                        get_string('subscriptionsource', 'calendar', $event->subscription->name));
85
        mdl: 'MDL-58866',
153
            } else {
-
 
154
                // File based ical.
-
 
155
                $source = get_string('subscriptionsource', 'calendar', $event->subscription->name);
-
 
156
            }
-
 
157
            $output .= html_writer::tag('div', $source, array('class' => 'subscription'));
-
 
158
        }
-
 
159
        if (!empty($event->courselink)) {
-
 
160
            $output .= html_writer::tag('div', $event->courselink);
86
        final: true,
161
        }
87
    )]
162
        if (!empty($event->time)) {
-
 
163
            $output .= html_writer::tag('span', $event->time, array('class' => 'date float-sm-right mr-1'));
-
 
164
        } else {
-
 
165
            $attrs = array('class' => 'date float-sm-right mr-1');
-
 
166
            $output .= html_writer::tag('span', calendar_time_representation($event->timestart), $attrs);
-
 
167
        }
-
 
168
 
-
 
169
        if (!empty($event->actionurl)) {
-
 
170
            $actionlink = html_writer::link(new moodle_url($event->actionurl), $event->actionname);
-
 
171
            $output .= html_writer::tag('div', $actionlink, ['class' => 'action']);
-
 
172
        }
-
 
173
 
-
 
174
        $output .= $this->output->box_end();
-
 
175
        $eventdetailshtml = '';
-
 
176
        $eventdetailsclasses = '';
-
 
177
 
-
 
178
        $eventdetailshtml .= format_text($event->description, $event->format, array('context' => $context));
88
    public function event() {
179
        $eventdetailsclasses .= 'description card-block';
-
 
180
        if (isset($event->cssclass)) {
-
 
181
            $eventdetailsclasses .= ' '.$event->cssclass;
-
 
182
        }
-
 
183
 
-
 
184
        if (!empty($eventdetailshtml)) {
-
 
185
            $output .= html_writer::tag('div', $eventdetailshtml, array('class' => $eventdetailsclasses));
-
 
186
        }
-
 
187
 
-
 
188
        $eventhtml = html_writer::tag('div', $output, array('class' => 'card'));
-
 
189
        return html_writer::tag('div', $eventhtml, array('class' => 'event', 'id' => 'event_' . $event->id));
89
        \core\deprecation::emit_deprecation(__FUNCTION__);
Línea 190... Línea 90...
190
    }
90
    }
191
 
91
 
192
    /**
92
    /**
Línea 196... Línea 96...
196
     * @param string $label The label to use for the course select.
96
     * @param string $label The label to use for the course select.
197
     * @param int $courseid The id of the course to be selected.
97
     * @param int $courseid The id of the course to be selected.
198
     * @param int|null $calendarinstanceid The instance ID of the calendar we're generating this course filter for.
98
     * @param int|null $calendarinstanceid The instance ID of the calendar we're generating this course filter for.
199
     * @return string
99
     * @return string
200
     */
100
     */
201
    public function course_filter_selector(moodle_url $returnurl, $label = null, $courseid = null, int $calendarinstanceid = null) {
101
    public function course_filter_selector(moodle_url $returnurl, $label = null, $courseid = null, ?int $calendarinstanceid = null) {
202
        global $CFG, $DB;
102
        global $CFG, $DB;
Línea 203... Línea 103...
203
 
103
 
204
        if (!isloggedin() or isguestuser()) {
104
        if (!isloggedin() or isguestuser()) {
205
            return '';
105
            return '';
Línea 206... Línea 106...
206
        }
106
        }
207
 
107
 
Línea 208... Línea 108...
208
        $contextrecords = [];
108
        $contextrecords = [];
209
        $courses = calendar_get_default_courses($courseid, 'id, shortname');
109
        $courses = calendar_get_default_courses($courseid, 'id, shortname, fullname');
210
 
110
 
211
        if (!empty($courses) && count($courses) > CONTEXT_CACHE_MAX_SIZE) {
111
        if (!empty($courses) && count($courses) > CONTEXT_CACHE_MAX_SIZE) {
Línea 232... Línea 132...
232
        $courseoptions[SITEID] = get_string('fulllistofcourses');
132
        $courseoptions[SITEID] = get_string('fulllistofcourses');
233
        foreach ($courses as $course) {
133
        foreach ($courses as $course) {
234
            if (isset($contextrecords[$course->id])) {
134
            if (isset($contextrecords[$course->id])) {
235
                context_helper::preload_from_record($contextrecords[$course->id]);
135
                context_helper::preload_from_record($contextrecords[$course->id]);
236
            }
136
            }
-
 
137
 
-
 
138
            // Limit the displayed course name to prevent the dropdown from getting too wide.
-
 
139
            $coursename = format_string(get_course_display_name_for_list($course), true, [
237
            $coursecontext = context_course::instance($course->id);
140
                'context' => \core\context\course::instance($course->id),
-
 
141
            ]);
238
            $courseoptions[$course->id] = format_string($course->shortname, true, array('context' => $coursecontext));
142
            $courseoptions[$course->id] = shorten_text($coursename, 50, true);
239
        }
143
        }
Línea 240... Línea 144...
240
 
144
 
241
        if ($courseid) {
145
        if ($courseid) {
242
            $selected = $courseid;
146
            $selected = $courseid;
Línea 249... Línea 153...
249
        $courseurl->remove_params('course');
153
        $courseurl->remove_params('course');
Línea 250... Línea 154...
250
 
154
 
251
        $labelattributes = [];
155
        $labelattributes = [];
252
        if (empty($label)) {
156
        if (empty($label)) {
253
            $label = get_string('listofcourses');
157
            $label = get_string('listofcourses');
254
            $labelattributes['class'] = 'sr-only';
158
            $labelattributes['class'] = 'visually-hidden';
Línea 255... Línea 159...
255
        }
159
        }
256
 
160
 
257
        $filterid = 'calendar-course-filter';
161
        $filterid = 'calendar-course-filter';
258
        if ($calendarinstanceid) {
162
        if ($calendarinstanceid) {
259
            $filterid .= "-$calendarinstanceid";
163
            $filterid .= "-$calendarinstanceid";
260
        }
164
        }
261
        $select = html_writer::label($label, $filterid, false, $labelattributes);
165
        $select = html_writer::label($label, $filterid, false, $labelattributes);
Línea 262... Línea 166...
262
        $select .= html_writer::select($courseoptions, 'course', $selected, false,
166
        $select .= html_writer::select($courseoptions, 'course', $selected, false,
263
                ['class' => 'cal_courses_flt ml-1 mr-auto', 'id' => $filterid]);
167
                ['class' => 'cal_courses_flt ms-1 me-auto me-2 mb-2', 'id' => $filterid]);
Línea 264... Línea 168...
264
 
168
 
Línea 271... Línea 175...
271
     * @return string
175
     * @return string
272
     */
176
     */
273
    public function render_subscriptions_header(): string {
177
    public function render_subscriptions_header(): string {
274
        $importcalendarbutton = new single_button(new moodle_url('/calendar/import.php', calendar_get_export_import_link_params()),
178
        $importcalendarbutton = new single_button(new moodle_url('/calendar/import.php', calendar_get_export_import_link_params()),
275
                get_string('importcalendar', 'calendar'), 'get', single_button::BUTTON_PRIMARY);
179
                get_string('importcalendar', 'calendar'), 'get', single_button::BUTTON_PRIMARY);
276
        $importcalendarbutton->class .= ' float-sm-right float-right';
180
        $importcalendarbutton->class .= ' float-sm-end float-end';
277
        $exportcalendarbutton = new single_button(new moodle_url('/calendar/export.php', calendar_get_export_import_link_params()),
181
        $exportcalendarbutton = new single_button(new moodle_url('/calendar/export.php', calendar_get_export_import_link_params()),
278
                get_string('exportcalendar', 'calendar'), 'get', single_button::BUTTON_PRIMARY);
182
                get_string('exportcalendar', 'calendar'), 'get', single_button::BUTTON_PRIMARY);
279
        $exportcalendarbutton->class .= ' float-sm-right float-right';
183
        $exportcalendarbutton->class .= ' float-sm-end float-end';
280
        $output = $this->output->heading(get_string('managesubscriptions', 'calendar'));
184
        $output = $this->output->heading(get_string('managesubscriptions', 'calendar'));
281
        $output .= html_writer::start_div('header d-flex flex-wrap mt-5');
185
        $output .= html_writer::start_div('header d-flex flex-wrap mt-5');
282
        $headerattr = [
186
        $headerattr = [
283
            'class' => 'mr-auto',
187
            'class' => 'me-auto',
284
            'aria-describedby' => 'subscription_details_table',
188
            'aria-describedby' => 'subscription_details_table',
285
        ];
189
        ];
286
        $output .= html_writer::tag('h3', get_string('yoursubscriptions', 'calendar'), $headerattr);
190
        $output .= html_writer::tag('h3', get_string('yoursubscriptions', 'calendar'), $headerattr);
287
        $output .= $this->output->render($importcalendarbutton);
191
        $output .= $this->output->render($importcalendarbutton);
288
        $output .= $this->output->render($exportcalendarbutton);
192
        $output .= $this->output->render($exportcalendarbutton);
Línea 389... Línea 293...
389
     * Creates a form to perform actions on a given subscription.
293
     * Creates a form to perform actions on a given subscription.
390
     *
294
     *
391
     * @return string
295
     * @return string
392
     */
296
     */
393
    protected function subscription_action_links(): string {
297
    protected function subscription_action_links(): string {
394
        $html = html_writer::start_tag('div', array('class' => 'btn-group float-left'));
298
        $html = html_writer::start_tag('div', array('class' => 'btn-group float-start'));
395
        $html .= html_writer::span(html_writer::link('#', get_string('delete'),
299
        $html .= html_writer::span(html_writer::link('#', get_string('delete'),
396
            ['data-action' => 'delete-subscription']), '');
300
            ['data-action' => 'delete-subscription']), '');
397
        $html .= html_writer::end_tag('div');
301
        $html .= html_writer::end_tag('div');
398
        return $html;
302
        return $html;
399
    }
303
    }