update options
This commit is contained in:
parent
feeceaf1fa
commit
e4651dfc5b
|
@ -348,28 +348,34 @@ class ComicPressBackendFilesystemAdmin {
|
|||
// @codeCoverageIgnoreEnd
|
||||
|
||||
function handle_update_comicpress_options($info) {
|
||||
if (isset($info['backend_options']['filesystem'])) {
|
||||
$info = $info['backend_options']['filesystem'];
|
||||
$comicpress = ComicPress::get_instance();
|
||||
if (is_array($info)) {
|
||||
if (isset($info['backend_options']['filesystem'])) {
|
||||
if (is_array($info['backend_options']['filesystem'])) {
|
||||
$info = $info['backend_options']['filesystem'];
|
||||
$comicpress = ComicPress::get_instance();
|
||||
|
||||
if (!isset($comicpress->comicpress_options['backend_options'])) {
|
||||
$comicpress->comicpress_options['backend_options'] = array();
|
||||
}
|
||||
if (!isset($comicpress->comicpress_options['backend_options']['filesystem'])) {
|
||||
$comicpress->comicpress_options['backend_options']['filesystem'] = array();
|
||||
}
|
||||
|
||||
foreach (array('folders', 'search_pattern', 'url_pattern') as $valid_field) {
|
||||
if (is_array($info[$valid_field])) {
|
||||
$comicpress->comicpress_options['backend_options']['filesystem'][$valid_field] = array();
|
||||
foreach ($info[$valid_field] as $field => $value) {
|
||||
$comicpress->comicpress_options['backend_options']['filesystem'][$valid_field][$field] = strip_tags($value);
|
||||
if (!isset($comicpress->comicpress_options['backend_options'])) {
|
||||
$comicpress->comicpress_options['backend_options'] = array();
|
||||
}
|
||||
} else {
|
||||
$comicpress->comicpress_options['backend_options']['filesystem'][$valid_field] = strip_tags($info[$valid_field]);
|
||||
if (!isset($comicpress->comicpress_options['backend_options']['filesystem'])) {
|
||||
$comicpress->comicpress_options['backend_options']['filesystem'] = array();
|
||||
}
|
||||
|
||||
foreach (array('folders', 'search_pattern', 'url_pattern') as $valid_field) {
|
||||
if (isset($info[$valid_field])) {
|
||||
if (is_array($info[$valid_field])) {
|
||||
$comicpress->comicpress_options['backend_options']['filesystem'][$valid_field] = array();
|
||||
foreach ($info[$valid_field] as $field => $value) {
|
||||
$comicpress->comicpress_options['backend_options']['filesystem'][$valid_field][$field] = strip_tags($value);
|
||||
}
|
||||
} else {
|
||||
$comicpress->comicpress_options['backend_options']['filesystem'][$valid_field] = strip_tags($info[$valid_field]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$comicpress->save();
|
||||
}
|
||||
}
|
||||
$comicpress->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -90,5 +90,64 @@ class ComicPressBackendFilesystemAdminTest extends PHPUnit_Framework_TestCase {
|
|||
ComicPressBackendFilesystemAdmin::save_post(1);
|
||||
|
||||
$this->assertEquals($expected_post_meta, get_post_meta(1, 'backend_filesystem_image_meta', true));
|
||||
|
||||
$comicpress = ComicPress::get_instance(true);
|
||||
}
|
||||
|
||||
function providerTestUpdateComicPressOptions() {
|
||||
return array(
|
||||
array(false, array()),
|
||||
array(array(), array()),
|
||||
array(
|
||||
array('backend_options' => array(
|
||||
'filesystem' => 'test'
|
||||
)),
|
||||
array()
|
||||
),
|
||||
array(
|
||||
array('backend_options' => array(
|
||||
'filesystem' => array()
|
||||
)),
|
||||
array(
|
||||
'backend_options' => array('filesystem' => array())
|
||||
)
|
||||
),
|
||||
array(
|
||||
array('backend_options' => array(
|
||||
'filesystem' => array(
|
||||
'search_pattern' => '<b>value</b>',
|
||||
'url_pattern' => '<b>value</b>',
|
||||
'folders' => array(
|
||||
'one' => '<b>value</b>',
|
||||
'two' => '<b>value</b>',
|
||||
),
|
||||
)
|
||||
)),
|
||||
array(
|
||||
'backend_options' => array('filesystem' => array(
|
||||
'search_pattern' => 'value',
|
||||
'url_pattern' => 'value',
|
||||
'folders' => array(
|
||||
'one' => 'value',
|
||||
'two' => 'value'
|
||||
)
|
||||
))
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerTestUpdateComicPressOptions
|
||||
*/
|
||||
function testUpdateComicPressOptions($info, $expected_comicpress_options) {
|
||||
$comicpress = ComicPress::get_instance(true);
|
||||
$comicpress->comicpress_options = array();
|
||||
|
||||
ComicPressBackendFilesystemAdmin::handle_update_comicpress_options($info);
|
||||
|
||||
$this->assertEquals($expected_comicpress_options, $comicpress->comicpress_options);
|
||||
|
||||
$comicpress = ComicPress::get_instance(true);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue