Skip to content

Commit

Permalink
MDL-25619 portfolio: exported HTML output can not be cleaned
Browse files Browse the repository at this point in the history
  • Loading branch information
mudrd8mz committed Dec 8, 2010
1 parent f085c3e commit 7e514cd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
18 changes: 18 additions & 0 deletions lib/portfoliolib.php
Expand Up @@ -1171,6 +1171,24 @@ function portfolio_existing_exports_by_plugin($userid) {
return $DB->get_records_sql_menu($sql, $values);
}

/**
* Return default common options for {@link format_text()} when preparing a content to be exported
*
* It is important not to apply filters and not to clean the HTML in format_text()
*
* @return stdClass
*/
function portfolio_format_text_options() {

$options = new stdClass();
$options->para = false;
$options->newlines = true;
$options->filter = false;
$options->noclean = true;
$options->overflowdiv = false;

return $options;
}

/**
* callback function from {@link portfolio_rewrite_pluginfile_urls}
Expand Down
4 changes: 1 addition & 3 deletions mod/assignment/type/online/assignment.class.php
Expand Up @@ -295,9 +295,7 @@ function portfolio_get_sha1($caller) {

function portfolio_prepare_package($exporter, $user) {
$submission = $this->get_submission($user->id);
$options = new stdClass();
$options->para = false;
$options->filter = false;
$options = portfolio_format_text_options();
$html = format_text($submission->data1, $submission->data2, $options);
$html = portfolio_rewrite_pluginfile_urls($html, $this->context->id, 'mod_assignment', $this->filearea, $submission->id, $exporter->get('format'));
if (in_array($exporter->get('formatclass'), array(PORTFOLIO_FORMAT_PLAINHTML, PORTFOLIO_FORMAT_RICHHTML))) {
Expand Down
4 changes: 1 addition & 3 deletions mod/forum/locallib.php
Expand Up @@ -293,9 +293,7 @@ private function prepare_post($post, $fileoutputextras=null) {
$post->author = $users[$post->userid];
$viewfullnames = true;
// format the post body
$options = new stdClass();
$options->para = false;
$options->filter = false;
$options = portfolio_format_text_options();
$format = $this->get('exporter')->get('format');
$formattedtext = format_text($post->message, $post->messageformat, $options, $this->get('course')->id);
$formattedtext = portfolio_rewrite_pluginfile_urls($formattedtext, $this->modcontext->id, 'mod_forum', 'post', $post->id, $format);
Expand Down
4 changes: 1 addition & 3 deletions mod/glossary/locallib.php
Expand Up @@ -375,10 +375,8 @@ public static function entry_content($course, $cm, $glossary, $entry, $aliases,
global $OUTPUT, $DB;
$entry = clone $entry;
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$options = new stdClass();
$options->para = false;
$options = portfolio_format_text_options();
$options->trusted = $entry->definitiontrust;
$options->filter = false;
$options->context = $context;

$output = '<table class="glossarypost dictionary" cellspacing="0">' . "\n";
Expand Down

0 comments on commit 7e514cd

Please sign in to comment.