]> git.wh0rd.org Git - tt-rss.git/commitdiff
more mobile work (add missing files)
authorAndrew Dolgov <fox@bah.spb.su>
Mon, 27 Mar 2006 02:47:07 +0000 (03:47 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Mon, 27 Mar 2006 02:47:07 +0000 (03:47 +0100)
mobile/functions.php [new file with mode: 0644]
mobile/login.php [new file with mode: 0644]
mobile/mobile.css [new file with mode: 0644]

diff --git a/mobile/functions.php b/mobile/functions.php
new file mode 100644 (file)
index 0000000..0cfad97
--- /dev/null
@@ -0,0 +1,239 @@
+<?
+
+       function render_feeds_list($link, $tags = false) {
+
+               print "<ul class=\"feedList\">";
+
+               $owner_uid = $_SESSION["uid"];
+
+               if (!$tags) {
+
+                       /* virtual feeds */
+
+                       if (get_pref($link, 'ENABLE_FEED_CATS')) {
+                               print "<li class=\"feedCat\">Special</li>";
+                               print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">";
+                       }
+
+                       $result = db_query($link, "SELECT count(id) as num_starred 
+                               FROM ttrss_entries,ttrss_user_entries 
+                               WHERE marked = true AND 
+                               ttrss_user_entries.ref_id = ttrss_entries.id AND
+                               unread = true AND owner_uid = '$owner_uid'");
+                       $num_starred = db_fetch_result($result, 0, "num_starred");
+
+                       $class = "virt";
+
+                       if ($num_starred > 0) $class .= "Unread";
+
+                       printFeedEntry(-1, $class, "Starred articles", $num_starred, 
+                               "../images/mark_set.png", $link);
+
+                       if (get_pref($link, 'ENABLE_FEED_CATS')) {
+                               print "</ul>";
+                       }
+
+                       if (GLOBAL_ENABLE_LABELS && get_pref($link, 'ENABLE_LABELS')) {
+       
+                               $result = db_query($link, "SELECT id,sql_exp,description FROM
+                                       ttrss_labels WHERE owner_uid = '$owner_uid' ORDER by description");
+               
+                               if (db_num_rows($result) > 0) {
+                                       if (get_pref($link, 'ENABLE_FEED_CATS')) {
+                                               print "<li class=\"feedCat\">Labels</li>";
+                                               print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">";
+                                       } else {
+                                               print "<li><hr></li>";
+                                       }
+                               }
+               
+                               while ($line = db_fetch_assoc($result)) {
+       
+                                       error_reporting (0);
+               
+                                       $tmp_result = db_query($link, "SELECT count(id) as count 
+                                               FROM ttrss_entries,ttrss_user_entries
+                                               WHERE (" . $line["sql_exp"] . ") AND unread = true AND
+                                               ttrss_user_entries.ref_id = ttrss_entries.id
+                                               AND owner_uid = '$owner_uid'");
+       
+                                       $count = db_fetch_result($tmp_result, 0, "count");
+       
+                                       $class = "label";
+       
+                                       if ($count > 0) {
+                                               $class .= "Unread";
+                                       }
+                                       
+                                       error_reporting (DEFAULT_ERROR_LEVEL);
+       
+                                       printFeedEntry(-$line["id"]-11, 
+                                               $class, $line["description"], $count, "../images/label.png", $link);
+               
+                               }
+
+                               if (db_num_rows($result) > 0) {
+                                       if (get_pref($link, 'ENABLE_FEED_CATS')) {
+                                               print "</ul>";
+                                       }
+                               }
+
+                       }
+
+//                     if (!get_pref($link, 'ENABLE_FEED_CATS')) {
+                               print "<li><hr></li>";
+//                     }
+
+                       if (get_pref($link, 'ENABLE_FEED_CATS')) {
+                               $order_by_qpart = "category,title";
+                       } else {
+                               $order_by_qpart = "title";
+                       }
+
+                       $result = db_query($link, "SELECT ttrss_feeds.*,
+                               (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries
+                                       WHERE feed_id = ttrss_feeds.id AND 
+                                       ttrss_user_entries.ref_id = ttrss_entries.id AND
+                                       owner_uid = '$owner_uid') AS total,
+                               (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,
+                               cat_id,last_error,
+                               ttrss_feed_categories.title AS category,
+                               ttrss_feed_categories.collapsed 
+                               FROM ttrss_feeds LEFT JOIN ttrss_feed_categories 
+                                       ON (ttrss_feed_categories.id = cat_id)                          
+                               WHERE 
+                                       ttrss_feeds.owner_uid = '$owner_uid' AND parent_feed IS NULL
+                               ORDER BY $order_by_qpart"); 
+
+                       $actid = $_GET["actid"];
+       
+                       /* real feeds */
+       
+                       $lnum = 0;
+       
+                       $total_unread = 0;
+
+                       $category = "";
+       
+                       while ($line = db_fetch_assoc($result)) {
+                       
+                               $feed = db_unescape_string($line["title"]);
+                               $feed_id = $line["id"];   
+       
+                               $subop = $_GET["subop"];
+                               
+                               $total = $line["total"];
+                               $unread = $line["unread"];
+
+                               $rtl_content = sql_bool_to_bool($line["rtl_content"]);
+
+                               if ($rtl_content) {
+                                       $rtl_tag = "dir=\"RTL\"";
+                               } else {
+                                       $rtl_tag = "";
+                               }
+
+                               $tmp_result = db_query($link,
+                                       "SELECT id,COUNT(unread) AS unread
+                                       FROM ttrss_feeds LEFT JOIN ttrss_user_entries 
+                                               ON (ttrss_feeds.id = ttrss_user_entries.feed_id) 
+                                       WHERE parent_feed = '$feed_id' AND unread = true 
+                                       GROUP BY ttrss_feeds.id");
+                       
+                               if (db_num_rows($tmp_result) > 0) {                             
+                                       while ($l = db_fetch_assoc($tmp_result)) {
+                                               $unread += $l["unread"];
+                                       }
+                               }
+
+                               $cat_id = $line["cat_id"];
+
+                               $tmp_category = $line["category"];
+
+                               if (!$tmp_category) {
+                                       $tmp_category = "Uncategorized";
+                               }
+                               
+       //                      $class = ($lnum % 2) ? "even" : "odd";
+
+                               if ($line["last_error"]) {
+                                       $class = "error";
+                               } else {
+                                       $class = "feed";
+                               }
+       
+                               if ($unread > 0) $class .= "Unread";
+       
+                               if ($actid == $feed_id) {
+                                       $class .= "Selected";
+                               }
+       
+                               $total_unread += $unread;
+
+                               if ($category != $tmp_category && get_pref($link, 'ENABLE_FEED_CATS')) {
+                               
+                                       if ($category) {
+                                               print "</ul></li>";
+                                       }
+                               
+                                       $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 = "";
+                                               $ellipsis = "";
+                                       }
+
+                                       if ($cat_id) {
+                                               $cat_id_qpart = "cat_id = '$cat_id'";
+                                       } else {
+                                               $cat_id_qpart = "cat_id IS NULL";
+                                       }
+
+                                       $tmp_result = db_query($link, "SELECT count(int_id) AS unread
+                                               FROM ttrss_user_entries,ttrss_feeds WHERE
+                                                       unread = true AND
+                                                       feed_id = ttrss_feeds.id AND $cat_id_qpart AND
+                                                       ttrss_user_entries.owner_uid = " . $_SESSION["uid"]);
+
+                                       $cat_unread = db_fetch_result($tmp_result, 0, "unread");
+
+                                       $cat_id = sprintf("%d", $cat_id);
+                                       
+                                       print "<li class=\"feedCat\">
+                                               <a href=\"FIXME\">$tmp_category</a>
+                                                       <a href=\"FIXME\">
+                                                               <span class=\"$catctr_class\">($cat_unread unread)$ellipsis</span></a></li>";
+
+                                       // !!! NO SPACE before <ul...feedCatList - breaks firstChild DOM function
+                                       // -> keyboard navigation, etc.
+                                       print "<li id=\"feedCatHolder\" class=\"$holder_class\"><ul class=\"feedCatList\" id=\"FCATLIST-$cat_id\">";
+                               }
+       
+                               printFeedEntry($feed_id, $class, $feed, $unread, 
+                                       "icons/$feed_id.ico", $link, $rtl_content);
+       
+                               ++$lnum;
+                       }
+
+
+       } else {
+               print "Function not implemented.";
+       }
+       }
+
+?>
diff --git a/mobile/login.php b/mobile/login.php
new file mode 100644 (file)
index 0000000..0e2d0c8
--- /dev/null
@@ -0,0 +1,93 @@
+<?
+//     require_once "sessions.php";
+
+       require_once "../version.php"; 
+       require_once "../config.php";
+       require_once "../functions.php";
+
+       $url_path = get_script_urlpath();
+       $redirect_base = "http://" . $_SERVER["SERVER_NAME"] . $url_path;
+
+       if (SINGLE_USER_MODE) {
+               header("Location: $redirect_base/tt-rss.php");
+               exit;
+       }
+
+       $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); 
+
+       $login = $_POST["login"];
+       $password = $_POST["password"];
+       $return_to = $_POST["rt"];
+
+       if ($_COOKIE["ttrss_sid"]) {
+               require_once "../sessions.php";
+               if ($_SESSION["uid"]) {
+                       initialize_user_prefs($link, $_SESSION["uid"]); 
+                       header("Location: $redirect_base/tt-rss.php");
+                       exit;
+               }
+       }
+
+       if ($login && $password) {
+
+               if ($_POST["remember_me"]) {
+                       session_set_cookie_params(SESSION_COOKIE_LIFETIME_REMEMBER);
+               } else {
+                       session_set_cookie_params(SESSION_COOKIE_LIFETIME);
+               }
+                       
+               require_once "../sessions.php";
+
+               if (authenticate_user($link, $login, $password)) {
+                       initialize_user_prefs($link, $_SESSION["uid"]); 
+
+                       if ($_POST["remember_me"]) {
+                               $_SESSION["cookie_lifetime"] = time() + SESSION_COOKIE_LIFETIME_REMEMBER;
+                       } else {
+                               $_SESSION["cookie_lifetime"] = time() + SESSION_COOKIE_LIFETIME;
+                       }
+
+                       setcookie("ttrss_cltime", $_SESSION["cookie_lifetime"], 
+                               $_SESSION["cookie_lifetime"]);
+
+                       if (!$return_to) {
+                               $return_to = "tt-rss.php";
+                       }
+                       header("Location: $redirect_base/$return_to");
+                       exit;
+               }
+       }
+
+?>
+<html>
+<head>
+       <title>Tiny Tiny RSS : Login</title>
+       <link rel="stylesheet" type="text/css" href="mobile.css">
+       <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+</head>
+
+<body>
+
+       <div class="main">
+
+       <h1>Tiny Tiny RSS</h1>
+
+       <form action="login.php" method="POST">
+
+               Login: <input name="login"><br>
+               Password: <input type="password" name="password"><br>
+
+               <input type="checkbox" name="remember_me" id="remember_me">
+               <label for="remember_me">Remember me</label><br>
+               
+               <input type="submit" class="button" value="Login">
+               <input type="hidden" name="rt" value="<?= $_GET['rt'] ?>">
+
+       </form>
+
+       </div>
+</body>
+</html>
+
+<? db_close($link); ?>
+
diff --git a/mobile/mobile.css b/mobile/mobile.css
new file mode 100644 (file)
index 0000000..796bf23
--- /dev/null
@@ -0,0 +1,79 @@
+body {
+       padding : 0px;
+       margin : 0px;
+}
+
+input {
+       border : 1px solid #a0a0a0;
+}
+
+.button {
+       border : 1px solid #d0d0d0;
+       background-image : url("../images/button.png");
+       background-position : top;
+       background-repeat : repeat-x;
+       background-color : white;
+       color : black;  
+}
+
+.button:hover {
+       background : white;
+       text-decoration : none;
+       color : black;
+}
+
+td.heading {
+       font-weight : bold;
+}
+
+td.content {
+       background-image : url("../images/vgrad_light_rev.png");
+       background-position : top left;
+       background-repeat : repeat-x;
+       border-width : 1px 0px 0px 0px;
+       border-style : solid;
+       border-color : #c0c0c0;
+}
+
+form {
+       padding : 0px;
+       margin : 0px;
+}
+
+ul.feedList {
+       list-style-type : none;
+       margin : 5px;
+       padding : 0px 0px 0px 10px;
+}
+
+ul.feedList li.feedCat {
+       margin : 0px;
+       padding : 3px 0px 3px 0px;
+       color : #707070;
+       font-size : x-small;
+}
+
+ul.feedList li.feedCat a {
+       color : #707070;
+}
+
+ul.feedList li.feedCat a:hover {
+       color : #5050aa;
+}
+
+ul.feedCatList {
+       list-style-type : none;
+       margin : 0px 0px 0px 20px;
+       padding : 0px;  
+}
+
+ul.feedCatList li {
+       margin : 0px;
+       padding : 0px 0px 0px 0px;
+       color : black;
+}
+
+ul.feedList li {
+       margin : 0px;
+}
+