minor feed edit dialog improvments

- redirect to feed edit dialog if the changed feed settings couldn't be saved
- add default values and drop isset (similar to the feed add dialog)
This commit is contained in:
Mathias Kresin 2015-04-11 23:05:57 +02:00
parent 07a930cac3
commit 46d69b15f6
3 changed files with 11 additions and 11 deletions

View File

@ -32,18 +32,18 @@ Router\get_action('edit-feed', function() {
Router\post_action('edit-feed', function() { Router\post_action('edit-feed', function() {
$values = Request\values(); $values = Request\values();
$values += array('enabled' => 0, 'download_content' => 0, 'rtl' => 0, 'cloak_referrer' => 0);
list($valid, $errors) = Model\Feed\validate_modification($values); list($valid, $errors) = Model\Feed\validate_modification($values);
if ($valid) { if ($valid) {
if (Model\Feed\update($values)) { if (Model\Feed\update($values)) {
Session\flash(t('Your subscription has been updated.')); Session\flash(t('Your subscription has been updated.'));
Response\redirect('?action=feeds');
} }
else { else {
Session\flash_error(t('Unable to edit your subscription.')); Session\flash_error(t('Unable to edit your subscription.'));
} }
Response\redirect('?action=feeds');
} }
Response\html(Template\layout('edit_feed', array( Response\html(Template\layout('edit_feed', array(

View File

@ -100,10 +100,10 @@ function update(array $values)
'title' => $values['title'], 'title' => $values['title'],
'site_url' => $values['site_url'], 'site_url' => $values['site_url'],
'feed_url' => $values['feed_url'], 'feed_url' => $values['feed_url'],
'enabled' => empty($values['enabled']) ? 0 : $values['enabled'], 'enabled' => $values['enabled'],
'rtl' => empty($values['rtl']) ? 0 : $values['rtl'], 'rtl' => $values['rtl'],
'download_content' => empty($values['download_content']) ? 0 : $values['download_content'], 'download_content' => $values['download_content'],
'cloak_referrer' => empty($values['cloak_referrer']) ? 0 : $values['cloak_referrer'], 'cloak_referrer' => $values['cloak_referrer'],
)); ));
} }

View File

@ -21,13 +21,13 @@
<?= Helper\form_label(t('Feed URL'), 'feed_url') ?> <?= Helper\form_label(t('Feed URL'), 'feed_url') ?>
<?= Helper\form_text('feed_url', $values, $errors, array('required', 'placeholder="http://..."')) ?> <?= Helper\form_text('feed_url', $values, $errors, array('required', 'placeholder="http://..."')) ?>
<?= Helper\form_checkbox('rtl', t('Force RTL mode (Right-to-left language)'), 1, isset($values['rtl']) ? $values['rtl'] : false) ?><br /> <?= Helper\form_checkbox('rtl', t('Force RTL mode (Right-to-left language)'), 1, $values['rtl']) ?><br />
<?= Helper\form_checkbox('download_content', t('Download full content'), 1, isset($values['download_content']) ? $values['download_content'] : false) ?><br /> <?= Helper\form_checkbox('download_content', t('Download full content'), 1, $values['download_content']) ?><br />
<?= Helper\form_checkbox('cloak_referrer', t('Cloak the image referrer'), 1, isset($values['cloak_referrer']) ? $values['cloak_referrer'] : false) ?><br /> <?= Helper\form_checkbox('cloak_referrer', t('Cloak the image referrer'), 1, $values['cloak_referrer']) ?><br />
<?= Helper\form_checkbox('enabled', t('Activated'), 1, isset($values['enabled']) ? $values['enabled'] : false) ?> <?= Helper\form_checkbox('enabled', t('Activated'), 1, $values['enabled']) ?>
<div class="form-actions"> <div class="form-actions">
<button type="submit" class="btn btn-blue"><?= t('Save') ?></button> <button type="submit" class="btn btn-blue"><?= t('Save') ?></button>