summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/Controller/Comment.php41
-rw-r--r--app/Template/comment/create.php (renamed from app/Template/comment_create.php)4
-rw-r--r--app/Template/comment/edit.php (renamed from app/Template/comment_edit.php)4
-rw-r--r--app/Template/comment/forbidden.php7
-rw-r--r--app/Template/comment/remove.php17
-rw-r--r--app/Template/comment/show.php (renamed from app/Template/comment_show.php)4
-rw-r--r--app/Template/comment_forbidden.php9
-rw-r--r--app/Template/comment_remove.php16
-rw-r--r--app/Template/task_comments.php4
9 files changed, 49 insertions, 57 deletions
diff --git a/app/Controller/Comment.php b/app/Controller/Comment.php
index efa7e066..fb21353e 100644
--- a/app/Controller/Comment.php
+++ b/app/Controller/Comment.php
@@ -25,7 +25,7 @@ class Comment extends Base
}
if (! $this->acl->isAdminUser() && $comment['user_id'] != $this->acl->getUserId()) {
- $this->response->html($this->template->layout('comment_forbidden', array(
+ $this->response->html($this->template->layout('comment/forbidden', array(
'title' => t('Access Forbidden')
)));
}
@@ -38,16 +38,20 @@ class Comment extends Base
*
* @access public
*/
- public function create()
+ public function create(array $values = array(), array $errors = array())
{
$task = $this->getTask();
- $this->response->html($this->taskLayout('comment_create', array(
- 'values' => array(
+ if (empty($values)) {
+ $values = array(
'user_id' => $this->acl->getUserId(),
'task_id' => $task['id'],
- ),
- 'errors' => array(),
+ );
+ }
+
+ $this->response->html($this->taskLayout('comment/create', array(
+ 'values' => $values,
+ 'errors' => $errors,
'task' => $task,
'title' => t('Add a comment')
)));
@@ -77,12 +81,7 @@ class Comment extends Base
$this->response->redirect('?controller=task&action=show&task_id='.$task['id'].'#comments');
}
- $this->response->html($this->taskLayout('comment_create', array(
- 'values' => $values,
- 'errors' => $errors,
- 'task' => $task,
- 'title' => t('Add a comment')
- )));
+ $this->create($values, $errors);
}
/**
@@ -90,14 +89,14 @@ class Comment extends Base
*
* @access public
*/
- public function edit()
+ public function edit(array $values = array(), array $errors = array())
{
$task = $this->getTask();
$comment = $this->getComment();
- $this->response->html($this->taskLayout('comment_edit', array(
- 'values' => $comment,
- 'errors' => array(),
+ $this->response->html($this->taskLayout('comment/edit', array(
+ 'values' => empty($values) ? $comment : $values,
+ 'errors' => $errors,
'comment' => $comment,
'task' => $task,
'title' => t('Edit a comment')
@@ -129,13 +128,7 @@ class Comment extends Base
$this->response->redirect('?controller=task&action=show&task_id='.$task['id'].'#comment-'.$comment['id']);
}
- $this->response->html($this->taskLayout('comment_edit', array(
- 'values' => $values,
- 'errors' => $errors,
- 'comment' => $comment,
- 'task' => $task,
- 'title' => t('Edit a comment')
- )));
+ $this->edit($values, $errors);
}
/**
@@ -148,7 +141,7 @@ class Comment extends Base
$task = $this->getTask();
$comment = $this->getComment();
- $this->response->html($this->taskLayout('comment_remove', array(
+ $this->response->html($this->taskLayout('comment/remove', array(
'comment' => $comment,
'task' => $task,
'title' => t('Remove a comment')
diff --git a/app/Template/comment_create.php b/app/Template/comment/create.php
index 5590b77d..d72fa627 100644
--- a/app/Template/comment_create.php
+++ b/app/Template/comment/create.php
@@ -2,7 +2,7 @@
<h2><?= t('Add a comment') ?></h2>
</div>
-<form method="post" action="?controller=comment&amp;action=save&amp;task_id=<?= $task['id'] ?>" autocomplete="off">
+<form method="post" action="<?= Helper\u('comment', 'save', array('task_id' => $task['id'])) ?>" autocomplete="off">
<?= Helper\form_csrf() ?>
<?= Helper\form_hidden('task_id', $values) ?>
<?= Helper\form_hidden('user_id', $values) ?>
@@ -30,7 +30,7 @@
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
<?php if (! isset($skip_cancel)): ?>
<?= t('or') ?>
- <a href="?controller=task&amp;action=show&amp;task_id=<?= $task['id'] ?>"><?= t('cancel') ?></a>
+ <?= Helper\a(t('cancel'), 'task', 'show', array('task_id' => $task['id'])) ?>
<?php endif ?>
</div>
</form>
diff --git a/app/Template/comment_edit.php b/app/Template/comment/edit.php
index 96b7a872..386dd9b1 100644
--- a/app/Template/comment_edit.php
+++ b/app/Template/comment/edit.php
@@ -2,7 +2,7 @@
<h2><?= t('Edit a comment') ?></h2>
</div>
-<form method="post" action="?controller=comment&amp;action=update&amp;task_id=<?= $task['id'] ?>&amp;comment_id=<?= $comment['id'] ?>" autocomplete="off">
+<form method="post" action="<?= Helper\u('comment', 'update', array('task_id' => $task['id'], 'comment_id' => $comment['id'])) ?>" autocomplete="off">
<?= Helper\form_csrf() ?>
<?= Helper\form_hidden('id', $values) ?>
@@ -30,6 +30,6 @@
<div class="form-actions">
<input type="submit" value="<?= t('Update') ?>" class="btn btn-blue"/>
<?= t('or') ?>
- <a href="?controller=task&amp;action=show&amp;task_id=<?= $task['id'] ?>"><?= t('cancel') ?></a>
+ <?= Helper\a(t('cancel'), 'task', 'show', array('task_id' => $task['id'])) ?>
</div>
</form>
diff --git a/app/Template/comment/forbidden.php b/app/Template/comment/forbidden.php
new file mode 100644
index 00000000..1e306d45
--- /dev/null
+++ b/app/Template/comment/forbidden.php
@@ -0,0 +1,7 @@
+<div class="page-header">
+ <h2><?= t('Forbidden') ?></h2>
+</div>
+
+<p class="alert alert-error">
+ <?= t('Only administrators or the creator of the comment can access to this page.') ?>
+</p> \ No newline at end of file
diff --git a/app/Template/comment/remove.php b/app/Template/comment/remove.php
new file mode 100644
index 00000000..50382369
--- /dev/null
+++ b/app/Template/comment/remove.php
@@ -0,0 +1,17 @@
+<div class="page-header">
+ <h2><?= t('Remove a comment') ?></h2>
+</div>
+
+<div class="confirm">
+ <p class="alert alert-info">
+ <?= t('Do you really want to remove this comment?') ?>
+ </p>
+
+ <?= Helper\template('comment/show', array('comment' => $comment, 'task' => $task, 'preview' => true)) ?>
+
+ <div class="form-actions">
+ <?= Helper\a(t('Yes'), 'comment', 'remove', array('task_id' => $task['id'], 'comment_id' => $comment['id']), true, 'btn btn-red') ?>
+ <?= t('or') ?>
+ <?= Helper\a(t('cancel'), 'task', 'show', array('task_id' => $task['id'])) ?>
+ </div>
+</div> \ No newline at end of file
diff --git a/app/Template/comment_show.php b/app/Template/comment/show.php
index b2ccc25a..5e1e9337 100644
--- a/app/Template/comment_show.php
+++ b/app/Template/comment/show.php
@@ -11,10 +11,10 @@
<li><a href="#comment-<?= $comment['id'] ?>"><?= t('link') ?></a></li>
<?php if ((! isset($not_editable) || ! $not_editable) && (Helper\is_admin() || Helper\is_current_user($comment['user_id']))): ?>
<li>
- <a href="?controller=comment&amp;action=confirm&amp;task_id=<?= $task['id'] ?>&amp;comment_id=<?= $comment['id'] ?>"><?= t('remove') ?></a>
+ <?= Helper\a(t('remove'), 'comment', 'confirm', array('task_id' => $task['id'], 'comment_id' => $comment['id'])) ?>
</li>
<li>
- <a href="?controller=comment&amp;action=edit&amp;task_id=<?= $task['id'] ?>&amp;comment_id=<?= $comment['id'] ?>"><?= t('edit') ?></a>
+ <?= Helper\a(t('edit'), 'comment', 'edit', array('task_id' => $task['id'], 'comment_id' => $comment['id'])) ?>
</li>
<?php endif ?>
</ul>
diff --git a/app/Template/comment_forbidden.php b/app/Template/comment_forbidden.php
deleted file mode 100644
index eeea8404..00000000
--- a/app/Template/comment_forbidden.php
+++ /dev/null
@@ -1,9 +0,0 @@
-<section id="main">
- <div class="page-header">
- <h2><?= t('Forbidden') ?></h2>
- </div>
-
- <p class="alert alert-error">
- <?= t('Only administrators or the creator of the comment can access to this page.') ?>
- </p>
-</section> \ No newline at end of file
diff --git a/app/Template/comment_remove.php b/app/Template/comment_remove.php
deleted file mode 100644
index 7b117781..00000000
--- a/app/Template/comment_remove.php
+++ /dev/null
@@ -1,16 +0,0 @@
-<div class="page-header">
- <h2><?= t('Remove a comment') ?></h2>
-</div>
-
-<div class="confirm">
- <p class="alert alert-info">
- <?= t('Do you really want to remove this comment?') ?>
- </p>
-
- <?= Helper\template('comment_show', array('comment' => $comment, 'task' => $task, 'preview' => true)) ?>
-
- <div class="form-actions">
- <a href="?controller=comment&amp;action=remove&amp;task_id=<?= $task['id'] ?>&amp;comment_id=<?= $comment['id'].Helper\param_csrf() ?>" class="btn btn-red"><?= t('Yes') ?></a>
- <?= t('or') ?> <a href="?controller=task&amp;action=show&amp;task_id=<?= $task['id'] ?>#comment-<?= $comment['id'] ?>"><?= t('cancel') ?></a>
- </div>
-</div> \ No newline at end of file
diff --git a/app/Template/task_comments.php b/app/Template/task_comments.php
index 5cfa99ce..343e66c5 100644
--- a/app/Template/task_comments.php
+++ b/app/Template/task_comments.php
@@ -5,7 +5,7 @@
</div>
<?php foreach ($comments as $comment): ?>
- <?= Helper\template('comment_show', array(
+ <?= Helper\template('comment/show', array(
'comment' => $comment,
'task' => $task,
'project' => $project,
@@ -15,7 +15,7 @@
<?php endforeach ?>
<?php if (! isset($not_editable)): ?>
- <?= Helper\template('comment_create', array(
+ <?= Helper\template('comment/create', array(
'skip_cancel' => true,
'values' => array(
'user_id' => Helper\get_user_id(),