Index: trunk/core/units/statistics/statistics_tag_processor.php =================================================================== diff -u -N -r4524 -r4651 --- trunk/core/units/statistics/statistics_tag_processor.php (.../statistics_tag_processor.php) (revision 4524) +++ trunk/core/units/statistics/statistics_tag_processor.php (.../statistics_tag_processor.php) (revision 4651) @@ -194,34 +194,71 @@ function CountPending($params) { $prefix = $params['prefix']; - - $statistics_info = $this->Application->getUnitOption($prefix.'.pending', 'StatisticsInfo'); - if (!$statistics_info) { - return 0; + $value = $this->Application->getCache('statistics.pending', $prefix); + if ($value === false) { + $statistics_info = $this->Application->getUnitOption($prefix.'.pending', 'StatisticsInfo'); + if (!$statistics_info) { + return 0; + } + + $table = $this->Application->getUnitOption($prefix, 'TableName'); + $status_field = array_shift( $this->Application->getUnitOption($prefix, 'StatusField') ); + $sql = 'SELECT COUNT(*) + FROM '.$table.' + WHERE '.$status_field.' = '.$statistics_info['status']; + $value = $this->Conn->GetOne($sql); + $this->Application->setCache('statistics.pending', $prefix, $value); } + return $value; + } + + function GetTotalPending() + { + $sql = 'SELECT Prefix + FROM '.TABLE_PREFIX.'ItemTypes'; + $prefixes = $this->Conn->GetCol($sql); - $table = $this->Application->getUnitOption($prefix, 'TableName'); - $status_field = array_shift( $this->Application->getUnitOption($prefix, 'StatusField') ); - $sql = 'SELECT COUNT(*) - FROM '.$table.' - WHERE '.$status_field.' = '.$statistics_info['status']; - return $this->Conn->GetOne($sql); + $sum = 0; + foreach ($prefixes as $prefix) { + $sum += $this->CountPending( Array('prefix' => $prefix) ); + } + return $sum; } function PrintPendingStatistics($params) { $sql = 'SELECT Prefix FROM '.TABLE_PREFIX.'ItemTypes'; - $prefixes = $this->Conn->GetCol($sql); + $check_prefixes = $this->Conn->GetCol($sql); + if (!$check_prefixes) { + return ''; + } - $block_params = Array('name' => $this->SelectParam($params, 'render_as,block') ); - $ret = ''; - foreach ($prefixes as $prefix) { + $columns = $params['columns']; + $block_params = $this->prepareTagParams( Array('name' => $this->SelectParam($params, 'render_as,block') ) ); + + $prefixes = Array(); + foreach ($check_prefixes as $prefix) { + $statistics_info = $this->Application->getUnitOption($prefix.'.pending', 'StatisticsInfo'); + if ($statistics_info) { + $prefixes[] = $prefix; + } + } + + $row_number = 0; + + foreach ($prefixes as $i => $prefix) { $block_params['prefix'] = $prefix; $statistics_info = $this->Application->getUnitOption($prefix.'.pending', 'StatisticsInfo'); - if (!$statistics_info) continue; + if ($i % $columns == 0) { + $column_number = 1; + $ret .= ''; + } + + $block_params['column_number'] = $column_number; + $block_params['is_first'] = $i < $columns ? 1 : 0; $template = $statistics_info['url']['t']; unset($statistics_info['url']['t']); $url = $this->Application->HREF($template, '', $statistics_info['url']); @@ -233,7 +270,11 @@ $block_params['icon'] = $statistics_info['icon']; $block_params['label'] = $statistics_info['label']; $ret .= $this->Application->ParseBlock($block_params); - + $column_number++; + + if (($i+1) % $columns == 0) { + $ret .= ''; + } } return $ret; }