diff options
author | Frederic Guillot <fred@kanboard.net> | 2017-10-12 15:25:13 -0700 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2017-10-12 15:25:13 -0700 |
commit | 7c52546ed2b5ed724d19af95fe97726ab6156291 (patch) | |
tree | ad48580069860a4ef8970805615cdaad0a8f857d | |
parent | 4bb422b41fd995cb67c41ad4b7ba155a84c6f1eb (diff) |
Generate a link if the reference is a URL
-rw-r--r-- | app/Helper/TaskHelper.php | 15 | ||||
-rw-r--r-- | app/Template/board/task_footer.php | 2 | ||||
-rw-r--r-- | app/Template/task/details.php | 2 | ||||
-rw-r--r-- | app/Template/task_list/task_icons.php | 2 |
4 files changed, 18 insertions, 3 deletions
diff --git a/app/Helper/TaskHelper.php b/app/Helper/TaskHelper.php index 3b9e9745..065ece10 100644 --- a/app/Helper/TaskHelper.php +++ b/app/Helper/TaskHelper.php @@ -220,6 +220,21 @@ class TaskHelper extends Base return $html; } + public function renderReference(array $task) + { + if (! empty($task['reference'])) { + $reference = $this->helper->text->e($task['reference']); + + if (filter_var($task['reference'], FILTER_VALIDATE_URL) !== false) { + return sprintf('<a href="%s" target=_blank">%s</a>', $reference, $reference); + } + + return $reference; + } + + return ''; + } + public function getProgress($task) { if (! isset($this->columns[$task['project_id']])) { diff --git a/app/Template/board/task_footer.php b/app/Template/board/task_footer.php index c78616e9..4ea5bb31 100644 --- a/app/Template/board/task_footer.php +++ b/app/Template/board/task_footer.php @@ -32,7 +32,7 @@ <div class="task-board-icons-row"> <?php if ($task['reference']): ?> <span class="task-board-reference" title="<?= t('Reference') ?>"> - <?= $this->text->e($task['reference']) ?> + <?= $this->task->renderReference($task) ?> </span> <?php endif ?> </div> diff --git a/app/Template/task/details.php b/app/Template/task/details.php index a42e09d1..3b4d4b38 100644 --- a/app/Template/task/details.php +++ b/app/Template/task/details.php @@ -22,7 +22,7 @@ </li> <?php if (! empty($task['reference'])): ?> <li> - <strong><?= t('Reference:') ?></strong> <span><?= $this->text->e($task['reference']) ?></span> + <strong><?= t('Reference:') ?></strong> <span><?= $this->task->renderReference($task) ?></span> </li> <?php endif ?> <?php if (! empty($task['score'])): ?> diff --git a/app/Template/task_list/task_icons.php b/app/Template/task_list/task_icons.php index 03a891a2..d02c9021 100644 --- a/app/Template/task_list/task_icons.php +++ b/app/Template/task_list/task_icons.php @@ -1,7 +1,7 @@ <div class="task-list-icons"> <?php if ($task['reference']): ?> <span class="task-board-reference" title="<?= t('Reference') ?>"> - <?= $this->text->e($task['reference']) ?> + <?= $this->task->renderReference($task) ?> </span> <?php endif ?> <?php if ($task['is_milestone'] == 1): ?> |