diff options
Diffstat (limited to 'app')
50 files changed, 281 insertions, 320 deletions
diff --git a/app/Controller/Action.php b/app/Controller/Action.php index 645b53b7..482a210b 100644 --- a/app/Controller/Action.php +++ b/app/Controller/Action.php @@ -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(), diff --git a/app/Controller/Activity.php b/app/Controller/Activity.php index 38658345..db520ebe 100644 --- a/app/Controller/Activity.php +++ b/app/Controller/Activity.php @@ -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']), diff --git a/app/Controller/Analytic.php b/app/Controller/Analytic.php index d203fb8e..e7ab9ebc 100644 --- a/app/Controller/Analytic.php +++ b/app/Controller/Analytic.php @@ -1,6 +1,7 @@ <?php namespace Kanboard\Controller; + use Kanboard\Model\Task as TaskModel; /** @@ -12,22 +13,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 * * @access public @@ -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, diff --git a/app/Controller/App.php b/app/Controller/App.php index bdd7fbcf..1ce74506 100644 --- a/app/Controller/App.php +++ b/app/Controller/App.php @@ -13,22 +13,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 * * @access private @@ -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, diff --git a/app/Controller/Auth.php b/app/Controller/Auth.php index 5284e126..fef7f0e3 100644 --- a/app/Controller/Auth.php +++ b/app/Controller/Auth.php @@ -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, diff --git a/app/Controller/Base.php b/app/Controller/Base.php index 0939f44c..a80b3528 100644 --- a/app/Controller/Base.php +++ b/app/Controller/Base.php @@ -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, ))); @@ -180,48 +180,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'].' > '.$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'].' > '.$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 * * @access protected diff --git a/app/Controller/Board.php b/app/Controller/Board.php index f64de69a..199f1703 100644 --- a/app/Controller/Board.php +++ b/app/Controller/Board.php @@ -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()), diff --git a/app/Controller/Calendar.php b/app/Controller/Calendar.php index 67a402d3..a0a25e41 100644 --- a/app/Controller/Calendar.php +++ b/app/Controller/Calendar.php @@ -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'))); } diff --git a/app/Controller/Category.php b/app/Controller/Category.php index a0af4139..258a3b78 100644 --- a/app/Controller/Category.php +++ b/app/Controller/Category.php @@ -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') diff --git a/app/Controller/Column.php b/app/Controller/Column.php index 1ce575d7..3201c549 100644 --- a/app/Controller/Column.php +++ b/app/Controller/Column.php @@ -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') diff --git a/app/Controller/Comment.php b/app/Controller/Comment.php index 549c0c65..1e94779f 100644 --- a/app/Controller/Comment.php +++ b/app/Controller/Comment.php @@ -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') diff --git a/app/Controller/Config.php b/app/Controller/Config.php index 4aee8553..53f7cdb6 100644 --- a/app/Controller/Config.php +++ b/app/Controller/Config.php @@ -11,24 +11,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 * * @access private @@ -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').' > '.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').' > '.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').' > '.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').' > '.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').' > '.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').' > '.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').' > '.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').' > '.t('API'), ))); } diff --git a/app/Controller/Currency.php b/app/Controller/Currency.php index 42e404f8..ecaa9834 100644 --- a/app/Controller/Currency.php +++ b/app/Controller/Currency.php @@ -11,29 +11,13 @@ 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 * * @access public */ 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, diff --git a/app/Controller/Customfilter.php b/app/Controller/Customfilter.php index 1b43f1d0..da7eb77b 100644 --- a/app/Controller/Customfilter.php +++ b/app/Controller/Customfilter.php @@ -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, diff --git a/app/Controller/Doc.php b/app/Controller/Doc.php index a233b120..6f309d48 100644 --- a/app/Controller/Doc.php +++ b/app/Controller/Doc.php @@ -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))); } } diff --git a/app/Controller/Export.php b/app/Controller/Export.php index c39f58a1..977a4107 100644 --- a/app/Controller/Export.php +++ b/app/Controller/Export.php @@ -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, diff --git a/app/Controller/File.php b/app/Controller/File.php index 18e787f1..b347f67f 100644 --- a/app/Controller/File.php +++ b/app/Controller/File.php @@ -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, ))); diff --git a/app/Controller/Gantt.php b/app/Controller/Gantt.php index f312130c..b1dc2b7e 100644 --- a/app/Controller/Gantt.php +++ b/app/Controller/Gantt.php @@ -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(), diff --git a/app/Controller/Group.php b/app/Controller/Group.php index e952c0e5..fa47f428 100644 --- a/app/Controller/Group.php +++ b/app/Controller/Group.php @@ -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'), ))); diff --git a/app/Controller/Link.php b/app/Controller/Link.php index d52d1f91..ec7ab1af 100644 --- a/app/Controller/Link.php +++ b/app/Controller/Link.php @@ -12,22 +12,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 * * @access private @@ -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') ))); diff --git a/app/Controller/Listing.php b/app/Controller/Listing.php index b9c851f5..c7d3d9a8 100644 --- a/app/Controller/Listing.php +++ b/app/Controller/Listing.php @@ -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, ))); } diff --git a/app/Controller/Oauth.php b/app/Controller/Oauth.php index bc670d1e..452faecd 100644 --- a/app/Controller/Oauth.php +++ b/app/Controller/Oauth.php @@ -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, diff --git a/app/Controller/PasswordReset.php b/app/Controller/PasswordReset.php index 23567c9c..f6a0eb8e 100644 --- a/app/Controller/PasswordReset.php +++ b/app/Controller/PasswordReset.php @@ -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, diff --git a/app/Controller/Project.php b/app/Controller/Project.php index 661fd68b..cdfbd94a 100644 --- a/app/Controller/Project.php +++ b/app/Controller/Project.php @@ -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') ))); diff --git a/app/Controller/ProjectEdit.php b/app/Controller/ProjectEdit.php index 29793c47..f4a3a7cb 100644 --- a/app/Controller/ProjectEdit.php +++ b/app/Controller/ProjectEdit.php @@ -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, diff --git a/app/Controller/ProjectPermission.php b/app/Controller/ProjectPermission.php index e0e58240..800da02f 100644 --- a/app/Controller/ProjectPermission.php +++ b/app/Controller/ProjectPermission.php @@ -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']), diff --git a/app/Controller/Projectuser.php b/app/Controller/Projectuser.php index 78b93ab6..9cd21021 100644 --- a/app/Controller/Projectuser.php +++ b/app/Controller/Projectuser.php @@ -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, diff --git a/app/Controller/Search.php b/app/Controller/Search.php index 390210c0..9b9b9e65 100644 --- a/app/Controller/Search.php +++ b/app/Controller/Search.php @@ -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', diff --git a/app/Controller/Subtask.php b/app/Controller/Subtask.php index caaaa85e..526962a9 100644 --- a/app/Controller/Subtask.php +++ b/app/Controller/Subtask.php @@ -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, ))); diff --git a/app/Controller/Swimlane.php b/app/Controller/Swimlane.php index 66410888..4e8c2863 100644 --- a/app/Controller/Swimlane.php +++ b/app/Controller/Swimlane.php @@ -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') diff --git a/app/Controller/Task.php b/app/Controller/Task.php index 1811dcb7..0d463725 100644 --- a/app/Controller/Task.php +++ b/app/Controller/Task.php @@ -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, ))); } diff --git a/app/Controller/TaskExternalLink.php b/app/Controller/TaskExternalLink.php index 9b9a7d3d..f26922dd 100644 --- a/app/Controller/TaskExternalLink.php +++ b/app/Controller/TaskExternalLink.php @@ -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, ))); diff --git a/app/Controller/TaskImport.php b/app/Controller/TaskImport.php index f09c14ce..460c608c 100644 --- a/app/Controller/TaskImport.php +++ b/app/Controller/TaskImport.php @@ -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, diff --git a/app/Controller/Taskduplication.php b/app/Controller/Taskduplication.php index 2362ae42..f940eee3 100644 --- a/app/Controller/Taskduplication.php +++ b/app/Controller/Taskduplication.php @@ -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, diff --git a/app/Controller/Tasklink.php b/app/Controller/Tasklink.php index 73c641fb..fdb4fada 100644 --- a/app/Controller/Tasklink.php +++ b/app/Controller/Tasklink.php @@ -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, ))); diff --git a/app/Controller/Taskmodification.php b/app/Controller/Taskmodification.php index 940b8a22..dc368390 100644 --- a/app/Controller/Taskmodification.php +++ b/app/Controller/Taskmodification.php @@ -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)); } } diff --git a/app/Controller/Taskstatus.php b/app/Controller/Taskstatus.php index e28d5911..c07f2cc5 100644 --- a/app/Controller/Taskstatus.php +++ b/app/Controller/Taskstatus.php @@ -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, ))); } diff --git a/app/Controller/Twofactor.php b/app/Controller/Twofactor.php index 8dbfcf66..10292261 100644 --- a/app/Controller/Twofactor.php +++ b/app/Controller/Twofactor.php @@ -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, ))); } diff --git a/app/Controller/User.php b/app/Controller/User.php index 97e01553..881266d4 100644 --- a/app/Controller/User.php +++ b/app/Controller/User.php @@ -15,27 +15,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 * * @access public @@ -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, ))); } diff --git a/app/Controller/UserImport.php b/app/Controller/UserImport.php index cbc5aa14..debd69e5 100644 --- a/app/Controller/UserImport.php +++ b/app/Controller/UserImport.php @@ -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'), diff --git a/app/Helper/Layout.php b/app/Helper/Layout.php index 685c7b84..8c00a311 100644 --- a/app/Helper/Layout.php +++ b/app/Helper/Layout.php @@ -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'].' > '.$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); + } } diff --git a/app/Template/analytic/layout.php b/app/Template/analytic/layout.php index ff532fc0..4f22db10 100644 --- a/app/Template/analytic/layout.php +++ b/app/Template/analytic/layout.php @@ -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 ?> diff --git a/app/Template/app/layout.php b/app/Template/app/layout.php index d54b1da7..0550cef4 100644 --- a/app/Template/app/layout.php +++ b/app/Template/app/layout.php @@ -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> diff --git a/app/Template/config/layout.php b/app/Template/config/layout.php index 028f138c..f34caaab 100644 --- a/app/Template/config/layout.php +++ b/app/Template/config/layout.php @@ -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>
\ No newline at end of file diff --git a/app/Template/config/sidebar.php b/app/Template/config/sidebar.php index a8174505..1b42bcc1 100644 --- a/app/Template/config/sidebar.php +++ b/app/Template/config/sidebar.php @@ -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> diff --git a/app/Template/project/layout.php b/app/Template/project/layout.php index 8ba92ef9..eb391ae5 100644 --- a/app/Template/project/layout.php +++ b/app/Template/project/layout.php @@ -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>
\ No newline at end of file diff --git a/app/Template/project_user/layout.php b/app/Template/project_user/layout.php index a87efbff..3ced5590 100644 --- a/app/Template/project_user/layout.php +++ b/app/Template/project_user/layout.php @@ -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"> diff --git a/app/Template/task/details.php b/app/Template/task/details.php index d885ca9c..2e70e561 100644 --- a/app/Template/task/details.php +++ b/app/Template/task/details.php @@ -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 ?> diff --git a/app/Template/task/layout.php b/app/Template/task/layout.php index 9fe1a716..09dbb2ea 100644 --- a/app/Template/task/layout.php +++ b/app/Template/task/layout.php @@ -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>
\ No newline at end of file diff --git a/app/Template/user/layout.php b/app/Template/user/layout.php index 1e456348..3a0a5ba6 100644 --- a/app/Template/user/layout.php +++ b/app/Template/user/layout.php @@ -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>
\ No newline at end of file |