@@ -155,7 +155,7 @@ public function get_content() {
155
155
$ summary = file_rewrite_pluginfile_urls ($ section ->summary , 'pluginfile.php ' , $ context ->id , 'course ' ,
156
156
'section ' , $ section ->id );
157
157
$ summary = format_text ($ summary , $ section ->summaryformat , array ('para ' => false , 'context ' => $ context ));
158
- $ title = format_string ($ this -> extract_title ($ summary ), true , array ( 'context ' => $ context) );
158
+ $ title = format_string (\ block_course_contents \autotitle:: extract_title ($ summary ), true , [ 'context ' => $ context] );
159
159
}
160
160
161
161
// If at this point we have no title available, use the default one.
@@ -294,46 +294,4 @@ public function get_content() {
294
294
$ this ->content ->text = $ text ;
295
295
return $ this ->content ;
296
296
}
297
-
298
-
299
- /**
300
- * Given a section summary, exctract a text suitable as a section title
301
- *
302
- * @param string $summary Section summary as returned from database (no slashes)
303
- * @return string Section title
304
- */
305
- private function extract_title ($ summary ) {
306
- global $ CFG ;
307
- require_once (dirname (__FILE__ ).'/lib/simple_html_dom.php ' );
308
-
309
- $ node = new simple_html_dom ();
310
- $ node ->load ($ summary );
311
- return $ this ->node_plain_text ($ node );
312
- }
313
-
314
-
315
- /**
316
- * Recursively find the first suitable plaintext from the HTML DOM.
317
- *
318
- * Internal private function called only from {@link extract_title()}
319
- *
320
- * @param simple_html_dom $node Current root node
321
- * @return string
322
- */
323
- private function node_plain_text ($ node ) {
324
- if ($ node ->nodetype == HDOM_TYPE_TEXT ) {
325
- $ t = trim ($ node ->plaintext );
326
- if (!empty ($ t )) {
327
- return $ t ;
328
- }
329
- }
330
- $ t = '' ;
331
- foreach ($ node ->nodes as $ n ) {
332
- $ t = $ this ->node_plain_text ($ n );
333
- if (!empty ($ t )) {
334
- break ;
335
- }
336
- }
337
- return $ t ;
338
- }
339
297
}
0 commit comments