Group export feeds by category (#9079)

* Group export feeds by category

## What changed
- Groups feed choices in the import/export page by their existing FreshRSS category.
- Preserves the current export request format and selection behavior.

## Why
The export selector previously mixed feeds from every category, making a category-specific export difficult to assemble.

Closes #5555

* Declare export feed count view data

* Fix select size

---------

Co-authored-by: Gerard Alvear <gerard.alvear@logiqd.me>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
This commit is contained in:
Gerard Alvear Porras
2026-07-29 16:58:54 +02:00
committed by GitHub
parent f3b85383e5
commit dd2ef8ffa6
3 changed files with 17 additions and 6 deletions

View File

@@ -32,7 +32,8 @@ class FreshRSS_importExport_Controller extends FreshRSS_ActionController {
* This action displays the main page for import / export system.
*/
public function indexAction(): void {
$this->view->feeds = $this->feedDAO->listFeeds();
$this->view->categories = $this->categoryDAO->listCategories();
$this->view->feedCount = array_sum(array_map(static fn(FreshRSS_Category $category): int => count($category->feeds()), $this->view->categories));
FreshRSS_View::prependTitle(_t('sub.import_export.title') . ' · ');
$this->listSqliteArchives();
}

View File

@@ -91,6 +91,7 @@ class FreshRSS_View extends Minz_View {
// Export / Import
public string $content;
public int $feedCount;
/** @var array<string,array<string>> */
public array $entryIdsTagNames = [];
public string $list_title;

View File

@@ -35,7 +35,7 @@
</form>
<h2><?= _t('sub.import_export.export') ?></h2>
<?php if (count($this->feeds) > 0) { ?>
<?php if ($this->feedCount > 0) { ?>
<form method="post" action="<?= _url('importExport', 'export') ?>" data-auto-leave-validation="1">
<input type="hidden" name="_csrf" value="<?= FreshRSS_Auth::csrfToken() ?>" />
<div class="form-group">
@@ -58,14 +58,23 @@
<?php
$select_args = '';
if (extension_loaded('zip')) {
$select_args = ' size="' . min(10, count($this->feeds)) . '" multiple="multiple"';
$select_args = ' size="' . min(10, count($this->categories) + $this->feedCount) . '" multiple="multiple"';
}
?>
<select name="export_feeds[]"<?= $select_args ?>>
<?= extension_loaded('zip') ? '' : '<option></option>' ?>
<?php foreach ($this->feeds as $feed) { ?>
<option value="<?= $feed->id() ?>"><?= $feed->name() ?></option>
<?php } ?>
<?php foreach ($this->categories as $category):
$feeds = $category->feeds();
if (empty($feeds)) {
continue;
}
?>
<optgroup label="<?= $category->name() ?>">
<?php foreach ($feeds as $feed) { ?>
<option value="<?= $feed->id() ?>"><?= $feed->name() ?></option>
<?php } ?>
</optgroup>
<?php endforeach; ?>
</select>
</div>
</div>