コード例 #1
0
ファイル: render.php プロジェクト: TheReaCompany/pooplog
 function render_tab($template_id, $rpar = array())
 {
     $rdef = array("post_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" => "", "time_restirctions" => "N", "time_remaining" => 0, "time_date" => "");
     $rpar = wp_parse_args($rpar, $rdef);
     $rpar = apply_filters('gdsr_t2parameters_tab', $rpar);
     extract($rpar, EXTR_SKIP);
     $template = GDSRRenderT2::get_template($template_id, "TAB");
     $tpl_render = $allow_vote ? $template->elm["active"] : $template->elm["inactive"];
     $tpl_render = html_entity_decode($tpl_render);
     $tpl_render = apply_filters('gdsr_t2render_tab_' . ($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("%HEADER_TEXT%", html_entity_decode($header_text), $tpl_render);
     if (in_array("%THUMBS_TEXT%", $allow_vote ? $template->tag["active"] : $template->tag["inactive"])) {
         $rating_text = GDSRRenderT2::render_tat($template->dep["TAT"], array("votes" => $votes, "score" => $score, "votes_plus" => $votes_plus, "votes_minus" => $votes_minus, "id" => $post_id, "time_restirctions" => $time_restirctions, "time_remaining" => $time_remaining, "time_date" => $time_date));
         $rating_text = '<div id="gdsr_thumb_text_' . $post_id . '_a" class="gdt-size-' . $unit_width . ($allow_vote ? "" : " voted") . ' gdthumbtext">' . $rating_text . '</div>';
         $tpl_render = str_replace("%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_a_up" class="gdt-size-%s gdthumb gdup"><a id="gdsrX%sXupXaX%sX%sX%s" class="gdt-%s" rel="nofollow"></a></div>', $post_id, $unit_width, $post_id, $template_id, $unit_width, $wait_msg == '' ? "N" : "Y", $style);
             if ($wait_msg != '') {
                 $rater_wait = GDSRRender::rating_wait(sprintf("gdsr_thumb_%s_a_loader_up", $post_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_a_up" class="gdt-size-%s gdthumb gdup"><div class="gdt-%s"></div></div>', $post_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_a_dw" class="gdt-size-%s gdthumb gddw"><a id="gdsrX%sXdwXaX%sX%sX%s" class="gdt-%s" rel="nofollow"></a></div>', $post_id, $unit_width, $post_id, $template_id, $unit_width, $wait_msg == '' ? "N" : "Y", $style);
             if ($wait_msg != '') {
                 $rater_wait = GDSRRender::rating_wait(sprintf("gdsr_thumb_%s_a_loader_dw", $post_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_a_dw" class="gdt-size-%s gdthumb gddw"><div class="gdt-%s"></div></div>', $post_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;
 }
コード例 #2
0
ファイル: render.php プロジェクト: hewu/blogwp
 function render_tab($template_id, $rpar = array())
 {
     $rdef = array("post_id" => 0, "votes" => 0, "score" => 0, "votes_plus" => 0, "votes_minus" => 0, "style" => "starrating", "unit_width" => 20, "already_voted" => false, "allow_vote" => true, "user_id" => 0, "tags_css" => array(), "header_text" => "", "debug" => "", "wait_msg" => "", "time_restirctions" => "N", "time_remaining" => 0, "time_date" => "");
     $rpar = wp_parse_args($rpar, $rdef);
     $rpar = apply_filters('gdsr_t2parameters_tab', $rpar);
     extract($rpar, EXTR_SKIP);
     $template = GDSRRenderT2::get_template($template_id, "TAB");
     $tpl_render = $allow_vote ? $template->elm["active"] : $template->elm["inactive"];
     $tpl_render = html_entity_decode($tpl_render);
     $tpl_render = apply_filters('gdsr_t2render_tab_' . ($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("%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, "TAB", "%RATING%"), $tpl_render);
     $tpl_render = str_replace('%PERCENTAGE%', apply_filters('gdsr_t2_tag_value', $percent, "TAB", "%PERCENTAGE%"), $tpl_render);
     $tpl_render = str_replace('%VOTES%', apply_filters('gdsr_t2_tag_value', $votes, "TAB", "%VOTES%"), $tpl_render);
     $tpl_render = str_replace('%VOTES_UP%', apply_filters('gdsr_t2_tag_value', $votes_plus, "TAB", "%VOTES_UP%"), $tpl_render);
     $tpl_render = str_replace('%VOTES_DOWN%', apply_filters('gdsr_t2_tag_value', $votes_minus, "TAB", "%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%', $post_id, $tpl_render);
     if (in_array("%THUMBS_TEXT%", $allow_vote ? $template->tag["active"] : $template->tag["inactive"])) {
         $rating_text = GDSRRenderT2::render_tat($template->dep["TAT"], array("score_number" => $score_number, "percent" => $percent, "votes" => $votes, "score" => $score, "votes_plus" => $votes_plus, "votes_minus" => $votes_minus, "id" => $post_id, "time_restirctions" => $time_restirctions, "time_remaining" => $time_remaining, "time_date" => $time_date));
         $rating_text = '<div id="gdsr_thumb_text_' . $post_id . '_a" class="gdt-size-' . $unit_width . ($already_voted ? " voted" : "") . ($allow_vote ? "" : " inactive") . ' gdthumbtext">' . $rating_text . '</div>';
         $tpl_render = str_replace("%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_a_up" class="gdt-size-%s gdthumb gdup"><a id="gdsrX%sXupXaX%sX%sX%s" class="gdt-%s" rel="nofollow"></a></div>', $post_id, $unit_width, $post_id, $template_id, $unit_width, $wait_msg == '' ? "N" : "Y", $style);
             if ($wait_msg != '') {
                 $rater_wait = GDSRRender::rating_wait(sprintf("gdsr_thumb_%s_a_loader_up", $post_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_a_up" class="gdt-size-%s gdthumb gdup"><div class="gdt-%s"></div></div>', $post_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_a_dw" class="gdt-size-%s gdthumb gddw"><a id="gdsrX%sXdwXaX%sX%sX%s" class="gdt-%s" rel="nofollow"></a></div>', $post_id, $unit_width, $post_id, $template_id, $unit_width, $wait_msg == '' ? "N" : "Y", $style);
             if ($wait_msg != '') {
                 $rater_wait = GDSRRender::rating_wait(sprintf("gdsr_thumb_%s_a_loader_dw", $post_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_a_dw" class="gdt-size-%s gdthumb gddw"><div class="gdt-%s"></div></div>', $post_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;
 }