2424 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2525 */
2626
27+ namespace format_weeksrev \output ;
28+
29+ use core_courseformat \output \section_renderer ;
30+ use core_courseformat \output \local \content \section ;
31+ use core_courseformat \output \local \content \section \cmlist ;
32+ use core_courseformat \output \local \content \section \availability ;
33+ use core_courseformat \output \local \content \section \summary ;
34+ use core_courseformat \output \local \content \addsection ;
35+ use html_writer ;
2736
2837defined ('MOODLE_INTERNAL ' ) || die ();
29- require_once ($ CFG ->dirroot .'/course/format/renderer.php ' );
38+ require_once ($ CFG ->dirroot .'/course/format/weeksrev/classes/output/ renderer.php ' );
3039require_once ($ CFG ->dirroot .'/course/format/weeksrev/lib.php ' );
3140
32-
3341/**
3442 * Basic renderer for weeksrev format.
3543 *
3846 * based on code from 2012 Dan Poltawski
3947 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
4048 */
41- class format_weeksrev_renderer extends format_section_renderer_base {
49+ class renderer extends section_renderer {
50+
4251 /**
4352 * Generate the starting container html for a list of sections
4453 * @return string HTML to output.
@@ -59,7 +68,7 @@ protected function end_section_list() {
5968 * @return string the page title
6069 */
6170 protected function page_title () {
62- return get_string ('weeklyoutline ' );
71+ return get_string ('weeklyoutline ' , ' format_weeksrev ' );
6372 }
6473
6574 /**
@@ -111,18 +120,14 @@ protected function section_header($section, $course, $onsectionpage, $sectionret
111120 }
112121
113122 $ o .= html_writer::start_tag ('li ' , ['id ' => 'section- ' . $ section ->section ,
114- ' class ' => ' section main clearfix ' . $ sectionstyle , 'role ' => 'region ' ,
123+ $ sectionstyle , 'role ' => 'region ' ,
115124 'aria-label ' => get_section_name ($ course , $ section )]);
116125
117126 // Create a span that contains the section title to be used to create the keyboard section move menu.
118127 $ o .= html_writer::tag ('span ' , get_section_name ($ course , $ section ), ['class ' => 'hidden sectionname ' ]);
119128
120- $ leftcontent = $ this ->section_left_content ($ section , $ course , $ onsectionpage );
121- $ o .= html_writer::tag ('div ' , $ leftcontent , ['class ' => 'left side ' ]);
122-
123- $ rightcontent = $ this ->section_right_content ($ section , $ course , $ onsectionpage );
124- $ o .= html_writer::tag ('div ' , $ rightcontent , ['class ' => 'right side ' ]);
125- $ o .= html_writer::start_tag ('div ' , ['class ' => 'content ' ]);
129+ $ sectionoutput = new section ($ courseformat , $ section );
130+ $ o .= $ this ->render ($ sectionoutput );
126131
127132 // When not on a section page, we display the section titles except the general section if null.
128133 $ hasnamenotsecpg = (!$ onsectionpage && ($ section ->section != 0 || !is_null ($ section ->name )));
@@ -134,13 +139,13 @@ protected function section_header($section, $course, $onsectionpage, $sectionret
134139 if ($ hasnamenotsecpg || $ hasnamesecpg ) {
135140 $ classes = '' ;
136141 }
137- $ sectionname = html_writer::tag ('span ' , $ this ->section_title ($ section , $ course ));
138- $ o .= $ this ->output ->heading ($ sectionname , 3 , 'sectionname ' . $ classes );
139142
140- $ o .= $ this ->section_availability ($ section );
143+ $ availability = new availability ($ courseformat , $ section );
144+ $ o .= $ this ->render ($ availability );
141145
142146 $ o .= html_writer::start_tag ('div ' , ['class ' => 'summary ' ]);
143- $ o .= $ this ->format_summary_text ($ section );
147+ $ summary = new summary ($ courseformat , $ section );
148+ $ o .= $ summary ->format_summary_text ();
144149 $ o .= html_writer::end_tag ('div ' );
145150
146151 return $ o ;
@@ -185,11 +190,13 @@ protected function section_summary($section, $course, $mods) {
185190 $ o .= $ this ->output ->heading ($ title , 3 , 'section-title ' );
186191
187192 $ o .= html_writer::start_tag ('div ' , ['class ' => 'summarytext ' ]);
188- $ o .= $ this ->format_summary_text ($ section );
193+ $ summary = new summary ($ courseformat , $ section );
194+ $ o .= $ summary ->format_summary_text ();
189195 $ o .= html_writer::end_tag ('div ' );
190196 $ o .= $ this ->section_activity_summary ($ section , $ course , null );
191197
192- $ o .= $ this ->section_availability ($ section );
198+ $ availability = new availability ($ courseformat , $ section );
199+ $ o .= $ this ->render ($ availability );
193200
194201 $ o .= html_writer::end_tag ('div ' );
195202 $ o .= html_writer::end_tag ('li ' );
@@ -207,7 +214,7 @@ protected function section_summary($section, $course, $mods) {
207214 * @param int $displaysection The section number in the course which is being displayed
208215 */
209216 public function print_single_section_page ($ course , $ sections , $ mods , $ modnames , $ modnamesused , $ displaysection ) {
210- $ context = context_course::instance ($ course ->id );
217+ $ context = \ context_course::instance ($ course ->id );
211218 $ canviewhidden = has_capability ('moodle/course:viewhiddensections ' , $ context );
212219 if ($ course ->hidefuture && $ canviewhidden ) {
213220 echo html_writer::tag ('ul ' ,
@@ -232,19 +239,16 @@ public function print_multiple_section_page($course, $sections, $mods, $modnames
232239 $ courseformat = course_get_format ($ course );
233240 $ course = $ courseformat ->get_course ();
234241
235- $ context = context_course::instance ($ course ->id );
242+ $ context = \ context_course::instance ($ course ->id );
236243 // Title with completion help icon.
237- $ completioninfo = new completion_info ($ course );
238- echo $ completioninfo -> display_help_icon ( );
244+ $ completioninfo = new \ completion_info ($ course );
245+ echo $ this -> output -> help_icon ( ' completion ' , ' completion ' );
239246 echo $ this ->output ->heading ($ this ->page_title (), 2 , 'accesshide ' );
240247
241- // Copy activity clipboard..
242- echo $ this ->course_activity_clipboard ($ course , 0 );
243-
244248 $ canviewhidden = has_capability ('moodle/course:viewhiddensections ' , $ context );
245249 if ($ course ->hidefuture && $ canviewhidden ) {
246- echo html_writer::tag ('ul ' ,
247- html_writer::tag ('li ' , get_string ('futureweeks ' , 'format_weeksrev ' ), ['class ' => 'future-legend ' ]),
250+ echo \ html_writer::tag ('ul ' ,
251+ \ html_writer::tag ('li ' , get_string ('futureweeks ' , 'format_weeksrev ' ), ['class ' => 'future-legend ' ]),
248252 ['class ' => 'weeksrev ' ]
249253 );
250254 }
@@ -263,9 +267,6 @@ public function print_multiple_section_page($course, $sections, $mods, $modnames
263267 // 0-section is displayed a little different then the others.
264268 if ($ thissection ->summary or !empty ($ modinfo ->sections [0 ]) or $ PAGE ->user_is_editing ()) {
265269 echo $ this ->section_header ($ thissection , $ course , false , 0 );
266- echo $ this ->courserenderer ->course_section_cm_list ($ course , $ thissection , 0 );
267- echo $ this ->courserenderer ->course_section_add_cm_control ($ course , 0 , 0 );
268- echo $ this ->section_footer ();
269270 }
270271 continue ;
271272 }
@@ -295,11 +296,6 @@ public function print_multiple_section_page($course, $sections, $mods, $modnames
295296 echo $ this ->section_summary ($ thissection , $ course , null );
296297 } else {
297298 echo $ this ->section_header ($ thissection , $ course , false , 0 );
298- if ($ thissection ->uservisible ) {
299- echo $ this ->courserenderer ->course_section_cm_list ($ course , $ thissection , 0 );
300- echo $ this ->courserenderer ->course_section_add_cm_control ($ course , $ section , 0 );
301- }
302- echo $ this ->section_footer ();
303299 }
304300 }
305301
@@ -311,13 +307,12 @@ public function print_multiple_section_page($course, $sections, $mods, $modnames
311307 continue ;
312308 }
313309 echo $ this ->stealth_section_header ($ section );
314- echo $ this ->courserenderer ->course_section_cm_list ($ course , $ thissection , 0 );
315- echo $ this ->stealth_section_footer ();
316310 }
317311
318312 echo $ this ->end_section_list ();
319313
320- echo $ this ->change_number_sections ($ course , 0 );
314+ $ addsection = new addsection ($ courseformat );
315+ echo $ this ->render ($ addsection );
321316 } else {
322317 echo $ this ->end_section_list ();
323318 }
0 commit comments