-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathrenderable.php
executable file
·305 lines (266 loc) · 9.14 KB
/
renderable.php
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle 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 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Internal library of functions for module newsletter
*
* @package mod_newsletter
* @copyright 2013 Ivan Šakić <[email protected]>
* @copyright 2015 onwards David Bogner <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Renderable page header
* @package mod_newsletter
* @copyright 2013 Ivan Šakić <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class newsletter_header implements renderable {
/** @public stdClass the newsletter record */
public $newsletter = null;
/** @public mixed context|null the context record */
public $context = null;
/** @public bool $showintro - show or hide the intro */
public $showintro = false;
/** @public int coursemoduleid - The course module id */
public $coursemoduleid = 0;
/** @public boolean embed - Embed or not */
public $embed = false;
/**
* Constructor
*
* @param stdClass $newsletter - the newsletter database record
* @param mixed $context context|null - the course module context
* (or the course context if the coursemodule has not been created yet)
* @param bool $showintro - show or hide the intro
* @param int $coursemoduleid - the course module id
* @param bool $embed - render with or without page header
*/
public function __construct(stdClass $newsletter, context $context, bool $showintro, int $coursemoduleid, bool $embed = false) {
$this->newsletter = $newsletter;
$this->context = $context;
$this->showintro = $showintro;
$this->coursemoduleid = $coursemoduleid;
$this->embed = $embed;
}
}
/**
* Renderable moodleform
* @package mod_newsletter
* @copyright 2013 Ivan Šakić <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class newsletter_form implements renderable {
/** @public moodleform $form is the edit submission form */
public $form = null;
/** @public string $title is the title to be displayed in the header */
public $title = '';
/** @public string $classname is the name of the class to assign to the container */
public $classname = '';
/** @public string $jsinitfunction is an optional js function to add to the page requires */
public $jsinitfunction = '';
/**
* Constructor
* @param moodleform $form This is the moodleform
* @param string $classname This is the class name for the container div
* @param string $jsinitfunction This is an optional js function to add to the page requires
*/
public function __construct(moodleform $form, $title = '', $classname = '', $jsinitfunction = '') {
$this->form = $form;
$this->title = $title;
$this->classname = $classname;
$this->jsinitfunction = $jsinitfunction;
}
}
/**
* Data for rendering newsletter issue.
*/
class newsletter_issue implements renderable {
public $id;
public $cmid;
public $newsletterid;
public $title;
public $htmlcontent;
public $publishon;
public $numsubscriptions;
public $numdelivered;
public $numnotyetdelivered;
/**
* Constructor
*/
public function __construct(stdClass $issue) {
$this->id = $issue->id;
$this->cmid = $issue->cmid;
$this->newsletterid = $issue->newsletterid;
$this->title = $issue->title;
$this->publishon = $issue->publishon;
$this->htmlcontent = $issue->htmlcontent;
$this->numsubscriptions = isset($issue->numsubscriptions) ? $issue->numsubscriptions : 0;
$this->numdelivered = isset($issue->numdelivered) ? $issue->numdelivered : 0;
$this->numnotyetdelivered = isset($issue->numnotyetdelivered) ? $issue->numnotyetdelivered : $this->numsubscriptions;
}
}
/**
*
*/
class newsletter_issue_summary extends newsletter_issue {
public $editissue;
public $deleteissue;
public $duplicateissue;
public function __construct(stdClass $issue, $editissue = false, $deleteissue = false, $duplicateissue = false) {
parent::__construct($issue);
$this->editissue = $editissue;
$this->deleteissue = $deleteissue;
$this->duplicateissue = $duplicateissue;
}
}
class newsletter_subscription_list implements renderable {
public int $cmid;
public array $subscriptions;
public array $columns;
public function __construct($cmid, array $subscriptions, array $columns) {
$this->cmid = $cmid;
$this->subscriptions = $subscriptions;
$this->columns = $columns;
}
}
class newsletter_issue_summary_list implements renderable {
public $issues = array();
/**
* Constructor
*/
public function __construct(array $issues = array()) {
$this->issues = $issues;
}
public function add_issue_summary(newsletter_issue_summary $issue) {
$this->issues[] = $issue;
}
}
class newsletter_section_list implements renderable {
public string $heading = '';
public array $sections = array();
/**
* Constructor
*/
public function __construct($heading, array $sections = array()) {
$this->heading = $heading;
$this->sections = $sections;
}
public function add_issue_section(newsletter_section $section) {
$this->sections[] = $section;
}
}
class newsletter_section implements renderable {
public $heading = '';
public $summarylist = array();
/**
* Constructor
*/
public function __construct($heading, newsletter_issue_summary_list $summarylist) {
$this->heading = $heading;
$this->summarylist = $summarylist;
}
}
class newsletter_navigation_bar implements renderable {
public $firstissue;
public $previousissue;
public $currentissue;
public $nextissue;
public $lastissue;
public function __construct(stdClass $currentissue,
stdClass $firstissue = null,
stdClass $previousissue = null,
stdClass $nextissue = null,
stdClass $lastissue = null) {
$this->currentissue = $currentissue;
$this->firstissue = $firstissue;
$this->previousissue = $previousissue;
$this->nextissue = $nextissue;
$this->lastissue = $lastissue;
}
}
class newsletter_pager implements renderable {
public $url;
public $from;
public $count;
public $pages;
public $totalentries;
public $totalfiltered;
public function __construct(moodle_url $url, $from, $count, $pages, $totalentries, $totalfiltered) {
$this->url = $url;
$this->from = $from;
$this->count = $count;
$this->pages = $pages;
$this->totalentries = $totalentries;
$this->totalfiltered = $totalfiltered;
}
}
class newsletter_main_toolbar implements renderable {
public $cmid;
public $groupby;
public $createissues;
public $managesubs;
public function __construct($cmid, $groupby, $createissues = false, $managesubs = false) {
$this->cmid = $cmid;
$this->groupby = $groupby;
$this->createissues = $createissues;
$this->managesubs = $managesubs;
}
}
class newsletter_progressbar implements renderable {
public $tocomplete;
public $completed;
public function __construct($tocomplete, $completed) {
$this->tocomplete = $tocomplete;
$this->completed = $completed;
}
}
class newsletter_attachment_list implements renderable {
public $files;
public function __construct(array $files) {
$this->files = $files;
}
}
class newsletter_publish_countdown implements renderable {
public $now;
public $until;
public function __construct($now, $until) {
$this->now = $now;
$this->until = $until;
}
}
class newsletter_action_button implements renderable {
public $cmid;
public $issueid;
public $action;
public $label;
public function __construct($cmid, $issueid, $action, $label) {
$this->cmid = $cmid;
$this->issueid = $issueid;
$this->action = $action;
$this->label = $label;
}
}
class newsletter_action_link implements renderable {
public $url;
public $text;
public $class;
public function __construct(moodle_url $url, $text = '', $class = 'mod_newsletter__action-link') {
$this->url = $url;
$this->text = $text;
$this->class = $class;
}
}