Simplify layout and templates generation

This commit is contained in:
Frederic Guillot 2016-01-31 21:44:49 -05:00
parent 271543431e
commit 26492aba7e
51 changed files with 282 additions and 320 deletions

View File

@ -26,6 +26,7 @@ Improvements:
* Have a new task assigned to the creator by default instead of "no assignee"
* Show progress for task links in board tooltips
* Simplify code to handle ajax popover and redirects
* Simplify layout and templates generation
* Move task form elements to Task helper
Version 1.0.24

View File

@ -20,7 +20,7 @@ class Action extends Base
$project = $this->getProject();
$actions = $this->action->getAllByProject($project['id']);
$this->response->html($this->projectLayout('action/index', array(
$this->response->html($this->helper->layout->project('action/index', array(
'values' => array('project_id' => $project['id']),
'project' => $project,
'actions' => $actions,
@ -51,7 +51,7 @@ class Action extends Base
$this->response->redirect($this->helper->url->to('action', 'index', array('project_id' => $project['id'])));
}
$this->response->html($this->projectLayout('action/event', array(
$this->response->html($this->helper->layout->project('action/event', array(
'values' => $values,
'project' => $project,
'events' => $this->actionManager->getCompatibleEvents($values['action_name']),
@ -83,7 +83,7 @@ class Action extends Base
$projects_list = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
unset($projects_list[$project['id']]);
$this->response->html($this->projectLayout('action/params', array(
$this->response->html($this->helper->layout->project('action/params', array(
'values' => $values,
'action_params' => $action_params,
'columns_list' => $this->board->getColumnsList($project['id']),
@ -138,7 +138,7 @@ class Action extends Base
{
$project = $this->getProject();
$this->response->html($this->projectLayout('action/remove', array(
$this->response->html($this->helper->layout->project('action/remove', array(
'action' => $this->action->getById($this->request->getIntegerParam('action_id')),
'available_events' => $this->eventManager->getAll(),
'available_actions' => $this->actionManager->getAvailableActions(),

View File

@ -19,8 +19,7 @@ class Activity extends Base
{
$project = $this->getProject();
$this->response->html($this->template->layout('activity/project', array(
'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
$this->response->html($this->helper->layout->app('activity/project', array(
'events' => $this->projectActivity->getProject($project['id']),
'project' => $project,
'title' => t('%s\'s activity', $project['name'])
@ -36,7 +35,7 @@ class Activity extends Base
{
$task = $this->getTask();
$this->response->html($this->taskLayout('activity/task', array(
$this->response->html($this->helper->layout->task('activity/task', array(
'title' => $task['title'],
'task' => $task,
'events' => $this->projectActivity->getTask($task['id']),

View File

@ -1,6 +1,7 @@
<?php
namespace Kanboard\Controller;
use Kanboard\Model\Task as TaskModel;
/**
@ -11,22 +12,6 @@ use Kanboard\Model\Task as TaskModel;
*/
class Analytic extends Base
{
/**
* Common layout for analytic views
*
* @access private
* @param string $template Template name
* @param array $params Template parameters
* @return string
*/
private function layout($template, array $params)
{
$params['board_selector'] = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
$params['content_for_sublayout'] = $this->template->render($template, $params);
return $this->template->layout('analytic/layout', $params);
}
/**
* Show average Lead and Cycle time
*
@ -37,7 +22,7 @@ class Analytic extends Base
$project = $this->getProject();
list($from, $to) = $this->getDates();
$this->response->html($this->layout('analytic/lead_cycle_time', array(
$this->response->html($this->helper->layout->analytic('analytic/lead_cycle_time', array(
'values' => array(
'from' => $from,
'to' => $to,
@ -69,7 +54,7 @@ class Analytic extends Base
->setQuery($query)
->calculate();
$this->response->html($this->layout('analytic/compare_hours', array(
$this->response->html($this->helper->layout->analytic('analytic/compare_hours', array(
'project' => $project,
'paginator' => $paginator,
'metrics' => $this->estimatedTimeComparisonAnalytic->build($project['id']),
@ -86,7 +71,7 @@ class Analytic extends Base
{
$project = $this->getProject();
$this->response->html($this->layout('analytic/avg_time_columns', array(
$this->response->html($this->helper->layout->analytic('analytic/avg_time_columns', array(
'project' => $project,
'metrics' => $this->averageTimeSpentColumnAnalytic->build($project['id']),
'title' => t('Average time spent into each column for "%s"', $project['name']),
@ -102,7 +87,7 @@ class Analytic extends Base
{
$project = $this->getProject();
$this->response->html($this->layout('analytic/tasks', array(
$this->response->html($this->helper->layout->analytic('analytic/tasks', array(
'project' => $project,
'metrics' => $this->taskDistributionAnalytic->build($project['id']),
'title' => t('Task repartition for "%s"', $project['name']),
@ -118,7 +103,7 @@ class Analytic extends Base
{
$project = $this->getProject();
$this->response->html($this->layout('analytic/users', array(
$this->response->html($this->helper->layout->analytic('analytic/users', array(
'project' => $project,
'metrics' => $this->userDistributionAnalytic->build($project['id']),
'title' => t('User repartition for "%s"', $project['name']),
@ -160,7 +145,7 @@ class Analytic extends Base
$display_graph = $this->projectDailyColumnStats->countDays($project['id'], $from, $to) >= 2;
$this->response->html($this->layout($template, array(
$this->response->html($this->helper->layout->analytic($template, array(
'values' => array(
'from' => $from,
'to' => $to,

View File

@ -12,22 +12,6 @@ use Kanboard\Model\Subtask as SubtaskModel;
*/
class App extends Base
{
/**
* Common layout for dashboard views
*
* @access private
* @param string $template Template name
* @param array $params Template parameters
* @return string
*/
private function layout($template, array $params)
{
$params['board_selector'] = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
$params['content_for_sublayout'] = $this->template->render($template, $params);
return $this->template->layout('app/layout', $params);
}
/**
* Get project pagination
*
@ -101,7 +85,7 @@ class App extends Base
{
$user = $this->getUser();
$this->response->html($this->layout('app/overview', array(
$this->response->html($this->helper->layout->dashboard('app/overview', array(
'title' => t('Dashboard'),
'project_paginator' => $this->getProjectPaginator($user['id'], 'index', 10),
'task_paginator' => $this->getTaskPaginator($user['id'], 'index', 10),
@ -119,7 +103,7 @@ class App extends Base
{
$user = $this->getUser();
$this->response->html($this->layout('app/tasks', array(
$this->response->html($this->helper->layout->dashboard('app/tasks', array(
'title' => t('My tasks'),
'paginator' => $this->getTaskPaginator($user['id'], 'tasks', 50),
'user' => $user,
@ -135,7 +119,7 @@ class App extends Base
{
$user = $this->getUser();
$this->response->html($this->layout('app/subtasks', array(
$this->response->html($this->helper->layout->dashboard('app/subtasks', array(
'title' => t('My subtasks'),
'paginator' => $this->getSubtaskPaginator($user['id'], 'subtasks', 50),
'user' => $user,
@ -151,7 +135,7 @@ class App extends Base
{
$user = $this->getUser();
$this->response->html($this->layout('app/projects', array(
$this->response->html($this->helper->layout->dashboard('app/projects', array(
'title' => t('My projects'),
'paginator' => $this->getProjectPaginator($user['id'], 'projects', 25),
'user' => $user,
@ -167,7 +151,7 @@ class App extends Base
{
$user = $this->getUser();
$this->response->html($this->layout('app/activity', array(
$this->response->html($this->helper->layout->dashboard('app/activity', array(
'title' => t('My activity stream'),
'events' => $this->projectActivity->getProjects($this->projectPermission->getActiveProjectIds($user['id']), 100),
'user' => $user,
@ -181,7 +165,7 @@ class App extends Base
*/
public function calendar()
{
$this->response->html($this->layout('app/calendar', array(
$this->response->html($this->helper->layout->dashboard('app/calendar', array(
'title' => t('My calendar'),
'user' => $this->getUser(),
)));
@ -196,7 +180,7 @@ class App extends Base
{
$user = $this->getUser();
$this->response->html($this->layout('app/notifications', array(
$this->response->html($this->helper->layout->dashboard('app/notifications', array(
'title' => t('My notifications'),
'notifications' => $this->userUnreadNotification->getAll($user['id']),
'user' => $user,

View File

@ -21,7 +21,7 @@ class Auth extends Base
$this->response->redirect($this->helper->url->to('app', 'index'));
}
$this->response->html($this->template->layout('auth/index', array(
$this->response->html($this->helper->layout->app('auth/index', array(
'captcha' => ! empty($values['username']) && $this->userLocking->hasCaptcha($values['username']),
'errors' => $errors,
'values' => $values,

View File

@ -131,7 +131,7 @@ abstract class Base extends \Kanboard\Core\Base
*/
protected function notfound($no_layout = false)
{
$this->response->html($this->template->layout('app/notfound', array(
$this->response->html($this->helper->layout->app('app/notfound', array(
'title' => t('Page not found'),
'no_layout' => $no_layout,
)));
@ -149,7 +149,7 @@ abstract class Base extends \Kanboard\Core\Base
$this->response->text('Access Forbidden', 403);
}
$this->response->html($this->template->layout('app/forbidden', array(
$this->response->html($this->helper->layout->app('app/forbidden', array(
'title' => t('Access Forbidden'),
'no_layout' => $no_layout,
)));
@ -179,48 +179,6 @@ abstract class Base extends \Kanboard\Core\Base
}
}
/**
* Common layout for task views
*
* @access protected
* @param string $template Template name
* @param array $params Template parameters
* @return string
*/
protected function taskLayout($template, array $params)
{
$content = $this->template->render($template, $params);
if ($this->request->isAjax()) {
return $content;
}
$params['title'] = $params['task']['project_name'].' &gt; '.$params['task']['title'];
$params['task_content_for_layout'] = $content;
$params['board_selector'] = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
return $this->template->layout('task/layout', $params);
}
/**
* Common layout for project views
*
* @access protected
* @param string $template Template name
* @param array $params Template parameters
* @return string
*/
protected function projectLayout($template, array $params, $sidebar_template = 'project/sidebar')
{
$content = $this->template->render($template, $params);
$params['project_content_for_layout'] = $content;
$params['title'] = $params['project']['name'] === $params['title'] ? $params['title'] : $params['project']['name'].' &gt; '.$params['title'];
$params['board_selector'] = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
$params['sidebar_template'] = $sidebar_template;
return $this->template->layout('project/layout', $params);
}
/**
* Common method to get a task for task views
*

View File

@ -27,7 +27,7 @@ class Board extends Base
}
// Display the board with a specific layout
$this->response->html($this->template->layout('board/view_public', array(
$this->response->html($this->helper->layout->app('board/view_public', array(
'project' => $project,
'swimlanes' => $this->board->getBoard($project['id']),
'title' => $project['name'],
@ -49,7 +49,7 @@ class Board extends Base
{
$params = $this->getProjectFilters('board', 'show');
$this->response->html($this->template->layout('board/view_private', array(
$this->response->html($this->helper->layout->app('board/view_private', array(
'categories_list' => $this->category->getList($params['project']['id'], false),
'users_list' => $this->projectUserRole->getAssignableUsersList($params['project']['id'], false),
'custom_filters_list' => $this->customFilter->getAll($params['project']['id'], $this->userSession->getId()),

View File

@ -20,7 +20,7 @@ class Calendar extends Base
*/
public function show()
{
$this->response->html($this->template->layout('calendar/show', array(
$this->response->html($this->helper->layout->app('calendar/show', array(
'check_interval' => $this->config->get('board_private_refresh_interval'),
) + $this->getProjectFilters('calendar', 'show')));
}

View File

@ -38,7 +38,7 @@ class Category extends Base
{
$project = $this->getProject();
$this->response->html($this->projectLayout('category/index', array(
$this->response->html($this->helper->layout->project('category/index', array(
'categories' => $this->category->getList($project['id'], false),
'values' => $values + array('project_id' => $project['id']),
'errors' => $errors,
@ -81,7 +81,7 @@ class Category extends Base
$project = $this->getProject();
$category = $this->getCategory($project['id']);
$this->response->html($this->projectLayout('category/edit', array(
$this->response->html($this->helper->layout->project('category/edit', array(
'values' => empty($values) ? $category : $values,
'errors' => $errors,
'project' => $project,
@ -123,7 +123,7 @@ class Category extends Base
$project = $this->getProject();
$category = $this->getCategory($project['id']);
$this->response->html($this->projectLayout('category/remove', array(
$this->response->html($this->helper->layout->project('category/remove', array(
'project' => $project,
'category' => $category,
'title' => t('Remove a category')

View File

@ -26,7 +26,7 @@ class Column extends Base
$values['task_limit['.$column['id'].']'] = $column['task_limit'] ?: null;
}
$this->response->html($this->projectLayout('column/index', array(
$this->response->html($this->helper->layout->project('column/index', array(
'errors' => $errors,
'values' => $values + array('project_id' => $project['id']),
'columns' => $columns,
@ -75,7 +75,7 @@ class Column extends Base
$project = $this->getProject();
$column = $this->board->getColumn($this->request->getIntegerParam('column_id'));
$this->response->html($this->projectLayout('column/edit', array(
$this->response->html($this->helper->layout->project('column/edit', array(
'errors' => $errors,
'values' => $values ?: $column,
'project' => $project,
@ -136,7 +136,7 @@ class Column extends Base
{
$project = $this->getProject();
$this->response->html($this->projectLayout('column/remove', array(
$this->response->html($this->helper->layout->project('column/remove', array(
'column' => $this->board->getColumn($this->request->getIntegerParam('column_id')),
'project' => $project,
'title' => t('Remove a column from a board')

View File

@ -47,7 +47,7 @@ class Comment extends Base
);
}
$this->response->html($this->taskLayout('comment/create', array(
$this->response->html($this->helper->layout->task('comment/create', array(
'values' => $values,
'errors' => $errors,
'task' => $task,
@ -90,7 +90,7 @@ class Comment extends Base
$task = $this->getTask();
$comment = $this->getComment();
$this->response->html($this->taskLayout('comment/edit', array(
$this->response->html($this->helper->layout->task('comment/edit', array(
'values' => empty($values) ? $comment : $values,
'errors' => $errors,
'comment' => $comment,
@ -135,7 +135,7 @@ class Comment extends Base
$task = $this->getTask();
$comment = $this->getComment();
$this->response->html($this->taskLayout('comment/remove', array(
$this->response->html($this->helper->layout->task('comment/remove', array(
'comment' => $comment,
'task' => $task,
'title' => t('Remove a comment')

View File

@ -10,24 +10,6 @@ namespace Kanboard\Controller;
*/
class Config extends Base
{
/**
* Common layout for config views
*
* @access private
* @param string $template Template name
* @param array $params Template parameters
* @return string
*/
private function layout($template, array $params)
{
$params['board_selector'] = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
$params['values'] = $this->config->getAll();
$params['errors'] = array();
$params['config_content_for_layout'] = $this->template->render($template, $params);
return $this->template->layout('config/layout', $params);
}
/**
* Common method between pages
*
@ -72,7 +54,7 @@ class Config extends Base
*/
public function index()
{
$this->response->html($this->layout('config/about', array(
$this->response->html($this->helper->layout->config('config/about', array(
'db_size' => $this->config->getDatabaseSize(),
'title' => t('Settings').' &gt; '.t('About'),
)));
@ -85,7 +67,7 @@ class Config extends Base
*/
public function plugins()
{
$this->response->html($this->layout('config/plugins', array(
$this->response->html($this->helper->layout->config('config/plugins', array(
'plugins' => $this->pluginLoader->plugins,
'title' => t('Settings').' &gt; '.t('Plugins'),
)));
@ -100,7 +82,7 @@ class Config extends Base
{
$this->common('application');
$this->response->html($this->layout('config/application', array(
$this->response->html($this->helper->layout->config('config/application', array(
'languages' => $this->config->getLanguages(),
'timezones' => $this->config->getTimezones(),
'date_formats' => $this->dateParser->getAvailableFormats(),
@ -117,7 +99,7 @@ class Config extends Base
{
$this->common('project');
$this->response->html($this->layout('config/project', array(
$this->response->html($this->helper->layout->config('config/project', array(
'colors' => $this->color->getList(),
'default_columns' => implode(', ', $this->board->getDefaultColumns()),
'title' => t('Settings').' &gt; '.t('Project settings'),
@ -133,7 +115,7 @@ class Config extends Base
{
$this->common('board');
$this->response->html($this->layout('config/board', array(
$this->response->html($this->helper->layout->config('config/board', array(
'title' => t('Settings').' &gt; '.t('Board settings'),
)));
}
@ -147,7 +129,7 @@ class Config extends Base
{
$this->common('calendar');
$this->response->html($this->layout('config/calendar', array(
$this->response->html($this->helper->layout->config('config/calendar', array(
'title' => t('Settings').' &gt; '.t('Calendar settings'),
)));
}
@ -161,7 +143,7 @@ class Config extends Base
{
$this->common('integrations');
$this->response->html($this->layout('config/integrations', array(
$this->response->html($this->helper->layout->config('config/integrations', array(
'title' => t('Settings').' &gt; '.t('Integrations'),
)));
}
@ -175,7 +157,7 @@ class Config extends Base
{
$this->common('webhook');
$this->response->html($this->layout('config/webhook', array(
$this->response->html($this->helper->layout->config('config/webhook', array(
'title' => t('Settings').' &gt; '.t('Webhook settings'),
)));
}
@ -187,7 +169,7 @@ class Config extends Base
*/
public function api()
{
$this->response->html($this->layout('config/api', array(
$this->response->html($this->helper->layout->config('config/api', array(
'title' => t('Settings').' &gt; '.t('API'),
)));
}

View File

@ -10,22 +10,6 @@ namespace Kanboard\Controller;
*/
class Currency extends Base
{
/**
* Common layout for config views
*
* @access private
* @param string $template Template name
* @param array $params Template parameters
* @return string
*/
private function layout($template, array $params)
{
$params['board_selector'] = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
$params['config_content_for_layout'] = $this->template->render($template, $params);
return $this->template->layout('config/layout', $params);
}
/**
* Display all currency rates and form
*
@ -33,7 +17,7 @@ class Currency extends Base
*/
public function index(array $values = array(), array $errors = array())
{
$this->response->html($this->layout('currency/index', array(
$this->response->html($this->helper->layout->config('currency/index', array(
'config_values' => array('application_currency' => $this->config->get('application_currency')),
'values' => $values,
'errors' => $errors,

View File

@ -21,7 +21,7 @@ class Customfilter extends Base
{
$project = $this->getProject();
$this->response->html($this->projectLayout('custom_filter/index', array(
$this->response->html($this->helper->layout->project('custom_filter/index', array(
'values' => $values + array('project_id' => $project['id']),
'errors' => $errors,
'project' => $project,
@ -90,7 +90,7 @@ class Customfilter extends Base
$this->checkPermission($project, $filter);
$this->response->html($this->projectLayout('custom_filter/edit', array(
$this->response->html($this->helper->layout->project('custom_filter/edit', array(
'values' => empty($values) ? $filter : $values,
'errors' => $errors,
'project' => $project,

View File

@ -52,8 +52,6 @@ class Doc extends Base
}
}
$this->response->html($this->template->layout('doc/show', $this->readFile($filename) + array(
'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
)));
$this->response->html($this->helper->layout->app('doc/show', $this->readFile($filename)));
}
}

View File

@ -27,7 +27,7 @@ class Export extends Base
$this->response->csv($data);
}
$this->response->html($this->projectLayout('export/'.$action, array(
$this->response->html($this->helper->layout->project('export/'.$action, array(
'values' => array(
'controller' => 'export',
'action' => $action,

View File

@ -26,7 +26,7 @@ class File extends Base
return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true);
}
$this->response->html($this->taskLayout('file/screenshot', array(
$this->response->html($this->helper->layout->task('file/screenshot', array(
'task' => $task,
)));
}
@ -40,7 +40,7 @@ class File extends Base
{
$task = $this->getTask();
$this->response->html($this->taskLayout('file/new', array(
$this->response->html($this->helper->layout->task('file/new', array(
'task' => $task,
'max_size' => ini_get('upload_max_filesize'),
)));
@ -178,7 +178,7 @@ class File extends Base
$task = $this->getTask();
$file = $this->file->getById($this->request->getIntegerParam('file_id'));
$this->response->html($this->taskLayout('file/remove', array(
$this->response->html($this->helper->layout->task('file/remove', array(
'task' => $task,
'file' => $file,
)));

View File

@ -23,10 +23,9 @@ class Gantt extends Base
$project_ids = $this->projectPermission->getActiveProjectIds($this->userSession->getId());
}
$this->response->html($this->template->layout('gantt/projects', array(
$this->response->html($this->helper->layout->app('gantt/projects', array(
'projects' => $this->projectGanttFormatter->filter($project_ids)->format(),
'title' => t('Gantt chart for all projects'),
'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
)));
}
@ -65,7 +64,7 @@ class Gantt extends Base
$filter->getQuery()->asc('column_position')->asc(TaskModel::TABLE.'.position');
}
$this->response->html($this->template->layout('gantt/project', $params + array(
$this->response->html($this->helper->layout->app('gantt/project', $params + array(
'users_list' => $this->projectUserRole->getAssignableUsersList($params['project']['id'], false),
'sorting' => $sorting,
'tasks' => $filter->format(),

View File

@ -24,8 +24,7 @@ class Group extends Base
->setQuery($this->group->getQuery())
->calculate();
$this->response->html($this->template->layout('group/index', array(
'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
$this->response->html($this->helper->layout->app('group/index', array(
'title' => t('Groups').' ('.$paginator->getTotal().')',
'paginator' => $paginator,
)));
@ -48,8 +47,7 @@ class Group extends Base
->setQuery($this->groupMember->getQuery($group_id))
->calculate();
$this->response->html($this->template->layout('group/users', array(
'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
$this->response->html($this->helper->layout->app('group/users', array(
'title' => t('Members of %s', $group['name']).' ('.$paginator->getTotal().')',
'paginator' => $paginator,
'group' => $group,
@ -63,8 +61,7 @@ class Group extends Base
*/
public function create(array $values = array(), array $errors = array())
{
$this->response->html($this->template->layout('group/create', array(
'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
$this->response->html($this->helper->layout->app('group/create', array(
'errors' => $errors,
'values' => $values,
'title' => t('New group')
@ -104,8 +101,7 @@ class Group extends Base
$values = $this->group->getById($this->request->getIntegerParam('group_id'));
}
$this->response->html($this->template->layout('group/edit', array(
'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
$this->response->html($this->helper->layout->app('group/edit', array(
'errors' => $errors,
'values' => $values,
'title' => t('Edit group')
@ -148,8 +144,7 @@ class Group extends Base
$values['group_id'] = $group_id;
}
$this->response->html($this->template->layout('group/associate', array(
'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
$this->response->html($this->helper->layout->app('group/associate', array(
'users' => $this->user->prepareList($this->groupMember->getNotMembers($group_id)),
'group' => $group,
'errors' => $errors,
@ -191,7 +186,7 @@ class Group extends Base
$group = $this->group->getById($group_id);
$user = $this->user->getById($user_id);
$this->response->html($this->template->layout('group/dissociate', array(
$this->response->html($this->helper->layout->app('group/dissociate', array(
'group' => $group,
'user' => $user,
'title' => t('Remove user from group "%s"', $group['name']),
@ -228,7 +223,7 @@ class Group extends Base
$group_id = $this->request->getIntegerParam('group_id');
$group = $this->group->getById($group_id);
$this->response->html($this->template->layout('group/remove', array(
$this->response->html($this->helper->layout->app('group/remove', array(
'group' => $group,
'title' => t('Remove group'),
)));

View File

@ -11,22 +11,6 @@ namespace Kanboard\Controller;
*/
class Link extends Base
{
/**
* Common layout for config views
*
* @access private
* @param string $template Template name
* @param array $params Template parameters
* @return string
*/
private function layout($template, array $params)
{
$params['board_selector'] = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
$params['config_content_for_layout'] = $this->template->render($template, $params);
return $this->template->layout('config/layout', $params);
}
/**
* Get the current link
*
@ -51,7 +35,7 @@ class Link extends Base
*/
public function index(array $values = array(), array $errors = array())
{
$this->response->html($this->layout('link/index', array(
$this->response->html($this->helper->layout->config('link/index', array(
'links' => $this->link->getMergedList(),
'values' => $values,
'errors' => $errors,
@ -91,7 +75,7 @@ class Link extends Base
$link = $this->getLink();
$link['label'] = t($link['label']);
$this->response->html($this->layout('link/edit', array(
$this->response->html($this->helper->layout->config('link/edit', array(
'values' => $values ?: $link,
'errors' => $errors,
'labels' => $this->link->getList($link['id']),
@ -131,7 +115,7 @@ class Link extends Base
{
$link = $this->getLink();
$this->response->html($this->layout('link/remove', array(
$this->response->html($this->helper->layout->config('link/remove', array(
'link' => $link,
'title' => t('Remove a link')
)));

View File

@ -30,7 +30,7 @@ class Listing extends Base
->setQuery($query)
->calculate();
$this->response->html($this->template->layout('listing/show', $params + array(
$this->response->html($this->helper->layout->app('listing/show', $params + array(
'paginator' => $paginator,
)));
}

View File

@ -95,7 +95,7 @@ class Oauth extends Base
if ($this->authenticationManager->oauthAuthentication($provider)) {
$this->response->redirect($this->helper->url->to('app', 'index'));
} else {
$this->response->html($this->template->layout('auth/index', array(
$this->response->html($this->helper->layout->app('auth/index', array(
'errors' => array('login' => t('External authentication failed')),
'values' => array(),
'no_layout' => true,

View File

@ -17,7 +17,7 @@ class PasswordReset extends Base
{
$this->checkActivation();
$this->response->html($this->template->layout('password_reset/create', array(
$this->response->html($this->helper->layout->app('password_reset/create', array(
'errors' => $errors,
'values' => $values,
'no_layout' => true,
@ -53,7 +53,7 @@ class PasswordReset extends Base
$user_id = $this->passwordReset->getUserIdByToken($token);
if ($user_id !== false) {
$this->response->html($this->template->layout('password_reset/change', array(
$this->response->html($this->helper->layout->app('password_reset/change', array(
'token' => $token,
'errors' => $errors,
'values' => $values,

View File

@ -32,8 +32,7 @@ class Project extends Base
->setQuery($this->project->getQueryColumnStats($project_ids))
->calculate();
$this->response->html($this->template->layout('project/index', array(
'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
$this->response->html($this->helper->layout->app('project/index', array(
'paginator' => $paginator,
'nb_projects' => $nb_projects,
'title' => t('Projects').' ('.$nb_projects.')'
@ -49,7 +48,7 @@ class Project extends Base
{
$project = $this->getProject();
$this->response->html($this->projectLayout('project/show', array(
$this->response->html($this->helper->layout->project('project/show', array(
'project' => $project,
'stats' => $this->project->getTaskStats($project['id']),
'title' => $project['name'],
@ -78,7 +77,7 @@ class Project extends Base
$this->response->redirect($this->helper->url->to('project', 'share', array('project_id' => $project['id'])));
}
$this->response->html($this->projectLayout('project/share', array(
$this->response->html($this->helper->layout->project('project/share', array(
'project' => $project,
'title' => t('Public access'),
)));
@ -99,7 +98,7 @@ class Project extends Base
$this->response->redirect($this->helper->url->to('project', 'integrations', array('project_id' => $project['id'])));
}
$this->response->html($this->projectLayout('project/integrations', array(
$this->response->html($this->helper->layout->project('project/integrations', array(
'project' => $project,
'title' => t('Integrations'),
'webhook_token' => $this->config->get('webhook_token'),
@ -124,7 +123,7 @@ class Project extends Base
$this->response->redirect($this->helper->url->to('project', 'notifications', array('project_id' => $project['id'])));
}
$this->response->html($this->projectLayout('project/notifications', array(
$this->response->html($this->helper->layout->project('project/notifications', array(
'notifications' => $this->projectNotification->readSettings($project['id']),
'types' => $this->projectNotificationType->getTypes(),
'project' => $project,
@ -153,7 +152,7 @@ class Project extends Base
$this->response->redirect($this->helper->url->to('project', 'index'));
}
$this->response->html($this->projectLayout('project/remove', array(
$this->response->html($this->helper->layout->project('project/remove', array(
'project' => $project,
'title' => t('Remove project')
)));
@ -182,7 +181,7 @@ class Project extends Base
$this->response->redirect($this->helper->url->to('project', 'show', array('project_id' => $project_id)));
}
$this->response->html($this->projectLayout('project/duplicate', array(
$this->response->html($this->helper->layout->project('project/duplicate', array(
'project' => $project,
'title' => t('Clone this project')
)));
@ -209,7 +208,7 @@ class Project extends Base
$this->response->redirect($this->helper->url->to('project', 'show', array('project_id' => $project['id'])));
}
$this->response->html($this->projectLayout('project/disable', array(
$this->response->html($this->helper->layout->project('project/disable', array(
'project' => $project,
'title' => t('Project activation')
)));
@ -236,7 +235,7 @@ class Project extends Base
$this->response->redirect($this->helper->url->to('project', 'show', array('project_id' => $project['id'])));
}
$this->response->html($this->projectLayout('project/enable', array(
$this->response->html($this->helper->layout->project('project/enable', array(
'project' => $project,
'title' => t('Project activation')
)));

View File

@ -114,7 +114,7 @@ class ProjectEdit extends Base
{
$project = $this->getProject();
$this->response->html($this->projectLayout($template, array(
$this->response->html($this->helper->layout->project($template, array(
'owners' => $this->projectUserRole->getAssignableUsersList($project['id'], true),
'values' => empty($values) ? $project : $values,
'errors' => $errors,

View File

@ -43,7 +43,7 @@ class ProjectPermission extends Base
$values['role'] = Role::PROJECT_MEMBER;
}
$this->response->html($this->projectLayout('project_permission/index', array(
$this->response->html($this->helper->layout->project('project_permission/index', array(
'project' => $project,
'users' => $this->projectUserRole->getUsers($project['id']),
'groups' => $this->projectGroupRole->getGroups($project['id']),

View File

@ -14,23 +14,6 @@ use Kanboard\Core\Security\Role;
*/
class Projectuser extends Base
{
/**
* Common layout for users overview views
*
* @access private
* @param string $template Template name
* @param array $params Template parameters
* @return string
*/
private function layout($template, array $params)
{
$params['board_selector'] = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
$params['content_for_sublayout'] = $this->template->render($template, $params);
$params['filter'] = array('user_id' => $params['user_id']);
return $this->template->layout('project_user/layout', $params);
}
private function common()
{
$user_id = $this->request->getIntegerParam('user_id', UserModel::EVERYBODY_ID);
@ -62,7 +45,7 @@ class Projectuser extends Base
->setQuery($query)
->calculate();
$this->response->html($this->layout('project_user/roles', array(
$this->response->html($this->helper->layout->projectUser('project_user/roles', array(
'paginator' => $paginator,
'title' => $title,
'user_id' => $user_id,
@ -88,7 +71,7 @@ class Projectuser extends Base
->setQuery($query)
->calculate();
$this->response->html($this->layout('project_user/tasks', array(
$this->response->html($this->helper->layout->projectUser('project_user/tasks', array(
'paginator' => $paginator,
'title' => $title,
'user_id' => $user_id,

View File

@ -36,8 +36,7 @@ class Search extends Base
$nb_tasks = $paginator->getTotal();
}
$this->response->html($this->template->layout('search/index', array(
'board_selector' => $projects,
$this->response->html($this->helper->layout->app('search/index', array(
'values' => array(
'search' => $search,
'controller' => 'search',

View File

@ -45,7 +45,7 @@ class Subtask extends Base
);
}
$this->response->html($this->taskLayout('subtask/create', array(
$this->response->html($this->helper->layout->task('subtask/create', array(
'values' => $values,
'errors' => $errors,
'users_list' => $this->projectUserRole->getAssignableUsersList($task['project_id']),
@ -92,7 +92,7 @@ class Subtask extends Base
$task = $this->getTask();
$subtask = $this->getSubTask();
$this->response->html($this->taskLayout('subtask/edit', array(
$this->response->html($this->helper->layout->task('subtask/edit', array(
'values' => empty($values) ? $subtask : $values,
'errors' => $errors,
'users_list' => $this->projectUserRole->getAssignableUsersList($task['project_id']),
@ -138,7 +138,7 @@ class Subtask extends Base
$task = $this->getTask();
$subtask = $this->getSubtask();
$this->response->html($this->taskLayout('subtask/remove', array(
$this->response->html($this->helper->layout->task('subtask/remove', array(
'subtask' => $subtask,
'task' => $task,
)));

View File

@ -40,7 +40,7 @@ class Swimlane extends Base
{
$project = $this->getProject();
$this->response->html($this->projectLayout('swimlane/index', array(
$this->response->html($this->helper->layout->project('swimlane/index', array(
'default_swimlane' => $this->swimlane->getDefault($project['id']),
'active_swimlanes' => $this->swimlane->getAllByStatus($project['id'], SwimlaneModel::ACTIVE),
'inactive_swimlanes' => $this->swimlane->getAllByStatus($project['id'], SwimlaneModel::INACTIVE),
@ -108,7 +108,7 @@ class Swimlane extends Base
$project = $this->getProject();
$swimlane = $this->getSwimlane($project['id']);
$this->response->html($this->projectLayout('swimlane/edit', array(
$this->response->html($this->helper->layout->project('swimlane/edit', array(
'values' => empty($values) ? $swimlane : $values,
'errors' => $errors,
'project' => $project,
@ -150,7 +150,7 @@ class Swimlane extends Base
$project = $this->getProject();
$swimlane = $this->getSwimlane($project['id']);
$this->response->html($this->projectLayout('swimlane/remove', array(
$this->response->html($this->helper->layout->project('swimlane/remove', array(
'project' => $project,
'swimlane' => $swimlane,
'title' => t('Remove a swimlane')

View File

@ -30,7 +30,7 @@ class Task extends Base
$this->notfound(true);
}
$this->response->html($this->template->layout('task/public', array(
$this->response->html($this->helper->layout->app('task/public', array(
'project' => $project,
'comments' => $this->comment->getAll($task['id']),
'subtasks' => $this->subtask->getAll($task['id']),
@ -64,7 +64,7 @@ class Task extends Base
$this->dateParser->format($values, array('date_started'), 'Y-m-d H:i');
$this->response->html($this->taskLayout('task/show', array(
$this->response->html($this->helper->layout->task('task/show', array(
'project' => $this->project->getById($task['project_id']),
'files' => $this->file->getAllDocuments($task['id']),
'images' => $this->file->getAllImages($task['id']),
@ -95,7 +95,7 @@ class Task extends Base
{
$task = $this->getTask();
$this->response->html($this->taskLayout('task/analytics', array(
$this->response->html($this->helper->layout->task('task/analytics', array(
'title' => $task['title'],
'task' => $task,
'lead_time' => $this->taskAnalytic->getLeadTime($task),
@ -121,7 +121,7 @@ class Task extends Base
->setQuery($this->subtaskTimeTracking->getTaskQuery($task['id']))
->calculateOnlyIf($this->request->getStringParam('pagination') === 'subtasks');
$this->response->html($this->taskLayout('task/time_tracking_details', array(
$this->response->html($this->helper->layout->task('task/time_tracking_details', array(
'task' => $task,
'subtask_paginator' => $subtask_paginator,
)));
@ -136,7 +136,7 @@ class Task extends Base
{
$task = $this->getTask();
$this->response->html($this->taskLayout('task/transitions', array(
$this->response->html($this->helper->layout->task('task/transitions', array(
'task' => $task,
'transitions' => $this->transition->getAllByTask($task['id']),
)));
@ -167,7 +167,7 @@ class Task extends Base
$this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])));
}
$this->response->html($this->taskLayout('task/remove', array(
$this->response->html($this->helper->layout->task('task/remove', array(
'task' => $task,
)));
}

View File

@ -21,7 +21,7 @@ class TaskExternalLink extends Base
{
$task = $this->getTask();
$this->response->html($this->taskLayout('task_external_link/show', array(
$this->response->html($this->helper->layout->task('task_external_link/show', array(
'links' => $this->taskExternalLink->getAll($task['id']),
'task' => $task,
'title' => t('List of external links'),
@ -37,7 +37,7 @@ class TaskExternalLink extends Base
{
$task = $this->getTask();
$this->response->html($this->taskLayout('task_external_link/find', array(
$this->response->html($this->helper->layout->task('task_external_link/find', array(
'values' => $values,
'errors' => $errors,
'task' => $task,
@ -60,7 +60,7 @@ class TaskExternalLink extends Base
$provider = $this->externalLinkManager->setUserInput($values)->find();
$link = $provider->getLink();
$this->response->html($this->taskLayout('task_external_link/create', array(
$this->response->html($this->helper->layout->task('task_external_link/create', array(
'values' => array(
'title' => $link->getTitle(),
'url' => $link->getUrl(),
@ -116,7 +116,7 @@ class TaskExternalLink extends Base
$provider = $this->externalLinkManager->getProvider($values['link_type']);
$this->response->html($this->taskLayout('task_external_link/edit', array(
$this->response->html($this->helper->layout->task('task_external_link/edit', array(
'values' => $values,
'errors' => $errors,
'task' => $task,
@ -158,7 +158,7 @@ class TaskExternalLink extends Base
return $this->notfound();
}
$this->response->html($this->taskLayout('task_external_link/remove', array(
$this->response->html($this->helper->layout->task('task_external_link/remove', array(
'link' => $link,
'task' => $task,
)));

View File

@ -20,7 +20,7 @@ class TaskImport extends Base
{
$project = $this->getProject();
$this->response->html($this->projectLayout('task_import/step1', array(
$this->response->html($this->helper->layout->project('task_import/step1', array(
'project' => $project,
'values' => $values,
'errors' => $errors,

View File

@ -32,7 +32,7 @@ class Taskduplication extends Base
}
}
$this->response->html($this->taskLayout('task_duplication/duplicate', array(
$this->response->html($this->helper->layout->task('task_duplication/duplicate', array(
'task' => $task,
)));
}
@ -128,7 +128,7 @@ class Taskduplication extends Base
$users_list = array();
}
$this->response->html($this->taskLayout($template, array(
$this->response->html($this->helper->layout->task($template, array(
'values' => $values,
'task' => $task,
'projects_list' => $projects_list,

View File

@ -38,7 +38,7 @@ class Tasklink extends Base
$task = $this->getTask();
$project = $this->project->getById($task['project_id']);
$this->response->html($this->taskLayout('tasklink/show', array(
$this->response->html($this->helper->layout->task('tasklink/show', array(
'links' => $this->taskLink->getAllGroupedByLabel($task['id']),
'task' => $task,
'project' => $project,
@ -56,7 +56,7 @@ class Tasklink extends Base
{
$task = $this->getTask();
$this->response->html($this->taskLayout('tasklink/create', array(
$this->response->html($this->helper->layout->task('tasklink/create', array(
'values' => $values,
'errors' => $errors,
'task' => $task,
@ -106,7 +106,7 @@ class Tasklink extends Base
$values['title'] = '#'.$opposite_task['id'].' - '.$opposite_task['title'];
}
$this->response->html($this->taskLayout('tasklink/edit', array(
$this->response->html($this->helper->layout->task('tasklink/edit', array(
'values' => $values,
'errors' => $errors,
'task_link' => $task_link,
@ -150,7 +150,7 @@ class Tasklink extends Base
$task = $this->getTask();
$link = $this->getTaskLink();
$this->response->html($this->taskLayout('tasklink/remove', array(
$this->response->html($this->helper->layout->task('tasklink/remove', array(
'link' => $link,
'task' => $task,
)));

View File

@ -56,7 +56,7 @@ class Taskmodification extends Base
$values = array('id' => $task['id'], 'description' => $task['description']);
}
$this->response->html($this->taskLayout('task_modification/edit_description', array(
$this->response->html($this->helper->layout->task('task_modification/edit_description', array(
'values' => $values,
'errors' => $errors,
'task' => $task,
@ -104,7 +104,7 @@ class Taskmodification extends Base
$this->dateParser->format($values, array('date_due'));
$this->response->html($this->taskLayout('task_modification/edit_task', array(
$this->response->html($this->helper->layout->task('task_modification/edit_task', array(
'project' => $project,
'values' => $values,
'errors' => $errors,
@ -176,6 +176,6 @@ class Taskmodification extends Base
'recurrence_basedate_list' => $this->task->getRecurrenceBasedateList(),
);
$this->response->html($this->taskLayout('task_modification/edit_recurrence', $params));
$this->response->html($this->helper->layout->task('task_modification/edit_recurrence', $params));
}
}

View File

@ -55,7 +55,7 @@ class Taskstatus extends Base
return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true);
}
$this->response->html($this->taskLayout($template, array(
$this->response->html($this->helper->layout->task($template, array(
'task' => $task,
)));
}

View File

@ -33,7 +33,7 @@ class Twofactor extends User
$this->checkCurrentUser($user);
unset($this->sessionStorage->twoFactorSecret);
$this->response->html($this->layout('twofactor/index', array(
$this->response->html($this->helper->layout->user('twofactor/index', array(
'user' => $user,
'provider' => $this->authenticationManager->getPostAuthenticationProvider()->getName(),
)));
@ -60,7 +60,7 @@ class Twofactor extends User
$provider->setSecret($this->sessionStorage->twoFactorSecret);
}
$this->response->html($this->layout('twofactor/show', array(
$this->response->html($this->helper->layout->user('twofactor/show', array(
'user' => $user,
'secret' => $this->sessionStorage->twoFactorSecret,
'qrcode_url' => $provider->getQrCodeUrl($label),
@ -165,7 +165,7 @@ class Twofactor extends User
$this->sessionStorage->twoFactorBeforeCodeCalled = true;
}
$this->response->html($this->template->layout('twofactor/check', array(
$this->response->html($this->helper->layout->app('twofactor/check', array(
'title' => t('Check two factor authentication code'),
)));
}
@ -191,7 +191,7 @@ class Twofactor extends User
$this->response->redirect($this->helper->url->to('user', 'show', array('user_id' => $user['id'])));
}
$this->response->html($this->layout('twofactor/disable', array(
$this->response->html($this->helper->layout->user('twofactor/disable', array(
'user' => $user,
)));
}

View File

@ -14,27 +14,6 @@ use Kanboard\Core\Security\Role;
*/
class User extends Base
{
/**
* Common layout for user views
*
* @access protected
* @param string $template Template name
* @param array $params Template parameters
* @return string
*/
protected function layout($template, array $params)
{
$content = $this->template->render($template, $params);
$params['user_content_for_layout'] = $content;
$params['board_selector'] = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
if (isset($params['user'])) {
$params['title'] = ($params['user']['name'] ?: $params['user']['username']).' (#'.$params['user']['id'].')';
}
return $this->template->layout('user/layout', $params);
}
/**
* List all users
*
@ -50,8 +29,7 @@ class User extends Base
->calculate();
$this->response->html(
$this->template->layout('user/index', array(
'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
$this->helper->layout->app('user/index', array(
'title' => t('Users').' ('.$paginator->getTotal().')',
'paginator' => $paginator,
)));
@ -71,8 +49,7 @@ class User extends Base
}
$this->response->html(
$this->template->layout('user/profile', array(
'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
$this->helper->layout->app('user/profile', array(
'title' => $user['name'] ?: $user['username'],
'user' => $user,
)
@ -88,11 +65,10 @@ class User extends Base
{
$is_remote = $this->request->getIntegerParam('remote') == 1 || (isset($values['is_ldap_user']) && $values['is_ldap_user'] == 1);
$this->response->html($this->template->layout($is_remote ? 'user/create_remote' : 'user/create_local', array(
$this->response->html($this->helper->layout->app($is_remote ? 'user/create_remote' : 'user/create_local', array(
'timezones' => $this->config->getTimezones(true),
'languages' => $this->config->getLanguages(true),
'roles' => $this->role->getApplicationRoles(),
'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
'projects' => $this->project->getList(),
'errors' => $errors,
'values' => $values + array('role' => Role::APP_USER),
@ -142,7 +118,7 @@ class User extends Base
public function show()
{
$user = $this->getUser();
$this->response->html($this->layout('user/show', array(
$this->response->html($this->helper->layout->user('user/show', array(
'user' => $user,
'timezones' => $this->config->getTimezones(true),
'languages' => $this->config->getLanguages(true),
@ -166,7 +142,7 @@ class User extends Base
->setQuery($this->subtaskTimeTracking->getUserQuery($user['id']))
->calculateOnlyIf($this->request->getStringParam('pagination') === 'subtasks');
$this->response->html($this->layout('user/timesheet', array(
$this->response->html($this->helper->layout->user('user/timesheet', array(
'subtask_paginator' => $subtask_paginator,
'user' => $user,
)));
@ -180,7 +156,7 @@ class User extends Base
public function passwordReset()
{
$user = $this->getUser();
$this->response->html($this->layout('user/password_reset', array(
$this->response->html($this->helper->layout->user('user/password_reset', array(
'tokens' => $this->passwordReset->getAll($user['id']),
'user' => $user,
)));
@ -194,7 +170,7 @@ class User extends Base
public function last()
{
$user = $this->getUser();
$this->response->html($this->layout('user/last', array(
$this->response->html($this->helper->layout->user('user/last', array(
'last_logins' => $this->lastLogin->getAll($user['id']),
'user' => $user,
)));
@ -208,7 +184,7 @@ class User extends Base
public function sessions()
{
$user = $this->getUser();
$this->response->html($this->layout('user/sessions', array(
$this->response->html($this->helper->layout->user('user/sessions', array(
'sessions' => $this->rememberMeSession->getAll($user['id']),
'user' => $user,
)));
@ -243,7 +219,7 @@ class User extends Base
$this->response->redirect($this->helper->url->to('user', 'notifications', array('user_id' => $user['id'])));
}
$this->response->html($this->layout('user/notifications', array(
$this->response->html($this->helper->layout->user('user/notifications', array(
'projects' => $this->projectUserRole->getProjectsByUser($user['id'], array(ProjectModel::ACTIVE)),
'notifications' => $this->userNotification->readSettings($user['id']),
'types' => $this->userNotificationType->getTypes(),
@ -268,7 +244,7 @@ class User extends Base
$this->response->redirect($this->helper->url->to('user', 'integrations', array('user_id' => $user['id'])));
}
$this->response->html($this->layout('user/integrations', array(
$this->response->html($this->helper->layout->user('user/integrations', array(
'user' => $user,
'values' => $this->userMetadata->getall($user['id']),
)));
@ -282,7 +258,7 @@ class User extends Base
public function external()
{
$user = $this->getUser();
$this->response->html($this->layout('user/external', array(
$this->response->html($this->helper->layout->user('user/external', array(
'last_logins' => $this->lastLogin->getAll($user['id']),
'user' => $user,
)));
@ -310,7 +286,7 @@ class User extends Base
$this->response->redirect($this->helper->url->to('user', 'share', array('user_id' => $user['id'])));
}
$this->response->html($this->layout('user/share', array(
$this->response->html($this->helper->layout->user('user/share', array(
'user' => $user,
'title' => t('Public access'),
)));
@ -342,7 +318,7 @@ class User extends Base
}
}
$this->response->html($this->layout('user/password', array(
$this->response->html($this->helper->layout->user('user/password', array(
'values' => $values,
'errors' => $errors,
'user' => $user,
@ -384,7 +360,7 @@ class User extends Base
}
}
$this->response->html($this->layout('user/edit', array(
$this->response->html($this->helper->layout->user('user/edit', array(
'values' => $values,
'errors' => $errors,
'user' => $user,
@ -422,7 +398,7 @@ class User extends Base
}
}
$this->response->html($this->layout('user/authentication', array(
$this->response->html($this->helper->layout->user('user/authentication', array(
'values' => $values,
'errors' => $errors,
'user' => $user,
@ -450,7 +426,7 @@ class User extends Base
$this->response->redirect($this->helper->url->to('user', 'index'));
}
$this->response->html($this->layout('user/remove', array(
$this->response->html($this->helper->layout->user('user/remove', array(
'user' => $user,
)));
}

View File

@ -18,7 +18,7 @@ class UserImport extends Base
*/
public function step1(array $values = array(), array $errors = array())
{
$this->response->html($this->template->layout('user_import/step1', array(
$this->response->html($this->helper->layout->app('user_import/step1', array(
'values' => $values,
'errors' => $errors,
'max_size' => ini_get('upload_max_filesize'),

View File

@ -26,7 +26,146 @@ class Layout extends Base
return $this->template->render($template, $params);
}
$params['board_selector'] = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
if (! isset($params['no_layout']) && ! isset($params['board_selector'])) {
$params['board_selector'] = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
}
return $this->template->layout($template, $params);
}
/**
* Common layout for user views
*
* @access public
* @param string $template Template name
* @param array $params Template parameters
* @return string
*/
public function user($template, array $params)
{
if (isset($params['user'])) {
$params['title'] = '#'.$params['user']['id'].' '.($params['user']['name'] ?: $params['user']['username']);
}
return $this->subLayout('user/layout', 'user/sidebar', $template, $params);
}
/**
* Common layout for task views
*
* @access public
* @param string $template Template name
* @param array $params Template parameters
* @return string
*/
public function task($template, array $params)
{
$params['title'] = '#'.$params['task']['id'].' '.$params['task']['title'];
return $this->subLayout('task/layout', 'task/sidebar', $template, $params);
}
/**
* Common layout for project views
*
* @access public
* @param string $template
* @param array $params
* @param string $sidebar
* @return string
*/
public function project($template, array $params, $sidebar = 'project/sidebar')
{
if (empty($params['title'])) {
$params['title'] = $params['project']['name'];
} elseif ($params['project']['name'] !== $params['title']) {
$params['title'] = $params['project']['name'].' &gt; '.$params['title'];
}
return $this->subLayout('project/layout', $sidebar, $template, $params);
}
/**
* Common layout for project user views
*
* @access public
* @param string $template
* @param array $params
* @return string
*/
public function projectUser($template, array $params)
{
$params['filter'] = array('user_id' => $params['user_id']);
return $this->subLayout('project_user/layout', 'project_user/sidebar', $template, $params);
}
/**
* Common layout for config views
*
* @access public
* @param string $template
* @param array $params
* @return string
*/
public function config($template, array $params)
{
if (! isset($params['values'])) {
$params['values'] = $this->config->getAll();
}
if (! isset($params['errors'])) {
$params['errors'] = array();
}
return $this->subLayout('config/layout', 'config/sidebar', $template, $params);
}
/**
* Common layout for dashboard views
*
* @access public
* @param string $template
* @param array $params
* @return string
*/
public function dashboard($template, array $params)
{
return $this->subLayout('app/layout', 'app/sidebar', $template, $params);
}
/**
* Common layout for analytic views
*
* @access public
* @param string $template
* @param array $params
* @return string
*/
public function analytic($template, array $params)
{
return $this->subLayout('analytic/layout', 'analytic/sidebar', $template, $params);
}
/**
* Common method to generate a sublayout
*
* @access public
* @param string $sublayout
* @param string $sidebar
* @param string $template
* @param array $params
* @return string
*/
public function subLayout($sublayout, $sidebar, $template, array $params = array())
{
$content = $this->template->render($template, $params);
if ($this->request->isAjax()) {
return $content;
}
$params['content_for_sublayout'] = $content;
$params['sidebar_template'] = $sidebar;
return $this->app($sublayout, $params);
}
}

View File

@ -33,7 +33,7 @@
</div>
<section class="sidebar-container" id="analytic-section">
<?= $this->render('analytic/sidebar', array('project' => $project)) ?>
<?= $this->render($sidebar_template, array('project' => $project)) ?>
<div class="sidebar-content">
<?= $content_for_sublayout ?>

View File

@ -22,7 +22,7 @@
</ul>
</div>
<section class="sidebar-container" id="dashboard">
<?= $this->render('app/sidebar', array('user' => $user)) ?>
<?= $this->render($sidebar_template, array('user' => $user)) ?>
<div class="sidebar-content">
<?= $content_for_sublayout ?>
</div>

View File

@ -1,10 +1,10 @@
<section id="main">
<section class="sidebar-container" id="config-section">
<?= $this->render('config/sidebar') ?>
<?= $this->render($sidebar_template) ?>
<div class="sidebar-content">
<?= $config_content_for_layout ?>
<?= $content_for_sublayout ?>
</div>
</section>
</section>

View File

@ -34,9 +34,6 @@
<li <?= $this->app->checkMenuSelection('config', 'api') ?>>
<?= $this->url->link(t('API'), 'config', 'api') ?>
</li>
<li>
<?= $this->url->link(t('Documentation'), 'doc', 'show') ?>
</li>
<?= $this->hook->render('template:config:sidebar') ?>
</ul>
<div class="sidebar-collapse"><a href="#" title="<?= t('Hide sidebar') ?>"><i class="fa fa-chevron-left"></i></a></div>

View File

@ -30,7 +30,7 @@
<?= $this->render($sidebar_template, array('project' => $project)) ?>
<div class="sidebar-content">
<?= $project_content_for_layout ?>
<?= $content_for_sublayout ?>
</div>
</section>
</section>

View File

@ -15,7 +15,7 @@
</div>
<section class="sidebar-container">
<?= $this->render('project_user/sidebar', array('users' => $users, 'filter' => $filter)) ?>
<?= $this->render($sidebar_template, array('users' => $users, 'filter' => $filter)) ?>
<div class="sidebar-content">
<div class="page-header">

View File

@ -1,5 +1,5 @@
<div class="color-<?= $task['color_id'] ?> task-show-details">
<h2><?= $this->e('#'.$task['id'].' '.$task['title']) ?></h2>
<h2><?= $this->e($task['title']) ?></h2>
<?php if ($task['score']): ?>
<span class="task-score"><?= $this->e($task['score']) ?></span>
<?php endif ?>

View File

@ -19,10 +19,10 @@
</div>
<section class="sidebar-container" id="task-section">
<?= $this->render('task/sidebar', array('task' => $task)) ?>
<?= $this->render($sidebar_template, array('task' => $task)) ?>
<div class="sidebar-content">
<?= $task_content_for_layout ?>
<?= $content_for_sublayout ?>
</div>
</section>
</section>

View File

@ -13,7 +13,7 @@
<?= $this->render('user/sidebar', array('user' => $user)) ?>
<div class="sidebar-content">
<?= $user_content_for_layout ?>
<?= $content_for_sublayout ?>
</div>
</section>
</section>