Index: db_tag_processor.php
===================================================================
--- db_tag_processor.php (revision 14917)
+++ db_tag_processor.php (working copy)
@@ -451,17 +451,19 @@
function PrintList2($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);
$o = '';
- $direction = (isset($params['direction']) && $params['direction']=="H")?"H":"V";
- $columns = (isset($params['columns'])) ? $params['columns'] : 1;
+ $direction = (isset($params['direction']) && $params['direction'] == "H") ? "H" : "V";
+ $columns = (isset($params['columns'])) ? $params['columns'] : 1;
$id_field = (isset($params['id_field'])) ? $params['id_field'] : $this->Application->getUnitOption($this->Prefix, 'IDField');
- if ($columns > 1 && $direction == 'V') {
+ if ( $columns > 1 && $direction == 'V' ) {
$records_left = array_splice($list->Records, $list->GetSelectedCount()); // because we have 1 more record for "More..." link detection (don't need to sort it)
$list->Records = $this->LinearToVertical($list->Records, $columns, $list->GetPerPage());
$list->Records = array_merge($list->Records, $records_left);
@@ -469,23 +471,23 @@
$list->GoFirst();
- $block_params=$this->prepareTagParams($params);
+ $block_params = $this->prepareTagParams($params);
$block_params['name'] = $this->SelectParam($params, 'render_as,block');
$block_params['pass_params'] = 'true';
$block_params['column_width'] = $params['column_width'] = 100 / $columns;
$block_start_row_params = $this->prepareTagParams($params);
$block_start_row_params['name'] = $this->SelectParam($params, 'row_start_render_as,block_row_start,row_start_block');
- $block_end_row_params=$this->prepareTagParams($params);
+ $block_end_row_params = $this->prepareTagParams($params);
$block_end_row_params['name'] = $this->SelectParam($params, 'row_end_render_as,block_row_end,row_end_block');
$block_empty_cell_params = $this->prepareTagParams($params);
$block_empty_cell_params['name'] = $this->SelectParam($params, 'empty_cell_render_as,block_empty_cell,empty_cell_block');
- $i=0;
+ $i = 0;
- $backup_id=$this->Application->GetVar($this->Prefix."_id");
- $displayed = array();
+ $backup_id = $this->Application->GetVar($this->Prefix . '_id');
+ $displayed = Array ();
$column_number = 1;
$cache_mod_rw = $this->Application->getUnitOption($this->Prefix, 'CacheModRewrite') &&
@@ -494,20 +496,21 @@
$limit = isset($params['limit']) ? $params['limit'] : false;
while (!$list->EOL() && (!$limit || $i<$limit)) {
- $this->Application->SetVar( $this->getPrefixSpecial().'_id', $list->GetDBField($id_field) ); // for edit/delete links using GET
- $this->Application->SetVar( $this->Prefix.'_id', $list->GetDBField($id_field) );
+ $this->Application->SetVar($this->getPrefixSpecial() . '_id', $list->GetDBField($id_field)); // for edit/delete links using GET
+ $this->Application->SetVar($this->Prefix . '_id', $list->GetDBField($id_field));
$block_params['is_last'] = ($i == $list->GetSelectedCount() - 1);
- $block_params['last_row'] = ($i + (($i+1) % $columns) >= $list->GetSelectedCount() - 1);
+ $block_params['last_row'] = ($i + (($i + 1) % $columns) >= $list->GetSelectedCount() - 1);
$block_params['not_last'] = !$block_params['is_last']; // for front-end
- if ($cache_mod_rw) {
+ if ( $cache_mod_rw ) {
$serial_name = $this->Application->incrementCacheSerial($this->Prefix, $list->GetDBField($id_field), false);
- if ($this->Prefix == 'c') {
+ if ( $this->Prefix == 'c' ) {
// for listing subcategories in category
- $this->Application->setCache('filenames[%' . $serial_name . '%]' , $list->GetDBField('NamedParentPath'));
+ $this->Application->setCache('filenames[%' . $serial_name . '%]', $list->GetDBField('NamedParentPath'));
$this->Application->setCache('category_tree[%CIDSerial:' . $list->GetDBField($id_field) . '%]', $list->GetDBField('TreeLeft') . ';' . $list->GetDBField('TreeRight'));
- } else {
+ }
+ else {
// for listing items in category
$this->Application->setCache('filenames[%' . $serial_name . '%]', $list->GetDBField('Filename'));
@@ -516,12 +519,10 @@
}
}
- if ($i % $columns == 0) {
+ if ( $i % $columns == 0 ) {
// record in this iteration is first in row, then open row
$column_number = 1;
- $o.= $block_start_row_params['name'] ?
- $this->Application->ParseBlock($block_start_row_params) :
- (!isset($params['no_table']) ? '<tr>' : '');
+ $o .= $block_start_row_params['name'] ? $this->Application->ParseBlock($block_start_row_params) : (!isset($params['no_table']) ? '<tr>' : '');
}
else {
$column_number++;
@@ -531,25 +532,28 @@
$block_params['last_col'] = $column_number == $columns ? 1 : 0;
$block_params['column_number'] = $column_number;
- $block_params['num'] = ($i+1);
+ $block_params['num'] = ($i + 1);
$this->PrepareListElementParams($list, $block_params); // new, no need to rewrite PrintList
- $o.= $this->Application->ParseBlock($block_params);
+ $o .= $this->Application->ParseBlock($block_params);
array_push($displayed, $list->GetDBField($id_field));
- if($direction == 'V' && $list->GetSelectedCount() % $columns > 0 && $column_number == ($columns - 1) && ceil(($i + 1) / $columns) > $list->GetSelectedCount() % ceil($list->GetSelectedCount() / $columns)) {
+ if ( $direction == 'V' && $list->GetSelectedCount() % $columns > 0 && $column_number == ($columns - 1) && ceil(($i + 1) / $columns) > $list->GetSelectedCount() % ceil($list->GetSelectedCount() / $columns) ) {
// if vertical output, then draw empty cells vertically, not horizontally
$o .= $block_empty_cell_params['name'] ? $this->Application->ParseBlock($block_empty_cell_params) : '<td> </td>';
$i++;
}
- if (($i + 1) % $columns == 0) {
+ 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) :
- (!isset($params['no_table']) ? '</tr>' : '');
+ $o .= $block_end_row_params['name'] ? $this->Application->ParseBlock($block_end_row_params) : (!isset($params['no_table']) ? '</tr>' : '');
}
+ if ( $this->Special && $this->Application->hasObject($this->Prefix) ) {
+ // object, produced by "kDBList::linkToParent" method, that otherwise would keep it's id
+ $this->Application->removeObject($this->Prefix);
+ }
+
$list->GoNext();
$i++;
}
@@ -559,28 +563,28 @@
// until next cell will be in new row append empty cells
$o .= $block_empty_cell_params['name'] ? $this->Application->ParseBlock($block_empty_cell_params) : '<td> </td>';
- if (($i+1) % $columns == 0) {
+ 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) : '</tr>';
}
$i++;
}
- $cur_displayed = $this->Application->GetVar($this->Prefix.'_displayed_ids');
- if (!$cur_displayed) {
- $cur_displayed = Array();
+ $cur_displayed = $this->Application->GetVar($this->Prefix . '_displayed_ids');
+ if ( !$cur_displayed ) {
+ $cur_displayed = Array ();
}
else {
$cur_displayed = explode(',', $cur_displayed);
}
$displayed = array_unique(array_merge($displayed, $cur_displayed));
- $this->Application->SetVar($this->Prefix.'_displayed_ids', implode(',',$displayed));
+ $this->Application->SetVar($this->Prefix . '_displayed_ids', implode(',', $displayed));
- $this->Application->SetVar( $this->Prefix.'_id', $backup_id);
- $this->Application->SetVar( $this->getPrefixSpecial().'_id', '');
+ $this->Application->SetVar($this->Prefix . '_id', $backup_id);
+ $this->Application->SetVar($this->getPrefixSpecial() . '_id', '');
- if (isset($params['more_link_render_as'])) {
+ if ( isset($params['more_link_render_as']) ) {
$block_params = $params;
$params['render_as'] = $params['more_link_render_as'];
$o .= $this->MoreLink($params);