2016-05-04 02:15:20 +02:00
|
|
|
<?php
|
|
|
|
|
2016-12-26 15:44:53 +01:00
|
|
|
namespace Miniflux\Controller;
|
|
|
|
|
|
|
|
use Miniflux\Helper;
|
2016-08-25 03:17:58 +02:00
|
|
|
use Miniflux\Router;
|
|
|
|
use Miniflux\Response;
|
|
|
|
use Miniflux\Request;
|
2016-12-26 15:44:53 +01:00
|
|
|
use Miniflux\Session\SessionStorage;
|
2016-08-25 03:17:58 +02:00
|
|
|
use Miniflux\Template;
|
|
|
|
use Miniflux\Model;
|
|
|
|
|
2016-05-04 02:15:20 +02:00
|
|
|
Router\get_action('search', function() {
|
2016-12-26 15:44:53 +01:00
|
|
|
$user_id = SessionStorage::getInstance()->getUserId();
|
2016-05-04 02:15:20 +02:00
|
|
|
$text = Request\param('text', '');
|
|
|
|
$offset = Request\int_param('offset', 0);
|
|
|
|
|
|
|
|
$items = array();
|
|
|
|
$nb_items = 0;
|
|
|
|
if ($text) {
|
2016-12-26 15:44:53 +01:00
|
|
|
$items = Model\ItemSearch\get_all_items($user_id, $text, $offset, Helper\config('items_per_page'));
|
|
|
|
$nb_items = Model\ItemSearch\count_items($user_id, $text);
|
2016-05-04 02:15:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Response\html(Template\layout('search', array(
|
2016-12-26 15:44:53 +01:00
|
|
|
'favicons' => Model\Favicon\get_items_favicons($items),
|
|
|
|
'original_marks_read' => Helper\config('original_marks_read'),
|
2016-05-04 02:15:20 +02:00
|
|
|
'text' => $text,
|
|
|
|
'items' => $items,
|
|
|
|
'order' => '',
|
|
|
|
'direction' => '',
|
2016-12-26 15:44:53 +01:00
|
|
|
'display_mode' => Helper\config('items_display_mode'),
|
|
|
|
'item_title_link' => Helper\config('item_title_link'),
|
2016-05-04 02:15:20 +02:00
|
|
|
'group_id' => array(),
|
|
|
|
'nb_items' => $nb_items,
|
|
|
|
'offset' => $offset,
|
2016-12-26 15:44:53 +01:00
|
|
|
'items_per_page' => Helper\config('items_per_page'),
|
2016-05-04 02:15:20 +02:00
|
|
|
'nothing_to_read' => Request\int_param('nothing_to_read'),
|
|
|
|
'menu' => 'search',
|
|
|
|
'title' => t('Search').' ('.$nb_items.')'
|
|
|
|
)));
|
|
|
|
});
|