keep selected options on feed adding error

This commit is contained in:
Mathias Kresin 2015-04-10 20:08:33 +02:00
parent ee98a62519
commit f346af2f38
2 changed files with 9 additions and 13 deletions

View File

@ -129,10 +129,10 @@ Router\get_action('feeds', function() {
// Display form to add one feed // Display form to add one feed
Router\get_action('add', function() { Router\get_action('add', function() {
$values = array('download_content' => 0, 'rtl' => 0, 'cloak_referrer' => 0);
Response\html(Template\layout('add', array( Response\html(Template\layout('add', array(
'values' => array( 'values' => $values + array('csrf' => Model\Config\generate_csrf()),
'csrf' => Model\Config\generate_csrf(),
),
'errors' => array(), 'errors' => array(),
'nb_unread_items' => Model\Item\count_by_status('unread'), 'nb_unread_items' => Model\Item\count_by_status('unread'),
'menu' => 'feeds', 'menu' => 'feeds',
@ -158,9 +158,8 @@ Router\action('subscribe', function() {
} }
} }
$values += array('download_content' => 0, 'rtl' => 0, 'cloak_referrer' => 0); $values += array('url' => trim($url), 'download_content' => 0, 'rtl' => 0, 'cloak_referrer' => 0);
$url = trim($url); $feed_id = Model\Feed\create($values['url'], $values['download_content'], $values['rtl'], $values['cloak_referrer']);
$feed_id = Model\Feed\create($url, $values['download_content'], $values['rtl'], $values['cloak_referrer']);
if ($feed_id) { if ($feed_id) {
Session\flash(t('Subscription added successfully.')); Session\flash(t('Subscription added successfully.'));
@ -171,10 +170,7 @@ Router\action('subscribe', function() {
} }
Response\html(Template\layout('add', array( Response\html(Template\layout('add', array(
'values' => array( 'values' => $values + array('csrf' => Model\Config\generate_csrf()),
'url' => $url,
'csrf' => Model\Config\generate_csrf(),
),
'nb_unread_items' => Model\Item\count_by_status('unread'), 'nb_unread_items' => Model\Item\count_by_status('unread'),
'menu' => 'feeds', 'menu' => 'feeds',
'title' => t('Subscriptions') 'title' => t('Subscriptions')

View File

@ -17,9 +17,9 @@
<?= Helper\form_label(t('Website or Feed URL'), 'url') ?> <?= Helper\form_label(t('Website or Feed URL'), 'url') ?>
<?= Helper\form_text('url', $values, array(), array('required', 'autofocus', 'placeholder="'.t('http://website/').'"')) ?><br/><br/> <?= Helper\form_text('url', $values, array(), array('required', 'autofocus', 'placeholder="'.t('http://website/').'"')) ?><br/><br/>
<?= 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 />
<p class="form-help"><?= t('Downloading full content is slower because Miniflux grab the content from the original website. You should use that for subscriptions that display only a summary. This feature doesn\'t work with all websites.') ?></p> <p class="form-help"><?= t('Downloading full content is slower because Miniflux grab the content from the original website. You should use that for subscriptions that display only a summary. This feature doesn\'t work with all websites.') ?></p>
<div class="form-actions"> <div class="form-actions">