Index: branches/5.2.x/core/units/helpers/list_helper.php =================================================================== diff -u -N -r14782 -r14865 --- branches/5.2.x/core/units/helpers/list_helper.php (.../list_helper.php) (revision 14782) +++ branches/5.2.x/core/units/helpers/list_helper.php (.../list_helper.php) (revision 14865) @@ -1,6 +1,6 @@ addFilter('navigation_filter', $where_clause); // do extractCalculatedFields (transforms having into where), since we don't select fields from JOINed tables - $sql = str_replace('%1$s', $list->TableName, $list->extractCalculatedFields($list->GetSelectSQL())); + $sql = $list->extractCalculatedFields($list->GetSelectSQL(), 1, true); $list->removeFilter('navigation_filter'); $list->setOrderFields($order_fields_backup); Index: branches/5.2.x/core/kernel/db/db_tag_processor.php =================================================================== diff -u -N -r14838 -r14865 --- branches/5.2.x/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 14838) +++ branches/5.2.x/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 14865) @@ -1,6 +1,6 @@ getPrefixSpecial(); $total_pages = $list->GetTotalPages(); - if ($total_pages > 1) $this->Application->Parser->DataExists = true; + if ( $total_pages > 1 ) { + $this->Application->Parser->DataExists = true; + } - if($total_pages == 0) $total_pages = 1; // display 1st page as selected in case if we have no pages at all + if ( $total_pages == 0 ) { + // display 1st page as selected in case if we have no pages at all + $total_pages = 1; + } + $o = ''; // what are these 2 lines for? - $this->Application->SetVar($prefix_special.'_event',''); - $this->Application->SetVar($prefix_special.'_id',''); + $this->Application->SetVar($prefix_special . '_event', ''); + $this->Application->SetVar($prefix_special . '_id', ''); $current_page = $list->GetPage(); // $this->Application->RecallVar($prefix_special.'_Page'); $block_params = $this->prepareTagParams($params); - $split = ( isset($params['split'] ) ? $params['split'] : 10 ); + $split = (isset($params['split']) ? $params['split'] : 10); + $split_start = $current_page - ceil($split / 2); - $split_start = $current_page - ceil($split/2); - if ($split_start < 1){ + if ( $split_start < 1 ) { $split_start = 1; } - $split_end = $split_start + $split-1; - if ($split_end > $total_pages) { + $split_end = $split_start + $split - 1; + + if ( $split_end > $total_pages ) { $split_end = $total_pages; $split_start = max($split_end - $split + 1, 1); } - if ($current_page > 1){ + if ( $current_page > 1 ) { $prev_block_params = $this->prepareTagParams($params); - if ($total_pages > $split){ - $prev_block_params['page'] = max($current_page-$split, 1); + if ( $total_pages > $split ) { + $prev_block_params['page'] = max($current_page - $split, 1); $prev_block_params['name'] = $this->SelectParam($params, 'prev_page_split_render_as,prev_page_split_block'); - if ($prev_block_params['name']){ + + if ( $prev_block_params['name'] ) { $o .= $this->Application->ParseBlock($prev_block_params); } } $prev_block_params['name'] = 'page'; - $prev_block_params['page'] = $current_page-1; + $prev_block_params['page'] = $current_page - 1; $prev_block_params['name'] = $this->SelectParam($params, 'prev_page_render_as,block_prev_page,prev_page_block'); - if ($prev_block_params['name']) { - $this->Application->SetVar($this->getPrefixSpecial().'_Page', $current_page-1); + + if ( $prev_block_params['name'] ) { + $this->Application->SetVar($this->getPrefixSpecial() . '_Page', $current_page - 1); $o .= $this->Application->ParseBlock($prev_block_params); } } @@ -1402,10 +1411,21 @@ } } + $total_records = $list->GetRecordsCount(); $separator_params['name'] = $this->SelectParam($params, 'separator_render_as,block_separator'); - for ($i = $split_start; $i <= $split_end; $i++) - { - if ($i == $current_page) { + + for ($i = $split_start; $i <= $split_end; $i++) { + $from_record = ($i - 1) * $list->GetPerPage(true); + $to_record = $from_record + $list->GetPerPage(true); + + if ( $to_record > $total_records ) { + $to_record = $total_records; + } + + $block_params['from_record'] = $from_record + 1; + $block_params['to_record'] = $to_record; + + if ( $i == $current_page ) { $block = $this->SelectParam($params, 'current_render_as,active_render_as,block_current,active_block'); } else { @@ -1414,28 +1434,29 @@ $block_params['name'] = $block; $block_params['page'] = $i; - $this->Application->SetVar($this->getPrefixSpecial().'_Page', $i); + $this->Application->SetVar($this->getPrefixSpecial() . '_Page', $i); $o .= $this->Application->ParseBlock($block_params); - if ($this->SelectParam($params, 'separator_render_as,block_separator') - && $i < $split_end) - { + if ( $this->SelectParam($params, 'separator_render_as,block_separator') && $i < $split_end ) { $o .= $this->Application->ParseBlock($separator_params); } } - if ($current_page < $total_pages){ + if ( $current_page < $total_pages ) { $next_block_params = $this->prepareTagParams($params); - $next_block_params['page']=$current_page+1; + $next_block_params['page'] = $current_page + 1; $next_block_params['name'] = $this->SelectParam($params, 'next_page_render_as,block_next_page,next_page_block'); - if ($next_block_params['name']){ - $this->Application->SetVar($this->getPrefixSpecial().'_Page', $current_page+1); + + if ( $next_block_params['name'] ) { + $this->Application->SetVar($this->getPrefixSpecial() . '_Page', $current_page + 1); $o .= $this->Application->ParseBlock($next_block_params); } - if ($total_pages > $split){ - $next_block_params['page']=min($current_page+$split, $total_pages); + + if ( $total_pages > $split ) { + $next_block_params['page'] = min($current_page + $split, $total_pages); $next_block_params['name'] = $this->SelectParam($params, 'next_page_split_render_as,next_page_split_block'); - if ($next_block_params['name']){ + + if ( $next_block_params['name'] ) { $o .= $this->Application->ParseBlock($next_block_params); } } @@ -1449,7 +1470,8 @@ } } - $this->Application->SetVar($this->getPrefixSpecial().'_Page', $current_page); + $this->Application->SetVar($this->getPrefixSpecial() . '_Page', $current_page); + return $o; } @@ -2678,7 +2700,7 @@ { $list =& $this->GetList($params); - return $list->GetPerPage() == $params['per_page'] ? $params['selected'] : ''; + return $list->GetPerPage(true) == $params['per_page'] ? $params['selected'] : ''; } /** Index: branches/5.2.x/core/kernel/db/dblist.php =================================================================== diff -u -N -r14738 -r14865 --- branches/5.2.x/core/kernel/db/dblist.php (.../dblist.php) (revision 14738) +++ branches/5.2.x/core/kernel/db/dblist.php (.../dblist.php) (revision 14865) @@ -1,6 +1,6 @@ getCalculatedFields($aggregated); - if (is_array($fields) && count($fields) > 0) { + + if ( is_array($fields) && count($fields) > 0 ) { foreach ($fields as $field_name => $field_expression) { - $clause = preg_replace('/(\\(+)[(,` ]*'.$field_name.'[` ]{1}/', '\1 ('.$field_expression.') ', $clause); - $clause = preg_replace('/[,` ]{1}'.$field_name.'[` ]{1}/', ' ('.$field_expression.') ', $clause); + $clause = preg_replace('/(\\(+)[(,` ]*' . $field_name . '[` ]{1}/', '\1 (' . $field_expression . ') ', $clause); + $clause = preg_replace('/[,` ]{1}' . $field_name . '[` ]{1}/', ' (' . $field_expression . ') ', $clause); } } - return $clause; + + return $replace_table ? str_replace('%1$s', $this->TableName, $clause) : $clause; } /**