summaryrefslogtreecommitdiff
path: root/app/Controller
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2017-01-08 21:18:54 -0500
committerFrederic Guillot <fred@kanboard.net>2017-01-08 21:18:54 -0500
commit0960a4d0b00c9491b554cd49557b052414168e86 (patch)
tree5b5d58917b9eb7d3cbf23a4312be46a35d2b5fb4 /app/Controller
parent47f4bceb1aea51bda9211a16d635b7a0f9664976 (diff)
Improve link labels pages navigation
Diffstat (limited to 'app/Controller')
-rw-r--r--app/Controller/CurrencyController.php18
-rw-r--r--app/Controller/LinkController.php50
2 files changed, 40 insertions, 28 deletions
diff --git a/app/Controller/CurrencyController.php b/app/Controller/CurrencyController.php
index 2b2275ac..155e229e 100644
--- a/app/Controller/CurrencyController.php
+++ b/app/Controller/CurrencyController.php
@@ -19,9 +19,9 @@ class CurrencyController extends BaseController
{
$this->response->html($this->helper->layout->config('currency/show', array(
'application_currency' => $this->configModel->get('application_currency'),
- 'rates' => $this->currencyModel->getAll(),
- 'currencies' => $this->currencyModel->getCurrencies(),
- 'title' => t('Settings').' &gt; '.t('Currency rates'),
+ 'rates' => $this->currencyModel->getAll(),
+ 'currencies' => $this->currencyModel->getCurrencies(),
+ 'title' => t('Settings') . ' &gt; ' . t('Currency rates'),
)));
}
@@ -34,9 +34,9 @@ class CurrencyController extends BaseController
*/
public function create(array $values = array(), array $errors = array())
{
- $this->response->html($this->helper->layout->config('currency/create', array(
- 'values' => $values,
- 'errors' => $errors,
+ $this->response->html($this->template->render('currency/create', array(
+ 'values' => $values,
+ 'errors' => $errors,
'currencies' => $this->currencyModel->getCurrencies(),
)));
}
@@ -77,9 +77,9 @@ class CurrencyController extends BaseController
$values['application_currency'] = $this->configModel->get('application_currency');
}
- $this->response->html($this->helper->layout->config('currency/change', array(
- 'values' => $values,
- 'errors' => $errors,
+ $this->response->html($this->template->render('currency/change', array(
+ 'values' => $values,
+ 'errors' => $errors,
'currencies' => $this->currencyModel->getCurrencies(),
)));
}
diff --git a/app/Controller/LinkController.php b/app/Controller/LinkController.php
index 477b25a4..2ad8a2b5 100644
--- a/app/Controller/LinkController.php
+++ b/app/Controller/LinkController.php
@@ -16,11 +16,11 @@ class LinkController extends BaseController
/**
* Get the current link
*
- * @access private
+ * @access protected
* @return array
* @throws PageNotFoundException
*/
- private function getLink()
+ protected function getLink()
{
$link = $this->linkModel->getById($this->request->getIntegerParam('link_id'));
@@ -32,19 +32,31 @@ class LinkController extends BaseController
}
/**
- * List of links
+ * List of labels
+ *
+ * @access public
+ */
+ public function show()
+ {
+ $this->response->html($this->helper->layout->config('link/show', array(
+ 'links' => $this->linkModel->getMergedList(),
+ 'title' => t('Settings').' &gt; '.t('Link labels'),
+ )));
+ }
+
+ /**
+ * Add new link label
*
* @access public
* @param array $values
* @param array $errors
*/
- public function index(array $values = array(), array $errors = array())
+ public function create(array $values = array(), array $errors = array())
{
- $this->response->html($this->helper->layout->config('link/index', array(
- 'links' => $this->linkModel->getMergedList(),
+ $this->response->html($this->template->render('link/create', array(
+ 'links' => $this->linkModel->getMergedList(),
'values' => $values,
'errors' => $errors,
- 'title' => t('Settings').' &gt; '.t('Task\'s links'),
)));
}
@@ -61,21 +73,22 @@ class LinkController extends BaseController
if ($valid) {
if ($this->linkModel->create($values['label'], $values['opposite_label']) !== false) {
$this->flash->success(t('Link added successfully.'));
- return $this->response->redirect($this->helper->url->to('LinkController', 'index'));
+ $this->response->redirect($this->helper->url->to('LinkController', 'show'), true);
+ return;
} else {
$this->flash->failure(t('Unable to create your link.'));
}
}
- return $this->index($values, $errors);
+ $this->create($values, $errors);
}
/**
* Edit form
*
* @access public
- * @param array $values
- * @param array $errors
+ * @param array $values
+ * @param array $errors
* @throws PageNotFoundException
*/
public function edit(array $values = array(), array $errors = array())
@@ -83,12 +96,11 @@ class LinkController extends BaseController
$link = $this->getLink();
$link['label'] = t($link['label']);
- $this->response->html($this->helper->layout->config('link/edit', array(
+ $this->response->html($this->template->render('link/edit', array(
'values' => $values ?: $link,
'errors' => $errors,
'labels' => $this->linkModel->getList($link['id']),
- 'link' => $link,
- 'title' => t('Link modification')
+ 'link' => $link,
)));
}
@@ -105,13 +117,14 @@ class LinkController extends BaseController
if ($valid) {
if ($this->linkModel->update($values)) {
$this->flash->success(t('Link updated successfully.'));
- return $this->response->redirect($this->helper->url->to('LinkController', 'index'));
+ $this->response->redirect($this->helper->url->to('LinkController', 'show'), true);
+ return;
} else {
$this->flash->failure(t('Unable to update your link.'));
}
}
- return $this->edit($values, $errors);
+ $this->edit($values, $errors);
}
/**
@@ -123,9 +136,8 @@ class LinkController extends BaseController
{
$link = $this->getLink();
- $this->response->html($this->helper->layout->config('link/remove', array(
+ $this->response->html($this->template->render('link/remove', array(
'link' => $link,
- 'title' => t('Remove a link')
)));
}
@@ -145,6 +157,6 @@ class LinkController extends BaseController
$this->flash->failure(t('Unable to remove this link.'));
}
- $this->response->redirect($this->helper->url->to('LinkController', 'index'));
+ $this->response->redirect($this->helper->url->to('LinkController', 'show'), true);
}
}