Changeset 1435 for trunk/rss/cls/items.php
- Timestamp:
- 04/13/06 11:20:37 (3 years ago)
- Files:
-
- 1 modified
-
trunk/rss/cls/items.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/rss/cls/items.php
r1181 r1435 244 244 var $unreadIids = array(); 245 245 var $rss; 246 247 246 var $_template; 247 248 var $_sqlActualWhat = ""; 249 var $_sqlActualFrom = ""; 250 var $_sqlActualWhere= ""; 251 var $_sqlActualOrder= ""; 252 var $_sqlActualLimit= ""; 248 253 249 254 function ItemList() { 250 255 $this -> _template = 'itemlist.php'; 251 256 $this -> rss = &$GLOBALS['rss']; 252 257 … … 277 282 function populate($sqlWhere, $sqlOrder="", $startItem = 0, $itemCount = -1, $hint = ITEM_SORT_HINT_MIXED, $includeDeprecated = false) { 278 283 279 _pf('ItemList::populate()');280 $ sql = "selecti.title, c.title, c.id, i.unread, "284 _pf('ItemList::populate()'); 285 $this -> _sqlActualWhat = " i.title, c.title, c.id, i.unread, " 281 286 ."i.url, i.enclosure, i.author, i.description, c.icon, " 282 287 ." unix_timestamp(ifnull(i.pubdate,i.added)) as ts, " 283 ." i.pubdate is not null as ispubdate, i.id, r.rating " 284 ." from ".getTable("item") ." i "288 ." i.pubdate is not null as ispubdate, i.id, r.rating "; 289 $this -> _sqlActualFrom = getTable("item") ." i " 285 290 ." left join " 286 291 . getTable("rating") ." r on (i.id = r.iid), " 287 292 .getTable("channels")." c, " 288 .getTable("folders") ." f " 289 290 ." where " 291 ." i.cid = c.id and " 293 .getTable("folders") ." f "; 294 295 $this -> _sqlActualWhere = " i.cid = c.id and " 292 296 ." f.id=c.parent and ". (false == $includeDeprecated ? " not(c.mode & ".RSS_MODE_DELETED_STATE.") and " : "") 293 297 ." not(i.unread & ".RSS_MODE_DELETED_STATE.") and "; … … 296 300 297 301 if (hidePrivate()) { 298 $ sql.= " not(i.unread & ".RSS_MODE_PRIVATE_STATE.") and ";299 } 300 301 if ($ sqlWhere) {302 $ sql.= $sqlWhere ." and ";303 } 304 $ sql.= " 1=1 ";302 $this -> _sqlActualWhere .= " not(i.unread & ".RSS_MODE_PRIVATE_STATE.") and "; 303 } 304 305 if ($this -> _sqlActualWhere) { 306 $this -> _sqlActualWhere .= $sqlWhere ." and "; 307 } 308 $this -> _sqlActualWhere .= " 1=1 "; 305 309 306 310 /// Order by … … 318 322 break; 319 323 } 320 $sql .= " order by "; 324 321 325 if (!getConfig('rss.config.feedgrouping')) { 322 326 if(getConfig("rss.config.datedesc.$skey")){ 323 $ sql .= " ts desc, f.position asc, c.position asc ";327 $this -> _sqlActualOrder = " ts desc, f.position asc, c.position asc "; 324 328 }else{ 325 $ sql .= " ts asc, f.position asc, c.position asc ";329 $this -> _sqlActualOrder = " ts asc, f.position asc, c.position asc "; 326 330 } 327 331 } elseif (getConfig('rss.config.absoluteordering')) { 328 $ sql .= " f.position asc, c.position asc";332 $this -> _sqlActualOrder = " f.position asc, c.position asc"; 329 333 } else { 330 $ sql .= " f.name asc, c.title asc";334 $this -> _sqlActualOrder = " f.name asc, c.title asc"; 331 335 } 332 336 if(getConfig("rss.config.datedesc.$skey")){ 333 $ sql.= ", ts desc, i.id asc";337 $this -> _sqlActualOrder .= ", ts desc, i.id asc"; 334 338 }else{ 335 $ sql.= ", ts asc, i.id asc";339 $this -> _sqlActualOrder .= ", ts asc, i.id asc"; 336 340 } 337 341 } else { 338 $ sql .= " $sqlOrder ";342 $this -> _sqlActualOrder = " $sqlOrder "; 339 343 } 340 344 if (($itemCount < 0) || ($itemCount > RSS_DB_MAX_QUERY_RESULTS)) { 341 345 $itemCount = RSS_DB_MAX_QUERY_RESULTS; 342 346 } 343 $sql .= " limit $startItem, $itemCount"; 344 347 $this -> _sqlActualLimit = " $startItem, $itemCount"; 348 349 $sql = "select " 350 .$this -> _sqlActualWhat 351 . " from " 352 .$this -> _sqlActualFrom 353 . " where " 354 . $this -> _sqlActualWhere 355 . " order by " 356 . $this -> _sqlActualOrder 357 . " limit " 358 . $this -> _sqlActualLimit; 359 345 360 //echo $sql; 346 361 $this -> iids = array(); … … 461 476 rss_plugin_hook('rss.plugins.items.beforeitems', null); 462 477 463 eval($this-> rss ->getCachedTemplateFile( "itemlist.php"));478 eval($this-> rss ->getCachedTemplateFile($this -> _template)); 464 479 465 480 _pf("done: ItemList -> render()"); … … 470 485 } 471 486 472 487 class ItemListNavigation { 488 var $_parent; 489 var $pages; 490 function ItemListNavigation($il) { 491 $this -> _parent = $il; 492 $this -> pages = array(); 493 $base = $_SERVER["REQUEST_URI"]; 494 if (!preg_match('#page=[0-9]+$#',$base)) { 495 $base .= "?page=0"; 496 } 497 $last = ceil( $this -> _parent -> numItems / $this -> _parent -> itemsPerPage); 498 $lastin = 0; 499 for ($i = 0; $i < $last; $i++) { 500 if ($i == 0 || $i == $last-1 || abs($i - $this -> _parent -> page) < 3) { 501 $url = preg_replace('#^(.+)page=[0-9]+$#','${1}page='.$i, $base); 502 $this -> pages[$i] = array($url, $i == $this -> _parent -> page, false); 503 $lastin = $i; 504 } elseif ($i - 1 == $lastin) { 505 $this -> pages[$i] = array(null,false,true); 506 } 507 } 508 } 509 function render() { 510 eval($this-> _parent -> rss ->getCachedTemplateFile('pagination.php')); 511 } 512 } 513 514 class PaginatedItemList extends ItemList { 515 var $page; 516 var $navigation; 517 var $itemsPerPage = 0; 518 var $numItems = 0; 519 function PaginatedItemList() { 520 parent::ItemList(); 521 if (isset($_REQUEST['page'])) { 522 $this -> page = sanitize($_REQUEST['page'], RSS_SANITIZER_NUMERIC); 523 } else { 524 $this -> page = 0; 525 } 526 527 $this -> itemsPerPage = getConfig('rss.output.frontpage.numitems'); 528 } 529 function populate($sqlWhere, $sqlOrder="", $startItem = 0, $itemCount = -1, $hint = ITEM_SORT_HINT_MIXED, $includeDeprecated = false) { 530 531 $si = $this -> page * $this -> itemsPerPage; 532 parent::populate($sqlWhere, $sqlOrder, $si, $this -> itemsPerPage, $hint, $includeDeprecated); 533 534 $sql = "select count(*) as cnt " 535 . " from " 536 . $this -> _sqlActualFrom 537 . " where " 538 . $this -> _sqlActualWhere; 539 list($this -> numItems) = rss_fetch_row(rss_query($sql)); 540 $this -> navigation = new ItemListNavigation(& $this); 541 } 542 } 473 543 ?>
