Example #1
0
 function rating_stars($style, $unit_width, $rater_id, $class, $rating_width, $allow_vote, $unit_count, $type, $id, $user_id, $loader_id, $rater_length, $typecls, $wait_msg = '', $template_id = 0)
 {
     $css_style = " gdsr-" . $style;
     $css_sizes = " gdsr-size-" . $unit_width;
     $rater = '<div id="' . $rater_id . '" class="' . $class . $css_style . $css_sizes . '"><div class="starsbar' . $css_sizes . '">';
     $rater .= '<div class="gdouter gdheight"><div id="gdr_vote_' . $type . $id . '" style="width: ' . $rating_width . 'px;" class="gdinner gdheight"></div>';
     if ($allow_vote) {
         $rater .= '<div id="gdr_stars_' . $type . $id . '" class="gdsr_rating_as">';
         for ($ic = 0; $ic < $unit_count; $ic++) {
             $ncount = $unit_count - $ic;
             $url = $_SERVER['REQUEST_URI'];
             $url_pos = strpos($url, "?");
             if ($url_pos === false) {
                 $first_char = '?';
             } else {
                 $first_char = '&amp;';
             }
             $ajax_id = sprintf("gdsrX%sX%sX%sX%sX%sX%sX%sX%s", $id, $ncount, $user_id, $type, $rater_id, $loader_id, $template_id, $unit_width);
             $rater .= '<a id="' . $ajax_id . '" title="' . $ncount . ' / ' . $unit_count . '" class="s' . $ncount . '" rel="nofollow"></a>';
         }
         $rater .= '</div>';
     }
     $rater .= '</div></div></div>';
     if ($allow_vote) {
         $rater .= GDSRRender::rating_wait($loader_id, $rater_length . "px", $typecls, $wait_msg);
     }
     return $rater;
 }
Example #2
0
 function render_tcb($template_id, $rpar = array())
 {
     $rdef = array("comment_id" => 0, "votes" => 0, "score" => 0, "votes_plus" => 0, "votes_minus" => 0, "style" => "starrating", "unit_width" => 20, "allow_vote" => true, "user_id" => 0, "tags_css" => array(), "header_text" => "", "debug" => "", "wait_msg" => "");
     $rpar = wp_parse_args($rpar, $rdef);
     $rpar = apply_filters('gdsr_t2parameters_tcb', $rpar);
     extract($rpar, EXTR_SKIP);
     $template = GDSRRenderT2::get_template($template_id, "TCB");
     $tpl_render = $allow_vote ? $template->elm["active"] : $template->elm["inactive"];
     $tpl_render = html_entity_decode($tpl_render);
     $tpl_render = apply_filters('gdsr_t2render_tcb_' . ($allow_vote ? "active" : "inactive"), $tpl_render, $template, $rpar, $allow_vote ? "active" : "inactive");
     foreach ($tags_css as $tag => $value) {
         $tpl_render = str_replace('%' . $tag . '%', $value, $tpl_render);
     }
     $tpl_render = str_replace("%CMM_HEADER_TEXT%", html_entity_decode($header_text), $tpl_render);
     if (in_array("%CMM_THUMBS_TEXT%", $allow_vote ? $template->tag["active"] : $template->tag["inactive"])) {
         $rating_text = GDSRRenderT2::render_tct($template->dep["TCT"], array("votes" => $votes, "score" => $score, "votes_plus" => $votes_plus, "votes_minus" => $votes_minus, "id" => $comment_id));
         $rating_text = '<div id="gdsr_thumb_text_' . $comment_id . '_c" class="gdt-size-' . $unit_width . ($allow_vote ? "" : " voted") . ' gdthumbtext">' . $rating_text . '</div>';
         $tpl_render = str_replace("%CMM_THUMBS_TEXT%", $rating_text, $tpl_render);
     }
     if (in_array("%THUMB_UP%", $allow_vote ? $template->tag["active"] : $template->tag["inactive"])) {
         if ($allow_vote) {
             $rater = sprintf('<div id="gdsr_thumb_%s_c_up" class="gdt-size-%s gdthumb gdup"><a id="gdsrX%sXupXcX%sX%sX%s" class="gdt-%s" rel="nofollow"></a></div>', $comment_id, $unit_width, $comment_id, $template_id, $unit_width, $wait_msg == '' ? "N" : "Y", $style);
             if ($wait_msg != '') {
                 $rater_wait = GDSRRender::rating_wait(sprintf("gdsr_thumb_%s_c_loader_up", $comment_id), $unit_width . "px", 'loadup', $wait_msg);
                 $rater .= sprintf($rater_wait, sprintf("width: %spx; height: %spx;", $unit_width, $unit_width));
             }
         } else {
             $rater = sprintf('<div id="gdsr_thumb_%s_c_up" class="gdt-size-%s gdthumb gdup"><div class="gdt-%s"></div></div>', $comment_id, $unit_width, $style);
         }
         $tpl_render = str_replace("%THUMB_UP%", $rater, $tpl_render);
     }
     if (in_array("%THUMB_DOWN%", $allow_vote ? $template->tag["active"] : $template->tag["inactive"])) {
         if ($allow_vote) {
             $rater = sprintf('<div id="gdsr_thumb_%s_c_dw" class="gdt-size-%s gdthumb gddw"><a id="gdsrX%sXdwXcX%sX%sX%s" class="gdt-%s" rel="nofollow"></a></div>', $comment_id, $unit_width, $comment_id, $template_id, $unit_width, $wait_msg == '' ? "N" : "Y", $style);
             if ($wait_msg != '') {
                 $rater_wait = GDSRRender::rating_wait(sprintf("gdsr_thumb_%s_c_loader_dw", $comment_id), $unit_width . "px", 'loaddw', $wait_msg);
                 $rater .= sprintf($rater_wait, sprintf("width: %spx; height: %spx;", $unit_width, $unit_width));
             }
         } else {
             $rater = sprintf('<div id="gdsr_thumb_%s_c_dw" class="gdt-size-%s gdthumb gddw"><div class="gdt-%s"></div></div>', $comment_id, $unit_width, $style);
         }
         $tpl_render = str_replace("%THUMB_DOWN%", $rater, $tpl_render);
     }
     if ($debug != '') {
         $tpl_render = '<div style="display: none">' . $debug . '</div>' . $tpl_render;
     }
     return $tpl_render;
 }
Example #3
0
 function render_tcb($template_id, $rpar = array())
 {
     $rdef = array("comment_id" => 0, "votes" => 0, "score" => 0, "votes_plus" => 0, "votes_minus" => 0, "style" => "starrating", "unit_width" => 20, "already_voted" => false, "allow_vote" => true, "header_text" => "", "debug" => "", "wait_msg" => "", "tags_css" => array(), "user_id" => 0);
     $rpar = wp_parse_args($rpar, $rdef);
     $rpar = apply_filters('gdsr_t2parameters_tcb', $rpar);
     extract($rpar, EXTR_SKIP);
     $template = GDSRRenderT2::get_template($template_id, "TCB");
     $tpl_render = $allow_vote ? $template->elm["active"] : $template->elm["inactive"];
     $tpl_render = html_entity_decode($tpl_render);
     $tpl_render = apply_filters('gdsr_t2render_tcb_' . ($allow_vote ? "active" : "inactive"), $tpl_render, $template, $rpar, $allow_vote ? "active" : "inactive");
     foreach ($tags_css as $tag => $value) {
         $tpl_render = str_replace('%' . $tag . '%', $value, $tpl_render);
     }
     $tpl_render = str_replace("%CMM_HEADER_TEXT%", html_entity_decode(__($header_text)), $tpl_render);
     $percent = $votes_plus + $votes_minus == 0 ? 0 : $votes_plus * 100 / ($votes_plus + $votes_minus);
     $percent = number_format($percent, 0);
     if ($percent == 0) {
         $percent = gdsr_zero_percentage();
     }
     $score_number = $score;
     $score = $score > 0 ? "+" . $score : $score;
     $css = intval($score_number) == 0 ? "zero" : (intval($score_number) > 0 ? "positive" : "negative");
     if ($already_voted) {
         $css .= " voted";
     }
     if (!$allow_vote) {
         $css .= " inactive";
     }
     $tpl_render = str_replace('%RATING%', apply_filters('gdsr_t2_tag_value', $score, "TCT", "%RATING%"), $tpl_render);
     $tpl_render = str_replace('%PERCENTAGE%', apply_filters('gdsr_t2_tag_value', $percent, "TCT", "%PERCENTAGE%"), $tpl_render);
     $tpl_render = str_replace('%VOTES%', apply_filters('gdsr_t2_tag_value', $votes, "TCT", "%VOTES%"), $tpl_render);
     $tpl_render = str_replace('%VOTES_UP%', apply_filters('gdsr_t2_tag_value', $votes_plus, "TCT", "%VOTES_UP%"), $tpl_render);
     $tpl_render = str_replace('%VOTES_DOWN%', apply_filters('gdsr_t2_tag_value', $votes_minus, "TCT", "%VOTES_DOWN%"), $tpl_render);
     $tpl_render = str_replace('%CSS_AUTO%', apply_filters('gdsr_t2_tag_value', $css, "TAB", "%CSS_AUTO%"), $tpl_render);
     $tpl_render = str_replace('%ID%', $comment_id, $tpl_render);
     if (in_array("%CMM_THUMBS_TEXT%", $allow_vote ? $template->tag["active"] : $template->tag["inactive"])) {
         $rating_text = GDSRRenderT2::render_tct($template->dep["TCT"], array("score_number" => $score_number, "percent" => $percent, "votes" => $votes, "score" => $score, "votes_plus" => $votes_plus, "votes_minus" => $votes_minus, "id" => $comment_id));
         $rating_text = '<div id="gdsr_thumb_text_' . $comment_id . '_c" class="gdt-size-' . $unit_width . ($already_voted ? " voted" : "") . ($allow_vote ? "" : " inactive") . ' gdthumbtext">' . $rating_text . '</div>';
         $tpl_render = str_replace("%CMM_THUMBS_TEXT%", $rating_text, $tpl_render);
     }
     if (in_array("%THUMB_UP%", $allow_vote ? $template->tag["active"] : $template->tag["inactive"])) {
         if ($allow_vote) {
             $rater = sprintf('<div id="gdsr_thumb_%s_c_up" class="gdt-size-%s gdthumb gdup"><a id="gdsrX%sXupXcX%sX%sX%s" class="gdt-%s" rel="nofollow"></a></div>', $comment_id, $unit_width, $comment_id, $template_id, $unit_width, $wait_msg == '' ? "N" : "Y", $style);
             if ($wait_msg != '') {
                 $rater_wait = GDSRRender::rating_wait(sprintf("gdsr_thumb_%s_c_loader_up", $comment_id), $unit_width . "px", ' loadup', $wait_msg);
                 $rater .= sprintf($rater_wait, sprintf("width: %spx; height: %spx;", $unit_width, $unit_width));
             }
         } else {
             $rater = sprintf('<div id="gdsr_thumb_%s_c_up" class="gdt-size-%s gdthumb gdup"><div class="gdt-%s"></div></div>', $comment_id, $unit_width, $style);
         }
         $tpl_render = str_replace("%THUMB_UP%", $rater, $tpl_render);
     }
     if (in_array("%THUMB_DOWN%", $allow_vote ? $template->tag["active"] : $template->tag["inactive"])) {
         if ($allow_vote) {
             $rater = sprintf('<div id="gdsr_thumb_%s_c_dw" class="gdt-size-%s gdthumb gddw"><a id="gdsrX%sXdwXcX%sX%sX%s" class="gdt-%s" rel="nofollow"></a></div>', $comment_id, $unit_width, $comment_id, $template_id, $unit_width, $wait_msg == '' ? "N" : "Y", $style);
             if ($wait_msg != '') {
                 $rater_wait = GDSRRender::rating_wait(sprintf("gdsr_thumb_%s_c_loader_dw", $comment_id), $unit_width . "px", ' loaddw', $wait_msg);
                 $rater .= sprintf($rater_wait, sprintf("width: %spx; height: %spx;", $unit_width, $unit_width));
             }
         } else {
             $rater = sprintf('<div id="gdsr_thumb_%s_c_dw" class="gdt-size-%s gdthumb gddw"><div class="gdt-%s"></div></div>', $comment_id, $unit_width, $style);
         }
         $tpl_render = str_replace("%THUMB_DOWN%", $rater, $tpl_render);
     }
     if ($debug != '') {
         $tpl_render = '<div style="display: none">' . $debug . '</div>' . $tpl_render;
     }
     return $tpl_render;
 }
 function render_mrb($style, $template_id, $allow_vote, $votes, $post_id, $set, $height, $header_text, $tags_css, $avg_style, $avg_size, $time_restirctions = "N", $time_remaining = 0, $time_date = "", $button_active = true, $button_text = "Submit", $debug = '', $wait_msg = '')
 {
     $template = GDSRRenderT2::get_template($template_id, "MRB");
     $tpl_render = $template->elm["normal"];
     $tpl_render = html_entity_decode($tpl_render);
     foreach ($tags_css as $tag => $value) {
         $tpl_render = str_replace('%' . $tag . '%', $value, $tpl_render);
     }
     $tpl_render = str_replace("%MUR_HEADER_TEXT%", html_entity_decode($header_text), $tpl_render);
     $rater = '<div id="gdsr_mur_block_' . $post_id . '_' . $set->multi_id . '" class="ratingmulti ' . $tags_css["MUR_CSS_BLOCK"] . '">';
     $empty_value = str_repeat("0X", count($set->object));
     $empty_value = substr($empty_value, 0, strlen($empty_value) - 1);
     if ($debug != '') {
         $rater .= '<div style="display: none">' . $debug . '</div>';
     }
     if ($allow_vote) {
         $rater .= '<input type="hidden" id="gdsr_multi_' . $post_id . '_' . $set->multi_id . '" name="gdsrmulti[' . $post_id . '][' . $set->id . ']" value="' . $empty_value . '" />';
     }
     $i = 0;
     $weighted = 0;
     $total_votes = 0;
     $weight_norm = array_sum($set->weight);
     $rating_stars = "";
     $table_row_class = $template->dep["MRS"]->dep["ETR"];
     foreach ($set->object as $el) {
         $single_row = html_entity_decode($template->dep["MRS"]->elm["item"]);
         $single_row = str_replace('%ELEMENT_NAME%', $el, $single_row);
         $single_row = str_replace('%ELEMENT_ID%', $i, $single_row);
         $single_row = str_replace('%ELEMENT_STARS%', GDSRRender::rating_stars_multi($style, $post_id, $template_id, $set->multi_id, $i, $height, $set->stars, $allow_vote, $votes[$i]["rating"]), $single_row);
         $single_row = str_replace('%TABLE_ROW_CLASS%', is_odd($i) ? $table_row_class->elm["odd"] : $table_row_class->elm["even"], $single_row);
         $rating_stars .= $single_row;
         $weighted += $votes[$i]["rating"] * $set->weight[$i] / $weight_norm;
         $total_votes += $votes[$i]["votes"];
         $i++;
     }
     $rating = @number_format($weighted, 1);
     $total_votes = @number_format($total_votes / $i, 0);
     if (in_array("%MUR_RATING_TEXT%", $template->tag["normal"])) {
         $rating_text = GDSRRenderT2::render_mrt($template->dep["MRT"], $rating, $set->stars, $total_votes, $post_id, $time_restirctions, $time_remaining, $time_date);
         if ($allow_vote) {
             $rating_wait = GDSRRender::rating_wait("gdsr_mur_loader_" . $post_id . "_" . $set->multi_id, "100%", "", $wait_msg);
         }
         $rating_text = $rating_wait . '<div id="gdsr_mur_text_' . $post_id . '_' . $set->multi_id . '">' . $rating_text . '</div>';
         $tpl_render = str_replace("%MUR_RATING_TEXT%", $rating_text, $tpl_render);
     }
     if (in_array("%BUTTON%", $template->tag["normal"])) {
         if ($button_active) {
             $rating_button = '<div class="ratingbutton gdinactive gdsr_multisbutton_as ' . $tags_css["MUR_CSS_BUTTON"] . '" id="gdsr_button_' . $post_id . '_' . $set->multi_id . '_' . $template_id . '"><a rel="nofollow">' . $button_text . '</a></div>';
         } else {
             $rating_button = "";
         }
         $tpl_render = str_replace("%BUTTON%", $rating_button, $tpl_render);
     }
     $tpl_render = str_replace("%MUR_RATING_STARS%", $rating_stars, $tpl_render);
     $tpl_render = str_replace("%AVG_RATING%", $rating, $tpl_render);
     if (in_array("%AVG_RATING_STARS%", $template->tag["normal"])) {
         $avg_id = "gdsr_mur_avgstars_" . $post_id . "_" . $set->multi_id;
         $tpl_render = str_replace("%AVG_RATING_STARS%", GDSRRender::render_static_stars($avg_style, $avg_size, $set->stars, $rating, $avg_id, "DIV"), $tpl_render);
     }
     $rater .= $tpl_render . "</div>";
     return $rater;
 }