summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDries Buytaert2008-11-08 20:43:54 (GMT)
committerDries Buytaert2008-11-08 20:43:54 (GMT)
commit0290031d45f8d315ff7455a65e3f8fb55e97890d (patch)
tree772f046dfb66c2e084432b9e134dc80c75d96f86
parentb3b68b8b18cd2fe86510cd71ae553cdbc97e59d3 (diff)
- Patch #319788 by stella, nedjo et al: pass language code to filters when available.
-rw-r--r--modules/block/block.module2
-rw-r--r--modules/comment/comment.module4
-rw-r--r--modules/filter/filter.module12
-rw-r--r--modules/node/node.module4
4 files changed, 13 insertions, 9 deletions
diff --git a/modules/block/block.module b/modules/block/block.module
index f56e428..9c482e1 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -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;
}
}
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 7644e0f..d1797fe 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -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);
diff --git a/modules/filter/filter.module b/modules/filter/filter.module
index 8366216..7e21d5f 100644
--- a/modules/filter/filter.module
+++ b/modules/filter/filter.module
@@ -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.
diff --git a/modules/node/node.module b/modules/node/node.module
index eed4cf3..7c8763c 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -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(