コード例 #1
0
ファイル: download_shortcodes.php プロジェクト: notzen/e107
 function sc_download_view_rating()
 {
     global $dlrow;
     $frm = e107::getForm();
     $options = array('label' => ' ', 'template' => 'RATE|VOTES|STATUS');
     return $frm->rate("download", $dlrow['download_id'], $options);
     require_once e_HANDLER . "rate_class.php";
     $rater = new rater();
     $text = "\n      \t\t<table style='width:100%'>\n      \t\t<tr>\n      \t\t<td style='width:50%'>";
     if ($ratearray = $rater->getrating("download", $dlrow['download_id'])) {
         for ($c = 1; $c <= $ratearray[1]; $c++) {
             $text .= "<img src='" . e_IMAGE . "rate/star.png' alt='*' />";
         }
         if ($ratearray[2]) {
             $text .= "<img src='" . e_IMAGE . "rate/" . $ratearray[2] . ".png'  alt='*' />";
         }
         if ($ratearray[2] == "") {
             $ratearray[2] = 0;
         }
         $text .= "&nbsp;" . $ratearray[1] . "." . $ratearray[2] . " - " . $ratearray[0] . "&nbsp;";
         $text .= $ratearray[0] == 1 ? LAN_dl_43 : LAN_dl_44;
     } else {
         $text .= LAN_dl_13;
     }
     $text .= "</td><td style='width:50%; text-align:right'>";
     if (!$rater->checkrated("download", $dlrow['download_id']) && USER) {
         $text .= $rater->rateselect("&nbsp;&nbsp;&nbsp;&nbsp; <b>" . LAN_dl_14, "download", $dlrow['download_id']) . "</b>";
     } else {
         if (!USER) {
             $text .= "&nbsp;";
         } else {
             $text .= LAN_dl_15;
         }
     }
     $text .= "</td></tr></table>";
     return $text;
 }
コード例 #2
0
ファイル: main.php プロジェクト: testt98/ebattles
/**
* Add ratings to a plugins
* <p>This method returns the HTML for a ratings form. In addition, it will post ratings to the e107v7
* ratings database and get any existing ratings for the current item.</p>
* @param   string   a unique ID for this plugin, maximum of 10 character
* @param   int      id of the item comments are allowed for
* @param   boolean  true to show the rating selection drop down if user not already rated this item
* @return  string   HTML for existing comments for an item and the comments form to allow new comments to be posted
*/
function ebGetRating($pluginid, $id, $allowrating = true, $notext = false, $userid = false)
{
    $rater = new rater();
    $text = "";
    $ratearray = $rater->GetRating($pluginid, $id, $userid);
    if ($ratearray) {
        if ($ratearray[0] == 0) {
            if ($ratearray[1] > 0) {
                for ($c = 1; $c <= $ratearray[1]; $c++) {
                    $text .= "<img src='" . e_IMAGE . "rate/" . IMODE . "/star.png' alt='' />";
                }
                $text .= "&nbsp;" . $ratearray[1];
            } else {
                $text .= EB_RATELAN_4;
            }
        } else {
            for ($c = 1; $c <= $ratearray[1]; $c++) {
                $text .= "<img src='" . e_IMAGE . "rate/" . IMODE . "/star.png' alt='' />";
            }
            if ($ratearray[2]) {
                $text .= "<img src='" . e_IMAGE . "rate/" . IMODE . "/" . $ratearray[2] . ".png'  alt='' />";
            }
            if ($ratearray[2] == "") {
                $ratearray[2] = 0;
            }
            $text .= "&nbsp;" . $ratearray[1] . "." . $ratearray[2];
            if (!$notext) {
                $text .= " - " . $ratearray[0] . "&nbsp;" . ($ratearray[0] == 1 ? EB_RATELAN_0 : EB_RATELAN_1);
            }
        }
    } else {
        $text .= EB_RATELAN_4;
    }
    if ($allowrating) {
        if (!$rater->checkrated($pluginid, $id) && USER) {
            $ratetext = $rater->rateselect("&nbsp;&nbsp;&nbsp;&nbsp;<b>" . EB_RATELAN_2, $pluginid, $id) . "</b>";
            $ratetext = str_replace("../../rate.php", e_PLUGIN . "ebattles/rate.php", $ratetext);
            if ($userid) {
                $text = $ratetext;
            } else {
                $text .= $ratetext;
            }
        } else {
            if (!USER) {
                $text .= "&nbsp;";
            } else {
                //$text .= "&nbsp;-&nbsp;".EB_RATELAN_3;
            }
        }
    }
    return $text;
}