Index: branches/5.2.x/core/units/reviews/reviews_tag_processor.php =================================================================== diff -u -N -r14652 -r14769 --- branches/5.2.x/core/units/reviews/reviews_tag_processor.php (.../reviews_tag_processor.php) (revision 14652) +++ branches/5.2.x/core/units/reviews/reviews_tag_processor.php (.../reviews_tag_processor.php) (revision 14769) @@ -1,6 +1,6 @@ getObject($params); + /* @var $object kDBItem */ + + $parent_prefix = $this->Application->getUnitOption($this->Prefix, 'ParentPrefix'); + + $main_object =& $this->Application->recallObject($parent_prefix); + /* @var $main_object kCatDBItem */ + + if ( !isset($cache) ) { + $sql = 'SELECT COUNT(*), Rating + FROM ' . $object->TableName . ' + WHERE ItemId = ' . $main_object->GetDBField('ResourceId') . ' + GROUP BY Rating'; + $cache = $this->Conn->GetCol($sql, 'Rating'); + } + + $ratings = array_reverse( array_keys( $object->GetFieldOption('Rating', 'options') ) ); + + if ( !isset($params['show_none']) || !$params['show_none'] ) { + $none_index = array_search(0, $ratings); + + if ( $none_index !== false ) { + unset($ratings[$none_index]); + } + } + + $ret = ''; + $total = array_sum($cache); + $block_params = $this->prepareTagParams($params); + $block_params['name'] = $params['render_as']; + $block_params['strip_nl'] = 2; + + foreach ($ratings as $rating) { + $block_params['rating'] = $rating; + $block_params['count'] = isset($cache[$rating]) ? $cache[$rating] : 0; + $block_params['percent'] = round(($block_params['count'] / $total) * 100); + + $ret .= $this->Application->ParseBlock($block_params); + } + + return $ret; + } + + /** + * Returns requested field value + * + * @param Array $params + * @return string * @access public */ function Field($params) { $field = $this->SelectParam($params, 'name,field'); - + $object =& $this->getObject($params); /* @var $object kDBItem */ @@ -118,9 +171,11 @@ /* @var kDBList */ $parent_info = $object->getLinkedInfo(); + if ($parent_info['ParentId'] > 0) { $params['pass'] = 'm,'.$this->getPrefixSpecial().','.$parent_info['ParentPrefix']; } + return parent::PageLink($params); }