mobile: add feed search

This commit is contained in:
Andrew Dolgov 2009-12-18 16:00:58 +03:00
parent 95004daf9d
commit 3585a3c560
2 changed files with 46 additions and 11 deletions

View file

@ -23,7 +23,8 @@
$feed_id = db_escape_string($_REQUEST["id"]); $feed_id = db_escape_string($_REQUEST["id"]);
$cat_id = db_escape_string($_REQUEST["cat"]); $cat_id = db_escape_string($_REQUEST["cat"]);
$offset = (int) db_escape_string($_REQUEST["skip"]); $offset = (int) db_escape_string($_REQUEST["skip"]);
$search = db_escape_string($_REQUEST["search"]);
render_headlines_list($link, $feed_id, $cat_id, $offset); render_headlines_list($link, $feed_id, $cat_id, $offset, $search);
?> ?>

View file

@ -217,11 +217,13 @@
function render_categories_list($link) { function render_categories_list($link) {
$owner_uid = $_SESSION["uid"]; $owner_uid = $_SESSION["uid"];
print '<ul id="home" title="'.__('Home').'" selected="true" print '<ul id="home" title="'.__('Home').'" selected="true"
myBackLabel="'.__('Logout').'" myBackHref="logout.php" myBackTarget="_self">'; myBackLabel="'.__('Logout').'" myBackHref="logout.php" myBackTarget="_self">';
// print "<li><a href='#searchForm'>Search...</a></li>";
foreach (array(-1, -2) as $id) { foreach (array(-1, -2) as $id) {
$title = getCategoryTitle($link, $id); $title = getCategoryTitle($link, $id);
$unread = getFeedUnread($link, $id, true); $unread = getFeedUnread($link, $id, true);
@ -293,7 +295,7 @@
print "</ul>"; print "</ul>";
} }
function render_headlines_list($link, $feed_id, $cat_id, $offset) { function render_headlines_list($link, $feed_id, $cat_id, $offset, $search) {
$feed_id = $feed_id; $feed_id = $feed_id;
$limit = 15; $limit = 15;
@ -301,11 +303,13 @@
$is_cat = false; $is_cat = false;
$view_mode = 'adaptive'; $view_mode = 'adaptive';
/* do not rely on params below */ if ($search) {
$search_mode = 'this_feed';
$search = ''; $match_on = 'both';
$search_mode = ''; } else {
$match_on = ''; $search_mode = '';
$match_on = '';
}
$qfh_ret = queryFeedHeadlines($link, $feed_id, $limit, $qfh_ret = queryFeedHeadlines($link, $feed_id, $limit,
$view_mode, $is_cat, $search, $search_mode, $match_on, false, $offset); $view_mode, $is_cat, $search, $search_mode, $match_on, false, $offset);
@ -314,6 +318,23 @@
$feed_title = $qfh_ret[1]; $feed_title = $qfh_ret[1];
if (!$offset) { if (!$offset) {
print "<form id=\"searchForm\" class=\"dialog\" method=\"POST\"
action=\"feed.php\">
<input type=\"hidden\" name=\"id\" value=\"$feed_id\">
<input type=\"hidden\" name=\"cat\" value=\"$cat_id\">
<fieldset>
<h1>Search</h1>
<a class=\"button leftButton\" type=\"cancel\">Cancel</a>
<a class=\"button blueButton\" type=\"submit\">Search</a>
<label>Search:</label>
<input id=\"search\" type=\"text\" name=\"search\"/>
</fieldset>
</form>";
if ($cat_id) { if ($cat_id) {
$cat_title = getCategoryTitle($link, $cat_id); $cat_title = getCategoryTitle($link, $cat_id);
@ -323,6 +344,8 @@
print "<ul id=\"feed-$feed_id\" title=\"$feed_title\" selected=\"true\" print "<ul id=\"feed-$feed_id\" title=\"$feed_title\" selected=\"true\"
myBackLabel='".__("Home")."' myBackHref='home.php'>"; myBackLabel='".__("Home")."' myBackHref='home.php'>";
} }
print "<li><a href='#searchForm'>Search...</a></li>";
} }
$num_headlines = 0; $num_headlines = 0;
@ -352,6 +375,13 @@
} }
if ($num_headlines == 0 && $search) {
$articles_url = "feed.php?id=$feed_id&cat=$cat_id&skip=$next_offset";
print "<li><a href=\"$articles_url\">" . __("Nothing found (click to reload feed).") . "</a></li>";
}
// print "<a target='_replace' href='feed.php?id=$feed_id&cat=$cat_id&skip=0'>Next $limit articles...</a>"; // print "<a target='_replace' href='feed.php?id=$feed_id&cat=$cat_id&skip=0'>Next $limit articles...</a>";
$next_offset = $offset + $num_headlines; $next_offset = $offset + $num_headlines;
@ -359,8 +389,12 @@
/* FIXME needs normal implementation */ /* FIXME needs normal implementation */
if ($num_unread == 0 || $num_unread > $next_offset) { if ($num_headlines > 0 && ($num_unread == 0 || $num_unread > $next_offset)) {
print "<li><a href=\"feed.php?id=$feed_id&cat=$cat_id&skip=$next_offset\"
$articles_url = "feed.php?id=$feed_id&cat=$cat_id&skip=$next_offset".
"&search=$search";
print "<li><a href=\"$articles_url\"
target=\"_replace\">Get more articles...</a></li>"; target=\"_replace\">Get more articles...</a></li>";
} }