Пример #1
0
function rw_the_post_shortcode($atts)
{
    RWLogger::LogEnterence('rw_the_post_shortcode');
    if (RWLogger::IsOn()) {
        RWLogger::Log('rw_the_post_shortcode', var_export($atts, true));
    }
    extract(shortcode_atts(array('post_id' => false, 'type' => 'blog-post', 'add_schema' => true), $atts));
    if (is_string($add_schema)) {
        $add_schema = 'true' === strtolower($add_schema);
    }
    return rw_get_post_rating($post_id, $type, $add_schema);
}
    case 'product':
        $excluded_post = false === $rwp->rw_validate_visibility($post->ID, 'collection-product') && false === $rwp->rw_validate_visibility($post->ID, 'product');
        $rclass = 'product';
        break;
    case 'topic':
    case 'reply':
        $excluded_post = false === $rwp->rw_validate_visibility($post->ID, 'forum-post');
        $rclass = 'reply' === $post_type ? 'forum-reply' : 'forum-post';
        break;
    case 'post':
    default:
        $excluded_post = false === $rwp->rw_validate_visibility($post->ID, 'front-post') && false === $rwp->rw_validate_visibility($post->ID, 'blog-post');
        $rclass = 'blog-post';
        break;
}
RWLogger::Log('ShowPostMetaBox', 'Post Type = ' . $post_type);
add_action('admin_footer', array(&$rwp, "rw_attach_rating_js"), 5);
$multirating_options = ratingwidget()->get_multirating_options_by_class($rclass);
$multi_criteria = count($multirating_options->criteria) > 1;
$options = $rwp->get_options_by_class($rclass);
$default_hide_recommendations = isset($options->hideRecommendations) ? $options->hideRecommendations : false;
?>
<p>
	<input type="hidden" name="rw_post_meta_box_nonce"
	       value="<?php 
echo wp_create_nonce(basename(WP_RW__PLUGIN_FILE_FULL));
?>
"/>
<table
	class="rw-rating-table rw-<?php 
echo isset($options->advanced) && isset($options->advanced->layout) && !empty($options->advanced->layout->dir) ? $options->advanced->layout->dir : 'ltr';
 function GetElementInfoByRating($type, $rating)
 {
     if ('products' === $type) {
         $id = RatingWidgetPlugin::Urid2ForumPostId($rating->urid);
         // Make sure product is visible for the current visitor.
         $status = @get_post_status($id);
         if (false === $status) {
             if (RWLogger::IsOn()) {
                 RWLogger::Log('POST_NOT_EXIST', $id);
             }
             // Post not exist.
             return false;
         } else {
             if ('publish' !== $status && 'private' !== $status) {
                 if (RWLogger::IsOn()) {
                     RWLogger::Log('POST_NOT_VISIBLE', 'status = ' . $status);
                 }
                 // Post not yet published.
                 return false;
             } else {
                 if ('private' === $status && !is_user_logged_in()) {
                     if (RWLogger::IsOn()) {
                         RWLogger::Log('RatingWidgetPlugin_TopRatedWidget::widget', 'POST_PRIVATE && USER_LOGGED_OUT');
                     }
                     // Private post but user is not logged in.
                     return false;
                 }
             }
         }
         $product = new WC_Product($id);
         $post_img = $this->GetImageSrc($product);
         return array('id' => $id, 'title' => $product->get_title(), 'permalink' => $product->get_permalink(), 'img' => is_string($post_img) ? $post_img : '');
     }
     return false;
 }
        function widget($args, $instance)
        {
            if (RWLogger::IsOn()) {
                $params = func_get_args();
                RWLogger::LogEnterence("RatingWidgetPlugin_TopRatedWidget.widget", $params, true);
            }
            if (!defined("WP_RW__SITE_PUBLIC_KEY") || false === WP_RW__SITE_PUBLIC_KEY) {
                return;
            }
            if (RatingWidgetPlugin::$WP_RW__HIDE_RATINGS) {
                return;
            }
            extract($args, EXTR_SKIP);
            $bpInstalled = ratingwidget()->IsBuddyPressInstalled();
            $bbInstalled = ratingwidget()->IsBBPressInstalled();
            $types = $this->GetTypesInfo();
            $show_any = false;
            foreach ($types as $type => $data) {
                if (false !== $instance["show_{$type}"]) {
                    $show_any = true;
                    break;
                }
            }
            if (RWLogger::IsOn()) {
                RWLogger::Log('RatingWidgetPlugin_TopRatedWidget', 'show_any = ' . ($show_any ? 'TRUE' : 'FALSE'));
            }
            if (false === $show_any) {
                // Nothing to show.
                return;
            }
            $details = array("uid" => WP_RW__SITE_PUBLIC_KEY);
            $queries = array();
            foreach ($types as $type => $type_data) {
                if (isset($instance["show_{$type}"]) && $instance["show_{$type}"] && $instance["{$type}_count"] > 0) {
                    $options = ratingwidget()->GetOption($type_data["options"]);
                    $queries[$type] = array("rclasses" => $type_data["classes"], "votes" => max(1, (int) $instance["{$type}_min_votes"]), "orderby" => $instance["{$type}_orderby"], "order" => $instance["{$type}_order"], "limit" => (int) $instance["{$type}_count"], "types" => isset($options->type) ? $options->type : "star");
                    $since_created = isset($instance["{$type}_since_created"]) ? (int) $instance["{$type}_since_created"] : WP_RW__TIME_ALL_TIME;
                    // since_created should be at least 24 hours (86400 seconds), skip otherwise.
                    if ($since_created >= WP_RW__TIME_24_HOURS_IN_SEC) {
                        $time = current_time('timestamp', true) - $since_created;
                        // c: ISO 8601 full date/time, e.g.: 2004-02-12T15:19:21+00:00
                        $queries[$type]['since_created'] = date('c', $time);
                    }
                }
            }
            $details["queries"] = urlencode(json_encode($queries));
            $rw_ret_obj = ratingwidget()->RemoteCall("action/query/ratings.php", $details, WP_RW__CACHE_TIMEOUT_TOP_RATED);
            if (false === $rw_ret_obj) {
                return;
            }
            $rw_ret_obj = json_decode($rw_ret_obj);
            if (null === $rw_ret_obj || true !== $rw_ret_obj->success) {
                return;
            }
            $title = empty($instance['title']) ? __('Top Rated', WP_RW__ID) : apply_filters('widget_title', $instance['title']);
            $titleMaxLength = isset($instance['title_max_length']) && is_numeric($instance['title_max_length']) ? (int) $instance['title_max_length'] : 30;
            $empty = true;
            $toprated_data = new stdClass();
            $toprated_data->id = rand(1, 100);
            $toprated_data->title = array('label' => $title, 'show' => true, 'before' => $this->EncodeHtml($before_title), 'after' => $this->EncodeHtml($after_title));
            $toprated_data->options = array('align' => 'vertical', 'direction' => 'ltr', 'html' => array('before' => $this->EncodeHtml($before_widget), 'after' => $this->EncodeHtml($after_widget)));
            $toprated_data->site = array('id' => WP_RW__SITE_ID, 'domain' => $_SERVER['HTTP_HOST'], 'type' => 'WordPress');
            $toprated_data->itemGroups = array();
            if (count($rw_ret_obj->data) > 0) {
                foreach ($rw_ret_obj->data as $type => $ratings) {
                    if (is_array($ratings) && count($ratings) > 0) {
                        $item_group = new stdClass();
                        $item_group->type = $type;
                        $item_group->title = $instance["{$type}_title"];
                        $item_group->showTitle = 1 === $instance["show_{$type}_title"] && '' !== trim($item_group->title);
                        if (is_numeric($instance["{$type}_style"])) {
                            switch ($instance["{$type}_style"]) {
                                case 0:
                                    $instance["{$type}_style"] = 'legacy';
                                    break;
                                case 1:
                                default:
                                    $instance["{$type}_style"] = 'thumbs';
                                    break;
                            }
                        }
                        $item_group->style = $instance["{$type}_style"];
                        $item_group->options = array('title' => array('maxLen' => $titleMaxLength));
                        $item_group->items = array();
                        $has_thumb = strtolower($instance["{$type}_style"]) !== 'legacy';
                        $thumb_width = 160;
                        $thumb_height = 100;
                        if ($has_thumb) {
                            switch ($instance["{$type}_style"]) {
                                case '2':
                                case 'compact_thumbs':
                                    $thumb_width = 50;
                                    $thumb_height = 40;
                                    break;
                                case '1':
                                case 'thumbs':
                                default:
                                    $thumb_width = 160;
                                    $thumb_height = 100;
                                    break;
                            }
                            $item_group->options['thumb'] = array('width' => $thumb_width, 'height' => $thumb_height);
                        }
                        $cell = 0;
                        foreach ($ratings as $rating) {
                            $urid = $rating->urid;
                            $rclass = $types[$type]["rclass"];
                            $rclasses[$rclass] = true;
                            $extension_type = false;
                            if (RWLogger::IsOn()) {
                                RWLogger::Log('HANDLED_ITEM', 'Urid = ' . $urid . '; Class = ' . $rclass . ';');
                            }
                            if ('posts' === $type || 'pages' === $type) {
                                $post = null;
                                $id = RatingWidgetPlugin::Urid2PostId($urid);
                                $status = @get_post_status($id);
                                if (false === $status) {
                                    if (RWLogger::IsOn()) {
                                        RWLogger::Log('POST_NOT_EXIST', $id);
                                    }
                                    // Post not exist.
                                    continue;
                                } else {
                                    if ('publish' !== $status && 'private' !== $status) {
                                        if (RWLogger::IsOn()) {
                                            RWLogger::Log('POST_NOT_VISIBLE', 'status = ' . $status);
                                        }
                                        // Post not yet published.
                                        continue;
                                    } else {
                                        if ('private' === $status && !is_user_logged_in()) {
                                            if (RWLogger::IsOn()) {
                                                RWLogger::Log('RatingWidgetPlugin_TopRatedWidget::widget', 'POST_PRIVATE && USER_LOGGED_OUT');
                                            }
                                            // Private post but user is not logged in.
                                            continue;
                                        }
                                    }
                                }
                                $post = @get_post($id);
                                $title = trim(strip_tags($post->post_title));
                                $permalink = get_permalink($post->ID);
                            } else {
                                if ('comments' === $type) {
                                    $comment = null;
                                    $id = RatingWidgetPlugin::Urid2CommentId($urid);
                                    $status = @wp_get_comment_status($id);
                                    if (false === $status) {
                                        if (RWLogger::IsOn()) {
                                            RWLogger::Log('COMMENT_NOT_EXIST', $id);
                                        }
                                        // Comment not exist.
                                        continue;
                                    } else {
                                        if ('approved' !== $status) {
                                            if (RWLogger::IsOn()) {
                                                RWLogger::Log('COMMENT_NOT_VISIBLE', 'status = ' . $status);
                                            }
                                            // Comment not approved.
                                            continue;
                                        }
                                    }
                                    $comment = @get_comment($id);
                                    $title = trim(strip_tags($comment->comment_content));
                                    $permalink = get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID;
                                } else {
                                    if ('activity_updates' === $type || 'activity_comments' === $type) {
                                        $id = RatingWidgetPlugin::Urid2ActivityId($urid);
                                        $activity = new bp_activity_activity($id);
                                        if (!is_object($activity)) {
                                            if (RWLogger::IsOn()) {
                                                RWLogger::Log('BP_ACTIVITY_NOT_EXIST', $id);
                                            }
                                            // Activity not exist.
                                            continue;
                                        } else {
                                            if (!empty($activity->is_spam)) {
                                                if (RWLogger::IsOn()) {
                                                    RWLogger::Log('BP_ACTIVITY_NOT_VISIBLE (SPAM or TRASH)');
                                                }
                                                // Activity marked as SPAM or TRASH.
                                                continue;
                                            } else {
                                                if (!empty($activity->hide_sitewide)) {
                                                    if (RWLogger::IsOn()) {
                                                        RWLogger::Log('BP_ACTIVITY_HIDE_SITEWIDE');
                                                    }
                                                    // Activity marked as hidden in site.
                                                    continue;
                                                }
                                            }
                                        }
                                        $title = trim(strip_tags($activity->content));
                                        $permalink = bp_activity_get_permalink($id);
                                    } else {
                                        if ('users' === $type) {
                                            $id = RatingWidgetPlugin::Urid2UserId($urid);
                                            if ($bpInstalled) {
                                                $title = trim(strip_tags(bp_core_get_user_displayname($id)));
                                                $permalink = bp_core_get_user_domain($id);
                                            } else {
                                                if ($bbInstalled) {
                                                    $title = trim(strip_tags(bbp_get_user_display_name($id)));
                                                    $permalink = bbp_get_user_profile_url($id);
                                                } else {
                                                    continue;
                                                }
                                            }
                                        } else {
                                            if ('forum_posts' === $type || 'forum_replies' === $type) {
                                                $id = RatingWidgetPlugin::Urid2ForumPostId($urid);
                                                if (function_exists('bp_forums_get_post')) {
                                                    $forum_post = @bp_forums_get_post($id);
                                                    if (!is_object($forum_post)) {
                                                        continue;
                                                    }
                                                    $title = trim(strip_tags($forum_post->post_text));
                                                    $page = bb_get_page_number($forum_post->post_position);
                                                    $permalink = get_topic_link($id, $page) . "#post-{$id}";
                                                } else {
                                                    if (function_exists('bbp_get_reply_id')) {
                                                        $forum_item = bbp_get_topic();
                                                        if (is_object($forum_item)) {
                                                            $is_topic = true;
                                                        } else {
                                                            $is_topic = false;
                                                            $forum_item = bbp_get_reply($id);
                                                            if (!is_object($forum_item)) {
                                                                if (RWLogger::IsOn()) {
                                                                    RWLogger::Log('BBP_FORUM_ITEM_NOT_EXIST', $id);
                                                                }
                                                                // Invalid id (no topic nor reply).
                                                                continue;
                                                            }
                                                            if (RWLogger::IsOn()) {
                                                                RWLogger::Log('BBP_IS_TOPIC_REPLY', $is_topic ? 'FALSE' : 'TRUE');
                                                            }
                                                        }
                                                        // Visible statueses: Public or Closed.
                                                        $visible_statuses = array(bbp_get_public_status_id(), bbp_get_closed_status_id());
                                                        if (!in_array($forum_item->post_status, $visible_statuses)) {
                                                            if (RWLogger::IsOn()) {
                                                                RWLogger::Log('BBP_FORUM_ITEM_HIDDEN', $forum_item->post_status);
                                                            }
                                                            // Item is not public nor closed.
                                                            continue;
                                                        }
                                                        $is_reply = !$is_topic;
                                                        if ($is_reply) {
                                                            // Get parent topic.
                                                            $forum_topic = bbp_get_topic($forum_post->post_parent);
                                                            if (!in_array($forum_topic->post_status, $visible_statuses)) {
                                                                if (RWLogger::IsOn()) {
                                                                    RWLogger::Log('BBP_PARENT_FORUM_TOPIC_IS_HIDDEN', 'TRUE');
                                                                }
                                                                // Parent topic is not public nor closed.
                                                                continue;
                                                            }
                                                        }
                                                        $title = trim(strip_tags($forum_post->post_title));
                                                        $permalink = get_permalink($forum_post->ID);
                                                    } else {
                                                        continue;
                                                    }
                                                }
                                                $types[$type]['handler']->GetElementInfoByRating();
                                            } else {
                                                $found_handler = false;
                                                $extensions = ratingwidget()->GetExtensions();
                                                foreach ($extensions as $ext) {
                                                    $result = $ext->GetElementInfoByRating($type, $rating);
                                                    if (false !== $result) {
                                                        $found_handler = true;
                                                        break;
                                                    }
                                                }
                                                if ($found_handler) {
                                                    $id = $result['id'];
                                                    $title = $result['title'];
                                                    $permalink = $result['permalink'];
                                                    $img = rw_get_thumb_url($result['img'], $thumb_width, $thumb_height, $result['permalink']);
                                                    $extension_type = true;
                                                } else {
                                                    continue;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            $queued = ratingwidget()->QueueRatingData($urid, "", "", $rclass);
                            // Override rating class in case the same rating has already been queued with a different rclass.
                            $rclass = $queued['rclass'];
                            $short = mb_strlen($title) > $titleMaxLength ? trim(mb_substr($title, 0, $titleMaxLength)) . "..." : $title;
                            $item = array('site' => array('id' => WP_RW__SITE_ID, 'domain' => $_SERVER['HTTP_HOST']), 'page' => array('externalID' => $id, 'url' => $permalink, 'title' => $short), 'rating' => array('localID' => $urid, 'options' => array('rclass' => $rclass)));
                            // Add thumb url.
                            if ($extension_type && is_string($img)) {
                                $item['page']['img'] = $img;
                            } else {
                                if ($has_thumb && in_array($type, array('posts', 'pages'))) {
                                    $item['page']['img'] = rw_get_post_thumb_url($post, $thumb_width, $thumb_height);
                                }
                            }
                            $item_group->items[] = $item;
                            $cell++;
                            $empty = false;
                        }
                        $toprated_data->itemGroups[] = $item_group;
                    }
                }
            }
            if (true === $empty) {
                //            echo '<p style="margin: 0;">There are no rated items for this period.</p>';
                //        echo $before_widget;
                //        echo $after_widget;
            } else {
                // Set a flag that the widget is loaded.
                ratingwidget()->TopRatedWidgetLoaded();
                ?>
					<b class="rw-ui-recommendations" data-id="<?php 
                echo $toprated_data->id;
                ?>
"></b>
					<script type="text/javascript">
						var _rwq = _rwq || [];
						_rwq.push(['_setRecommendations', <?php 
                echo json_encode($toprated_data);
                ?>
]);
					</script>
				<?php 
            }
        }
Пример #5
0
 public function EmbedRatingByComment($pComment, $pClass = 'comment', $pHorAlign = false, $pCustomStyle = false, $pOptions = array())
 {
     if (RWLogger::IsOn()) {
         $params = func_get_args();
         RWLogger::LogEnterence('EmbedRatingByComment', $params);
     }
     // Add accumulator id if user accumulated rating.
     if ($this->IsUserAccumulatedRating() && (int) $pComment->user_id > 0) {
         $pOptions['uarid'] = $this->_getUserRatingGuid($pComment->user_id);
     }
     $comment_ratings_mode = $this->get_comment_ratings_mode();
     if (RWLogger::IsOn()) {
         RWLogger::Log('comment_ratings_mode', $comment_ratings_mode);
     }
     /**
      * If reviews mode, check if the previous submission of rating's value and vote has failed.
      * If the submission has failed, submit again.
      */
     if ($this->is_comment_review_mode()) {
         $comment_review_mode_settings = $this->get_comment_review_mode_settings();
         if (RWLogger::IsOn()) {
             RWLogger::Log('comment_review_mode_options', json_encode($comment_review_mode_settings));
         }
         $failed_requests = $comment_review_mode_settings->failed_requests;
         if (isset($failed_requests[$pComment->comment_ID])) {
             $request = $failed_requests[$pComment->comment_ID];
             $this->set_comment_review_vote($pComment->comment_ID, $request['request_params']);
         }
     }
     if ($this->is_comment_review_mode() || $this->is_comment_admin_ratings_mode()) {
         // Set the rating to read-only so that no other people can vote for the comment.
         $pOptions['read-only'] = 'true';
     }
     return $this->EmbedRating($pComment->comment_ID, (int) $pComment->user_id, strip_tags($pComment->comment_content), get_permalink($pComment->comment_post_ID) . '#comment-' . $pComment->comment_ID, $pClass, false, $pHorAlign, $pCustomStyle, $pOptions);
 }
<?php

/**
 * The content of the comment rating metabox. Loaded by ratingwidget()->show_comment_rating_metabox() method.
 */
global $comment, $rwp;
RWLogger::Log('show_comment_rating_metabox');
add_action('admin_footer', array(&$rwp, 'rw_attach_rating_js'), 5);
$rclass = 'comment';
$multirating_options = $rwp->get_multirating_options_by_class($rclass);
$multi_criterion = count($multirating_options->criteria) > 1;
$options = $rwp->get_options_by_class($rclass);
$default_hide_recommendations = isset($options->hideRecommendations) ? $options->hideRecommendations : false;
?>
<p>
	<input type="hidden" name="rw_comment_meta_box_nonce"
	       value="<?php 
echo wp_create_nonce(basename(WP_RW__PLUGIN_FILE_FULL));
?>
"/>
<table class="rw-rating-table rw-comment-admin-rating rw-left">
	<?php 
$urid_summary = $rwp->get_rating_id_by_element($comment->comment_ID, $rclass, false);
$criterion_id = 1;
foreach ($multirating_options->criteria as $criterion_key => $criterion) {
    $criterion_rclass = $rclass;
    if ($multi_criterion) {
        $criterion_rclass .= '-criteria-' . $criterion_id;
    }
    $urid = $rwp->get_rating_id_by_element($comment->comment_ID, $rclass, $multi_criterion ? $criterion_id++ : false);
    $rwp->QueueRatingData($urid, '', '', $criterion_rclass);
Пример #7
0
 function SavePostData($post_id)
 {
     if (RWLogger::IsOn()) {
         $params = func_get_args();
         RWLogger::LogEnterence("SavePostData", $params, true);
     }
     // Verify nonce.
     if (!isset($_POST['rw_post_meta_box_nonce']) || !wp_verify_nonce($_POST['rw_post_meta_box_nonce'], basename(__FILE__))) {
         return $post_id;
     }
     // Check autosave.
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return $post_id;
     }
     if (RWLogger::IsOn()) {
         RWLogger::Log("post_type", $_POST['post_type']);
     }
     // Check permissions.
     if ('page' == $_POST['post_type']) {
         if (!current_user_can('edit_page', $post_id)) {
             return $post_id;
         }
     } else {
         if (!current_user_can('edit_post', $post_id)) {
             return $post_id;
         }
     }
     //check whether this post/page is to be excluded
     $includePost = isset($_POST['rw_include_post']) && "1" == $_POST['rw_include_post'];
     $this->AddToVisibility($_POST['ID'], 'page' == $_POST['post_type'] ? array('page') : array('front-post', 'blog-post'), $includePost);
     $this->SaveVisibility();
     if (RWLogger::IsOn()) {
         RWLogger::LogDeparture("SavePostData");
     }
 }
Пример #8
0
 /**
  * Queue rating data for footer JS hook and return rating's html.
  *
  * @param int $pElementID
  * @param $pOwnerID
  * @param $pTitle
  * @param $pPermalink
  * @param $pElementClass
  * @param bool $pAddSchema
  * @param bool $pHorAlign
  * @param bool $pCustomStyle
  * @param array $pOptions
  * @param bool $pValidateVisibility
  * @param bool $pValidateCategory
  *
  * @return string Rating HTML container.
  *
  * @uses GetRatingHtml
  * @version 1.3.3
  */
 function EmbedRating($pElementID, $pOwnerID, $pTitle, $pPermalink, $pElementClass, $pAddSchema = false, $pHorAlign = false, $pCustomStyle = false, $pOptions = array(), $pValidateVisibility = false, $pValidateCategory = true)
 {
     if (RWLogger::IsOn()) {
         $params = func_get_args();
         RWLogger::LogEnterence("EmbedRating", $params);
     }
     $result = apply_filters('rw_filter_embed_rating', $pElementID, $pOwnerID);
     if (false === $result) {
         return '';
     }
     if ($pValidateVisibility && !$this->IsVisibleRating($pElementID, 'forum-reply' !== $pElementClass ? $pElementClass : 'forum-post', $pValidateCategory)) {
         return '';
     }
     $urid = $this->get_rating_id_by_element($pElementID, $pElementClass);
     // Get the read-only state of the exact post type, e.g.: post or product
     $is_rating_readonly = $this->is_rating_readonly($pElementID, get_post_type($pElementID));
     if (!$is_rating_readonly) {
         if (function_exists('is_buddypress') && is_buddypress()) {
             // Get the user ID associated with the current BuddyPress page being viewed.
             $buddypress_user_id = 'user' === $pElementClass ? $pElementID : $pOwnerID;
             // Set the rating to read-only if the current logged in user ID
             // is equal to the current BuddyPress user ID.
             $is_rating_readonly = get_current_user_id() == $buddypress_user_id;
         } else {
             if (function_exists('is_bbpress') && is_bbpress()) {
                 // Get the user ID associated with the current bbPress item being viewed.
                 $bbpress_user_id = 'user' === $pElementClass ? $pElementID : $pOwnerID;
                 // Set the rating to read-only if the current logged in user ID
                 // is equal to the current bbPress user ID.
                 $is_rating_readonly = get_current_user_id() == $bbpress_user_id;
             }
         }
     }
     if ($is_rating_readonly) {
         $pOptions['read-only'] = 'true';
     }
     if (!$this->has_multirating_options($pElementClass)) {
         RWLogger::Log('EmbedRating', 'Not multi-criteria rating');
         return $this->EmbedRawRating($urid, $pTitle, $pPermalink, $pElementClass, $pAddSchema, $pHorAlign, $pCustomStyle, $pOptions);
     } else {
         RWLogger::Log('EmbedRating', 'Multi-criteria rating');
         //Prefixed with mr_ to avoid possible collisions after calling extract()
         $vars = array('mr_add_schema' => $pAddSchema, 'mr_custom_style' => $pCustomStyle, 'mr_element_class' => $pElementClass, 'mr_element_id' => $pElementID, 'mr_embed_options' => $pOptions, 'mr_hor_align' => $pHorAlign, 'mr_permalink' => $pPermalink, 'mr_summary_urid' => $urid, 'mr_title' => $pTitle);
         return $this->embed_multi_rating($vars);
     }
 }
Пример #9
0
 function rw_display_activity_comment_rating($comment_content)
 {
     if (RWLogger::IsOn()) {
         $params = func_get_args();
         RWLogger::LogEnterence("rw_display_activity_comment_rating", $params);
     }
     if (!isset($this->current_comment) || null === $this->current_comment) {
         if (RWLogger::IsOn()) {
             RWLogger::Log("rw_display_activity_comment_rating", "Current comment is not set.");
         }
         return $comment_content;
     }
     // Find current comment.
     while (!$this->current_comment->children || false === current($this->current_comment->children)) {
         $this->current_comment = $this->current_comment->parent;
         next($this->current_comment->children);
     }
     $parent = $this->current_comment;
     $this->current_comment = current($this->current_comment->children);
     $this->current_comment->parent = $parent;
     // Check if comment rating isn't specifically excluded.
     if (false === $this->rw_validate_visibility($this->current_comment->id, "activity-comment")) {
         return $comment_content;
     }
     // Get activity comment user-rating-id.
     $comment_urid = $this->_getActivityRatingGuid($this->current_comment->id);
     // Queue activity-comment rating.
     self::QueueRatingData($comment_urid, strip_tags($this->current_comment->content), bp_activity_get_permalink($this->current_comment->id), "activity-comment");
     $rw = '<div class="rw-' . $this->activity_align["activity-comment"]->hor . '"><div class="rw-ui-container rw-class-activity-comment rw-urid-' . $comment_urid . '"></div></div><p></p>';
     // Attach rating html container.
     return $this->activity_align["activity-comment"]->ver == "top" ? $rw . $comment_content : $comment_content . $rw;
 }