53 lines
1.8 KiB
PHP
53 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Kanboard\Plugin\ShrinkVertically\Controller;
|
|
|
|
use Kanboard\Controller\BaseController;
|
|
|
|
/**
|
|
* Settings page for the ShrinkVertically plugin: configure how many pixels are
|
|
* reserved around the vertically collapsed board columns.
|
|
*/
|
|
class ConfigController extends BaseController
|
|
{
|
|
const DEFAULT_OFFSET = 240;
|
|
const MIN_OFFSET = 0;
|
|
const MAX_OFFSET = 2000;
|
|
|
|
public function show()
|
|
{
|
|
$offset = (int) $this->configModel->get('shrink_vertically_offset', self::DEFAULT_OFFSET);
|
|
$topScrollbar = (int) $this->configModel->get('shrink_vertically_top_scrollbar', 0);
|
|
|
|
$this->response->html($this->helper->layout->config('shrinkVertically:config/show', array(
|
|
'title' => t('Settings').' > '.t('Shrink Vertically'),
|
|
'values' => array(
|
|
'shrink_vertically_offset' => $offset,
|
|
'shrink_vertically_top_scrollbar' => $topScrollbar,
|
|
),
|
|
'errors' => array(),
|
|
)));
|
|
}
|
|
|
|
public function save()
|
|
{
|
|
$values = $this->request->getValues();
|
|
|
|
$offset = isset($values['shrink_vertically_offset']) ? (int) $values['shrink_vertically_offset'] : self::DEFAULT_OFFSET;
|
|
$offset = max(self::MIN_OFFSET, min(self::MAX_OFFSET, $offset));
|
|
|
|
$topScrollbar = isset($values['shrink_vertically_top_scrollbar']) ? 1 : 0;
|
|
|
|
if ($this->configModel->save(array(
|
|
'shrink_vertically_offset' => $offset,
|
|
'shrink_vertically_top_scrollbar' => $topScrollbar,
|
|
))) {
|
|
$this->flash->success(t('Settings saved successfully.'));
|
|
} else {
|
|
$this->flash->failure(t('Unable to save your settings.'));
|
|
}
|
|
|
|
$this->response->redirect($this->helper->url->to('ConfigController', 'show', array('plugin' => 'ShrinkVertically')));
|
|
}
|
|
}
|