+
+
+
+
+
+
+
diff --git a/plugins/mobile/logout.php b/plugins/mobile/logout.php
new file mode 100644
index 00000000..afc411ab
--- /dev/null
+++ b/plugins/mobile/logout.php
@@ -0,0 +1,15 @@
+
diff --git a/plugins/mobile/mobile-functions.php b/plugins/mobile/mobile-functions.php
new file mode 100644
index 00000000..8c2ab88c
--- /dev/null
+++ b/plugins/mobile/mobile-functions.php
@@ -0,0 +1,539 @@
+ 0) {
+ $limit_qpart = "LIMIT $limit OFFSET $offset";
+ } else {
+ $limit_qpart = "";
+ }
+
+ $result = db_query($link, "SELECT id,
+ title,
+ (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries
+ WHERE feed_id = ttrss_feeds.id AND unread = true
+ AND ttrss_user_entries.ref_id = ttrss_entries.id
+ AND owner_uid = '$owner_uid') AS unread
+ FROM ttrss_feeds
+ WHERE
+ ttrss_feeds.owner_uid = '$owner_uid'
+ ORDER BY $order_by $limit_qpart");
+
+ if (!$offset) print '
';
+
+
+ // print "- ".__('Actions...')."
";
+
+ $num_feeds = 0;
+
+ while ($line = db_fetch_assoc($result)) {
+ $id = $line["id"];
+ $unread = $line["unread"];
+
+ // $unread = rand(0, 100);
+
+ if ($unread > 0) {
+ $line["title"] = $line["title"] . " ($unread)";
+ $class = '';
+ } else {
+ $class = 'oldItem';
+ }
+
+ if (mobile_feed_has_icon($id)) {
+ $icon_url = "../../".ICONS_URL."/$id.ico";
+ } else {
+ $icon_url = "../../images/blank_icon.gif";
+ }
+
+ if ($unread > 0 || !mobile_get_pref($link, "HIDE_READ")) {
+ print "- " .
+ "".
+ $line["title"] . "
";
+ }
+
+ ++$num_feeds;
+ }
+
+/* $next_offset = $offset + $num_feeds;
+
+ print "- Show more feeds...
"; */
+
+ if (!$offset) print "
";
+
+ }
+
+ function render_category($link, $cat_id, $offset) {
+ $owner_uid = $_SESSION["uid"];
+
+ if ($cat_id >= 0) {
+
+ if ($cat_id != 0) {
+ $cat_query = "cat_id = '$cat_id'";
+ } else {
+ $cat_query = "cat_id IS NULL";
+ }
+
+ if (mobile_get_pref($link, "SORT_FEEDS_UNREAD")) {
+ $order_by = "unread DESC, title";
+ } else {
+ $order_by = "title";
+ }
+
+ $result = db_query($link, "SELECT id,
+ title,
+ (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries
+ WHERE feed_id = ttrss_feeds.id AND unread = true
+ AND ttrss_user_entries.ref_id = ttrss_entries.id
+ AND owner_uid = '$owner_uid') as unread
+ FROM ttrss_feeds
+ WHERE
+ ttrss_feeds.owner_uid = '$owner_uid' AND
+ $cat_query
+ ORDER BY $order_by");
+
+ $title = getCategoryTitle($link, $cat_id);
+
+ print "
";
+
+ // print "- ".__('Actions...')."
";
+
+ while ($line = db_fetch_assoc($result)) {
+ $id = $line["id"];
+ $unread = $line["unread"];
+
+ // $unread = rand(0, 100);
+
+ if ($unread > 0) {
+ $line["title"] = $line["title"] . " ($unread)";
+ $class = '';
+ } else {
+ $class = 'oldItem';
+ }
+
+ if (mobile_feed_has_icon($id)) {
+ $icon_url = "../../".ICONS_URL."/$id.ico";
+ } else {
+ $icon_url = "../../images/blank_icon.gif";
+ }
+
+ if ($unread > 0 || !mobile_get_pref($link, "HIDE_READ")) {
+ print "- " .
+ "".
+ $line["title"] . "
";
+ }
+ }
+
+ print "
";
+ } else if ($cat_id == -1) {
+
+ $title = __('Special');
+
+ print "
";
+
+ foreach (array(-4, -3, -1, -2, 0) as $id) {
+ $title = getFeedTitle($link, $id);
+ $unread = getFeedUnread($link, $id, false);
+ $icon = getFeedIcon($id);
+
+ if ($unread > 0) {
+ $title = $title . " ($unread)";
+ $class = '';
+ } else {
+ $class = 'oldItem';
+ }
+
+ if ($unread > 0 || !mobile_get_pref($link, "HIDE_READ")) {
+ print "-
+
+ $title
";
+ }
+ }
+
+ print "
";
+ } else if ($cat_id == -2) {
+
+ $title = __('Labels');
+
+ print "
";
+
+ $result = db_query($link, "SELECT id, caption FROM ttrss_labels2
+ WHERE owner_uid = '$owner_uid'");
+
+ $label_data = array();
+
+ while ($line = db_fetch_assoc($result)) {
+
+ $id = -$line["id"] - 11;
+
+ $unread = getFeedUnread($link, $id);
+ $title = $line["caption"];
+
+ if ($unread > 0) {
+ $title = $title . " ($unread)";
+ $class = '';
+ } else {
+ $class = 'oldItem';
+ }
+
+ if ($unread > 0 || !mobile_get_pref($link, "HIDE_READ")) {
+ print "-
+ $title
";
+ }
+ }
+ print "
";
+ }
+ }
+
+ function render_categories_list($link) {
+ $owner_uid = $_SESSION["uid"];
+
+ $cat_browse = mobile_get_pref($link, "BROWSE_CATS");
+
+ print '
';
+
+// print "- Search...
";
+
+ foreach (array(-1, -2) as $id) {
+ $title = getCategoryTitle($link, $id);
+ $unread = getFeedUnread($link, $id, true);
+ if ($unread > 0) {
+ $title = $title . " ($unread)";
+ $class = '';
+ } else {
+ $class = 'oldItem';
+ }
+
+ if ($cat_browse)
+ print "- $title
";
+ else
+ print "- $title
";
+ }
+
+ $result = db_query($link, "SELECT
+ ttrss_feed_categories.id,
+ ttrss_feed_categories.title,
+ COUNT(ttrss_feeds.id) AS num_feeds
+ FROM ttrss_feed_categories, ttrss_feeds
+ WHERE ttrss_feed_categories.owner_uid = $owner_uid
+ AND ttrss_feed_categories.id = cat_id
+ GROUP BY ttrss_feed_categories.id,
+ ttrss_feed_categories.title
+ ORDER BY ttrss_feed_categories.title");
+
+ while ($line = db_fetch_assoc($result)) {
+
+ if ($line["num_feeds"] > 0) {
+
+ $unread = getFeedUnread($link, $line["id"], true);
+ $id = $line["id"];
+
+ if ($unread > 0) {
+ $line["title"] = $line["title"] . " ($unread)";
+ $class = '';
+ } else {
+ $class = 'oldItem';
+ }
+
+ if ($unread > 0 || !mobile_get_pref($link, "HIDE_READ")) {
+
+ if ($cat_browse)
+ print "- " .
+ $line["title"] . "
";
+ else
+ print "- ".
+ $line["title"] . "
";
+ }
+ }
+ }
+
+
+ $result = db_query($link, "SELECT COUNT(*) AS nf FROM ttrss_feeds WHERE
+ cat_id IS NULL and owner_uid = '$owner_uid'");
+
+ $num_feeds = db_fetch_result($result, 0, "nf");
+
+ if ($num_feeds > 0) {
+ $unread = getFeedUnread($link, 0, true);
+ $title = "Uncategorized";
+
+ if ($unread > 0) {
+ $title = "$title ($unread)";
+ $class = '';
+ } else {
+ $class = 'oldItem';
+ }
+
+ if ($unread > 0 || !mobile_get_pref($link, "HIDE_READ")) {
+ if ($cat_browse)
+ print "- $title
";
+ else
+ print "- $title
";
+
+ }
+ }
+
+ print "
";
+ }
+
+ function render_headlines_list($link, $feed_id, $cat_id, $offset, $search,
+ $is_cat = false) {
+
+ $feed_id = $feed_id;
+ $limit = 15;
+ $filter = '';
+
+ if (!mobile_get_pref($link, "HIDE_READ"))
+ $view_mode = "all_articles";
+ else
+ $view_mode = 'adaptive';
+
+ if ($search) {
+ $search_mode = 'this_feed';
+ } else {
+ $search_mode = '';
+ }
+
+ $qfh_ret = queryFeedHeadlines($link, $feed_id, $limit,
+ $view_mode, $is_cat, $search, $search_mode,
+ "score DESC, date_entered ".(mobile_get_pref($link, 'REVERSE_HEADLINES') ? 'ASC' : 'DESC'), $offset);
+
+ $result = $qfh_ret[0];
+ $feed_title = $qfh_ret[1];
+
+ if (!$offset) {
+
+ print "
";
+
+ if ($cat_id) {
+ $cat_title = getCategoryTitle($link, $cat_id);
+
+ print "
";
+ } else {
+ print "";
+ }
+
+ print "- Search...
";
+ }
+
+ $num_headlines = 0;
+
+ while ($line = db_fetch_assoc($result)) {
+ $id = $line["id"];
+ $real_feed_id = $line["feed_id"];
+
+ if (sql_bool_to_bool($line["unread"])) {
+ $class = '';
+ } else {
+ $class = 'oldItem';
+ }
+
+ if (mobile_feed_has_icon($real_feed_id)) {
+ $icon_url = "../../".ICONS_URL."/$real_feed_id.ico";
+ } else {
+ $icon_url = "../../images/blank_icon.gif";
+ }
+
+ print "-
+ ";
+ print $line["title"];
+ print "
";
+
+ ++$num_headlines;
+
+ }
+
+ if ($num_headlines == 0 && $search) {
+ $articles_url = "feed.php?id=$feed_id&cat=$cat_id&skip=$next_offset";
+
+ print "- " . __("Nothing found (click to reload feed).") . "
";
+
+ }
+
+// print "Next $limit articles...";
+
+ $next_offset = $offset + $num_headlines;
+ $num_unread = getFeedUnread($link, $feed_id, $is_cat);
+
+ /* FIXME needs normal implementation */
+
+ if ($num_headlines > 0 && ($num_unread == 0 || $num_unread > $next_offset)) {
+
+ if ($is_cat) {
+ $articles_url = "feed.php?id=$feed_id&skip=$next_offset".
+ "&search=$search&is_cat=true";
+ } else {
+ $articles_url = "feed.php?id=$feed_id&cat=$cat_id&skip=$next_offset".
+ "&search=$search";
+ }
+
+ print "- Get more articles...
";
+ }
+
+ if (!$offset) print "
";
+
+ }
+
+ function render_article($link, $id, $feed_id, $cat_id, $is_cat) {
+
+ $query = "SELECT title,link,content,feed_id,comments,int_id,
+ marked,unread,published,
+ ".SUBSTRING_FOR_DATE."(updated,1,16) as updated,
+ author
+ FROM ttrss_entries,ttrss_user_entries
+ WHERE id = '$id' AND ref_id = id AND owner_uid = " .
+ $_SESSION["uid"] ;
+
+ $result = db_query($link, $query);
+
+ if (db_num_rows($result) != 0) {
+
+ $line = db_fetch_assoc($result);
+
+ $tmp_result = db_query($link, "UPDATE ttrss_user_entries
+ SET unread = false,last_read = NOW()
+ WHERE ref_id = '$id'
+ AND owner_uid = " . $_SESSION["uid"]);
+
+ $updated_fmt = make_local_datetime($link, $line['updated'], false);
+
+ $title = $line["title"];
+ $article_link = $line["link"];
+
+ if (!$is_cat)
+ $feed_title = getFeedTitle($link, $feed_id);
+ else
+ $feed_title = getCategoryTitle($link, $feed_id);
+
+ print "";
+
+ if ($line['feed_id'] != $feed_id) {
+ $real_feed_title = getFeedTitle($link, $line['feed_id']);
+ $real_feed_id = $line['feed_id'];
+ $feed_link = "(
$real_feed_title)";
+ }
+// print "
";
+
+ $content = sanitize($link, $line["content"]);
+ $content = preg_replace("/href=/i", "target=\"_blank\" href=", $content);
+
+ if (!mobile_get_pref($link, "SHOW_IMAGES")) {
+ $content = preg_replace('/
]+>/is', '', $content);
+ }
+
+ print "
$content
";
+
+ print "
+
+
Prev
+
Next
+
";
+
+ print "
";
+
+ print "
";
+
+ }
+ }
+?>
diff --git a/plugins/mobile/mobile.css b/plugins/mobile/mobile.css
new file mode 100644
index 00000000..8068e3d3
--- /dev/null
+++ b/plugins/mobile/mobile.css
@@ -0,0 +1,38 @@
+div.nav {
+ height: 40px;
+ -webkit-border-radius: 10px;
+ -moz-border-radius: 10px;
+ background-color: #ffffff;
+ border: 1px solid #999999;
+ text-align: center;
+ margin-bottom: 1em;
+}
+div.nav label {
+ line-height: 40px;
+ color: black;
+ font-weight: bold;
+}
+div.nav .button {
+ position: static;
+ margin: 5px 10px;
+ -webkit-border-image: url(../lib/iui/whiteButton.png) 0 12 0 12;
+ text-shadow: rgba(255, 255, 255, 0.7) 0 1px 0;
+ color: black;
+ cursor: pointer; /* On a touch screen ? */
+}
+div.nav .button.left {
+ float: left;
+}
+div.nav .button.right {
+ float: right;
+}
+
+ul li a.read {
+ color: #666666;
+}
+
+ul li span.browse {
+ color : #909090;
+ text-align : right;
+ float : right;
+}
diff --git a/plugins/mobile/mobile.js b/plugins/mobile/mobile.js
new file mode 100644
index 00000000..3fed3a1d
--- /dev/null
+++ b/plugins/mobile/mobile.js
@@ -0,0 +1,163 @@
+var backend = "backend.php";
+
+function toggleMarked(id, elem) {
+
+ var toggled = false;
+
+ if (elem.getAttribute("toggled") == "true") {
+ toggled = 1;
+ } else {
+ toggled = 0;
+ }
+
+ var query = "op=toggleMarked&id=" + id + "&mark=" + toggled;
+
+ new Ajax.Request(backend, {
+ parameters: query,
+ onComplete: function (transport) {
+ //
+ } });
+}
+
+function togglePublished(id, elem) {
+
+ var toggled = false;
+
+ if (elem.getAttribute("toggled") == "true") {
+ toggled = 1;
+ } else {
+ toggled = 0;
+ }
+
+ var query = "op=togglePublished&id=" + id + "&pub=" + toggled;
+
+ new Ajax.Request(backend, {
+ parameters: query,
+ onComplete: function (transport) {
+ //
+ } });
+
+}
+
+function toggleUnread(id, elem) {
+
+ var toggled = false;
+
+ if (elem.getAttribute("toggled") == "true") {
+ toggled = 1;
+ } else {
+ toggled = 0;
+ }
+
+ var query = "op=toggleUnread&id=" + id + "&unread=" + toggled;
+
+ new Ajax.Request(backend, {
+ parameters: query,
+ onComplete: function (transport) {
+ //
+ } });
+
+}
+
+function setPref(elem) {
+ var toggled = false;
+ var id = elem.id;
+
+ if (elem.getAttribute("toggled") == "true") {
+ toggled = 1;
+ } else {
+ toggled = 0;
+ }
+
+ var query = "op=setPref&id=" + id + "&to=" + toggled;
+
+ new Ajax.Request(backend, {
+ parameters: query,
+ onComplete: function (transport) {
+ //
+ } });
+
+}
+
+// Go directly to another item in the same feed
+function goToSibling(article_id, feed_id, link, step) {
+ var links = linksInFeed(feed_id);
+ for (var i=0 ; i= links.length) {
+ showRestOfFeed(feed_id);
+ return false;
+ }
+ console.log(links[index]);
+ var match = links[index].href.match(/.*article\.php\?(.*)/);
+ var qs = match[1];
+ var backwards = false;
+ if (step < 0) backwards = true;
+ link.setAttribute("selected", "progress");
+ function unselect() { link.removeAttribute("selected"); }
+ iui.showPageByHref("article.php?"+qs, null, null, null, unselect, backwards);
+ return false;
+ }
+ return false;
+}
+function goPrev(article_id, feed_id, link) {
+ return goToSibling(article_id, feed_id, link, -1);
+}
+function goNext(article_id, feed_id, link) {
+ return goToSibling(article_id, feed_id, link, 1);
+}
+
+// Get all the links in the feed. The all_links variable includes the "get more article" link
+function linksInFeed(feed_id, all_links) {
+ var feed_content = $("feed-"+feed_id);
+ var links_raw = feed_content.getElementsByTagName("a");
+ if (all_links) return links_raw;
+ var links = [];
+ // filter the array to remove the "get more articles" link
+ // and the "search" link (which is always first)
+ for (var i=1 ; i
+
+
+
+