Commit 0290031d authored by Dries's avatar Dries

- Patch #319788 by stella, nedjo et al: pass language code to filters when available.

parent b3b68b8b
......@@ -213,7 +213,7 @@ function block_block($op = 'list', $delta = 0, $edit = array()) {
case 'view':
$block = db_fetch_object(db_query('SELECT body, format FROM {boxes} WHERE bid = %d', $delta));
$data['content'] = check_markup($block->body, $block->format, FALSE);
$data['content'] = check_markup($block->body, $block->format, '', FALSE);
return $data;
}
}
......
......@@ -604,7 +604,7 @@ function comment_nodeapi_update_index(&$node, $arg = 0) {
$text = '';
$comments = db_query('SELECT subject, comment, format FROM {comments} WHERE nid = %d AND status = %d', $node->nid, COMMENT_PUBLISHED);
while ($comment = db_fetch_object($comments)) {
$text .= '<h2>' . check_plain($comment->subject) . '</h2>' . check_markup($comment->comment, $comment->format, FALSE);
$text .= '<h2>' . check_plain($comment->subject) . '</h2>' . check_markup($comment->comment, $comment->format, '', FALSE);
}
return $text;
}
......@@ -1597,7 +1597,7 @@ function theme_comment_view($comment, $node, $links = array(), $visible = TRUE)
// Switch to folded/unfolded view of the comment.
if ($visible) {
$comment->comment = check_markup($comment->comment, $comment->format, FALSE);
$comment->comment = check_markup($comment->comment, $comment->format, '', FALSE);
// Comment API hook.
comment_invoke_comment($comment, 'view');
$output .= theme('comment', $comment, $node, $links);
......
......@@ -409,6 +409,10 @@ function filter_list_format($format) {
* @param $format
* The format of the text to be filtered. Specify FILTER_FORMAT_DEFAULT for
* the default format.
* @param $langcode
* Optional: the language code of the text to be filtered, e.g. 'en' for
* English. This allows filters to be language aware so language specific
* text replacement can be implemented.
* @param $check
* Whether to check the $format with filter_access() first. Defaults to TRUE.
* Note that this will check the permissions of the current user, so you
......@@ -416,13 +420,13 @@ function filter_list_format($format) {
* showing content that is not (yet) stored in the database (eg. upon preview),
* set to TRUE so the user's permissions are checked.
*/
function check_markup($text, $format = FILTER_FORMAT_DEFAULT, $check = TRUE) {
function check_markup($text, $format = FILTER_FORMAT_DEFAULT, $langcode = '', $check = TRUE) {
// When $check = TRUE, do an access check on $format.
if (isset($text) && (!$check || filter_access($format))) {
$format = filter_resolve_format($format);
// Check for a cached version of this piece of text.
$cache_id = $format . ':' . md5($text);
$cache_id = $format . ':' . $langcode . ':' . md5($text);
if ($cached = cache_get($cache_id, 'cache_filter')) {
return $cached->data;
}
......@@ -439,12 +443,12 @@ function check_markup($text, $format = FILTER_FORMAT_DEFAULT, $check = TRUE) {
// Give filters the chance to escape HTML-like data such as code or formulas.
foreach ($filters as $filter) {
$text = module_invoke($filter->module, 'filter', 'prepare', $filter->delta, $format, $text, $cache_id);
$text = module_invoke($filter->module, 'filter', 'prepare', $filter->delta, $format, $text, $langcode, $cache_id);
}
// Perform filtering.
foreach ($filters as $filter) {
$text = module_invoke($filter->module, 'filter', 'process', $filter->delta, $format, $text, $cache_id);
$text = module_invoke($filter->module, 'filter', 'process', $filter->delta, $format, $text, $langcode, $cache_id);
}
// Store in cache with a minimum expiration time of 1 day.
......
......@@ -1088,10 +1088,10 @@ function node_prepare($node, $teaser = FALSE) {
$node->readmore = (strlen($node->teaser) < strlen($node->body));
if ($teaser == FALSE) {
$node->body = check_markup($node->body, $node->format, FALSE);
$node->body = check_markup($node->body, $node->format, $node->language, FALSE);
}
else {
$node->teaser = check_markup($node->teaser, $node->format, FALSE);
$node->teaser = check_markup($node->teaser, $node->format, $node->language, FALSE);
}
$node->content['body'] = array(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment