got dimensions updates working

This commit is contained in:
John Bintz 2009-07-06 22:19:18 -04:00
parent 9ed017b883
commit 8b34c320c3
2 changed files with 52 additions and 4 deletions

View File

@ -83,6 +83,7 @@ class ComicPressOptionsAdmin {
function handle_update() {
if (isset($_POST['cp'])) {
$this->get_comicpress_options();
foreach ($this->comicpress_options as $option => $value) {
if (isset($_POST['cp'][$option])) {
switch ($option) {
@ -96,15 +97,35 @@ class ComicPressOptionsAdmin {
break;
case 'comic_dimensions':
case 'rss_dimensions':
case 'tumbnail_dimensions':
case 'thumbnail_dimensions':
if (is_array($_POST['cp'][$option])) {
$dim_parts = array();
$is_valid = true;
foreach (array('width', 'height') as $field) {
$requested_dim = trim($_POST['cp'][$option][$field]);
if ($requested_dim == "") {
$dim_parts[] = $requested_dim;
} else {
if ((int)$requested_dim == $requested_dim) {
$dim_parts[] = $requested_dim;
} else {
$is_valid = false; break;
}
}
}
if ($is_valid) {
$this->comicpress_options[$option] = implode("x", $dim_parts);
}
}
break;
}
}
}
}
$this->update_comicpress_options();
}
}
}
$comicpress_options_admin = new ComicPressOptionsAdmin();

View File

@ -114,10 +114,37 @@ class OptionsPageTest extends PHPUnit_Framework_TestCase {
array(
array('comic_category_id' => 1),
array('cp' => array(
'comic_category_id' => 3),
),
'comic_category_id' => 3
)),
array('comic_category_id' => 1)
),
array(
array('comic_dimensions' => '150x150'),
array('cp' => array(
'comic_dimensions' => 'test'
)),
array('comic_dimensions' => '150x150')
),
array(
array('comic_dimensions' => '150x150'),
array('cp' => array(
'comic_dimensions' => array(
'width' => '150',
'height' => ''
)
)),
array('comic_dimensions' => '150x')
),
array(
array('comic_dimensions' => '150x150'),
array('cp' => array(
'comic_dimensions' => array(
'width' => '150.1',
'height' => ''
)
)),
array('comic_dimensions' => '150x150')
),
);
}