'В галерею!' , 'Безупречно' ,'Классная идея!' , 'Хорошее начало' , 'О композиции' , 'Лучшее впереди!' , 'Спасибо!' , 'Профессионально' , 'Красиво' , 'Стильно' , 'Грандиозно!' , 'Картина маслом!' , 'Отличный рецепт!' , 'Присоединяюсь' , 'Не соглашусь' , 'Молодца!' , 'У самовара!'); var $suffix = array( 0 => 'восхищаются' , 'ценят' , 'оценили идею' , 'заметили' , 'обращают внимание' , 'подбадривают' , 'благодарят' , 'отметили уровень' , 'любуются' , 'оценили стиль' , 'оценили труд' , 'ценят фото' , 'оценили рецепт' , 'одобряют' , 'не одобряют' , 'поддерживают' , 'любят форум'); var $images = array( 0 => 'agree.png' , 'disagree.png' , 'goodidea.png' , 'unfriendly.png' , 'badspelling.png' , 'wtf.png' , 'thanks.png' , 'rosette.png' , 'rainbow.png' , 'Smiley Star Pink.png' , 'award_star_gold_2.png' , 'palette.png' , 'star.png' , 'weather_sun.png' , 'weather_cloudy.png' , 'thumb_up.png' , 'samovar.png'); var $order = array( 0, 1, 2 , 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17); function build_buttons($post_id, $author_id) { $html = ''; if ($this->ipsclass->member['id'] != $author_id) { # query our own button $this->ipsclass->DB->query ("SELECT `rating` FROM `".SQL_PREFIX."ratings` WHERE `pid` = '" . $post_id . "' AND `uid` = '" . $this->ipsclass->member['id'] . "'" ); $our_button = -1; if( $this->ipsclass->DB->get_num_rows( ) ) { $row = $this->ipsclass->DB->fetch_row( ); $our_button = $row['rating']; } foreach ($this->order as $rid) { $rtext = $this->ratings[$rid]; $html .= $this->ipsclass->compiled_templates['skin_erate']->ratings_button( $post_id , $author_id , $rid, $this->images[$rid], $rtext, "rate_button" . (($rid == $our_button) ? '_rev' : '')); } } return($html); } function build_ratings(&$ratings, $post_id) { $html = ''; foreach ($this->order as $rid) { $rating = $ratings[$rid]; if ($rating > 0) { $html .= "
images[$rid] . "' ) \"> " . $rating . " x " . $this->ratings[$rid] . "
"; } } if ($html != '') { $html = '
--------------------
Оценки сообщения:
' . $html; $html .= '
Список оценивших пользователей
'; } return($html); } function cached_ratings(&$row) { $ratings = @explode(',', $row['cached_ratings']); if (!is_array($ratings) OR count($ratings) != count($this->ratings)) { # create/refresh cache $ratings = $this->create_post_cache($row['pid']); $row['cached_ratings'] = implode(',', $ratings); } return($ratings); } function uncached_ratings($pid) { $ratings = array_pad(array(), count($this->ratings), 0); $this->ipsclass->DB->query ("SELECT `rating`, COUNT(`rating`) as count FROM `".SQL_PREFIX."ratings` WHERE `pid` = '" . $pid . "' GROUP BY `rating`" ); return($this->cache_process_result()); } function update_post_cache($pid, $ratings) { $this->ipsclass->DB->query ( "UPDATE `".SQL_PREFIX."posts` SET `cached_ratings` = '" . implode(',', $ratings) . "' WHERE `pid` = '" . $pid . "'" ); } function create_post_cache($pid) { $ratings = $this->uncached_ratings($pid); $this->update_post_cache($pid, $ratings); return($ratings); } function cached_member_ratings(&$member) { $mrcache = @explode('|', $member['ratings_cache']); if (!is_array($mrcache) OR count($mrcache) != 2) { # create/refresh cache $ratings = $this->create_member_ratings_cache($member['id']); $member['ratings_cache'] = implode(',', $ratings['count']).'|'.implode(',', $ratings['normal']); return($ratings); } $ratings = array( 'count' => @explode(',', $mrcache[0]), 'normal' => @explode(',', $mrcache[1]), ); if ( !is_array($ratings['count']) OR count($ratings['count']) != count($this->ratings) OR !is_array($ratings['normal']) OR count($ratings['normal']) != count($this->ratings) ) { # create/refresh cache $ratings = $this->create_member_ratings_cache($member['id']); $member['ratings_cache'] = implode(',', $ratings['count']).'|'.implode(',', $ratings['normal']); } return($ratings); } function uncached_member_ratings($uid) { $this->ipsclass->DB->query ("SELECT `rating`, COUNT(`rating`) as count FROM `".SQL_PREFIX."ratings` WHERE `to_uid` = '" . $uid . "' GROUP BY `rating`" ); $count = $this->cache_process_result(); $this->ipsclass->DB->query ("SELECT DISTINCT(`uid`) AS uid, `rating`, COUNT(`rating`) as count FROM `".SQL_PREFIX."ratings` WHERE `to_uid` = '" . $uid . "' GROUP BY `uid`, `rating`" ); $normal = array_pad(array(), count($this->ratings), 0); if( $this->ipsclass->DB->get_num_rows( ) ) { while( $rrow = $this->ipsclass->DB->fetch_row( ) ) { $normal[$rrow['rating']] += 2 - sqrt(1 / $rrow['count']); } } $ratings = array( 'count' => $count, 'normal' => $normal, ); return($ratings); } function update_member_ratings_cache($uid, $ratings) { $this->ipsclass->DB->query ( "UPDATE `".SQL_PREFIX."members` SET `ratings_cache` = '" . implode(',', $ratings['count']).'|'.implode(',', $ratings['normal']) . "' WHERE `id` = '" . $uid . "'" ); } function create_member_ratings_cache($uid) { $ratings = $this->uncached_member_ratings($uid); $this->update_member_ratings_cache($uid, $ratings); return($ratings); } function cached_member_rated($member) { $ratings = @explode(',', $member['rated_cache']); if (!is_array($ratings) OR count($ratings) != count($this->ratings)) { # create/refresh cache $ratings = $this->create_member_rated_cache($member['id']); $member['rated_cache'] = implode(',', $ratings); } return($ratings); } function uncached_member_rated($uid) { $this->ipsclass->DB->query ("SELECT `rating`, COUNT(`rating`) as count FROM `".SQL_PREFIX."ratings` WHERE `uid` = '" . $uid . "' GROUP BY `rating`" ); return($this->cache_process_result()); } function update_member_rated_cache($uid, $ratings) { $this->ipsclass->DB->query ( "UPDATE `".SQL_PREFIX."members` SET `rated_cache` = '" . implode(',', $ratings) . "' WHERE `id` = '" . $uid . "'" ); } function create_member_rated_cache($uid) { $ratings = $this->uncached_member_rated($uid); $this->update_member_rated_cache($uid, $ratings); return($ratings); } function cache_process_result() { $ratings = array_pad(array(), count($this->ratings), 0); if( $this->ipsclass->DB->get_num_rows( ) ) { while( $rrow = $this->ipsclass->DB->fetch_row( ) ) { $ratings[$rrow['rating']] = $rrow['count']; } } return($ratings); } } ?>