Skip to content

Commit

Permalink
MDL-63660 privacy: Include CSS locally for data export
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Johnson committed Nov 14, 2018
1 parent dccda65 commit 80aff7d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 34 deletions.
32 changes: 4 additions & 28 deletions privacy/classes/local/request/moodle_content_writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -635,16 +635,9 @@ protected function write_html_data() {
$this->copy_data($moodleimgpath, ['pix', 'moodlelogo.svg']);

// Additional required css.
// Determine what direction to show the data export page according to the user preference.
$rtl = right_to_left();
if (!$rtl) {
$bootstrapdestination = 'bootstrap.min.css';
$this->write_url_content('https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css',
$bootstrapdestination);
} else {
$rtldestination = 'rtlbootstrap.min.css';
$this->write_url_content('https://cdn.rtlcss.com/bootstrap/v4.0.0/css/bootstrap.min.css', $rtldestination);
}
$csspath = ['theme', 'boost', 'style', 'moodle.css'];
$destination = ['moodle.css'];
$this->copy_data($csspath, $destination);

$csspath = ['privacy', 'export_files', 'general.css'];
$destination = ['general.css'];
Expand All @@ -666,6 +659,7 @@ protected function write_html_data() {
$siteurl = $CFG->wwwroot;

// Create custom index.html file.
$rtl = right_to_left();
$htmlpage = new \core_privacy\output\exported_html_page($navigationhtml, $systemname, $fullusername, $rtl, $siteurl);
$outputpage = $output->render_html_page($htmlpage);
$this->write_data('index.html', $outputpage);
Expand Down Expand Up @@ -720,22 +714,4 @@ protected function get_file_content(string $filepath) : String {
}
return $content;
}

/**
* Write url files to the export.
*
* @param string $url Url of the file.
* @param string $path Path to store the file.
*/
protected function write_url_content(string $url, string $path) {
$filepointer = fopen($url, 'r');
$targetpath = $this->path . DIRECTORY_SEPARATOR . $path;
check_dir_exists(dirname($targetpath), true, true);
$status = file_put_contents($targetpath, $filepointer);
if ($status === false) {
// There was an error. Throw an exception to allow the download status to remain as requiring download.
throw new \moodle_exception('Content download was incomplete');
}
$this->files[$path] = $targetpath;
}
}
7 changes: 1 addition & 6 deletions privacy/templates/htmlpage.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,7 @@
<head>
<meta charset="UTF-8">
<title>Data export</title>
{{^righttoleft}}
<link rel="stylesheet" href="bootstrap.min.css">
{{/righttoleft}}
{{#righttoleft}}
<link rel="stylesheet" href="rtlbootstrap.min.css">
{{/righttoleft}}
<link rel="stylesheet" type="text/css" href="moodle.css" />
<link rel="stylesheet" type="text/css" href="general.css" />
</head>
<body>
Expand Down

0 comments on commit 80aff7d

Please sign in to comment.