Ticket #263: 263.patch

File 263.patch, 9.1 kB (added by kdz13, 3 years ago)
  • dbstruct.sql

     
    119119insert into config (key_,value_,default_,type_,desc_,export_) values ("rss.config.ajaxparallelsize",'3','3','num','Sets the number of feeds to update in parallel. Remember to set rss.config.serverpush to false.',NULL); 
    120120insert into config (key_,value_,default_,type_,desc_,export_) values ("rss.config.ajaxbatchsize",'3','3','num','Sets the number of feeds in a batch when using the ajax updater. Remember to set rss.config.serverpush to false.',NULL); 
    121121insert into config (key_,value_,default_,type_,desc_,export_) values ("rss.config.defaultdashboard", '1', '1','boolean','If the first page seen when entering the admin section should be the dashboard',NULL); 
     122insert into config (key_,value_,default_,type_,desc_,export_) values ("rss.output.nav.unread", 'false', 'false','boolean','If the navigation hints on the feeds page should go to the next feed with unread items.  If false, it simply goes to the next feed.',NULL); 
    122123 
    123124DROP TABLE IF EXISTS `tag`; 
    124125CREATE TABLE `tag` ( 
  • schema.php

     
    383383                "rss.output.title"                      => array('Gregarius','Gregarius','string','Sets the title of this feedreader.',NULL), 
    384384                "rss.config.ajaxparallelsize"                   => array('3','3','num','Sets the number of feeds to update in parallel. Remember to set rss.config.serverpush to false.',NULL), 
    385385                "rss.config.ajaxbatchsize"                      => array('3','3','num','Sets the number of feeds in a batch when using the ajax updater. Remember to set rss.config.serverpush to false.',NULL), 
    386                 "rss.config.defaultdashboard"                   => array('true','true','boolean','If the first page seen when entering the admin section should be the dashboard',NULL) 
     386                "rss.config.defaultdashboard"                   => array('true','true','boolean','If the first page seen when entering the admin section should be the dashboard',NULL), 
     387                "rss.output.nav.unread"         =>              array('false','false','boolean','If the navigation hints on the feeds page should go to the next feed with unread items.  If false, it simply goes to the next feed.',NULL) 
    387388        ); 
    388389         
    389390         
  • feed.php

     
    840840            } elseif (strlen($lbl) > 40) { 
    841841                $lbl = substr($lbl,0,37) . "..."; 
    842842            } 
    843             $readMoreNav .= "<a href=\"".$prev['url']."\" class=\"fl\">".LBL_NAV_PREV_PREFIX ."$lbl</a>\n"; 
     843            $readMoreNav .= "<a href=\"".$prev['url']."\" class=\"fl\">".LBL_NAV_PREV_PREFIX . $lbl; 
     844            if( array_key_exists( 'unread', $prev ) && $prev['unread'] ) { 
     845                $readMoreNav .= "&nbsp;(" . $prev['unread'] . " " . LBL_UNREAD . ")"; 
     846            } 
     847            $readMoreNav .= "</a>\n"; 
    844848        } 
    845849 
    846850        if($succ != null) { 
     
    850854            } elseif (strlen($lbl) > 40) { 
    851855                $lbl = substr($lbl,0,37) . "..."; 
    852856            } 
    853             $readMoreNav .= "<a href=\"".$succ['url']."\" class=\"fr\">$lbl".LBL_NAV_SUCC_POSTFIX."</a>\n"; 
     857            $readMoreNav .= "<a href=\"".$succ['url']."\" class=\"fr\">$lbl"; 
     858            if( array_key_exists( 'unread', $succ ) && $succ['unread'] ) { 
     859                $readMoreNav .= "&nbsp;(" . $succ['unread'] . " " . LBL_UNREAD . ")"; 
     860            } 
     861            $readMoreNav .= LBL_NAV_SUCC_POSTFIX."</a>\n"; 
    854862        } 
    855863 
    856864        if ($readMoreNav != "") { 
     
    11441152        case 'feed': 
    11451153 
    11461154            $sql = "select " 
    1147                    ." c.id, c.title " 
    1148                    ." from " 
    1149                    .getTable("channels") ." c, " 
    1150                    . getTable("folders") ." d " 
    1151                    ." where d.id = c.parent "; 
     1155                   ." c.id, c.title"; 
     1156            if (getConfig('rss.output.nav.unread') ) { 
     1157                $sql .= ", count(i.id) as unreadCount "; 
     1158            } else { 
     1159                $sql .= ", 0"; 
     1160            } 
     1161            $sql .= " from "  
     1162                   .getTable("folders") ." d, " 
     1163                   .getTable("channels") ." c "; 
     1164            if (getConfig('rss.output.nav.unread') ) { 
     1165                $sql .= " left outer join " . getTable('item') . " i on i.cid=c.id "; 
     1166            } 
     1167            $sqlwhere = " where d.id = c.parent"; 
    11521168 
    1153  
    11541169            if (hidePrivate()) { 
    1155                 $sql .=" and not(c.mode & " . RSS_MODE_PRIVATE_STATE .") "; 
     1170                $sqlwhere .=" and not(c.mode & " . RSS_MODE_PRIVATE_STATE .") "; 
     1171                if (getConfig('rss.output.nav.unread') ) { 
     1172                    $sql .= " and not (i.unread & " . RSS_MODE_PRIVATE_STATE . ") "; 
     1173                } 
    11561174            } 
    1157             $sql .= " and not(c.mode & " .  RSS_MODE_DELETED_STATE .") "; 
     1175            $sqlwhere .= " and not(c.mode & " .  RSS_MODE_DELETED_STATE .") "; 
     1176            if (getConfig('rss.output.nav.unread') ) { 
     1177                $sql .= " and (i.unread & ".RSS_MODE_UNREAD_STATE . ") and not (i.unread & " .RSS_MODE_DELETED_STATE . ") "; 
     1178            } 
     1179            if (getConfig('rss.output.nav.unread') ) { 
     1180                $sqlwhere .= " group by i.cid"; 
     1181            } 
    11581182 
    11591183            if (getConfig('rss.config.absoluteordering')) { 
    1160                 $sql .=" order by d.position asc, c.position asc"; 
     1184                $sqlwhere .=" order by d.position asc, c.position asc"; 
    11611185            } else { 
    1162                 $sql .=" order by d.name asc, c.title asc"; 
     1186                $sqlwhere .=" order by d.name asc, c.title asc"; 
    11631187            } 
    11641188 
    1165  
    1166             $res  = rss_query($sql); 
     1189            $res  = rss_query($sql.$sqlwhere); 
    11671190            $pcid = $ptitile = null; 
    1168             $cidname=array(); 
     1191            $ciddata=array(); 
    11691192            $cids=array(); 
    1170             while (list ($cid_,$title_)=rss_fetch_row($res)) { 
     1193            while (list ($cid_,$title_,$unread_)=rss_fetch_row($res)) { 
    11711194                $cids[]=$cid_; 
    1172                 $cidname[]=array($cid_,$title_); 
     1195                $ciddata[]=array($cid_,$title_,$unread_); 
    11731196            } 
    11741197            $key = array_search($cid,$cids); 
    11751198            if ($key !== NULL && $key !== FALSE) { 
    1176                 //echo "$key " .count($cidname); 
    1177                 if ($key+1 < count($cidname)) { 
    1178                     list($cid_,$title_) = $cidname[$key+1]; 
     1199                //echo "$key " .count($ciddata); 
     1200                $succkey = $key + 1; 
     1201                $prevkey = $key - 1; 
     1202                while ($succkey < count($ciddata)) { 
     1203                    list($cid_,$title_,$unread_) = $ciddata[$succkey]; 
     1204                    if (getConfig('rss.output.nav.unread') ) { 
     1205                        if( !$unread_ ) { 
     1206                            if( $succkey + 1 < count($ciddata) ) { 
     1207                                $succkey++; 
     1208                                continue; 
     1209                            } 
     1210                            else { 
     1211                                $succkey = $key + 1; //no more feeds, we'll just use the regular "next" one 
     1212                            } 
     1213                        } 
     1214                    } 
     1215 
    11791216                    $succ = array( 
    11801217                                'url' => getPath(). 
    11811218                                       ( getConfig('rss.output.usemodrewrite') ? 
    11821219                                         preg_replace("/[^A-Za-z0-9\.]/","_",$title_) ."/" 
    11831220                                         :"feed.php?channel=$cid_") , 
    1184                                 'lbl' => htmlentities( $title_,ENT_COMPAT,"UTF-8" ) 
     1221                                'lbl' => htmlentities( $title_,ENT_COMPAT,"UTF-8" ) , 
     1222                                'unread' => $unread_ 
    11851223                            ); 
     1224                    break; 
    11861225                } 
    1187                 if ($key > 0) { 
    1188                     list($cid_,$title_) = $cidname[$key-1]; 
     1226                while ($prevkey >= 0) { 
     1227                    list($cid_,$title_,$unread_) = $ciddata[$prevkey]; 
     1228                    if (getConfig('rss.output.nav.unread') ) { 
     1229                        if( !$unread_ ) { 
     1230                            if( $prevkey > 0 ) { 
     1231                                $prevkey--; 
     1232                                continue; 
     1233                            } 
     1234                            else { 
     1235                                $prevkey = $key - 1; //no more feeds, we'll just use the regular "previous" one 
     1236                            } 
     1237                        } 
     1238                    } 
     1239 
    11891240                    $prev = array( 
    11901241                                'url' => getPath(). 
    11911242                                       ( getConfig('rss.output.usemodrewrite') ? 
    11921243                                         preg_replace("/[^A-Za-z0-9\.]/","_",$title_) ."/" 
    11931244                                         :"feed.php?channel=$cid_") , 
    1194                                 'lbl' => htmlentities( $title_,ENT_COMPAT,"UTF-8" ) 
     1245                                'lbl' => htmlentities( $title_,ENT_COMPAT,"UTF-8" ) , 
     1246                                'unread' => $unread_ 
    11951247                            ); 
     1248                    break; 
    11961249                } 
    11971250 
    11981251            }