]> git.wh0rd.org Git - tt-rss.git/commitdiff
mobile: implement WIP pagination for flat feedlist
authorAndrew Dolgov <fox@bah.org.ru>
Fri, 18 Dec 2009 12:19:34 +0000 (15:19 +0300)
committerAndrew Dolgov <fox@bah.org.ru>
Fri, 18 Dec 2009 12:19:34 +0000 (15:19 +0300)
functions.php
mobile/functions.php
mobile/home.php
mobile/index.php
mobile/prefs.php

index c0d9eaaea07b2d0077711b1a16e003a96fa62b6f..6708612d6c9f87c6b0ce03a72cc65cecebd8d581 100644 (file)
 
        }
 
+       function getSubscribedFeeds($link) {
+               $result = db_query($link, "SELECT COUNT(id) AS fn FROM 
+                       ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"]);
+
+               return db_fetch_result($result, 0, "fn");
+       }
+
        function getTagCounters($link, $smart_mode = SMART_RPC_COUNTERS) {
 
                if ($smart_mode) {
index 4880e1f57904e1069761b0123ca8fc1f80ec4559..30200a1369880a93027346f03e6b4f79e8cd5e84 100644 (file)
                return file_exists($filename) && filesize($filename) > 0;
        }
 
-       function render_flat_feed_list($link) {
+       function render_flat_feed_list($link, $offset) {
                $owner_uid = $_SESSION["uid"];
+               $limit = 30;
+
+               if (!$offset) $offset = 0;
 
                if (mobile_get_pref($link, "SORT_FEEDS_UNREAD")) {
                        $order_by = "unread DESC, title";
                                ttrss_feeds.hidden = false AND
                                ttrss_feeds.owner_uid = '$owner_uid' AND 
                                parent_feed IS NULL
-                       ORDER BY $order_by"); 
+                       ORDER BY $order_by LIMIT $limit OFFSET $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">';
 
        //              print "<li><a href='#cat-actions'>".__('Actions...')."</a></li>";
-       
+
+                       $num_feeds = 0;
+
                        while ($line = db_fetch_assoc($result)) {
                                $id = $line["id"];
                                $unread = $line["unread"];
                                        print "<li class='$class'><a href='feed.php?id=$id'>" . 
                                                "<img class='tinyIcon' src='$icon_url'/>".                              
                                                $line["title"] . "</a></li>";
+                                       ++$num_feeds;
                                }
                        }
-       
-                       print "</ul>";
 
+                       $next_offset = $offset + $num_feeds;
+
+                       print "<li><a href=\"home.php?skip=$next_offset\" 
+                               target=\"_replace\">Show more feeds...</a></li>";
 
+                       if (!$offset) print "</ul>";
 
        }
 
index 0ac313ac023f2b53370ad2eac52212022be2008d..2830f5530bbae1ad32abe84a9cb4519f8c7b84aa 100644 (file)
 
        login_sequence($link, true);
 
-       $use_cats = get_pref($link, 'ENABLE_FEED_CATS');
+       $use_cats = mobile_get_pref($link, 'ENABLE_CATS');
+       $offset = (int) db_escape_string($_REQUEST["skip"]);
 
        if ($use_cats) {
                render_categories_list($link); 
        } else {
-               render_flat_feed_list($link);
+               render_flat_feed_list($link, $offset);
        }
 ?>
index a530d0e8bc4fb5f41886baf5b6259cc719a6a680..b3221d67e831c5a02fd3fc37b9381302a76bf623 100644 (file)
     </div>
 
        <?php    
-       $use_cats = get_pref($link, 'ENABLE_FEED_CATS');
+       $use_cats = mobile_get_pref($link, 'ENABLE_CATS');
+       $offset = (int) db_escape_string($_REQUEST["skip"]);
 
        if ($use_cats) {
                render_categories_list($link); 
        } else {
-               render_flat_feed_list($link);
+               render_flat_feed_list($link, $offset);
        }
        ?>
 
index a42e31ce74743fe1472eb9f890b3add1f4c983f6..dd53148c27e7dfbf21c671729d7609bece5626fd 100644 (file)
        myBackLabel="<?php echo __('Home') ?>" myBackHref="home.php">
 
 <fieldset>
+
+<div class="row">
+       <label>Enable categories</label>
+       <div class="toggle" id="ENABLE_CATS" onclick="setPref(this)" toggled="<?php echo mobile_pref_toggled($link, "ENABLE_CATS") ?>"><span class="thumb"></span><span class="toggleOn">ON</span><span class="toggleOff">OFF</span></div>
+</div>
+
+<div class="row">
+       <label>Display images</label>
+       <div class="toggle" id="SHOW_IMAGES" onclick="setPref(this)" toggled="<?php echo mobile_pref_toggled($link, "SHOW_IMAGES") ?>"><span class="thumb"></span><span class="toggleOn">ON</span><span class="toggleOff">OFF</span></div>
+</div>
+
 <div class="row">
        <label>Hide read items</label>
        <div class="toggle" id="HIDE_READ" onclick="setPref(this)" toggled="<?php echo mobile_pref_toggled($link, "HIDE_READ") ?>"><span class="thumb"></span><span class="toggleOn">ON</span><span class="toggleOff">OFF</span></div>
@@ -35,9 +46,4 @@
        <div class="toggle" id="SORT_FEEDS_UNREAD" onclick="setPref(this)" toggled="<?php echo mobile_pref_toggled($link, "SORT_FEEDS_UNREAD") ?>"><span class="thumb"></span><span class="toggleOn">ON</span><span class="toggleOff">OFF</span></div>
 </div>
 
-<div class="row">
-       <label>Show images</label>
-       <div class="toggle" id="SHOW_IMAGES" onclick="setPref(this)" toggled="<?php echo mobile_pref_toggled($link, "SHOW_IMAGES") ?>"><span class="thumb"></span><span class="toggleOn">ON</span><span class="toggleOff">OFF</span></div>
-</div>
-
 </fieldset>