Вот хотел чтобы результаты голосования имели разные цветные бары, в коде так и прописано но почему то не работает, может так же разработчики отключили:
Спойлер (Показать)
code:<?php
defined('_VALID_LM') or die('Direct Access to this location is not allowed.');
function view_polls()
{
global $conn, $pollid, $lm_website, $Itemid;
$tabclass_arr = array("sectiontableentry2", "sectiontableentry1");
$tabcnt = 0;
?>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
if(selObj.options[selObj.selectedIndex].value=='')return;
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
<style type="text/css">
.polls_color_1{ background-color: #8D1B1B; border: 2px ridge #B22222; }
.polls_color_2{ background-color: #6740E1; border: 2px ridge #4169E1; }
.polls_color_3{ background-color: #8D8D8D; border: 2px ridge #D2D2D2; }
.polls_color_4{ background-color: #CC8500; border: 2px ridge #FFA500; }
.polls_color_5{ background-color: #5B781E; border: 2px ridge #6B8E23; }
</style>
<div class="componentheading"><?php echo _POLL_TITLE; ?></div>
<form name="form1">
<table width="100%" border="0" cellpadding="4" cellspacing="0" class="contentpane">
<tr>
<td colspan="2" > </td>
</tr>
<tr>
<td width="20%"><?php echo " " . _SEL_POLL;
?></td>
<td width="80%">
<select name="menu1" onChange="MM_jumpMenu('parent',this,0)" style="WIDTH:200px">
<option value=""><?php echo "Выберите опрос из списка";
?></option>
<?php
$rs = $conn->Execute("SELECT id,title,section,published,ordering FROM #__categories WHERE section='com_polls' AND published=1 ORDER BY ordering ASC");
$rsa = $rs->GetArray();
foreach($rsa as $row) {
echo "<option value='index.php?option=polls&Itemid=$Itemid&pollid=" . $row['id'] . "' ".((isset($pollid) && ($row['id']==$pollid))?"selected":"").">" . $row['title'] . "</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td colspan="2" > </td>
</tr>
<tr>
<td > </td>
<td >
<?php if (isset($pollid)) {
$rs = $conn->Execute("SELECT id,title,name,section,published FROM #__categories WHERE id=$pollid AND published=1 ");
$rsa = $rs->GetArray();
$rsar = $rsa[0];
if ($rs && $rs->RecordCount() > 0) {
$rs1 = $conn->Execute("SELECT id,polloption,hits FROM #__polls_data WHERE pollid=$pollid ORDER BY id ASC");
$poll_data = $rs1->GetArray();
$sumval = 0;
foreach($poll_data as $row) {
$sumval += $row['hits'];
}
?>
<table class='pollstableborder' cellspacing="0" cellpadding="0" border="0">
<tr>
<td colspan="2" class="sectiontableheader"> <b> <?php echo $rsar['title']; ?> </b></td>
</tr>
<?php
$maxval = 0;
if ($maxval < $sumval) {
$maxval = $sumval;
}
$polls_graphwidth = 200;
$polls_barheight = 2;
$polls_maxcolors = 5;
$polls_barcolor = 0;
for ($i = 0, $n = count($poll_data); $i < $n; $i++) {
$text = $poll_data[$i]["polloption"];
$hits = $poll_data[$i]["hits"];
if ($maxval > 0 && $sumval > 0) {
$width = ceil($hits * $polls_graphwidth / $maxval);
$percent = round(100 * $hits / $sumval, 1);
} else {
$width = 0;
$percent = 0;
}
?>
<tr class="<?php echo $tabclass_arr[$tabcnt];
?>">
<td width='100%' colspan='2'><?php echo $text;
?></td>
</tr>
<tr class="<?php echo $tabclass_arr[$tabcnt];
?>">
<td> <table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr class='<?php echo $tabclass_arr[$tabcnt];
?>'>
<td align="right" width="25"> <b><?php echo $hits;
?></b> </td>
<td align="left" width="2"> </td>
<td width="30" align="left"> <?php echo $percent;
?>% </td>
<?php
$tdclass = '';
$colorx = 0;
if ($polls_barcolor == 0) {
if ($colorx < $polls_maxcolors) {
$colorx = ++$colorx;
} else {
$colorx = 1;
}
$tdclass = "polls_color_" . $colorx;
} else {
$tdclass = "polls_color_" . $polls_barcolor;
}
?>
<td width="300" align="left">
<div align="left"> <img src='<?php echo $lm_website;
?>/images/common/spacer.gif' class='<?php echo $tdclass;
?>' height='<?php echo $polls_barheight;
?>' width='<?php echo $width;
?>'>
</div></td>
</tr>
</table></td>
</tr>
<?php
$tabcnt = 1 - $tabcnt;
}
?>
</table>
<br>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td class='smalldark'> <?php echo _NUM_VOTERS;
?> </td>
<td class='smalldark'> : <?php echo $sumval;
?> </td>
</tr>
</table>
<p>
<?php }
}
?>
</p>
</td>
</tr>
</table>
<p> </p>
</form>
<?php
}
?>
Стили прописаны:
code:</script>
<style type="text/css">
.polls_color_1{ background-color: #8D1B1B; border: 2px ridge #B22222; }
.polls_color_2{ background-color: #6740E1; border: 2px ridge #4169E1; }
.polls_color_3{ background-color: #8D8D8D; border: 2px ridge #D2D2D2; }
.polls_color_4{ background-color: #CC8500; border: 2px ridge #FFA500; }
.polls_color_5{ background-color: #5B781E; border: 2px ridge #6B8E23; }
</style>
Случайно не это??
code:<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
if(selObj.options[selObj.selectedIndex].value=='')return;
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//--> (Отредактировано автором: 10 мая 2013 — 19:41) |