From 34d7450d3c13342715e90ec21bceaa13e1baa876 Mon Sep 17 00:00:00 2001
From: Frédéric Guillot <fred@kanboard.net>
Date: Sun, 28 Dec 2014 11:28:50 -0500
Subject: Template helpers refactoring

---
 app/Template/subtask/create.php | 22 +++++++++++-----------
 app/Template/subtask/edit.php   | 30 +++++++++++++++---------------
 app/Template/subtask/remove.php |  6 +++---
 app/Template/subtask/show.php   | 24 ++++++++++++------------
 4 files changed, 41 insertions(+), 41 deletions(-)

(limited to 'app/Template/subtask')

diff --git a/app/Template/subtask/create.php b/app/Template/subtask/create.php
index 40a6da3d..ba550aea 100644
--- a/app/Template/subtask/create.php
+++ b/app/Template/subtask/create.php
@@ -2,26 +2,26 @@
     <h2><?= t('Add a sub-task') ?></h2>
 </div>
 
-<form method="post" action="<?= Helper\u('subtask', 'save', array('task_id' => $task['id'])) ?>" autocomplete="off">
+<form method="post" action="<?= $this->u('subtask', 'save', array('task_id' => $task['id'])) ?>" autocomplete="off">
 
-    <?= Helper\form_csrf() ?>
+    <?= $this->formCsrf() ?>
 
-    <?= Helper\form_hidden('task_id', $values) ?>
+    <?= $this->formHidden('task_id', $values) ?>
 
-    <?= Helper\form_label(t('Title'), 'title') ?>
-    <?= Helper\form_text('title', $values, $errors, array('required autofocus')) ?><br/>
+    <?= $this->formLabel(t('Title'), 'title') ?>
+    <?= $this->formText('title', $values, $errors, array('required autofocus')) ?><br/>
 
-    <?= Helper\form_label(t('Assignee'), 'user_id') ?>
-    <?= Helper\form_select('user_id', $users_list, $values, $errors) ?><br/>
+    <?= $this->formLabel(t('Assignee'), 'user_id') ?>
+    <?= $this->formSelect('user_id', $users_list, $values, $errors) ?><br/>
 
-    <?= Helper\form_label(t('Original estimate'), 'time_estimated') ?>
-    <?= Helper\form_numeric('time_estimated', $values, $errors) ?> <?= t('hours') ?><br/>
+    <?= $this->formLabel(t('Original estimate'), 'time_estimated') ?>
+    <?= $this->formNumeric('time_estimated', $values, $errors) ?> <?= t('hours') ?><br/>
 
-    <?= Helper\form_checkbox('another_subtask', t('Create another sub-task'), 1, isset($values['another_subtask']) && $values['another_subtask'] == 1) ?>
+    <?= $this->formCheckbox('another_subtask', t('Create another sub-task'), 1, isset($values['another_subtask']) && $values['another_subtask'] == 1) ?>
 
     <div class="form-actions">
         <input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
         <?= t('or') ?>
-        <?= Helper\a(t('cancel'), 'task', 'show', array('task_id' => $task['id'])) ?>
+        <?= $this->a(t('cancel'), 'task', 'show', array('task_id' => $task['id'])) ?>
     </div>
 </form>
diff --git a/app/Template/subtask/edit.php b/app/Template/subtask/edit.php
index 88ea6175..76a04e45 100644
--- a/app/Template/subtask/edit.php
+++ b/app/Template/subtask/edit.php
@@ -2,31 +2,31 @@
     <h2><?= t('Edit a sub-task') ?></h2>
 </div>
 
-<form method="post" action="<?= Helper\u('subtask', 'update', array('task_id' => $task['id'], 'subtask_id' => $subtask['id'])) ?>" autocomplete="off">
+<form method="post" action="<?= $this->u('subtask', 'update', array('task_id' => $task['id'], 'subtask_id' => $subtask['id'])) ?>" autocomplete="off">
 
-    <?= Helper\form_csrf() ?>
+    <?= $this->formCsrf() ?>
 
-    <?= Helper\form_hidden('id', $values) ?>
-    <?= Helper\form_hidden('task_id', $values) ?>
+    <?= $this->formHidden('id', $values) ?>
+    <?= $this->formHidden('task_id', $values) ?>
 
-    <?= Helper\form_label(t('Title'), 'title') ?>
-    <?= Helper\form_text('title', $values, $errors, array('required autofocus')) ?><br/>
+    <?= $this->formLabel(t('Title'), 'title') ?>
+    <?= $this->formText('title', $values, $errors, array('required autofocus')) ?><br/>
 
-    <?= Helper\form_label(t('Status'), 'status') ?>
-    <?= Helper\form_select('status', $status_list, $values, $errors) ?><br/>
+    <?= $this->formLabel(t('Status'), 'status') ?>
+    <?= $this->formSelect('status', $status_list, $values, $errors) ?><br/>
 
-    <?= Helper\form_label(t('Assignee'), 'user_id') ?>
-    <?= Helper\form_select('user_id', $users_list, $values, $errors) ?><br/>
+    <?= $this->formLabel(t('Assignee'), 'user_id') ?>
+    <?= $this->formSelect('user_id', $users_list, $values, $errors) ?><br/>
 
-    <?= Helper\form_label(t('Original estimate'), 'time_estimated') ?>
-    <?= Helper\form_numeric('time_estimated', $values, $errors) ?> <?= t('hours') ?><br/>
+    <?= $this->formLabel(t('Original estimate'), 'time_estimated') ?>
+    <?= $this->formNumeric('time_estimated', $values, $errors) ?> <?= t('hours') ?><br/>
 
-    <?= Helper\form_label(t('Time spent'), 'time_spent') ?>
-    <?= Helper\form_numeric('time_spent', $values, $errors) ?> <?= t('hours') ?><br/>
+    <?= $this->formLabel(t('Time spent'), 'time_spent') ?>
+    <?= $this->formNumeric('time_spent', $values, $errors) ?> <?= t('hours') ?><br/>
 
     <div class="form-actions">
         <input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
         <?= t('or') ?>
-        <?= Helper\a(t('cancel'), 'task', 'show', array('task_id' => $task['id'])) ?>
+        <?= $this->a(t('cancel'), 'task', 'show', array('task_id' => $task['id'])) ?>
     </div>
 </form>
diff --git a/app/Template/subtask/remove.php b/app/Template/subtask/remove.php
index 74245a7a..3d57ec9d 100644
--- a/app/Template/subtask/remove.php
+++ b/app/Template/subtask/remove.php
@@ -7,11 +7,11 @@
         <?= t('Do you really want to remove this sub-task?') ?>
     </p>
 
-    <p><strong><?= Helper\escape($subtask['title']) ?></strong></p>
+    <p><strong><?= $this->e($subtask['title']) ?></strong></p>
 
     <div class="form-actions">
-        <?= Helper\a(t('Yes'), 'subtask', 'remove', array('task_id' => $task['id'], 'subtask_id' => $subtask['id']), true, 'btn btn-red') ?>
+        <?= $this->a(t('Yes'), 'subtask', 'remove', array('task_id' => $task['id'], 'subtask_id' => $subtask['id']), true, 'btn btn-red') ?>
         <?= t('or') ?>
-        <?= Helper\a(t('cancel'), 'task', 'show', array('task_id' => $task['id'])) ?>
+        <?= $this->a(t('cancel'), 'task', 'show', array('task_id' => $task['id'])) ?>
     </div>
 </div>
\ No newline at end of file
diff --git a/app/Template/subtask/show.php b/app/Template/subtask/show.php
index 4d341f26..d0b3a606 100644
--- a/app/Template/subtask/show.php
+++ b/app/Template/subtask/show.php
@@ -17,34 +17,34 @@
         </tr>
         <?php foreach ($subtasks as $subtask): ?>
         <tr>
-            <td><?= Helper\escape($subtask['title']) ?></td>
+            <td><?= $this->e($subtask['title']) ?></td>
             <td>
                 <?php if (! isset($not_editable)): ?>
-                    <?= Helper\a(trim(Helper\template('subtask/icons', array('subtask' => $subtask))) . Helper\escape($subtask['status_name']),
+                    <?= $this->a(trim($this->render('subtask/icons', array('subtask' => $subtask))) . $this->e($subtask['status_name']),
                                  'subtask', 'toggleStatus', array('task_id' => $task['id'], 'subtask_id' => $subtask['id'])) ?>
                 <?php else: ?>
-                    <?= Helper\template('subtask/icons', array('subtask' => $subtask)) . Helper\escape($subtask['status_name']) ?>
+                    <?= $this->render('subtask/icons', array('subtask' => $subtask)) . $this->e($subtask['status_name']) ?>
                 <?php endif ?>
             </td>
             <td>
                 <?php if (! empty($subtask['username'])): ?>
-                    <?= Helper\escape($subtask['name'] ?: $subtask['username']) ?>
+                    <?= $this->e($subtask['name'] ?: $subtask['username']) ?>
                 <?php endif ?>
             </td>
             <td>
                 <?php if (! empty($subtask['time_spent'])): ?>
-                    <strong><?= Helper\escape($subtask['time_spent']).'h' ?></strong> <?= t('spent') ?>
+                    <strong><?= $this->e($subtask['time_spent']).'h' ?></strong> <?= t('spent') ?>
                 <?php endif ?>
 
                 <?php if (! empty($subtask['time_estimated'])): ?>
-                    <strong><?= Helper\escape($subtask['time_estimated']).'h' ?></strong> <?= t('estimated') ?>
+                    <strong><?= $this->e($subtask['time_estimated']).'h' ?></strong> <?= t('estimated') ?>
                 <?php endif ?>
             </td>
             <?php if (! isset($not_editable)): ?>
                 <td>
-                    <?= Helper\a(t('Edit'), 'subtask', 'edit', array('task_id' => $task['id'], 'subtask_id' => $subtask['id'])) ?>
+                    <?= $this->a(t('Edit'), 'subtask', 'edit', array('task_id' => $task['id'], 'subtask_id' => $subtask['id'])) ?>
                     <?= t('or') ?>
-                    <?= Helper\a(t('Remove'), 'subtask', 'confirm', array('task_id' => $task['id'], 'subtask_id' => $subtask['id'])) ?>
+                    <?= $this->a(t('Remove'), 'subtask', 'confirm', array('task_id' => $task['id'], 'subtask_id' => $subtask['id'])) ?>
                 </td>
             <?php endif ?>
         </tr>
@@ -52,10 +52,10 @@
     </table>
 
     <?php if (! isset($not_editable)): ?>
-        <form method="post" action="<?= Helper\u('subtask', 'save', array('task_id' => $task['id'])) ?>" autocomplete="off">
-            <?= Helper\form_csrf() ?>
-            <?= Helper\form_hidden('task_id', array('task_id' => $task['id'])) ?>
-            <?= Helper\form_text('title', array(), array(), array('required', 'placeholder="'.t('Type here to create a new sub-task').'"')) ?>
+        <form method="post" action="<?= $this->u('subtask', 'save', array('task_id' => $task['id'])) ?>" autocomplete="off">
+            <?= $this->formCsrf() ?>
+            <?= $this->formHidden('task_id', array('task_id' => $task['id'])) ?>
+            <?= $this->formText('title', array(), array(), array('required', 'placeholder="'.t('Type here to create a new sub-task').'"')) ?>
             <input type="submit" value="<?= t('Add') ?>" class="btn btn-blue"/>
         </form>
     <?php endif ?>
-- 
cgit v1.2.3