summaryrefslogtreecommitdiff
path: root/app/Helper
diff options
context:
space:
mode:
Diffstat (limited to 'app/Helper')
-rw-r--r--app/Helper/BoardHelper.php3
-rw-r--r--app/Helper/FormHelper.php42
-rw-r--r--app/Helper/HookHelper.php53
-rw-r--r--app/Helper/SubtaskHelper.php5
-rw-r--r--app/Helper/TaskHelper.php27
5 files changed, 103 insertions, 27 deletions
diff --git a/app/Helper/BoardHelper.php b/app/Helper/BoardHelper.php
index a86a6c18..f5df3db2 100644
--- a/app/Helper/BoardHelper.php
+++ b/app/Helper/BoardHelper.php
@@ -3,6 +3,7 @@
namespace Kanboard\Helper;
use Kanboard\Core\Base;
+use Kanboard\Model\UserMetadataModel;
/**
* Board Helper
@@ -21,6 +22,6 @@ class BoardHelper extends Base
*/
public function isCollapsed($project_id)
{
- return $this->userSession->isBoardCollapsed($project_id);
+ return $this->userMetadataCacheDecorator->get(UserMetadataModel::KEY_BOARD_COLLAPSED.$project_id, 0) == 1;
}
}
diff --git a/app/Helper/FormHelper.php b/app/Helper/FormHelper.php
index c2ea1d72..0bb94d39 100644
--- a/app/Helper/FormHelper.php
+++ b/app/Helper/FormHelper.php
@@ -307,6 +307,48 @@ class FormHelper extends Base
}
/**
+ * Date field
+ *
+ * @access public
+ * @param string $label
+ * @param string $name
+ * @param array $values
+ * @param array $errors
+ * @param array $attributes
+ * @return string
+ */
+ public function date($label, $name, array $values, array $errors = array(), array $attributes = array())
+ {
+ $userFormat = $this->dateParser->getUserDateFormat();
+ $values = $this->dateParser->format($values, array($name), $userFormat);
+ $attributes = array_merge(array('placeholder="'.date($userFormat).'"'), $attributes);
+
+ return $this->helper->form->label($label, $name) .
+ $this->helper->form->text($name, $values, $errors, $attributes, 'form-date');
+ }
+
+ /**
+ * Datetime field
+ *
+ * @access public
+ * @param string $label
+ * @param string $name
+ * @param array $values
+ * @param array $errors
+ * @param array $attributes
+ * @return string
+ */
+ public function datetime($label, $name, array $values, array $errors = array(), array $attributes = array())
+ {
+ $userFormat = $this->dateParser->getUserDateTimeFormat();
+ $values = $this->dateParser->format($values, array($name), $userFormat);
+ $attributes = array_merge(array('placeholder="'.date($userFormat).'"'), $attributes);
+
+ return $this->helper->form->label($label, $name) .
+ $this->helper->form->text($name, $values, $errors, $attributes, 'form-datetime');
+ }
+
+ /**
* Display the form error class
*
* @access private
diff --git a/app/Helper/HookHelper.php b/app/Helper/HookHelper.php
index cb4dc1ef..24b7d00a 100644
--- a/app/Helper/HookHelper.php
+++ b/app/Helper/HookHelper.php
@@ -2,6 +2,7 @@
namespace Kanboard\Helper;
+use Closure;
use Kanboard\Core\Base;
/**
@@ -24,8 +25,8 @@ class HookHelper extends Base
{
$buffer = '';
- foreach ($this->hook->getListeners($hook) as $file) {
- $buffer .= $this->helper->asset->$type($file);
+ foreach ($this->hook->getListeners($hook) as $params) {
+ $buffer .= $this->helper->asset->$type($params['template']);
}
return $buffer;
@@ -43,8 +44,18 @@ class HookHelper extends Base
{
$buffer = '';
- foreach ($this->hook->getListeners($hook) as $template) {
- $buffer .= $this->template->render($template, $variables);
+ foreach ($this->hook->getListeners($hook) as $params) {
+ if (! empty($params['variables'])) {
+ $variables = array_merge($variables, $params['variables']);
+ } elseif (! empty($params['callable'])) {
+ $result = call_user_func_array($params['callable'], $variables);
+
+ if (is_array($result)) {
+ $variables = array_merge($variables, $result);
+ }
+ }
+
+ $buffer .= $this->template->render($params['template'], $variables);
}
return $buffer;
@@ -54,13 +65,39 @@ class HookHelper extends Base
* Attach a template to a hook
*
* @access public
- * @param string $hook
- * @param string $template
+ * @param string $hook
+ * @param string $template
+ * @param array $variables
* @return $this
*/
- public function attach($hook, $template)
+ public function attach($hook, $template, array $variables = array())
{
- $this->hook->on($hook, $template);
+ $this->hook->on($hook, array(
+ 'template' => $template,
+ 'variables' => $variables,
+ ));
+
+ return $this;
+ }
+
+ /**
+ * Attach a template to a hook with a callable
+ *
+ * Arguments passed to the callback are the one passed to the hook
+ *
+ * @access public
+ * @param string $hook
+ * @param string $template
+ * @param Closure $callable
+ * @return $this
+ */
+ public function attachCallable($hook, $template, Closure $callable)
+ {
+ $this->hook->on($hook, array(
+ 'template' => $template,
+ 'callable' => $callable,
+ ));
+
return $this;
}
}
diff --git a/app/Helper/SubtaskHelper.php b/app/Helper/SubtaskHelper.php
index dac71203..833544a7 100644
--- a/app/Helper/SubtaskHelper.php
+++ b/app/Helper/SubtaskHelper.php
@@ -66,7 +66,10 @@ class SubtaskHelper extends Base
$html = $this->helper->form->label(t('Assignee'), 'user_id');
$html .= $this->helper->form->select('user_id', $users, $values, $errors, $attributes);
- $html .= '&nbsp;<a href="#" class="assign-me" data-target-id="form-user_id" data-current-id="'.$this->userSession->getId().'" title="'.t('Assign to me').'">'.t('Me').'</a>';
+ $html .= '&nbsp;';
+ $html .= '<small>';
+ $html .= '<a href="#" class="assign-me" data-target-id="form-user_id" data-current-id="'.$this->userSession->getId().'" title="'.t('Assign to me').'">'.t('Me').'</a>';
+ $html .= '</small>';
return $html;
}
diff --git a/app/Helper/TaskHelper.php b/app/Helper/TaskHelper.php
index 481a5efb..678b4bed 100644
--- a/app/Helper/TaskHelper.php
+++ b/app/Helper/TaskHelper.php
@@ -103,7 +103,10 @@ class TaskHelper extends Base
$html = $this->helper->form->label(t('Assignee'), 'owner_id');
$html .= $this->helper->form->select('owner_id', $users, $values, $errors, $attributes);
- $html .= '&nbsp;<a href="#" class="assign-me" data-target-id="form-owner_id" data-current-id="'.$this->userSession->getId().'" title="'.t('Assign to me').'">'.t('Me').'</a>';
+ $html .= '&nbsp;';
+ $html .= '<small>';
+ $html .= '<a href="#" class="assign-me" data-target-id="form-owner_id" data-current-id="'.$this->userSession->getId().'" title="'.t('Assign to me').'">'.t('Me').'</a>';
+ $html .= '</small>';
return $html;
}
@@ -148,7 +151,7 @@ class TaskHelper extends Base
{
$html = '';
- if ($project['priority_end'] > $project['priority_start']) {
+ if ($project['priority_end'] != $project['priority_start']) {
$range = range($project['priority_start'], $project['priority_end']);
$options = array_combine($range, $range);
$values += array('priority' => $project['priority_default']);
@@ -204,31 +207,21 @@ class TaskHelper extends Base
public function selectStartDate(array $values, array $errors = array(), array $attributes = array())
{
- $placeholder = date($this->configModel->get('application_date_format', 'm/d/Y H:i'));
- $attributes = array_merge(array('tabindex="12"', 'placeholder="'.$placeholder.'"'), $attributes);
-
- $html = $this->helper->form->label(t('Start Date'), 'date_started');
- $html .= $this->helper->form->text('date_started', $values, $errors, $attributes, 'form-datetime');
-
- return $html;
+ $attributes = array_merge(array('tabindex="12"'), $attributes);
+ return $this->helper->form->datetime(t('Start Date'), 'date_started', $values, $errors, $attributes);
}
public function selectDueDate(array $values, array $errors = array(), array $attributes = array())
{
- $placeholder = date($this->configModel->get('application_date_format', 'm/d/Y'));
- $attributes = array_merge(array('tabindex="13"', 'placeholder="'.$placeholder.'"'), $attributes);
-
- $html = $this->helper->form->label(t('Due Date'), 'date_due');
- $html .= $this->helper->form->text('date_due', $values, $errors, $attributes, 'form-date');
-
- return $html;
+ $attributes = array_merge(array('tabindex="13"'), $attributes);
+ return $this->helper->form->date(t('Due Date'), 'date_due', $values, $errors, $attributes);
}
public function formatPriority(array $project, array $task)
{
$html = '';
- if ($project['priority_end'] > $project['priority_start']) {
+ if ($project['priority_end'] != $project['priority_start']) {
$html .= '<span class="task-board-priority" title="'.t('Task priority').'">';
$html .= $task['priority'] >= 0 ? 'P'.$task['priority'] : '-P'.abs($task['priority']);
$html .= '</span>';