Issue when saving tab-based plugin configuration (#452)

This commit is contained in:
Matias Griese
2016-03-16 11:09:48 +02:00
parent 066c4bcd37
commit de82a05194
7 changed files with 27 additions and 14 deletions

View File

@@ -52,6 +52,11 @@ class AdminController
*/
public $post;
/**
* @var array|null
*/
public $data;
/**
* @var Admin
*/
@@ -79,6 +84,10 @@ class AdminController
$this->grav = $grav;
$this->view = $view;
$this->task = $task ? $task : 'display';
if (isset($post['data'])) {
$this->data = $this->getPost($post['data']);
unset($post['data']);
}
$this->post = $this->getPost($post);
$this->route = $route;
$this->admin = $this->grav['admin'];
@@ -898,7 +907,7 @@ class AdminController
// Filter value and save it.
$this->post = ['enabled' => true];
$obj = $this->prepareData();
$obj = $this->prepareData($this->post);
$obj->save();
$this->post = ['_redirect' => 'plugins'];
@@ -924,7 +933,7 @@ class AdminController
// Filter value and save it.
$this->post = ['enabled' => false];
$obj = $this->prepareData();
$obj = $this->prepareData($this->post);
$obj->save();
$this->post = ['_redirect' => 'plugins'];
@@ -1244,7 +1253,7 @@ class AdminController
return false;
}
$data = $this->post;
$data = (array) $this->data;
if ($data['route'] == '/') {
$path = $this->grav['locator']->findResource('page://');
@@ -1323,7 +1332,7 @@ class AdminController
return false;
}
$data = $this->post;
$data = (array) $this->data;
$config = $this->grav['config'];
@@ -1395,7 +1404,7 @@ class AdminController
} else {
// Handle standard data types.
$obj = $this->prepareData();
$obj = $this->prepareData($data);
$obj = $this->processFiles($obj);
$obj->validate();
$obj->filter();
@@ -1479,7 +1488,7 @@ class AdminController
return false;
}
$data = $this->post;
$data = (array) $this->data;
$route = $data['route'] != '/' ? $data['route'] : '';
$folder = ltrim($data['folder'], '_');
if (!empty($data['modular'])) {
@@ -1662,7 +1671,7 @@ class AdminController
return false;
}
$data = $this->post;
$data = (array) $this->data;
$language = $data['lang'];
if ($language) {
@@ -1802,7 +1811,7 @@ class AdminController
*
* @return array
*/
protected function &getPost($post)
protected function getPost($post)
{
unset($post['task']);
@@ -1852,10 +1861,10 @@ class AdminController
*
* @return object
*/
protected function prepareData()
protected function prepareData(array $data)
{
$type = trim("{$this->view}/{$this->admin->route}", '/');
$data = $this->admin->data($type, $this->post);
$data = $this->admin->data($type, $data);
return $data;
}
@@ -1905,7 +1914,7 @@ class AdminController
*/
protected function preparePage(Page $page, $clean_header = false, $language = '')
{
$input = $this->post;
$input = (array) $this->data;
if (isset($input['order'])) {
$order = max(0, (int)isset($input['order']) ? $input['order'] : $page->value('order'));