Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 12... Línea 12...
12
// GNU General Public License for more details.
12
// GNU General Public License for more details.
13
//
13
//
14
// You should have received a copy of the GNU General Public License
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
Línea -... Línea 16...
-
 
16
 
-
 
17
/**
-
 
18
 *
-
 
19
 * @package   theme_universe
-
 
20
 * @copyright 2022 - 2024 Marcin Czaja (https://rosea.io)
-
 
21
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
-
 
22
 *
16
 
23
 */
Línea 17... Línea -...
17
defined('MOODLE_INTERNAL') || die();
-
 
18
 
24
defined('MOODLE_INTERNAL') || die();
-
 
25
 
-
 
26
require_once($CFG->dirroot . "/mod/forum/renderer.php");
-
 
27
 
-
 
28
/**
-
 
29
 * Forum.
19
// Forum.
30
 *
20
require_once($CFG->dirroot . "/mod/forum/renderer.php");
31
 */
21
class theme_universe_mod_forum_renderer extends plugin_renderer_base {
32
class theme_universe_mod_forum_renderer extends plugin_renderer_base {
22
    /**
33
    /**
23
     * Returns the navigation to the previous and next discussion.
34
     * Returns the navigation to the previous and next discussion.
Línea 27... Línea 38...
27
     * @return string The output.
38
     * @return string The output.
28
     */
39
     */
29
    public function neighbouring_discussion_navigation($prev, $next) {
40
    public function neighbouring_discussion_navigation($prev, $next) {
30
        $html = '';
41
        $html = '';
31
        if ($prev || $next) {
42
        if ($prev || $next) {
32
            $html .= html_writer::start_tag('div', array('class' => 'discussion-nav clearfix border p-2 rounded'));
43
            $html .= html_writer::start_tag('div', ['class' => 'discussion-nav clearfix border p-2 rounded']);
33
            $html .= html_writer::start_tag('ul');
44
            $html .= html_writer::start_tag('ul');
34
            if ($prev) {
45
            if ($prev) {
35
                $url = new moodle_url('/mod/forum/discuss.php', array('d' => $prev->id));
46
                $url = new moodle_url('/mod/forum/discuss.php', ['d' => $prev->id]);
36
                $html .= html_writer::start_tag('li', array('class' => 'prev-discussion'));
47
                $html .= html_writer::start_tag('li', ['class' => 'prev-discussion']);
37
                $html .= html_writer::link(
48
                $html .= html_writer::link(
38
                    $url,
49
                    $url,
-
 
50
                    '<svg class="mr-2"
-
 
51
                        width="16"
-
 
52
                        height="16"
-
 
53
                        stroke-width="2"
-
 
54
                        viewBox="0 0 24 24"
-
 
55
                        fill="none"
39
                    '<svg class="mr-2" width="16" height="16" stroke-width="2" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" color="currentColor">
56
                        xmlns="http://www.w3.org/2000/svg"
-
 
57
                        color="currentColor">
40
                    <path d="M18.5 12H6m0 0l6-6m-6 6l6 6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
58
                    <path d="M18.5 12H6m0 0l6-6m-6 6l6 6"
-
 
59
                        stroke="currentColor"
-
 
60
                        stroke-width="2"
-
 
61
                        stroke-linecap="round"
-
 
62
                        stroke-linejoin="round"></path>
41
                    </svg>' . format_string($prev->name),
63
                    </svg>' . format_string($prev->name),
42
                    array(
64
                    [
43
                        'aria-label' => get_string('prevdiscussiona', 'mod_forum', format_string($prev->name)),
65
                        'aria-label' => get_string('prevdiscussiona', 'mod_forum', format_string($prev->name)),
44
                        'class' => 'btn btn-xs btn-secondary text-truncate'
66
                        'class' => 'btn btn-xs btn-secondary text-truncate',
45
                    )
67
                    ]
46
                );
68
                );
47
                $html .= html_writer::end_tag('li');
69
                $html .= html_writer::end_tag('li');
48
            }
70
            }
49
            if ($next) {
71
            if ($next) {
50
                $url = new moodle_url('/mod/forum/discuss.php', array('d' => $next->id));
72
                $url = new moodle_url('/mod/forum/discuss.php', ['d' => $next->id]);
51
                $html .= html_writer::start_tag('li', array('class' => 'next-discussion'));
73
                $html .= html_writer::start_tag('li', ['class' => 'next-discussion']);
52
                $html .= html_writer::link(
74
                $html .= html_writer::link(
53
                    $url,
75
                    $url,
-
 
76
                    format_string($next->name) .
-
 
77
                        '<svg class="ml-2"
-
 
78
                            width="16"
-
 
79
                            height="16"
-
 
80
                            stroke-width="2"
-
 
81
                            viewBox="0 0 24 24"
-
 
82
                            fill="none"
54
                    format_string($next->name) . '<svg class="ml-2" width="16" height="16" stroke-width="2" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" color="currentColor">
83
                            xmlns="http://www.w3.org/2000/svg"
-
 
84
                            color="currentColor">
55
                            <path d="M6 12h12.5m0 0l-6-6m6 6l-6 6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
85
                            <path d="M6 12h12.5m0 0l-6-6m6 6l-6 6"
-
 
86
                                stroke="currentColor"
-
 
87
                                stroke-width="2"
-
 
88
                                stroke-linecap="round"
-
 
89
                                stroke-linejoin="round"></path>
56
                        </svg>',
90
                        </svg>',
57
                    array(
91
                    [
58
                        'aria-label' => get_string('nextdiscussiona', 'mod_forum', format_string($next->name)),
92
                        'aria-label' => get_string('nextdiscussiona', 'mod_forum', format_string($next->name)),
59
                        'class' => 'btn btn-xs btn-secondary text-truncate'
93
                        'class' => 'btn btn-xs btn-secondary text-truncate',
60
                    )
94
                    ]
61
                );
95
                );
62
                $html .= html_writer::end_tag('li');
96
                $html .= html_writer::end_tag('li');
63
            }
97
            }
64
            $html .= html_writer::end_tag('ul');
98
            $html .= html_writer::end_tag('ul');
65
            $html .= html_writer::end_tag('div');
99
            $html .= html_writer::end_tag('div');
Línea 75... Línea 109...
75
     * @param user_selector_base $potentialuc
109
     * @param user_selector_base $potentialuc
76
     * @return string
110
     * @return string
77
     */
111
     */
78
    public function subscriber_selection_form(user_selector_base $existinguc, user_selector_base $potentialuc) {
112
    public function subscriber_selection_form(user_selector_base $existinguc, user_selector_base $potentialuc) {
79
        $output = '';
113
        $output = '';
80
        $formattributes = array();
114
        $formattributes = [];
81
        $formattributes['id'] = 'subscriberform';
115
        $formattributes['id'] = 'subscriberform';
82
        $formattributes['action'] = '';
116
        $formattributes['action'] = '';
83
        $formattributes['method'] = 'post';
117
        $formattributes['method'] = 'post';
84
        $output .= html_writer::start_tag('form', $formattributes);
118
        $output .= html_writer::start_tag('form', $formattributes);
85
        $output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
119
        $output .= html_writer::empty_tag('input', ['type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()]);
Línea 86... Línea 120...
86
 
120
 
87
        $existingcell = new html_table_cell();
121
        $existingcell = new html_table_cell();
88
        $existingcell->text = $existinguc->display(true);
122
        $existingcell->text = $existinguc->display(true);
89
        $existingcell->attributes['class'] = 'existing';
123
        $existingcell->attributes['class'] = 'existing';
90
        $actioncell = new html_table_cell();
124
        $actioncell = new html_table_cell();
91
        $actioncell->text = html_writer::start_tag('div', array());
125
        $actioncell->text = html_writer::start_tag('div', []);
-
 
126
        $actioncell->text .= html_writer::empty_tag('input',
92
        $actioncell->text .= html_writer::empty_tag('input',
127
            [
93
            array('type' => 'submit',
128
                'type' => 'submit',
94
                  'name' => 'subscribe',
129
                'name' => 'subscribe',
95
                  'value' => get_string('add'),
130
                'value' => get_string('add'),
-
 
131
                'class' => 'actionbutton btn btn-success',
96
                  'class' => 'actionbutton btn btn-success')
132
            ]
97
        );
133
        );
-
 
134
        $actioncell->text .= html_writer::empty_tag('input',
98
        $actioncell->text .= html_writer::empty_tag('input',
135
            [
99
            array('type' => 'submit',
136
                'type' => 'submit',
100
                  'name' => 'unsubscribe',
137
                'name' => 'unsubscribe',
101
                  'value' => get_string('remove'),
138
                'value' => get_string('remove'),
-
 
139
                'class' => 'actionbutton btn btn-danger',
102
                  'class' => 'actionbutton btn btn-danger')
140
            ],
103
        );
141
        );
104
        $actioncell->text .= html_writer::end_tag('div', array());
142
        $actioncell->text .= html_writer::end_tag('div', []);
105
        $actioncell->attributes['class'] = 'actions px-3';
143
        $actioncell->attributes['class'] = 'actions px-3';
106
        $potentialcell = new html_table_cell();
144
        $potentialcell = new html_table_cell();
107
        $potentialcell->text = $potentialuc->display(true);
145
        $potentialcell->text = $potentialuc->display(true);
Línea 108... Línea 146...
108
        $potentialcell->attributes['class'] = 'potential';
146
        $potentialcell->attributes['class'] = 'potential';
109
 
147
 
110
        $output .= html_writer::start_tag('fieldset', array('class' => 'w-100'));
148
        $output .= html_writer::start_tag('fieldset', ['class' => 'w-100']);
111
        $table = new html_table();
149
        $table = new html_table();
112
        $table->attributes['class'] = 'subscribertable boxaligncenter mb-2 border-bottom';
150
        $table->attributes['class'] = 'subscribertable boxaligncenter mb-2 border-bottom';
113
        $table->data = array(new html_table_row(array($existingcell, $actioncell, $potentialcell)));
151
        $table->data = [new html_table_row([$existingcell, $actioncell, $potentialcell])];
Línea 114... Línea 152...
114
        $output .= html_writer::table($table);
152
        $output .= html_writer::table($table);
115
        $output .= html_writer::end_tag('fieldset');
153
        $output .= html_writer::end_tag('fieldset');
Línea 148... Línea 186...
148
            $output .= $this->output->heading(get_string("subscriberstowithcount", "forum", $strparams));
186
            $output .= $this->output->heading(get_string("subscriberstowithcount", "forum", $strparams));
149
            $table = new html_table();
187
            $table = new html_table();
150
            $table->cellpadding = 5;
188
            $table->cellpadding = 5;
151
            $table->cellspacing = 5;
189
            $table->cellspacing = 5;
152
            $table->tablealign = 'center';
190
            $table->tablealign = 'center';
153
            $table->data = array();
191
            $table->data = [];
154
            foreach ($users as $user) {
192
            foreach ($users as $user) {
155
                $info = array($this->output->user_picture($user, array('courseid' => $course->id)), fullname($user));
193
                $info = [$this->output->user_picture($user, ['courseid' => $course->id]), fullname($user)];
156
                if ($canviewemail) {
194
                if ($canviewemail) {
157
                    array_push($info, $user->email);
195
                    array_push($info, $user->email);
158
                }
196
                }
159
                $table->data[] = $info;
197
                $table->data[] = $info;
160
            }
198
            }
Línea 185... Línea 223...
185
     * @param bool $visiblenow Indicicates that the discussion is currently
223
     * @param bool $visiblenow Indicicates that the discussion is currently
186
     * visible to all users.
224
     * visible to all users.
187
     * @return string
225
     * @return string
188
     */
226
     */
189
    public function timed_discussion_tooltip($discussion, $visiblenow) {
227
    public function timed_discussion_tooltip($discussion, $visiblenow) {
190
        $dates = array();
228
        $dates = [];
191
        if ($discussion->timestart) {
229
        if ($discussion->timestart) {
192
            $dates[] = get_string('displaystart', 'mod_forum') . ': ' . userdate($discussion->timestart);
230
            $dates[] = get_string('displaystart', 'mod_forum') . ': ' . userdate($discussion->timestart);
193
        }
231
        }
194
        if ($discussion->timeend) {
232
        if ($discussion->timeend) {
195
            $dates[] = get_string('displayend', 'mod_forum') . ': ' . userdate($discussion->timeend);
233
            $dates[] = get_string('displayend', 'mod_forum') . ': ' . userdate($discussion->timeend);
Línea 197... Línea 235...
197
 
235
 
198
        $str = $visiblenow ? 'timedvisible' : 'timedhidden';
236
        $str = $visiblenow ? 'timedvisible' : 'timedhidden';
Línea 199... Línea 237...
199
        $dates[] = get_string($str, 'mod_forum');
237
        $dates[] = get_string($str, 'mod_forum');
200
 
238
 
201
        $tooltip = implode("\n", $dates);
239
        $tooltip = implode("\n", $dates);
Línea 202... Línea 240...
202
        return $this->pix_icon('i/calendar', $tooltip, 'moodle', array('class' => 'smallicon timedpost'));
240
        return $this->pix_icon('i/calendar', $tooltip, 'moodle', ['class' => 'smallicon timedpost']);
203
    }
241
    }
204
 
242