From: Andrew Dolgov Date: Mon, 21 Dec 2009 13:56:59 +0000 (+0300) Subject: mobile: add classic mobile version X-Git-Tag: 1.4.0~150 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=1afd6227bcb259f9f5a663e2935eee833b51f558;p=tt-rss.git mobile: add classic mobile version --- diff --git a/mobile/classic/functions.php b/mobile/classic/functions.php new file mode 100644 index 00000000..88b25ab2 --- /dev/null +++ b/mobile/classic/functions.php @@ -0,0 +1,857 @@ +"; + + if ($tags) { + print __("Tags")." + (".__("View feeds").", "; + } else { + print __("Feeds")." + (".__("View tags").", "; + } + + print "".__("Search").", "; + + print "".__("Logout").")"; + print ""; + + print ""; + } + + $category = $tmp_category; + + $collapsed = $line["collapsed"]; + + // workaround for NULL category + if ($category == "Uncategorized") { + if ($_COOKIE["ttrss_vf_uclps"] == 1) { + $collapsed = "t"; + } + } + + if ($collapsed == "t" || $collapsed == "1") { + $holder_class = "invisible"; + $ellipsis = "..."; + } else { + $holder_class = "feedCatHolder"; + $ellipsis = ""; + } + + if ($cat_id) { + $cat_id_qpart = "cat_id = '$cat_id'"; + } else { + $cat_id_qpart = "cat_id IS NULL"; + } + + $cat_id = sprintf("%d", $cat_id); + $cat_unread = getCategoryUnread($link, $cat_id); + + if ($cat_unread > 0) { + $catctr_class = ""; + } else { + $catctr_class = "invisible"; + } + + print "
  • + $tmp_category + + ($cat_unread)$ellipsis +
  • "; + + print "
  • +
      "; + } + + printMobileFeedEntry($feed_id, $class, $feed, $unread, + "../icons/$feed_id.ico", $link, $rtl_content); + + ++$lnum; + } + + } else { + // tags + + $result = db_query($link, "SELECT tag_name,SUM((SELECT COUNT(int_id) + FROM ttrss_user_entries WHERE int_id = post_int_id + AND unread = true)) AS count FROM ttrss_tags + WHERE owner_uid = '".$_SESSION['uid']."' GROUP BY tag_name ORDER BY tag_name"); + + $tags = array(); + + while ($line = db_fetch_assoc($result)) { + $tags[$line["tag_name"]] += $line["count"]; + } + + foreach (array_keys($tags) as $tag) { + + $unread = $tags[$tag]; + + $class = "tag"; + + if ($unread > 0) { + $class .= "Unread"; + } + + printMobileFeedEntry($tag, $class, $tag, $unread, + "../images/tag.png", $link); + + } + + + } + } + + function printMobileFeedEntry($feed_id, $class, $feed_title, $unread, $icon_file, $link, + $rtl_content = false) { + + if (file_exists($icon_file) && filesize($icon_file) > 0) { + $feed_icon = ""; + } else { + $feed_icon = ""; + } + + if ($rtl_content) { + $rtl_tag = "dir=\"rtl\""; + } else { + $rtl_tag = "dir=\"ltr\""; + } + + $feed = "$feed_title"; + + print "
    • "; +# if (get_pref($link, 'ENABLE_FEED_ICONS')) { +# print "$feed_icon"; +# } + + print "$feed "; + + if ($unread != 0) { + print "($unread)"; + } + + print "
    • "; + + } + + function render_headlines($link) { + + $feed = db_escape_string($_GET["id"]); + $limit = db_escape_string($_GET["limit"]); + $view_mode = db_escape_string($_GET["viewmode"]); + $cat_view = db_escape_string($_GET["cat"]); + $subop = $_GET["subop"]; + $catchup_op = $_GET["catchup_op"]; + + if (!$view_mode) { + if ($_SESSION["mobile:viewmode"]) { + $view_mode = $_SESSION["mobile:viewmode"]; + } else { + $view_mode = "adaptive"; + } + } + + $_SESSION["mobile:viewmode"] = $view_mode; + + if (!$limit) $limit = 30; + if (!$feed) $feed = 0; + + if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) { + + $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds + WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]); + + if (db_num_rows($result) == 1) { + $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); + } else { + $rtl_content = false; + } + + if ($rtl_content) { + $rtl_tag = "dir=\"RTL\""; + } else { + $rtl_tag = ""; + } + } else { + $rtl_content = false; + $rtl_tag = ""; + } + + print "
      "; + + if ($subop == "ForceUpdate" && sprintf("%d", $feed) > 0) { + update_generic_feed($link, $feed, $cat_view, true); + } + + if ($subop == "MarkAllRead" || $catchup_op == "feed") { + catchup_feed($link, $feed, $cat_view); + } + + if ($catchup_op == "selection") { + $ids_to_mark = array_keys($_GET["sel_ids"]); + if ($ids_to_mark) { + foreach ($ids_to_mark as $id) { + db_query($link, "UPDATE ttrss_user_entries SET + unread = false,last_read = NOW() + WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); + } + } + } + + if ($subop == "MarkPageRead" || $catchup_op == "page") { + $ids_to_mark = $_SESSION["last_page_ids.$feed"]; + + if ($ids_to_mark) { + + foreach ($ids_to_mark as $id) { + db_query($link, "UPDATE ttrss_user_entries SET + unread = false,last_read = NOW() + WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); + } + } + } + + + /// START ///////////////////////////////////////////////////////////////////////////////// + + $search = db_escape_string($_GET["query"]); + $search_mode = db_escape_string($_GET["search_mode"]); + $match_on = db_escape_string($_GET["match_on"]); + + if (!$match_on) { + $match_on = "both"; + } + + $real_offset = $offset * $limit; + + if ($_GET["debug"]) $timing_info = print_checkpoint("H0", $timing_info); + + $qfh_ret = queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, + $search, $search_mode, $match_on, false, $real_offset); + + if ($_GET["debug"]) $timing_info = print_checkpoint("H1", $timing_info); + + $result = $qfh_ret[0]; + $feed_title = $qfh_ret[1]; + $feed_site_url = $qfh_ret[2]; + $last_error = $qfh_ret[3]; + + /// STOP ////////////////////////////////////////////////////////////////////////////////// + + if (!$result) { + print "
      ". + __("Could not display feed (query failed). Please check label match syntax or local configuration."). + "
      "; + return; + } + + print "
      "; + # if (!$cat_view && file_exists("../icons/$feed.ico") && filesize("../icons/$feed.ico") > 0) { + # print ""; + # } + + print "$feed_title ("; + print "".__("Back").", "; + print "".__("Search").", "; + print "".__("Update").""; + +# print "Mark as read: "; +# print "Page, "; +# print "Feed"; + + print ")"; + + print " " . __('View:'); + + print "
      "; + + /* print ""; */ + + $sel_values = array( + "adaptive" => __("Adaptive"), + "all_articles" => __("All Articles"), + "unread" => __("Unread"), + "marked" => __("Starred")); + + print_select_hash("viewmode", $view_mode, $sel_values); + + print " + + + "; + print "
      "; + + print "
      "; + + if (db_num_rows($result) > 0) { + + print "
      "; + print ""; + print ""; + print ""; + + print "
        "; + + $page_art_ids = array(); + + $lnum = 0; + + error_reporting (DEFAULT_ERROR_LEVEL); + + $num_unread = 0; + + while ($line = db_fetch_assoc($result)) { + + $class = ($lnum % 2) ? "even" : "odd"; + + $id = $line["id"]; + $feed_id = $line["feed_id"]; + + array_push($page_art_ids, $id); + + if ($line["last_read"] == "" && + ($line["unread"] != "t" && $line["unread"] != "1")) { + + $update_pic = "\"".__("Updated")."\""; + } else { + $update_pic = "\"".__("Updated")."\""; + } + + if ($line["unread"] == "t" || $line["unread"] == "1") { + $class .= "Unread"; + ++$num_unread; + $is_unread = true; + } else { + $is_unread = false; + } + + if ($line["marked"] == "t" || $line["marked"] == "1") { + $marked_pic = "\"S\""; + } else { + $marked_pic = "\"s\""; + } + + if ($line["published"] == "t" || $line["published"] == "1") { + $published_pic = "\"P\""; + } else { + $published_pic = "\"p\""; + } + + $content_link = "" . + $line["title"] . ""; + + if (get_pref($link, 'HEADLINES_SMART_DATE')) { + $updated_fmt = smart_date_time(strtotime($line["updated"])); + } else { + $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); + $updated_fmt = date($short_date, strtotime($line["updated"])); + } + + print "
      • "; + + print ""; + + print "$marked_pic"; + print "$published_pic"; + + print $content_link; + + if ($line["feed_title"]) { + print " (". + $line["feed_title"].")"; + } + + print " ($updated_fmt)"; + + print "
      • "; + + + ++$lnum; + } + + print "
      "; + + print "
      "; + + $_SESSION["last_page_ids.$feed"] = $page_art_ids; + +/* print "Page, "; + print "Feed
      "; */ + + print "Select: + ".__("All").", + ".__("Unread").", + ".__("None").", + ".__("Invert").""; + + print " "; + + print " + + "; + + print "
      "; + + } else { + print "
      No articles found.
      "; + } + + } + + function render_article($link) { + + $id = db_escape_string($_GET["id"]); + $feed_id = db_escape_string($_GET["feed"]); + $ret_feed_id = db_escape_string($_GET["ret_feed"]); + $cat_view = db_escape_string($_GET["cat"]); + + $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds + WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); + + if (db_num_rows($result) == 1) { + $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); + } else { + $rtl_content = false; + } + + if ($rtl_content) { + $rtl_tag = "dir=\"RTL\""; + $rtl_class = "RTL"; + } else { + $rtl_tag = ""; + $rtl_class = ""; + } + + $result = db_query($link, "UPDATE ttrss_user_entries + SET unread = false,last_read = NOW() + WHERE ref_id = '$id' AND feed_id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); + + $result = db_query($link, "SELECT title,link,content,feed_id,comments,int_id, + marked,published, + ".SUBSTRING_FOR_DATE."(updated,1,16) as updated, + (SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url, + num_comments, + author + FROM ttrss_entries,ttrss_user_entries + WHERE id = '$id' AND ref_id = id"); + + if ($result) { + + $line = db_fetch_assoc($result); + + $num_comments = $line["num_comments"]; + $entry_comments = ""; + + if ($num_comments > 0) { + if ($line["comments"]) { + $comments_url = $line["comments"]; + } else { + $comments_url = $line["link"]; + } + $entry_comments = "$num_comments comments"; + } else { + if ($line["comments"] && $line["link"] != $line["comments"]) { + $entry_comments = "comments"; + } + } + + $tmp_result = db_query($link, "SELECT DISTINCT tag_name FROM + ttrss_tags WHERE post_int_id = " . $line["int_id"] . " + ORDER BY tag_name"); + + $tags_str = ""; + $f_tags_str = ""; + + $num_tags = 0; + + while ($tmp_line = db_fetch_assoc($tmp_result)) { + $num_tags++; + $tag = $tmp_line["tag_name"]; + $tag_str = "$tag, "; + $tags_str .= $tag_str; + } + + $tags_str = preg_replace("/, $/", "", $tags_str); + + $parsed_updated = date(get_pref($link, 'SHORT_DATE_FORMAT'), + strtotime($line["updated"])); + + print "
      "; + + # if (file_exists("../icons/$feed_id.ico") && filesize("../icons/$feed_id.ico") > 0) { + # print ""; + # } + + if (!$cat_view) { + $feed_title = getFeedTitle($link, $ret_feed_id); + } else { + $feed_title = getCategoryTitle($link, $ret_feed_id); + $feed_title_native = getFeedTitle($link, $feed_id); + } + + if ($feed_title_native) { + $feed_link = "$feed_title_native"; + $feed_link .= " in + $feed_title"; + } else { + $feed_link = "$feed_title"; + } + + $feedlist = "".__('Back to feedlist').""; + + print "" . + truncate_string($line["title"], 30) . ""; + print " $parsed_updated ($feed_link, $feedlist)"; + print "
      "; + + if ($num_tags > 0) { + print "
      ".__("Tags:")." $tags_str
      "; + } + + if ($line["marked"] == "t" || $line["marked"] == "1") { + $marked_pic = ""; + } else { + $marked_pic = ""; + } + + if ($line["published"] == "t" || $line["published"] == "1") { + $published_pic = ""; + } else { + $published_pic = ""; + } + + + print "
      "; + print "$marked_pic"; + print "$published_pic"; + // Mark unread + print ""; + print "
      "; + + print sanitize_rss($link, $line["content"], true);; + + } + + print ""; + } + + function render_search_form($link, $active_feed_id = false, $is_cat = false) { + + print "
      "; + + print __("Search")." + (".__("Go back").")
      "; + + print "
      "; + + print ""; + print ""; + print ""; + + print ""; + + print ""; + + print "
      ".__('Search:').""; + print "
      ".__('Where:').""; + + print "
      ".__('Match on:').""; + + $search_fields = array( + "title" => __("Title"), + "content" => __("Content"), + "both" => __("Title or content")); + + print_select_hash("match_on", 3, $search_fields); + + print "
      "; + + print ""; + + print "
      "; + + print "
      "; + } + + function toggleMarked($link, $ts_id) { + $result = db_query($link, "UPDATE ttrss_user_entries SET marked = NOT marked + WHERE ref_id = '$ts_id' AND owner_uid = " . $_SESSION["uid"]); + } + + function togglePublished($link, $tp_id) { + $result = db_query($link, "UPDATE ttrss_user_entries SET published = NOT published + WHERE ref_id = '$tp_id' AND owner_uid = " . $_SESSION["uid"]); + } + + function markUnread($link, $mu_id) { + $result = db_query($link, "UPDATE ttrss_user_entries SET unread = true + WHERE ref_id = '$mu_id' AND owner_uid = " . $_SESSION["uid"]); + } + +?> diff --git a/mobile/classic/index.php b/mobile/classic/index.php new file mode 100644 index 00000000..85ea76b6 --- /dev/null +++ b/mobile/classic/index.php @@ -0,0 +1,155 @@ + + + + Tiny Tiny RSS + + + + + + + + + + + +
      + +
      + + + + + + + + + diff --git a/mobile/classic/login_form.php b/mobile/classic/login_form.php new file mode 100644 index 00000000..bf4f77ea --- /dev/null +++ b/mobile/classic/login_form.php @@ -0,0 +1,79 @@ + + + Tiny Tiny RSS : Login + + + + + + + + + + + + +
      +
      Tiny Tiny RSS
      + +
      + + + + +
      + + + + + + + + + + +
      + +
      + +
      +
      +
      + + + + diff --git a/mobile/classic/logout.php b/mobile/classic/logout.php new file mode 100644 index 00000000..b20cfc9a --- /dev/null +++ b/mobile/classic/logout.php @@ -0,0 +1,9 @@ + diff --git a/mobile/classic/mobile.css b/mobile/classic/mobile.css new file mode 100644 index 00000000..6ba79052 --- /dev/null +++ b/mobile/classic/mobile.css @@ -0,0 +1,218 @@ +body { + padding : 0px; + margin : 0px; + font-family : sans-serif; +} + +h1 { + font-size : medium; +} + +h2 { + font-size : medium; + font-weight : bold; + border-width : 0px 0px 1px 0px; + border-style : solid; + border-color : #88b0ff; +} + +h3 { + font-size : medium; + font-weight : bold; + border-width : 0px 0px 1px 0px; + border-style : solid; + border-color : #e0e0e0; +} + +#heading { + font-size : small; + +/* border-width : 0px 0px 1px 0px; + border-style : solid; + border-color : #88b0ff; + background : #ecf4ff; */ + + color : #88b0ff; + font-weight : bold; + margin-bottom : 10px; +} + +#content { + background : white; +} + +#footer { + font-size : x-small; + color : gray; + margin-top : 5px; +} + +form { + padding : 0px; + margin : 0px; +} + +li.feedCatHolder { + display : inline; +} + +ul.feedList { + list-style-type : none; + margin : 0px; + padding : 0px; + +} + +ul.feedList li.feedCat { + margin : 0px; + padding : 0px; + color : #707070; +} + +ul.feedList li.feedCat a { + color : #707070; +} + +ul.feedList li.feedCat a:hover { + color : #4684ff; +} + +ul.feedCatList { + list-style-type : none; + margin : 0px 0px 0px 1em; + padding : 0px; +} + +ul.feedCatList li { + margin : 0px; + padding : 0px; + color : black; +} + +ul.feedList li { + margin : 0px; +} + +hr { + border-width : 0px 0px 1px 0px; + border-style : dashed; + border-color : #e0e0e0; +} + +ul.headlines a, ul.feedList a { + color : black; +} + +a { + color : #4684ff; + text-decoration : none; +} + +a:hover { + color : black; +} + +ul.feedList img, img.tinyFeedIcon { + margin : 0px 3px 0px 0px; + width : 16px; + height : 16px; + border-width : 0px; +} + +ul.feedlist li.feedUnread, +ul.feedlist li.errorUnread, +ul.feedlist li.labelUnread, +ul.feedlist li.virtUnread, +ul.feedlist li.tagUnread { + font-weight : bold; +} + +.even { +/* background-color : #9bbdff; */ + border-width : 0px 0px 1px 0px; + border-color : #88b0ff; + border-style : solid; + background-color : #cbddff; +} + +.odd { + border-width : 0px 0px 1px 0px; + border-color : #88b0ff; + border-style : solid; +} + +.evenUnread { + border-width : 0px 0px 1px 0px; + border-color : #88b0ff; + border-style : solid; +/* background-color : #9bbdff; */ + font-weight : bold; + background-color : #cbddff; +} + +.oddUnread { + border-width : 0px 0px 1px 0px; + border-color : #88b0ff; + border-style : solid; + font-weight : bold; +} + +.evenSelected, .oddSelected, .evenUnreadSelected, .oddUnreadSelected { + background-color : #fff7d5; + border-width : 0px 0px 1px 0px; + border-color : #88b0ff; + border-style : solid; +} + +.evenUnreadSelected, .oddUnreadSelected { + font-weight : bold; +} + +.invisible { + display : none; +} + +ul.headlines { + list-style-type : none; + margin : 0px; + padding : 0px; +} + +ul.headlines span.hlUpdated { + color : gray; +} + +ul.headlines img.feedIcon { + width : 25px; + text-align : center; +} + +ul.headlines img.marked { + border-width : 0px; +} + +div.postStarOps img.marked { + border-width : 0px; +} + +div.postTags { + color : gray; + font-size : small; +} + +div.footerAddon { + font-size : small; +} + +.loginError { + color : red; + margin : 0.5em; +} + +form.searchForm { + margin : 5px; +} + +div.postStarOps { + float : right; +} diff --git a/mobile/classic/mobile.js b/mobile/classic/mobile.js new file mode 100644 index 00000000..599e0072 --- /dev/null +++ b/mobile/classic/mobile.js @@ -0,0 +1,94 @@ +function toggleSelectRow(cb, id) { + try { + + var row = document.getElementById("HROW-" + id); + var checked = cb.checked; + if (row) { + var unread = row.className.match("Unread"); + var new_classname = row.className; + + new_classname = new_classname.replace("Selected", ""); + new_classname = new_classname.replace("Unread", ""); + + if (unread) new_classname = new_classname + "Unread"; + if (checked) new_classname = new_classname + "Selected"; + + row.className = new_classname; + } + } catch (e) { + exception_error("toggleSelectRow", e); + } +} + +function selectHeadlines(mode) { + try { + + var cboxes = document.getElementsByTagName("INPUT"); + + for (var i = 0; i < cboxes.length; i++) { + if (cboxes[i].id && cboxes[i].id.match("HSCB-")) { + var row_id = cboxes[i].id.replace("HSCB-", "") + var row = document.getElementById("HROW-" + row_id); + + if (row) { + + if (mode == 1) { + cboxes[i].checked = true; + toggleSelectRow(cboxes[i], row_id); + } + + if (mode == 2) { + + var unread = row.className.match("Unread"); + + if (unread) { + cboxes[i].checked = true; + } else { + cboxes[i].checked = false; + } + } + + if (mode == 3) { + cboxes[i].checked = false; + } + + if (mode == 4) { + cboxes[i].checked = !cboxes[i].checked; + } + + toggleSelectRow(cboxes[i], row_id); + + } + + } + + } + + } catch (e) { + exception_error("selectHeadlines", e); + } +} + +function exception_error(location, e, silent) { + var msg; + + if (e.fileName) { + var base_fname = e.fileName.substring(e.fileName.lastIndexOf("/") + 1); + + msg = "Exception: " + e.name + ", " + e.message + + "\nFunction: " + location + "()" + + "\nLocation: " + base_fname + ":" + e.lineNumber; + + } else if (e.description) { + msg = "Exception: " + e.description + "\nFunction: " + location + "()"; + } else { + msg = "Exception: " + e + "\nFunction: " + location + "()"; + } + + debug("EXCEPTION: " + msg + ""); + + if (!silent) { + alert(msg); + } +} +