Exemplo n.º 1
0
 function render_multi_editor($settings)
 {
     $multi_id = $settings["multi_id"] == 0 ? $this->g->o["mur_review_set"] : $settings["multi_id"];
     $post_id = $settings["post_id"];
     $init_votes = $settings["votes"];
     $set = gd_get_multi_set($multi_id);
     if (is_null($set)) {
         $set = gd_get_multi_set();
     }
     $multi_id = !is_null($set) ? $set->multi_id : 0;
     if ($multi_id > 0 && $post_id > 0) {
         $vote_id = GDSRDBMulti::get_vote($post_id, $multi_id, count($set->object));
         $multi_data = GDSRDBMulti::get_values($vote_id, 'rvw');
         if (count($multi_data) == 0) {
             GDSRDBMulti::add_empty_review_values($vote_id, count($set->object));
             $multi_data = GDSRDBMulti::get_values($vote_id, 'rvw');
         }
     } else {
         $multi_data = array();
     }
     $votes = array();
     if (count($multi_data) > 0) {
         foreach ($multi_data as $md) {
             $single_vote = array();
             $single_vote["votes"] = 1;
             $single_vote["score"] = $md->user_votes;
             $single_vote["rating"] = $md->user_votes;
             $votes[] = $single_vote;
         }
     } else {
         for ($i = 0; $i < count($set->object); $i++) {
             $iv = isset($init_votes[$i]) ? $init_votes[$i] : 0;
             $votes[] = array("votes" => $iv == 0 ? 0 : 1, "score" => $iv == 0 ? 0 : $iv, "rating" => $iv == 0 ? 0 : $iv);
         }
     }
     if ($settings["admin"]) {
         include $this->g->plugin_path . 'integrate/edit_multi.php';
     } else {
         return GDSRRenderT2::render_mre(intval($settings["tpl"]), array("post_id" => $settings["post_id"], "style" => $settings["style"], "height" => $settings["size"], "votes" => $votes, "set" => $set, "allow_vote" => true));
     }
 }
Exemplo n.º 2
0
 function render_multi_custom_values($template_id, $multi_set_id, $custom_id, $votes, $header_text = '', $override = array(), $tags_css = array(), $star_factor = 1)
 {
     $set = gd_get_multi_set($multi_set_id);
     $rd_unit_width = $override["size"];
     $rd_unit_style = $this->g->is_ie6 ? $override["style_ie6"] : $override["style"];
     $rd_unit_width_avg = isset($override["average_size"]) ? $override["average_size"] : $override["style"];
     $rd_unit_style_avg = isset($override["average_stars"]) ? $this->g->is_ie6 ? $override["average_stars_ie6"] : $override["average_stars"] : $override["style"];
     return GDSRRenderT2::render_mrb($template_id, array("style" => $rd_unit_style, "allow_vote" => false, "votes" => $votes, "post_id" => $custom_id, "set" => $set, "height" => $rd_unit_width, "header_text" => $header_text, "tags_css" => array("MUR_CSS_BLOCK" => ""), "avg_style" => $rd_unit_style_avg, "avg_size" => $rd_unit_width_avg, "star_factor" => $star_factor));
 }
Exemplo n.º 3
0
 function widget($args, $instance)
 {
     global $gdsr, $userdata;
     if (is_single() || is_page()) {
         extract($args, EXTR_SKIP);
         if ($instance["display"] == "hide" || $instance["display"] == "users" && $userdata->ID == 0 || $instance["display"] == "visitors" && $userdata->ID > 0) {
             return;
         }
         echo $before_widget . $before_title . $instance['title'] . $after_title;
         echo GDSRRenderT2::render_wcr($instance);
         echo $after_widget;
     }
 }
Exemplo n.º 4
0
Arquivo: data.php Projeto: hewu/blogwp
/**
 * Returns calculated data for average blog rating including bayesian estimate mean.
 *
 * @global class $gdsr
 * @param string $select articles to select postpage|post|page
 * @param string $show votes to use: total|users|visitors
 * @return object with average blog rating values
 */
function wp_gdsr_blog_rating($select = "postpage", $show = "total")
{
    $widget = array("select" => $select, "show" => $show);
    return GDSRRenderT2::prepare_wbr($widget);
}
Exemplo n.º 5
0
/**
 * Renders comments rating widget element based on the $widget settings array
 *
 * @param array $widget settings to use for rendering
 * @param bool $echo echo results or return it as a string
 * @return string html with rendered contents
 */
function gdsr_render_comments_rating_widget($widget = array(), $echo = true)
{
    global $gdsr;
    $widget = wp_parse_args((array) $widget, $gdsr->default_widget_comments);
    if ($echo) {
        echo GDSRRenderT2::render_wcr($widget);
    } else {
        return GDSRRenderT2::render_wcr($widget);
    }
}
Exemplo n.º 6
0
 /**
  * Code for StarReviewMulti shortcode implementation
  *
  * @param array $atts
  */
 function shortcode_starreviewmulti($atts = array())
 {
     $settings = shortcode_atts($this->default_shortcode_starreviewmulti, $atts);
     $el_stars = $settings["element_stars"] != "" ? $settings["element_stars"] : $settings["style"];
     $el_size = $settings["element_size"] != "" ? $settings["element_size"] : $settings["size"];
     $post_id = $settings["post"];
     if ($post_id == 0) {
         global $post;
         $post_id = $post->ID;
     }
     $multi_id = $settings["id"] == 0 ? $this->o["mur_review_set"] : $settings["id"];
     $set = gd_get_multi_set($multi_id);
     if ($multi_id > 0 && $post_id > 0) {
         $vote_id = GDSRDBMulti::get_vote($post_id, $multi_id, count($set->object));
         $multi_data = GDSRDBMulti::get_values($vote_id, 'rvw');
         $votes = array();
         foreach ($multi_data as $md) {
             $single_vote = array();
             $single_vote["votes"] = 1;
             $single_vote["score"] = $md->user_votes;
             $single_vote["rating"] = $md->user_votes;
             $votes[] = $single_vote;
         }
         $avg_rating = GDSRDBMulti::get_multi_review_average($vote_id);
         return GDSRRenderT2::render_rmb($settings["tpl"], array("votes" => $votes, "star_factor" => $settings["factor"], "post_id" => $post_id, "set" => $set, "avg_rating" => $avg_rating, "style" => $el_stars, "size" => $el_size, "avg_style" => $settings["average_stars"], "avg_size" => $settings["average_size"]));
     } else {
         return '';
     }
 }
Exemplo n.º 7
0
 function vote_comment($votes, $id, $tpl_id, $unit_width)
 {
     global $userdata;
     $user = is_object($userdata) ? $userdata->ID : 0;
     $ip = $_SERVER["REMOTE_ADDR"];
     if ($this->g->o["save_user_agent"] == 1) {
         $ua = $_SERVER["HTTP_USER_AGENT"];
     } else {
         $ua = "";
     }
     $vote_value = $votes;
     wp_gdsr_dump("VOTE_CMM", "[CMM: " . $id . "] --" . $votes . "-- [" . $user . "] " . $unit_width . "px");
     $allow_vote = intval($votes) <= $this->g->o["cmm_stars"] && intval($votes) > 0;
     if ($allow_vote) {
         $allow_vote = gdsrFrontHelp::check_cookie($id, 'comment');
     }
     if ($allow_vote) {
         $allow_vote = gdsrBlgDB::check_vote($id, $user, 'comment', $ip, $this->g->o["cmm_logged"] != 1, $this->g->o["cmm_allow_mixed_ip_votes"] == 1);
     }
     if ($allow_vote) {
         gdsrBlgDB::save_vote_comment($id, $user, $ip, $ua, $votes);
         gdsrFrontHelp::save_cookie($id, 'comment');
         do_action("gdsr_vote_rating_comment", $id, $user, $votes);
     }
     $data = GDSRDatabase::get_comment_data($id);
     $post_data = GDSRDatabase::get_post_data($data->post_id);
     $unit_count = $this->g->o["cmm_stars"];
     $votes = $score = 0;
     if ($post_data->rules_comments == "A" || $post_data->rules_comments == "N") {
         $votes = $data->user_voters + $data->visitor_voters;
         $score = $data->user_votes + $data->visitor_votes;
     } else {
         if ($post_data->rules_comments == "V") {
             $votes = $data->visitor_voters;
             $score = $data->visitor_votes;
         } else {
             $votes = $data->user_voters;
             $score = $data->user_votes;
         }
     }
     if ($votes > 0) {
         $rating2 = $score / $votes;
     } else {
         $rating2 = 0;
     }
     $rating1 = @number_format($rating2, 1);
     $rating_width = number_format($rating2 * $unit_width, 0);
     include STARRATING_PATH . 'code/t2/templates.php';
     $template = new gdTemplateRender($tpl_id, "CRB");
     $rt = GDSRRenderT2::render_crt($template->dep["CRT"], array("rating" => $rating1, "unit_count" => $unit_count, "votes" => $votes, "vote_value" => $vote_value));
     $rating_width = apply_filters("gdsr_vote_rating_comment_return", $rating_width, $unit_width, $rating1, $vote_value);
     return '{ "status": "ok", "value": "' . $rating_width . '", "rater": "' . str_replace('"', '\\"', $rt) . '" }';
 }
Exemplo n.º 8
0
 function render_srr($widget)
 {
     $widget = apply_filters('gdsr_widget_parameters_srr', $widget);
     return GDSRRenderT2::render_wsr($widget, "SRR");
 }
Exemplo n.º 9
0
 function render_multi_rating($post, $user, $settings)
 {
     if ($this->is_bot) {
         return "";
     }
     if (is_feed()) {
         return "";
     }
     $set = gd_get_multi_set($settings["id"]);
     if ($set == null) {
         return "";
     }
     $dbg_allow = "F";
     $allow_vote = true;
     if ($this->is_ban && $this->o["ip_filtering"] == 1) {
         if ($this->o["ip_filtering_restrictive"] == 1) {
             return "";
         } else {
             $allow_vote = false;
         }
         $dbg_allow = "B";
     }
     if ($settings["read_only"] == 1) {
         $dbg_allow = "RO";
         $allow_vote = false;
     }
     if (is_single() || is_page() && $this->o["display_comment_page"] == 1) {
         $this->init_post();
     }
     $rd_post_id = intval($post->ID);
     $rd_user_id = intval($user->ID);
     $rd_is_page = $post->post_type == "page" ? "1" : "0";
     $remaining = 0;
     $deadline = "";
     if ($this->p) {
         $post_data = $this->p;
     } else {
         $post_data = GDSRDatabase::get_post_data($rd_post_id);
         if (count($post_data) == 0) {
             GDSRDatabase::add_default_vote($rd_post_id, $rd_is_page);
             $post_data = GDSRDatabase::get_post_data($rd_post_id);
         }
     }
     if ($post_data->rules_articles == "H") {
         return "";
     }
     if ($allow_vote) {
         if ($this->o["author_vote"] == 1 && $rd_user_id == $post->post_author) {
             $allow_vote = false;
             $dbg_allow = "A";
         }
     }
     if ($allow_vote) {
         if ($post_data->rules_articles == "" || $post_data->rules_articles == "A" || $post_data->rules_articles == "U" && $rd_user_id > 0 || $post_data->rules_articles == "V" && $rd_user_id == 0) {
             $allow_vote = true;
         } else {
             $allow_vote = false;
             $dbg_allow = "R_" . $post_data->rules_articles;
         }
     }
     if ($allow_vote && ($post_data->expiry_type == 'D' || $post_data->expiry_type == 'T')) {
         switch ($post_data->expiry_type) {
             case "D":
                 $remaining = GDSRHelper::expiration_date($post_data->expiry_value);
                 $deadline = $post_data->expiry_value;
                 break;
             case "T":
                 $remaining = GDSRHelper::expiration_countdown($post->post_date, $post_data->expiry_value);
                 $deadline = GDSRHelper::calculate_deadline($remaining);
                 break;
         }
         if ($remaining < 1) {
             GDSRDatabase::lock_post($rd_post_id);
             $allow_vote = false;
             $dbg_allow = "T";
         }
     }
     if ($allow_vote) {
         $allow_vote = GDSRDBMulti::check_vote($rd_post_id, $rd_user_id, $set->multi_id, 'multis', $_SERVER["REMOTE_ADDR"], $this->o["logged"] != 1, $this->o["mur_allow_mixed_ip_votes"] == 1);
         if (!$allow_vote) {
             $dbg_allow = "D";
         }
     }
     if ($allow_vote) {
         $allow_vote = $this->check_cookie($rd_post_id . "#" . $set->multi_id, "multis");
         if (!$allow_vote) {
             $dbg_allow = "C";
         }
     }
     $multi_record_id = GDSRDBMulti::get_vote($rd_post_id, $set->multi_id, count($set->object));
     $multi_data = GDSRDBMulti::get_values($multi_record_id);
     $votes = array();
     foreach ($multi_data as $md) {
         $single_vote = array();
         $single_vote["votes"] = 0;
         $single_vote["score"] = 0;
         if ($post_data->rules_articles == "A" || $post_data->rules_articles == "N") {
             $single_vote["votes"] = $md->user_voters + $md->visitor_voters;
             $single_vote["score"] = $md->user_votes + $md->visitor_votes;
         } else {
             if ($post_data->rules_articles == "V") {
                 $single_vote["votes"] = $md->visitor_voters;
                 $single_vote["score"] = $md->visitor_votes;
             } else {
                 $single_vote["votes"] = $md->user_voters;
                 $single_vote["score"] = $md->user_votes;
             }
         }
         if ($single_vote["votes"] > 0) {
             $rating = $single_vote["score"] / $single_vote["votes"];
         } else {
             $rating = 0;
         }
         if ($rating > $set->stars) {
             $rating = $set->stars;
         }
         $single_vote["rating"] = @number_format($rating, 1);
         $votes[] = $single_vote;
     }
     $debug = $rd_user_id == 0 ? "V" : "U";
     $debug .= $rd_user_id == $post->post_author ? "A" : "N";
     $debug .= ":" . $dbg_allow . " [" . STARRATING_VERSION . "]";
     $tags_css = array();
     $tags_css["MUR_CSS_BLOCK"] = $this->o["mur_class_block"];
     $tags_css["MUR_CSS_HEADER"] = $this->o["mur_class_header"];
     $tags_css["MUR_CSS_TEXT"] = $this->o["mur_class_text"];
     $tags_css["MUR_CSS_BUTTON"] = $this->o["mur_class_button"];
     if ($settings["tpl"] > 0) {
         $template_id = $settings["tpl"];
     } else {
         $template_id = $this->o["default_mrb_template"];
     }
     return GDSRRenderT2::render_mrb($this->o["mur_style"], $template_id, $allow_vote, $votes, $rd_post_id, $set, $this->o["mur_size"], $this->o["mur_header_text"], $tags_css, $settings["average_stars"], $settings["average_size"], $post_data->expiry_type, $remaining, $deadline, $this->o["mur_button_active"] == 1, $this->o["mur_button_text"], $debug, $this->loader_multis);
 }
Exemplo n.º 10
0
/**
 * Renders comments rating widget element based on the $widget settings array
 *
 * @param array $widget settings to use for rendering
 * @param bool $echo echo results or return it as a string
 * @return string html with rendered contents
 */
function wp_gdsr_render_comments_rating_widget($widget = array(), $echo = true)
{
    if ($echo) {
        echo GDSRRenderT2::render_wcr($widget);
    } else {
        return GDSRRenderT2::render_wcr($widget);
    }
}
Exemplo n.º 11
0
 function widget_articles_display($args, $widget_args = 1)
 {
     extract($args);
     global $gdsr, $wpdb, $userdata;
     if (is_numeric($widget_args)) {
         $widget_args = array('number' => $widget_args);
     }
     $widget_args = wp_parse_args($widget_args, array('number' => -1));
     extract($widget_args, EXTR_SKIP);
     $options_all = get_option('widget_gdstarrating');
     if (!isset($options_all[$number])) {
         return;
     }
     $this->w = $options_all[$number];
     if ($this->w["display"] == "hide" || $this->w["display"] == "users" && $userdata->ID == 0 || $this->w["display"] == "visitors" && $userdata->ID > 0) {
         return;
     }
     echo $before_widget . $before_title . $this->w['title'] . $after_title;
     echo GDSRRenderT2::render_wsr($this->w);
     echo $after_widget;
 }
Exemplo n.º 12
0
        <input onclick="gdsrMultiClear(<?php 
    echo $multi_id;
    ?>
, <?php 
    echo $post_id;
    ?>
, <?php 
    echo count($set->object);
    ?>
)" type="button" class="gdsr-input-button" value="<?php 
    _e("Clear", "gd-star-rating");
    ?>
" />
        <input onclick="gdsrMultiRevert(<?php 
    echo $multi_id;
    ?>
, <?php 
    echo $post_id;
    ?>
, <?php 
    echo count($set->object);
    ?>
)" type="button" class="gdsr-input-button" value="<?php 
    _e("Revert", "gd-star-rating");
    ?>
" />
<?php 
    echo '</td><td width="65%" class="gdsr-mur-review-stars">';
    echo GDSRRenderT2::render_mre("oxygen", 0, true, $votes, $post_id, $set, 20);
    echo '</td></tr></table>';
}
Exemplo n.º 13
0
        <input onclick="gdsrMultiClear(<?php 
    echo $multi_id;
    ?>
, <?php 
    echo $post_id;
    ?>
, <?php 
    echo count($set->object);
    ?>
)" type="button" class="gdsr-input-button" value="<?php 
    _e("Clear", "gd-star-rating");
    ?>
" />
        <input onclick="gdsrMultiRevert(<?php 
    echo $multi_id;
    ?>
, <?php 
    echo $post_id;
    ?>
, <?php 
    echo count($set->object);
    ?>
)" type="button" class="gdsr-input-button" value="<?php 
    _e("Revert", "gd-star-rating");
    ?>
" />
<?php 
    echo '</td><td width="65%" class="gdsr-mur-review-stars">';
    echo GDSRRenderT2::render_mre(0, array("post_id" => $post_id, "votes" => $votes, "style" => "oxygen", "set" => $set, "height" => 20, "allow_vote" => true));
    echo '</td></tr></table>';
}
Exemplo n.º 14
0
 function render_car($template_id, $votes, $rating, $comments, $star_style, $star_size, $star_max)
 {
     $template = GDSRRenderT2::get_template($template_id, "CAR");
     $tpl_render = $template->elm["normal"];
     $tpl_render = html_entity_decode($tpl_render);
     $tpl_render = str_replace("%CMM_COUNT%", $comments, $tpl_render);
     $tpl_render = str_replace("%CMM_VOTES%", $votes, $tpl_render);
     $tpl_render = str_replace("%MAX_CMM_RATING%", $star_max, $tpl_render);
     $tpl_render = str_replace("%CMM_RATING%", $rating, $tpl_render);
     $word_votes = $template->dep["EWV"];
     $tense = $votes == 1 ? $word_votes->elm["singular"] : $word_votes->elm["plural"];
     $tpl_render = str_replace('%WORD_VOTES%', __($tense), $tpl_render);
     $rating_stars = GDSRRender::render_static_stars($star_style, $star_size, $star_max, $rating);
     $tpl_render = str_replace("%CMM_STARS%", $rating_stars, $tpl_render);
     return $tpl_render;
 }