Skip to content

Commit

Permalink
MDL-36669 Filters: Remove the last ref to the UFO library.
Browse files Browse the repository at this point in the history
  • Loading branch information
scara committed Oct 20, 2014
1 parent b49de5d commit 8045696
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions lib/filelib.php
Expand Up @@ -2764,21 +2764,17 @@ function file_modify_html_header($text) {
global $CFG;

$stylesheetshtml = '';
/* foreach ($CFG->stylesheets as $stylesheet) {
/*
foreach ($CFG->stylesheets as $stylesheet) {
//TODO: MDL-21120
$stylesheetshtml .= '<link rel="stylesheet" type="text/css" href="'.$stylesheet.'" />'."\n";
}*/

$ufo = '';
if (filter_is_enabled('mediaplugin')) {
// this script is needed by most media filter plugins.
$attributes = array('type'=>'text/javascript', 'src'=>$CFG->httpswwwroot . '/lib/ufo.js');
$ufo = html_writer::tag('script', '', $attributes) . "\n";
}
*/
// TODO The code below is actually a waste of CPU. When MDL-29738 will be implemented it should be re-evaluated too.

preg_match('/\<head\>|\<HEAD\>/', $text, $matches);
if ($matches) {
$replacement = '<head>'.$ufo.$stylesheetshtml;
$replacement = '<head>'.$stylesheetshtml;
$text = preg_replace('/\<head\>|\<HEAD\>/', $replacement, $text, 1);
return $text;
}
Expand All @@ -2787,21 +2783,21 @@ function file_modify_html_header($text) {
preg_match('/\<html\>|\<HTML\>/', $text, $matches);
if ($matches) {
// replace <html> tag with <html><head>includes</head>
$replacement = '<html>'."\n".'<head>'.$ufo.$stylesheetshtml.'</head>';
$replacement = '<html>'."\n".'<head>'.$stylesheetshtml.'</head>';
$text = preg_replace('/\<html\>|\<HTML\>/', $replacement, $text, 1);
return $text;
}

// if not, look for <body> tag, and stick <head> before body
preg_match('/\<body\>|\<BODY\>/', $text, $matches);
if ($matches) {
$replacement = '<head>'.$ufo.$stylesheetshtml.'</head>'."\n".'<body>';
$replacement = '<head>'.$stylesheetshtml.'</head>'."\n".'<body>';
$text = preg_replace('/\<body\>|\<BODY\>/', $replacement, $text, 1);
return $text;
}

// if not, just stick a <head> tag at the beginning
$text = '<head>'.$ufo.$stylesheetshtml.'</head>'."\n".$text;
$text = '<head>'.$stylesheetshtml.'</head>'."\n".$text;
return $text;
}

Expand Down

0 comments on commit 8045696

Please sign in to comment.