Skip to content

Commit

Permalink
Merge branch 'MDL-29738-30' of git://github.com/andrewnicols/moodle i…
Browse files Browse the repository at this point in the history
…nto MOODLE_30_STABLE
  • Loading branch information
stronk7 committed Jul 5, 2016
2 parents 7ff1344 + 96b36b9 commit ea9061b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 53 deletions.
13 changes: 13 additions & 0 deletions lib/deprecatedlib.php
Expand Up @@ -2735,3 +2735,16 @@ function tag_autocomplete($text) {
FROM {tag} tg
WHERE tg.name LIKE ?", array(core_text::strtolower($text)."%"));
}

/**
* Add includes (js and css) into uploaded files before returning them,
* useful for themes and utf.js includes.
*
* @param string $text text to search and replace
* @return string text
* @deprecated Moodle 3.0.5 See MDL-29738
*/
function file_modify_html_header($text) {
debugging('file_modify_html_header() is deprecated and will not be replaced.', DEBUG_DEVELOPER);
return $text;
}
53 changes: 0 additions & 53 deletions lib/filelib.php
Expand Up @@ -2160,7 +2160,6 @@ function send_file($path, $filename, $lifetime = null , $filter=0, $pathisstring
$options->nocache = true; // temporary workaround for MDL-5136
$text = $pathisstring ? $path : implode('', file($path));

$text = file_modify_html_header($text);
$output = format_text($text, FORMAT_HTML, $options, $COURSE->id);

readstring_accel($output, $mimetype, false);
Expand Down Expand Up @@ -2344,7 +2343,6 @@ function send_stored_file($stored_file, $lifetime=null, $filter=0, $forcedownloa
$options->noclean = true;
$options->nocache = true; // temporary workaround for MDL-5136
$text = $stored_file->get_content();
$text = file_modify_html_header($text);
$output = format_text($text, FORMAT_HTML, $options, $COURSE->id);

readstring_accel($output, $mimetype, false);
Expand Down Expand Up @@ -2608,57 +2606,6 @@ function byteserving_send_file($handle, $mimetype, $ranges, $filesize) {
}
}

/**
* add includes (js and css) into uploaded files
* before returning them, useful for themes and utf.js includes
*
* @global stdClass $CFG
* @param string $text text to search and replace
* @return string text with added head includes
* @todo MDL-21120
*/
function file_modify_html_header($text) {
// first look for <head> tag
global $CFG;

$stylesheetshtml = '';
/*
foreach ($CFG->stylesheets as $stylesheet) {
//TODO: MDL-21120
$stylesheetshtml .= '<link rel="stylesheet" type="text/css" href="'.$stylesheet.'" />'."\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>'.$stylesheetshtml;
$text = preg_replace('/\<head\>|\<HEAD\>/', $replacement, $text, 1);
return $text;
}

// if not, look for <html> tag, and stick <head> right after
preg_match('/\<html\>|\<HTML\>/', $text, $matches);
if ($matches) {
// replace <html> tag with <html><head>includes</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>'.$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>'.$stylesheetshtml.'</head>'."\n".$text;
return $text;
}

/**
* RESTful cURL class
*
Expand Down
2 changes: 2 additions & 0 deletions lib/upgrade.txt
Expand Up @@ -7,6 +7,8 @@ information provided here is intended especially for developers.
* The parameter $usepost of the following functions has been deprecated and is not used any more:
- get_max_upload_file_size()
- get_user_max_upload_file_size()
* The following functions have been deprecated and should not be used any more:
- file_modify_html_header() - See MDL-29738 for more information.

=== 3.0.4 ===

Expand Down

0 comments on commit ea9061b

Please sign in to comment.