Index: branches/5.1.x/core/kernel/db/cat_event_handler.php =================================================================== diff -u -N -r13086 -r13159 --- branches/5.1.x/core/kernel/db/cat_event_handler.php (.../cat_event_handler.php) (revision 13086) +++ branches/5.1.x/core/kernel/db/cat_event_handler.php (.../cat_event_handler.php) (revision 13159) @@ -1,6 +1,6 @@ getObject(); + /* @var $object kDBList */ + // get PerPage (forced -> session -> config -> 10) - $per_page = $this->getPerPage($event); + $object->SetPerPage( $this->getPerPage($event) ); + // main lists on Front-End have special get parameter for page + $page = $object->mainList ? $this->Application->GetVar('page') : false; - $object =& $event->getObject(); - $object->SetPerPage($per_page); - $this->Application->StoreVarDefault($event->getPrefixSpecial().'_Page', 1, true); // true for optional + if (!$page) { + // page is given in "env" variable for given prefix + $page = $this->Application->GetVar($event->getPrefixSpecial() . '_Page'); + } - $page = $this->Application->GetVar($event->getPrefixSpecial().'_Page'); - if (!$page) - { - $page = $this->Application->GetVar($event->getPrefixSpecial(true).'_Page'); + if (!$page && $event->Special) { + // when not part of env, then variables like "prefix.special_Page" are + // replaced (by PHP) with "prefix_special_Page", so check for that too + $page = $this->Application->GetVar($event->getPrefixSpecial(true) . '_Page'); } - if (!$page) - { - if( $this->Application->RewriteURLs() ) - { - $page = $this->Application->GetVar($event->Prefix.'_Page'); - if (!$page) - { - $page = $this->Application->RecallVar($event->Prefix.'_Page'); + if (!$object->mainList) { + // main lists doesn't use session for page storing + $this->Application->StoreVarDefault($event->getPrefixSpecial() . '_Page', 1, true); // true for optional + + if (!$page) { + if ($this->Application->RewriteURLs()) { + // when page not found by prefix+special, then try to search it without special at all + $page = $this->Application->GetVar($event->Prefix . '_Page'); + + if (!$page) { + // page not found in request -> get from session + $page = $this->Application->RecallVar($event->Prefix . '_Page'); + } + + if ($page) { + // page found in request -> store in session + $this->Application->StoreVar($event->getPrefixSpecial() . '_Page', $page, true); //true for optional + } } - if($page) $this->Application->StoreVar($event->getPrefixSpecial().'_Page', $page, true); //true for optional + else { + // page not found in request -> get from session + $page = $this->Application->RecallVar($event->getPrefixSpecial() . '_Page'); + } } - else - { - $page = $this->Application->RecallVar($event->getPrefixSpecial().'_Page'); + else { + // page found in request -> store in session + $this->Application->StoreVar($event->getPrefixSpecial() . '_Page', $page, true); //true for optional } - } - else { - $this->Application->StoreVar($event->getPrefixSpecial().'_Page', $page, true); //true for optional - } - if( !$event->getEventParam('skip_counting') ) - { - $pages = $object->GetTotalPages(); - if($page > $pages) - { - $this->Application->StoreVar($event->getPrefixSpecial().'_Page', 1); - $page = 1; + if ( !$event->getEventParam('skip_counting') ) { + // when stored page is larger, then maximal list page number + // (such case is also processed in kDBList::Query method) + $pages = $object->GetTotalPages(); + + if ($page > $pages) { + $page = 1; + $this->Application->StoreVar($event->getPrefixSpecial().'_Page', 1, true); + } } } - /*$cur_per_page = $per_page; - $per_page = $event->getEventParam('per_page'); - if ($per_page == 'list_next') { - - $cur_page = $page; - - $object =& $this->Application->recallObject($event->Prefix); - $object->SetPerPage(1); - $cur_item_index = $object->CurrentIndex; - - $page = ($cur_page-1) * $cur_per_page + $cur_item_index + 1; - $object->SetPerPage(1); - }*/ - $object->SetPage($page); }