mobile: fix uncategorized category not respecting the browse cat setting

This commit is contained in:
Andrew Dolgov 2011-03-18 18:08:07 +03:00
parent ebb948c24e
commit 4308d33ff4
1 changed files with 56 additions and 52 deletions

View File

@ -4,7 +4,7 @@
/* TODO replace with interface to db-prefs */ /* TODO replace with interface to db-prefs */
function mobile_pref_toggled($link, $id) { function mobile_pref_toggled($link, $id) {
if (get_pref($link, "_MOBILE_$id")) if (get_pref($link, "_MOBILE_$id"))
return "true"; return "true";
else else
return ""; return "";
@ -51,10 +51,10 @@
AND ttrss_user_entries.ref_id = ttrss_entries.id AND ttrss_user_entries.ref_id = ttrss_entries.id
AND owner_uid = '$owner_uid') AS unread AND owner_uid = '$owner_uid') AS unread
FROM ttrss_feeds FROM ttrss_feeds
WHERE WHERE
ttrss_feeds.owner_uid = '$owner_uid' ttrss_feeds.owner_uid = '$owner_uid'
ORDER BY $order_by $limit_qpart"); ORDER BY $order_by $limit_qpart");
if (!$offset) print '<ul id="home" title="'.__('Home').'" selected="true" if (!$offset) print '<ul id="home" title="'.__('Home').'" selected="true"
myBackLabel="'.__('Logout').'" myBackHref="logout.php" myBackTarget="_self">'; myBackLabel="'.__('Logout').'" myBackHref="logout.php" myBackTarget="_self">';
@ -68,14 +68,14 @@
$unread = $line["unread"]; $unread = $line["unread"];
// $unread = rand(0, 100); // $unread = rand(0, 100);
if ($unread > 0) { if ($unread > 0) {
$line["title"] = $line["title"] . " ($unread)"; $line["title"] = $line["title"] . " ($unread)";
$class = ''; $class = '';
} else { } else {
$class = 'oldItem'; $class = 'oldItem';
} }
if (mobile_feed_has_icon($id)) { if (mobile_feed_has_icon($id)) {
$icon_url = "../".ICONS_URL."/$id.ico"; $icon_url = "../".ICONS_URL."/$id.ico";
} else { } else {
@ -83,8 +83,8 @@
} }
if ($unread > 0 || !mobile_get_pref($link, "HIDE_READ")) { if ($unread > 0 || !mobile_get_pref($link, "HIDE_READ")) {
print "<li class='$class'><a href='feed.php?id=$id'>" . print "<li class='$class'><a href='feed.php?id=$id'>" .
"<img class='tinyIcon' src='$icon_url'/>". "<img class='tinyIcon' src='$icon_url'/>".
$line["title"] . "</a></li>"; $line["title"] . "</a></li>";
} }
@ -93,7 +93,7 @@
/* $next_offset = $offset + $num_feeds; /* $next_offset = $offset + $num_feeds;
print "<li><a href=\"home.php?skip=$next_offset\" print "<li><a href=\"home.php?skip=$next_offset\"
target=\"_replace\">Show more feeds...</a></li>"; */ target=\"_replace\">Show more feeds...</a></li>"; */
if (!$offset) print "</ul>"; if (!$offset) print "</ul>";
@ -102,7 +102,7 @@
function render_category($link, $cat_id, $offset) { function render_category($link, $cat_id, $offset) {
$owner_uid = $_SESSION["uid"]; $owner_uid = $_SESSION["uid"];
if ($cat_id >= 0) { if ($cat_id >= 0) {
if ($cat_id != 0) { if ($cat_id != 0) {
@ -124,31 +124,31 @@
AND ttrss_user_entries.ref_id = ttrss_entries.id AND ttrss_user_entries.ref_id = ttrss_entries.id
AND owner_uid = '$owner_uid') as unread AND owner_uid = '$owner_uid') as unread
FROM ttrss_feeds FROM ttrss_feeds
WHERE WHERE
ttrss_feeds.owner_uid = '$owner_uid' AND ttrss_feeds.owner_uid = '$owner_uid' AND
$cat_query $cat_query
ORDER BY $order_by"); ORDER BY $order_by");
$title = getCategoryTitle($link, $cat_id); $title = getCategoryTitle($link, $cat_id);
print "<ul id='cat-$cat_id' title='$title' myBackLabel='".__("Home")."' print "<ul id='cat-$cat_id' title='$title' myBackLabel='".__("Home")."'
myBackHref='home.php'>"; myBackHref='home.php'>";
// print "<li><a href='#cat-actions'>".__('Actions...')."</a></li>"; // print "<li><a href='#cat-actions'>".__('Actions...')."</a></li>";
while ($line = db_fetch_assoc($result)) { while ($line = db_fetch_assoc($result)) {
$id = $line["id"]; $id = $line["id"];
$unread = $line["unread"]; $unread = $line["unread"];
// $unread = rand(0, 100); // $unread = rand(0, 100);
if ($unread > 0) { if ($unread > 0) {
$line["title"] = $line["title"] . " ($unread)"; $line["title"] = $line["title"] . " ($unread)";
$class = ''; $class = '';
} else { } else {
$class = 'oldItem'; $class = 'oldItem';
} }
if (mobile_feed_has_icon($id)) { if (mobile_feed_has_icon($id)) {
$icon_url = "../".ICONS_URL."/$id.ico"; $icon_url = "../".ICONS_URL."/$id.ico";
} else { } else {
@ -156,12 +156,12 @@
} }
if ($unread > 0 || !mobile_get_pref($link, "HIDE_READ")) { if ($unread > 0 || !mobile_get_pref($link, "HIDE_READ")) {
print "<li class='$class'><a href='feed.php?id=$id&cat=$cat_id'>" . print "<li class='$class'><a href='feed.php?id=$id&cat=$cat_id'>" .
"<img class='tinyIcon' src='$icon_url'/>". "<img class='tinyIcon' src='$icon_url'/>".
$line["title"] . "</a></li>"; $line["title"] . "</a></li>";
} }
} }
print "</ul>"; print "</ul>";
} else if ($cat_id == -1) { } else if ($cat_id == -1) {
@ -232,13 +232,13 @@
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>"; // 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);
if ($unread > 0) { if ($unread > 0) {
$title = $title . " ($unread)"; $title = $title . " ($unread)";
$class = ''; $class = '';
} else { } else {
@ -251,14 +251,14 @@
print "<li class='$class'><a href='feed.php?id=$id&is_cat=true'>$title</a></li>"; print "<li class='$class'><a href='feed.php?id=$id&is_cat=true'>$title</a></li>";
} }
$result = db_query($link, "SELECT $result = db_query($link, "SELECT
ttrss_feed_categories.id, ttrss_feed_categories.id,
ttrss_feed_categories.title, ttrss_feed_categories.title,
COUNT(ttrss_feeds.id) AS num_feeds COUNT(ttrss_feeds.id) AS num_feeds
FROM ttrss_feed_categories, ttrss_feeds FROM ttrss_feed_categories, ttrss_feeds
WHERE ttrss_feed_categories.owner_uid = $owner_uid WHERE ttrss_feed_categories.owner_uid = $owner_uid
AND ttrss_feed_categories.id = cat_id AND ttrss_feed_categories.id = cat_id
GROUP BY ttrss_feed_categories.id, GROUP BY ttrss_feed_categories.id,
ttrss_feed_categories.title ttrss_feed_categories.title
ORDER BY ttrss_feed_categories.title"); ORDER BY ttrss_feed_categories.title");
@ -278,8 +278,8 @@
if ($unread > 0 || !mobile_get_pref($link, "HIDE_READ")) { if ($unread > 0 || !mobile_get_pref($link, "HIDE_READ")) {
if ($cat_browse) if ($cat_browse)
print "<li class='$class'><a href='cat.php?id=$id'>" . print "<li class='$class'><a href='cat.php?id=$id'>" .
$line["title"] . "</a></li>"; $line["title"] . "</a></li>";
else else
print "<li class='$class'><a href='feed.php?id=$id&is_cat=true'>". print "<li class='$class'><a href='feed.php?id=$id&is_cat=true'>".
@ -306,14 +306,18 @@
} }
if ($unread > 0 || !mobile_get_pref($link, "HIDE_READ")) { if ($unread > 0 || !mobile_get_pref($link, "HIDE_READ")) {
print "<li class='$class'><a href='cat.php?id=0'>$title</a></li>"; if ($cat_browse)
print "<li class='$class'><a href='cat.php?id=0'>$title</a></li>";
else
print "<li class='$class'><a href='feed.php?id=0&is_cat=true'>$title</a></li>";
} }
} }
print "</ul>"; print "</ul>";
} }
function render_headlines_list($link, $feed_id, $cat_id, $offset, $search, function render_headlines_list($link, $feed_id, $cat_id, $offset, $search,
$is_cat = false) { $is_cat = false) {
$feed_id = $feed_id; $feed_id = $feed_id;
@ -329,7 +333,7 @@
$match_on = ''; $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);
$result = $qfh_ret[0]; $result = $qfh_ret[0];
@ -337,7 +341,7 @@
if (!$offset) { if (!$offset) {
print "<form id=\"searchForm-$feed_id-$cat_id\" class=\"dialog\" method=\"POST\" print "<form id=\"searchForm-$feed_id-$cat_id\" class=\"dialog\" method=\"POST\"
action=\"feed.php\"> action=\"feed.php\">
<input type=\"hidden\" name=\"id\" value=\"$feed_id\"> <input type=\"hidden\" name=\"id\" value=\"$feed_id\">
@ -351,7 +355,7 @@
<label>Search:</label> <label>Search:</label>
<input id=\"search\" type=\"text\" name=\"search\"/> <input id=\"search\" type=\"text\" name=\"search\"/>
</fieldset> </fieldset>
</form>"; </form>";
if ($cat_id) { if ($cat_id) {
$cat_title = getCategoryTitle($link, $cat_id); $cat_title = getCategoryTitle($link, $cat_id);
@ -412,7 +416,7 @@
$articles_url = "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"; "&search=$search";
print "<li><a href=\"$articles_url\" print "<li><a href=\"$articles_url\"
target=\"_replace\">Get more articles...</a></li>"; target=\"_replace\">Get more articles...</a></li>";
} }
@ -427,7 +431,7 @@
".SUBSTRING_FOR_DATE."(updated,1,16) as updated, ".SUBSTRING_FOR_DATE."(updated,1,16) as updated,
author author
FROM ttrss_entries,ttrss_user_entries FROM ttrss_entries,ttrss_user_entries
WHERE id = '$id' AND ref_id = id AND owner_uid = " . WHERE id = '$id' AND ref_id = id AND owner_uid = " .
$_SESSION["uid"] ; $_SESSION["uid"] ;
$result = db_query($link, $query); $result = db_query($link, $query);
@ -436,8 +440,8 @@
$line = db_fetch_assoc($result); $line = db_fetch_assoc($result);
$tmp_result = db_query($link, "UPDATE ttrss_user_entries $tmp_result = db_query($link, "UPDATE ttrss_user_entries
SET unread = false,last_read = NOW() SET unread = false,last_read = NOW()
WHERE ref_id = '$id' WHERE ref_id = '$id'
AND owner_uid = " . $_SESSION["uid"]); AND owner_uid = " . $_SESSION["uid"]);
@ -445,29 +449,29 @@
$title = $line["title"]; $title = $line["title"];
$article_link = $line["link"]; $article_link = $line["link"];
$feed_title = getFeedTitle($link, $feed_id, false); $feed_title = getFeedTitle($link, $feed_id, false);
print "<div class=\"panel\" id=\"article-$id\" title=\"$title\" print "<div class=\"panel\" id=\"article-$id\" title=\"$title\"
selected=\"true\" selected=\"true\"
myBackLabel='$feed_title' myBackHref='feed.php?id=$feed_id&cat=$cat_id'>"; myBackLabel='$feed_title' myBackHref='feed.php?id=$feed_id&cat=$cat_id'>";
print "<h2><a target='_blank' href='$article_link'>$title</a></h2>"; print "<h2><a target='_blank' href='$article_link'>$title</a></h2>";
print "<fieldset>"; print "<fieldset>";
/* print "<div class=\"row\">"; /* print "<div class=\"row\">";
print "<label id='title'><a target='_blank' href='$article_link'>$title</a></label>"; print "<label id='title'><a target='_blank' href='$article_link'>$title</a></label>";
print "</div>"; */ print "</div>"; */
$is_starred = (sql_bool_to_bool($line["marked"])) ? "true" : "false"; $is_starred = (sql_bool_to_bool($line["marked"])) ? "true" : "false";
$is_published = (sql_bool_to_bool($line["published"])) ? "true" : "false"; $is_published = (sql_bool_to_bool($line["published"])) ? "true" : "false";
print "<div class=\"row\">"; print "<div class=\"row\">";
print "<label id='updated'>Updated:</label>"; print "<label id='updated'>Updated:</label>";
print "<input enabled='false' name='updated' disabled value='$updated_fmt'/>"; print "<input enabled='false' name='updated' disabled value='$updated_fmt'/>";
print "</div>"; print "</div>";
print "</fieldset>"; print "</fieldset>";
$content = sanitize_rss($link, $line["content"]); $content = sanitize_rss($link, $line["content"]);
@ -491,7 +495,7 @@
<label>Starred</label> <label>Starred</label>
<div class=\"toggle\" onclick=\"toggleMarked($id, this)\" toggled=\"$is_starred\"><span class=\"thumb\"></span><span class=\"toggleOn\">ON</span><span class=\"toggleOff\">OFF</span></div> <div class=\"toggle\" onclick=\"toggleMarked($id, this)\" toggled=\"$is_starred\"><span class=\"thumb\"></span><span class=\"toggleOn\">ON</span><span class=\"toggleOff\">OFF</span></div>
</div>"; </div>";
print "<div class=\"row\"> print "<div class=\"row\">
<label>Published</label> <label>Published</label>
<div class=\"toggle\" onclick=\"togglePublished($id, this)\" toggled=\"$is_published\"><span class=\"thumb\"></span><span class=\"toggleOn\">ON</span><span class=\"toggleOff\">OFF</span></div> <div class=\"toggle\" onclick=\"togglePublished($id, this)\" toggled=\"$is_published\"><span class=\"thumb\"></span><span class=\"toggleOn\">ON</span><span class=\"toggleOff\">OFF</span></div>