Skip to content

Commit

Permalink
keep selected options on feed adding error
Browse files Browse the repository at this point in the history
  • Loading branch information
mkresin committed Apr 10, 2015
1 parent ee98a62 commit f346af2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
16 changes: 6 additions & 10 deletions controllers/feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@
// Display form to add one feed
Router\get_action('add', function() {

$values = array('download_content' => 0, 'rtl' => 0, 'cloak_referrer' => 0);

Response\html(Template\layout('add', array(
'values' => array(
'csrf' => Model\Config\generate_csrf(),
),
'values' => $values + array('csrf' => Model\Config\generate_csrf()),
'errors' => array(),
'nb_unread_items' => Model\Item\count_by_status('unread'),
'menu' => 'feeds',
Expand All @@ -158,9 +158,8 @@
}
}

$values += array('download_content' => 0, 'rtl' => 0, 'cloak_referrer' => 0);
$url = trim($url);
$feed_id = Model\Feed\create($url, $values['download_content'], $values['rtl'], $values['cloak_referrer']);
$values += array('url' => trim($url), 'download_content' => 0, 'rtl' => 0, 'cloak_referrer' => 0);
$feed_id = Model\Feed\create($values['url'], $values['download_content'], $values['rtl'], $values['cloak_referrer']);

if ($feed_id) {
Session\flash(t('Subscription added successfully.'));
Expand All @@ -171,10 +170,7 @@
}

Response\html(Template\layout('add', array(
'values' => array(
'url' => $url,
'csrf' => Model\Config\generate_csrf(),
),
'values' => $values + array('csrf' => Model\Config\generate_csrf()),
'nb_unread_items' => Model\Item\count_by_status('unread'),
'menu' => 'feeds',
'title' => t('Subscriptions')
Expand Down
6 changes: 3 additions & 3 deletions templates/add.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<?= 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_checkbox('rtl', t('Force RTL mode (Right-to-left language)'), 1, isset($values['rtl']) ? $values['rtl'] : false) ?><br/>
<?= Helper\form_checkbox('download_content', t('Download full content'), 1, isset($values['download_content']) ? $values['download_content'] : false) ?><br/>
<?= Helper\form_checkbox('cloak_referrer', t('Cloak the image referrer'), 1, isset($values['cloak_referrer']) ? $values['cloak_referrer'] : 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, $values['download_content']) ?><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>
<div class="form-actions">
Expand Down

0 comments on commit f346af2

Please sign in to comment.