Index: branches/5.1.x/core/kernel/db/db_tag_processor.php =================================================================== diff -u -N -r13470 -r13545 --- branches/5.1.x/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 13470) +++ branches/5.1.x/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 13545) @@ -1,6 +1,6 @@ Application->ParseBlock($block_start_row_params, 1) : + $this->Application->ParseBlock($block_start_row_params) : (!isset($params['no_table']) ? '' : ''); } else { @@ -572,19 +572,19 @@ $block_params['num'] = ($i+1); $this->PrepareListElementParams($list, $block_params); // new, no need to rewrite PrintList - $o.= $this->Application->ParseBlock($block_params, 1); + $o.= $this->Application->ParseBlock($block_params); array_push($displayed, $list->GetDBField($id_field)); if($direction == 'V' && $list->SelectedCount % $columns > 0 && $column_number == ($columns - 1) && ceil(($i + 1) / $columns) > $list->SelectedCount % ceil($list->SelectedCount / $columns)) { // if vertical output, then draw empty cells vertically, not horizontally - $o .= $block_empty_cell_params['name'] ? $this->Application->ParseBlock($block_empty_cell_params, 1) : ' '; + $o .= $block_empty_cell_params['name'] ? $this->Application->ParseBlock($block_empty_cell_params) : ' '; $i++; } if (($i + 1) % $columns == 0) { // record in next iteration is first in row too, then close this row $o.= $block_end_row_params['name'] ? - $this->Application->ParseBlock($block_end_row_params, 1) : + $this->Application->ParseBlock($block_end_row_params) : (!isset($params['no_table']) ? '' : ''); } @@ -595,11 +595,11 @@ // append empty cells in place of missing cells in last row while ($i % $columns != 0) { // until next cell will be in new row append empty cells - $o .= $block_empty_cell_params['name'] ? $this->Application->ParseBlock($block_empty_cell_params, 1) : ' '; + $o .= $block_empty_cell_params['name'] ? $this->Application->ParseBlock($block_empty_cell_params) : ' '; if (($i+1) % $columns == 0) { // record in next iteration is first in row too, then close this row - $o .= $block_end_row_params['name'] ? $this->Application->ParseBlock($block_end_row_params, 1) : ''; + $o .= $block_end_row_params['name'] ? $this->Application->ParseBlock($block_end_row_params) : ''; } $i++; } @@ -642,12 +642,25 @@ function MoreLink($params) { $per_page = $this->SelectParam($params, 'per_page,max_items'); - if ($per_page !== false) $params['per_page'] = $per_page; + + if ($per_page !== false) { + $params['per_page'] = $per_page; + } + $list =& $this->GetList($params); - if ($list->PerPage < $list->RecordsCount) { - $block_params = $this->prepareTagParams($params); - $block_params['name'] = $this->SelectParam($params, 'render_as,block'); + if ($list->Counted) { + $has_next_page = $list->Page < $list->GetTotalPages(); + } + else { + $has_next_page = $list->PerPage < $list->RecordsCount; + } + + if ($has_next_page) { + $block_params = Array ( + 'name' => $this->SelectParam($params, 'render_as,block'), + ); + return $this->Application->ParseBlock($block_params); } } @@ -889,10 +902,13 @@ } $first_chars = $this->SelectParam($params,'first_chars,cut_first'); + if ($first_chars) { - $needs_cut = mb_strlen($value) > $first_chars; - $value = mb_substr($value, 0, $first_chars); - if ($needs_cut) $value .= ' ...'; + $stripped_value = strip_tags($value, $this->SelectParam($params, 'allowed_tags')); + + if (mb_strlen($stripped_value) > $first_chars) { + $value = mb_substr($stripped_value, 0, $first_chars) . ' ...'; + } } if (array_key_exists('nl2br', $params) && $params['nl2br']) { @@ -1132,7 +1148,7 @@ $block_params['key'] = $key; $block_params['option'] = $val; $block_params[$selected_param_name] = ( in_array($key, $value) ? ' '.$selected : ''); - $o .= $this->Application->ParseBlock($block_params, 1); + $o .= $this->Application->ParseBlock($block_params); } } else { @@ -1141,7 +1157,7 @@ $block_params['key'] = $key; $block_params['option'] = $val; $block_params[$selected_param_name] = (strlen($key) == strlen($value) && ($key == $value) ? ' '.$selected : ''); - $o .= $this->Application->ParseBlock($block_params, 1); + $o .= $this->Application->ParseBlock($block_params); } } return $o; @@ -1271,13 +1287,13 @@ } if ($current_page > 1){ - $prev_block_params = $this->prepareTagParams(); + $prev_block_params = $this->prepareTagParams($params); 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']){ - $o .= $this->Application->ParseBlock($prev_block_params, 1); + $o .= $this->Application->ParseBlock($prev_block_params); } } @@ -1286,13 +1302,13 @@ $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); - $o .= $this->Application->ParseBlock($prev_block_params, 1); + $o .= $this->Application->ParseBlock($prev_block_params); } } else { if ( $no_prev_page_block = $this->SelectParam($params, 'no_prev_page_render_as,block_no_prev_page') ) { $block_params['name'] = $no_prev_page_block; - $o .= $this->Application->ParseBlock($block_params, 1); + $o .= $this->Application->ParseBlock($block_params); } } @@ -1309,35 +1325,35 @@ $block_params['name'] = $block; $block_params['page'] = $i; $this->Application->SetVar($this->getPrefixSpecial().'_Page', $i); - $o .= $this->Application->ParseBlock($block_params, 1); + $o .= $this->Application->ParseBlock($block_params); if ($this->SelectParam($params, 'separator_render_as,block_separator') && $i < $split_end) { - $o .= $this->Application->ParseBlock($separator_params, 1); + $o .= $this->Application->ParseBlock($separator_params); } } if ($current_page < $total_pages){ - $next_block_params = $this->prepareTagParams(); + $next_block_params = $this->prepareTagParams($params); $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); - $o .= $this->Application->ParseBlock($next_block_params, 1); + $o .= $this->Application->ParseBlock($next_block_params); } 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']){ - $o .= $this->Application->ParseBlock($next_block_params, 1); + $o .= $this->Application->ParseBlock($next_block_params); } } } else { if ( $no_next_page_block = $this->SelectParam($params, 'no_next_page_render_as,block_no_next_page') ) { $block_params['name'] = $no_next_page_block; - $o .= $this->Application->ParseBlock($block_params, 1); + $o .= $this->Application->ParseBlock($block_params); } } @@ -1840,11 +1856,14 @@ $title .= ' - '.$params['group_title']; } - $cut_first = array_key_exists('cut_first', $params) && $params['cut_first']; + $first_chars = $this->SelectParam($params, 'first_chars,cut_first'); - if ($cut_first && mb_strlen($title) > $cut_first) { - if (!preg_match('/(.*)<\/a>/',$title)) { - $title = mb_substr($title, 0, $cut_first).' ...'; + if ($first_chars && !preg_match('/(.*)<\/a>/', $title)) { + // don't cut titles, that contain phrase translation links + $stripped_title = strip_tags($title, $this->SelectParam($params, 'allowed_tags')); + + if (mb_strlen($stripped_title) > $first_chars) { + $title = mb_substr($stripped_title, 0, $first_chars) . ' ...'; } } @@ -1951,6 +1970,7 @@ $params['name'] = $params['blocks_prefix'] . $element_type; + // use $pass_params to pass 'SourcePrefix' parameter from PrintList to CustomInputName tag return $this->Application->ParseBlock($params, 1); } @@ -2290,16 +2310,16 @@ */ function ExportPath($params) { - $ret = EXPORT_PATH.'/'; + $export_options = unserialize($this->Application->RecallVar($this->getPrefixSpecial().'_options')); + $extension = $export_options['ExportFormat'] == 1 ? 'csv' : 'xml'; + $filename = preg_replace('/(.*)\.' . $extension . '$/', '\1', $export_options['ExportFilename']) . '.' . $extension; + $path = EXPORT_PATH . '/'; if (array_key_exists('as_url', $params) && $params['as_url']) { - $ret = str_replace( FULL_PATH.'/', $this->Application->BaseURL(), $ret); + $path = str_replace( FULL_PATH . '/', $this->Application->BaseURL(), $path); } - $export_options = unserialize($this->Application->RecallVar($this->getPrefixSpecial().'_options')); - $ret .= $export_options['ExportFilename'].'.'.($export_options['ExportFormat'] == 1 ? 'csv' : 'xml'); - - return $ret; + return $path . $filename; } function FieldTotal($params)