56 lines
1.9 KiB
PHP
56 lines
1.9 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace Kanboard\Plugin\TweakDrag\Controller;
|
||
|
|
|
||
|
|
use Kanboard\Controller\BaseController;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Settings page for the TweakDrag plugin: board drag/touch and column-gap options.
|
||
|
|
*/
|
||
|
|
class ConfigController extends BaseController
|
||
|
|
{
|
||
|
|
const DEFAULT_GAP_SIZE = 25;
|
||
|
|
const MIN_GAP_SIZE = 0;
|
||
|
|
const MAX_GAP_SIZE = 200;
|
||
|
|
|
||
|
|
public function show()
|
||
|
|
{
|
||
|
|
$gapSize = (int) $this->configModel->get('tweakdrag_column_gap_size', self::DEFAULT_GAP_SIZE);
|
||
|
|
$columnGap = (int) $this->configModel->get('tweakdrag_column_gap', 1);
|
||
|
|
$dragScroll = (int) $this->configModel->get('tweakdrag_drag_scroll', 1);
|
||
|
|
|
||
|
|
$this->response->html($this->helper->layout->config('tweakDrag:config/show', array(
|
||
|
|
'title' => t('Settings').' > '.t('Tweak Drag'),
|
||
|
|
'values' => array(
|
||
|
|
'tweakdrag_column_gap_size' => $gapSize,
|
||
|
|
'tweakdrag_column_gap' => $columnGap,
|
||
|
|
'tweakdrag_drag_scroll' => $dragScroll,
|
||
|
|
),
|
||
|
|
'errors' => array(),
|
||
|
|
)));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function save()
|
||
|
|
{
|
||
|
|
$values = $this->request->getValues();
|
||
|
|
|
||
|
|
$gapSize = isset($values['tweakdrag_column_gap_size']) ? (int) $values['tweakdrag_column_gap_size'] : self::DEFAULT_GAP_SIZE;
|
||
|
|
$gapSize = max(self::MIN_GAP_SIZE, min(self::MAX_GAP_SIZE, $gapSize));
|
||
|
|
|
||
|
|
$columnGap = isset($values['tweakdrag_column_gap']) ? 1 : 0;
|
||
|
|
$dragScroll = isset($values['tweakdrag_drag_scroll']) ? 1 : 0;
|
||
|
|
|
||
|
|
if ($this->configModel->save(array(
|
||
|
|
'tweakdrag_column_gap_size' => $gapSize,
|
||
|
|
'tweakdrag_column_gap' => $columnGap,
|
||
|
|
'tweakdrag_drag_scroll' => $dragScroll,
|
||
|
|
))) {
|
||
|
|
$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' => 'TweakDrag')));
|
||
|
|
}
|
||
|
|
}
|