3 namespace Friendica\Module\Search;
5 use Friendica\Content\Nav;
6 use Friendica\Content\Pager;
7 use Friendica\Content\Text\HTML;
8 use Friendica\Content\Widget;
9 use Friendica\Core\Renderer;
10 use Friendica\Database\DBA;
12 use Friendica\Model\Item;
13 use Friendica\Model\Post;
14 use Friendica\Model\Post\Category;
15 use Friendica\Module\BaseSearch;
16 use Friendica\Module\Security\Login;
18 class Filed extends BaseSearch
20 public static function content(array $parameters = [])
26 DI::page()['aside'] .= Widget::fileAs(DI::args()->getCommand(), $_GET['file'] ?? '');
28 if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll') && ($_GET['mode'] ?? '') != 'minimal') {
29 $tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
30 $o = Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
35 $file = $_GET['file'] ?? '';
37 // Rawmode is used for fetching new content at the end of the page
38 if (!(isset($_GET['mode']) && ($_GET['mode'] == 'raw'))) {
39 Nav::setSelected(DI::args()->get(0));
42 if (DI::mode()->isMobile()) {
43 $itemspage_network = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
44 DI::config()->get('system', 'itemspage_network_mobile'));
46 $itemspage_network = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
47 DI::config()->get('system', 'itemspage_network'));
50 $last_uriid = isset($_GET['last_uriid']) ? intval($_GET['last_uriid']) : 0;
52 $pager = new Pager(DI::l10n(), DI::args()->getQueryString(), $itemspage_network);
54 $term_condition = ['type' => Category::FILE, 'uid' => local_user()];
56 $term_condition['name'] = $file;
59 if (!empty($last_uriid)) {
60 $term_condition = DBA::mergeConditions($term_condition, ["`uri-id` < ?", $last_uriid]);
63 $term_params = ['order' => ['uri-id' => true], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
64 $result = DBA::select('category-view', ['uri-id'], $term_condition, $term_params);
66 $count = DBA::count('category-view', $term_condition);
69 while ($term = DBA::fetch($result)) {
70 $posts[] = $term['uri-id'];
74 if (count($posts) == 0) {
77 $item_condition = ['uid' => [0, local_user()], 'uri-id' => $posts];
78 $item_params = ['order' => ['uri-id' => true, 'uid' => true]];
80 $items = Post::toArray(Post::selectForUser(local_user(), Item::DISPLAY_FIELDLIST, $item_condition, $item_params));
82 $o .= DI::conversation()->create($items, 'filed', false, false, '', local_user());
84 if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) {
85 $o .= HTML::scrollLoader();
87 $o .= $pager->renderMinimal($count);