Move comment templates to a subfolder

This commit is contained in:
Frédéric Guillot 2014-11-25 21:28:29 -05:00
parent cdfd6a8abe
commit 5fb686dd9c
9 changed files with 49 additions and 57 deletions

View File

@ -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')

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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(),