From 29055d34d6f0ceee253a4122bb6c9dae6cb53b2b Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 27 Apr 2007 07:42:54 +0000 Subject: - Patch #137236 by merlinofchaos: provide a way to secure the theme variables system. --- modules/comment/comment.module | 27 ++++++++++++------- modules/comment/comment.tpl.php | 25 +++++++++++++++++ modules/node/node.tpl.php | 29 ++++++++++++++++++++ modules/system/block.tpl.php | 8 ++++++ modules/system/box.tpl.php | 8 ++++++ modules/system/page.tpl.php | 60 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 148 insertions(+), 9 deletions(-) create mode 100644 modules/comment/comment.tpl.php create mode 100644 modules/node/node.tpl.php create mode 100644 modules/system/block.tpl.php create mode 100644 modules/system/box.tpl.php create mode 100644 modules/system/page.tpl.php (limited to 'modules') diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 8cf30b3dc..1357a3462 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -162,6 +162,7 @@ function comment_theme() { ), 'comment' => array( 'arguments' => array('comment' => NULL, 'links' => array()), + 'file' => 'comment.tpl.php', ), 'comment_folded' => array( 'arguments' => array('comment' => NULL), @@ -1811,15 +1812,23 @@ function comment_controls_submit($form_id, $form_values) { } } -function theme_comment($comment, $links = array()) { - $output = '
'; - $output .= '
'. l($comment->subject, $_GET['q'], array('fragment' => "comment-$comment->cid")) .' '. theme('mark', $comment->new) ."
\n"; - $output .= '
'. t('by %a on %b', array('%a' => theme('username', $comment), '%b' => format_date($comment->timestamp))) ."
\n"; - $output .= '
'. $comment->comment .'
'; - $output .= theme('user_signature', $comment->signature); - $output .= ''; - $output .= '
'; - return $output; +/** + * Prepare values for comment.tpl.php + */ +function template_preprocess_comment(&$variables) { + $comment = $variables['comment']; + $variables['author'] = theme('username', $comment); + $variables['comment'] = $comment; + $variables['content'] = $comment->comment; + $variables['date'] = format_date($comment->timestamp); + $variables['links'] = isset($variables['links']) ? theme('links', $variables['links']) : ''; + $variables['new'] = $comment->new ? t('new') : ''; + $variables['picture'] = theme_get_setting('toggle_comment_user_picture') ? theme('user_picture', $comment) : ''; + $variables['signature'] = $comment->signature; + $variables['submitted'] = t('Submitted by !a on @b.', + array('!a' => theme('username', $comment), + '@b' => format_date($comment->timestamp))); + $variables['title'] = l($comment->subject, $_GET['q'], array('fragment' => "comment-$comment->cid")); } function theme_comment_folded($comment) { diff --git a/modules/comment/comment.tpl.php b/modules/comment/comment.tpl.php new file mode 100644 index 000000000..ac4eeb88a --- /dev/null +++ b/modules/comment/comment.tpl.php @@ -0,0 +1,25 @@ +
+ + +new) : ?> + + + + +

+ + + +
+ + +
+ +
+ +
+ + +
diff --git a/modules/node/node.tpl.php b/modules/node/node.tpl.php new file mode 100644 index 000000000..872ea0c29 --- /dev/null +++ b/modules/node/node.tpl.php @@ -0,0 +1,29 @@ +
+ + + + +

+ + +
+ + + + + + + +
+ +
+ +
+ + + +
\ No newline at end of file diff --git a/modules/system/block.tpl.php b/modules/system/block.tpl.php new file mode 100644 index 000000000..8ba204d40 --- /dev/null +++ b/modules/system/block.tpl.php @@ -0,0 +1,8 @@ +
+ +subject): ?> +

subject ?>

+ + +
content ?>
+
diff --git a/modules/system/box.tpl.php b/modules/system/box.tpl.php new file mode 100644 index 000000000..84d810cf0 --- /dev/null +++ b/modules/system/box.tpl.php @@ -0,0 +1,8 @@ +
+ + +

+ + +
+
diff --git a/modules/system/page.tpl.php b/modules/system/page.tpl.php new file mode 100644 index 000000000..fce977e5f --- /dev/null +++ b/modules/system/page.tpl.php @@ -0,0 +1,60 @@ + + + + + <?php print $head_title ?> + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ +

+
+ + + + +
+
+ + + + + -- cgit v1.2.3