diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-12-28 11:28:50 -0500 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-12-28 11:28:50 -0500 |
commit | 34d7450d3c13342715e90ec21bceaa13e1baa876 (patch) | |
tree | a2d8f2f22ad3fe9b56f01fe2db0357f9b963e660 /app/Controller | |
parent | 88d84073aecbe8bdc5f10825b6d7ca6b81c5f7b1 (diff) |
Template helpers refactoring
Diffstat (limited to 'app/Controller')
-rw-r--r-- | app/Controller/Analytic.php | 2 | ||||
-rw-r--r-- | app/Controller/App.php | 3 | ||||
-rw-r--r-- | app/Controller/Base.php | 24 | ||||
-rw-r--r-- | app/Controller/Board.php | 18 | ||||
-rw-r--r-- | app/Controller/Config.php | 2 | ||||
-rw-r--r-- | app/Controller/File.php | 2 | ||||
-rw-r--r-- | app/Controller/Project.php | 2 | ||||
-rw-r--r-- | app/Controller/Task.php | 6 | ||||
-rw-r--r-- | app/Controller/User.php | 2 |
9 files changed, 22 insertions, 39 deletions
diff --git a/app/Controller/Analytic.php b/app/Controller/Analytic.php index 6c49089b..115f75f0 100644 --- a/app/Controller/Analytic.php +++ b/app/Controller/Analytic.php @@ -21,7 +21,7 @@ class Analytic extends Base private function layout($template, array $params) { $params['board_selector'] = $this->projectPermission->getAllowedProjects($this->acl->getUserId()); - $params['analytic_content_for_layout'] = $this->template->load($template, $params); + $params['analytic_content_for_layout'] = $this->template->render($template, $params); return $this->template->layout('analytic/layout', $params); } diff --git a/app/Controller/App.php b/app/Controller/App.php index eb1d83af..56e81179 100644 --- a/app/Controller/App.php +++ b/app/Controller/App.php @@ -3,7 +3,6 @@ namespace Controller; use Model\SubTask as SubTaskModel; -use Helper; /** * Application controller @@ -192,7 +191,7 @@ class App extends Base $this->response->html('<p>'.t('Nothing to preview...').'</p>'); } else { - $this->response->html(Helper\markdown($payload['text'])); + $this->response->html($this->template->markdown($payload['text'])); } } diff --git a/app/Controller/Base.php b/app/Controller/Base.php index 19eb7f12..18f21ee8 100644 --- a/app/Controller/Base.php +++ b/app/Controller/Base.php @@ -17,6 +17,8 @@ use Symfony\Component\EventDispatcher\Event; * @package controller * @author Frederic Guillot * + * @property \Core\Session $session + * @property \Core\Template $template * @property \Model\Acl $acl * @property \Model\Authentication $authentication * @property \Model\Action $action @@ -70,22 +72,6 @@ abstract class Base protected $response; /** - * Template instance - * - * @accesss protected - * @var \Core\Template - */ - protected $template; - - /** - * Session instance - * - * @accesss public - * @var \Core\Session - */ - protected $session; - - /** * Container instance * * @access private @@ -104,8 +90,6 @@ abstract class Base $this->container = $container; $this->request = new Request; $this->response = new Response; - $this->session = new Session; - $this->template = new Template; } /** @@ -265,7 +249,7 @@ abstract class Base $params['hide_remove_menu'] = true; } - $content = $this->template->load($template, $params); + $content = $this->template->render($template, $params); $params['task_content_for_layout'] = $content; $params['title'] = $params['task']['project_name'].' > '.$params['task']['title']; $params['board_selector'] = $this->projectPermission->getAllowedProjects($this->acl->getUserId()); @@ -283,7 +267,7 @@ abstract class Base */ protected function projectLayout($template, array $params) { - $content = $this->template->load($template, $params); + $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->projectPermission->getAllowedProjects($this->acl->getUserId()); diff --git a/app/Controller/Board.php b/app/Controller/Board.php index 072acf26..2c10e105 100644 --- a/app/Controller/Board.php +++ b/app/Controller/Board.php @@ -39,7 +39,7 @@ class Board extends Base $task = $this->getTask(); $project = $this->project->getById($task['project_id']); - $this->response->html($this->template->load('board/assignee', array( + $this->response->html($this->template->render('board/assignee', array( 'values' => $task, 'users_list' => $this->projectPermission->getMemberList($project['id']), 'project' => $project, @@ -78,7 +78,7 @@ class Board extends Base $task = $this->getTask(); $project = $this->project->getById($task['project_id']); - $this->response->html($this->template->load('board/category', array( + $this->response->html($this->template->render('board/category', array( 'values' => $task, 'categories_list' => $this->category->getList($project['id']), 'project' => $project, @@ -360,7 +360,7 @@ class Board extends Base } $this->response->html( - $this->template->load('board/show', array( + $this->template->render('board/show', array( 'project' => $this->project->getById($project_id), 'swimlanes' => $this->board->getBoard($project_id), 'categories' => $this->category->getList($project_id, false), @@ -394,7 +394,7 @@ class Board extends Base } $this->response->html( - $this->template->load('board/show', array( + $this->template->render('board/show', array( 'project' => $this->project->getById($project_id), 'swimlanes' => $this->board->getBoard($project_id), 'categories' => $this->category->getList($project_id, false), @@ -412,7 +412,7 @@ class Board extends Base public function subtasks() { $task = $this->getTask(); - $this->response->html($this->template->load('board/subtasks', array( + $this->response->html($this->template->render('board/subtasks', array( 'subtasks' => $this->subTask->getAll($task['id']) ))); } @@ -427,7 +427,7 @@ class Board extends Base $task = $this->getTask(); $this->subTask->toggleStatus($this->request->getIntegerParam('subtask_id')); - $this->response->html($this->template->load('board/subtasks', array( + $this->response->html($this->template->render('board/subtasks', array( 'subtasks' => $this->subTask->getAll($task['id']) ))); } @@ -441,7 +441,7 @@ class Board extends Base { $task = $this->getTask(); - $this->response->html($this->template->load('board/files', array( + $this->response->html($this->template->render('board/files', array( 'files' => $this->file->getAll($task['id']) ))); } @@ -455,7 +455,7 @@ class Board extends Base { $task = $this->getTask(); - $this->response->html($this->template->load('board/comments', array( + $this->response->html($this->template->render('board/comments', array( 'comments' => $this->comment->getAll($task['id']) ))); } @@ -469,7 +469,7 @@ class Board extends Base { $task = $this->getTask(); - $this->response->html($this->template->load('board/description', array( + $this->response->html($this->template->render('board/description', array( 'task' => $task ))); } diff --git a/app/Controller/Config.php b/app/Controller/Config.php index 199259d7..4093b7a1 100644 --- a/app/Controller/Config.php +++ b/app/Controller/Config.php @@ -23,7 +23,7 @@ class Config extends Base $params['board_selector'] = $this->projectPermission->getAllowedProjects($this->acl->getUserId()); $params['values'] = $this->config->getAll(); $params['errors'] = array(); - $params['config_content_for_layout'] = $this->template->load($template, $params); + $params['config_content_for_layout'] = $this->template->render($template, $params); return $this->template->layout('config/layout', $params); } diff --git a/app/Controller/File.php b/app/Controller/File.php index ae44cac0..1585a701 100644 --- a/app/Controller/File.php +++ b/app/Controller/File.php @@ -75,7 +75,7 @@ class File extends Base $file = $this->file->getById($this->request->getIntegerParam('file_id')); if ($file['task_id'] == $task['id']) { - $this->response->html($this->template->load('file/open', array( + $this->response->html($this->template->render('file/open', array( 'file' => $file ))); } diff --git a/app/Controller/Project.php b/app/Controller/Project.php index 5395a5a4..9037a91a 100644 --- a/app/Controller/Project.php +++ b/app/Controller/Project.php @@ -447,7 +447,7 @@ class Project extends Base $this->forbidden(true); } - $this->response->xml($this->template->load('project/feed', array( + $this->response->xml($this->template->render('project/feed', array( 'events' => $this->projectActivity->getProject($project['id']), 'project' => $project, ))); diff --git a/app/Controller/Task.php b/app/Controller/Task.php index 33b4b039..284cbec0 100644 --- a/app/Controller/Task.php +++ b/app/Controller/Task.php @@ -89,7 +89,7 @@ class Task extends Base public function create(array $values = array(), array $errors = array()) { $project = $this->getProject(); - $method = $this->request->isAjax() ? 'load' : 'layout'; + $method = $this->request->isAjax() ? 'render' : 'layout'; if (empty($values)) { @@ -179,7 +179,7 @@ class Task extends Base ); if ($ajax) { - $this->response->html($this->template->load('task/edit', $params)); + $this->response->html($this->template->render('task/edit', $params)); } else { $this->response->html($this->taskLayout('task/edit', $params)); @@ -410,7 +410,7 @@ class Task extends Base ); if ($ajax) { - $this->response->html($this->template->load('task/edit_description', $params)); + $this->response->html($this->template->render('task/edit_description', $params)); } else { $this->response->html($this->taskLayout('task/edit_description', $params)); diff --git a/app/Controller/User.php b/app/Controller/User.php index 93b5ca18..619bbc90 100644 --- a/app/Controller/User.php +++ b/app/Controller/User.php @@ -76,7 +76,7 @@ class User extends Base */ private function layout($template, array $params) { - $content = $this->template->load($template, $params); + $content = $this->template->render($template, $params); $params['user_content_for_layout'] = $content; $params['board_selector'] = $this->projectPermission->getAllowedProjects($this->acl->getUserId()); |