diff --git a/app/Templates/comment_show.php b/app/Templates/comment_show.php
index 5069120d3..b2ccc25a8 100644
--- a/app/Templates/comment_show.php
+++ b/app/Templates/comment_show.php
@@ -21,7 +21,20 @@
- = Helper\markdown($comment['comment']) ?>
+
+ = Helper\markdown(
+ $comment['comment'],
+ array(
+ 'controller' => 'task',
+ 'action' => 'readonly',
+ 'params' => array(
+ 'token' => $project['token']
+ )
+ )
+ ) ?>
+
+ = Helper\markdown($comment['comment']) ?>
+
diff --git a/app/Templates/task_comments.php b/app/Templates/task_comments.php
index 12deff985..5cfa99ce1 100644
--- a/app/Templates/task_comments.php
+++ b/app/Templates/task_comments.php
@@ -8,7 +8,9 @@
= Helper\template('comment_show', array(
'comment' => $comment,
'task' => $task,
+ 'project' => $project,
'not_editable' => isset($not_editable) && $not_editable,
+ 'is_public' => isset($is_public) && $is_public,
)) ?>
diff --git a/app/Templates/task_public.php b/app/Templates/task_public.php
index 3f44ceecb..13fef1ed2 100644
--- a/app/Templates/task_public.php
+++ b/app/Templates/task_public.php
@@ -4,10 +4,24 @@
= Helper\a(t('Back to the board'), 'board', 'readonly', array('token' => $project['token'])) ?>
- = Helper\template('task_show_description', array('task' => $task)) ?>
+ = Helper\template('task_show_description', array(
+ 'task' => $task,
+ 'project' => $project,
+ 'is_public' => true
+ )) ?>
- = Helper\template('subtask_show', array('task' => $task, 'subtasks' => $subtasks, 'not_editable' => true)) ?>
+ = Helper\template('subtask_show', array(
+ 'task' => $task,
+ 'subtasks' => $subtasks,
+ 'not_editable' => true
+ )) ?>
- = Helper\template('task_comments', array('task' => $task, 'comments' => $comments, 'not_editable' => true)) ?>
+ = Helper\template('task_comments', array(
+ 'task' => $task,
+ 'comments' => $comments,
+ 'project' => $project,
+ 'not_editable' => true,
+ 'is_public' => true,
+ )) ?>
\ No newline at end of file
diff --git a/app/Templates/task_show.php b/app/Templates/task_show.php
index 0964a8f0f..ec5d5da42 100644
--- a/app/Templates/task_show.php
+++ b/app/Templates/task_show.php
@@ -4,4 +4,4 @@
= Helper\template('subtask_show', array('task' => $task, 'subtasks' => $subtasks)) ?>
= Helper\template('task_timesheet', array('timesheet' => $timesheet)) ?>
= Helper\template('file_show', array('task' => $task, 'files' => $files)) ?>
-= Helper\template('task_comments', array('task' => $task, 'comments' => $comments)) ?>
\ No newline at end of file
+= Helper\template('task_comments', array('task' => $task, 'comments' => $comments, 'project' => $project)) ?>
\ No newline at end of file
diff --git a/app/Templates/task_show_description.php b/app/Templates/task_show_description.php
index 67a384443..253121495 100644
--- a/app/Templates/task_show_description.php
+++ b/app/Templates/task_show_description.php
@@ -5,7 +5,20 @@
- = Helper\markdown($task['description']) ?: t('There is no description.') ?>
+
+ = Helper\markdown($task['description']) ?>
+
+ = Helper\markdown(
+ $task['description'],
+ array(
+ 'controller' => 'task',
+ 'action' => 'readonly',
+ 'params' => array(
+ 'token' => $project['token']
+ )
+ )
+ ) ?>
+
\ No newline at end of file
diff --git a/app/helpers.php b/app/helpers.php
index 9e0c2698f..cd6d630e8 100644
--- a/app/helpers.php
+++ b/app/helpers.php
@@ -103,17 +103,25 @@ function get_user_id()
/**
* Markdown transformation
*
- * @param string $text Markdown content
+ * @param string $text Markdown content
+ * @param array $link Link parameters for replacement
* @return string
*/
-function markdown($text)
+function markdown($text, array $link = array('controller' => 'task', 'action' => 'show', 'params' => array()))
{
$html = Parsedown::instance()
->setMarkupEscaped(true) # escapes markup (HTML)
->text($text);
// Replace task #123 by a link to the task
- $html = preg_replace('!#(\d+)!i', '$0', $html);
+ $html = preg_replace_callback('!#(\d+)!i', function($matches) use ($link) {
+ return a(
+ $matches[0],
+ $link['controller'],
+ $link['action'],
+ $link['params'] + array('task_id' => $matches[1])
+ );
+ }, $html);
return $html;
}