Changeset 620 for trunk/app/views/elements
- Timestamp:
- 07/02/08 18:44:15 (5 months ago)
- Files:
-
- 1 modified
-
trunk/app/views/elements/poll.ctp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/views/elements/poll.ctp
r458 r620 10 10 $poll = $session->read('poll'); 11 11 12 if ( $poll != null && $Element["Poll"]['Poll']['id'] == $poll) // the user has already voted, show poll results13 {12 if ( $poll != null && $Element["Poll"]['Poll']['id'] == $poll): // the user has already voted, show poll results 13 14 14 $total_votes = 0; 15 15 16 foreach ($Element["Poll"]["Pollrow"] as $key => $val) 17 { 18 $total_votes += $val["vote"]; // the total votes 19 } 16 foreach ($Element["Poll"]["Pollrow"] as $key => $val): 17 $total_votes += $val["vote"]; // the total votes 18 endforeach; 20 19 21 echo "<p><b>" . $Element["Poll"]['Poll']['question'] ."</b></p>";20 echo $html->para('negrita', $Element['Poll']['Poll']['question']); 22 21 23 foreach ($Element["Poll"]["Pollrow"] as $key => $val) 24 { 25 if ($val["vote"] > 0) 26 { 27 $percent = ($val["vote"] * 100) / $total_votes; // % = votes * 100 / total 28 } 29 else 30 { 22 foreach ($Element['Poll']['Pollrow'] as $val): 23 if ($val['vote'] > 0): 24 $percent = ($val['vote'] * 100) / $total_votes; // % = votes * 100 / total 25 else: 31 26 $percent = 0; 32 } 27 endif; 33 28 $width = number_format($percent, 0); 34 29 echo '<p><b>'.$val['answer'].'</b> '.number_format($percent, 2).'% <br />'; 35 30 echo $html->image('static/poll/'.$val["color"].'.png', array("height"=>"10", "width"=>$width, "alt"=>$val["answer"], "title"=>$val["answer"]) ); 36 31 echo " ". $val['vote']; 37 }32 endforeach; 38 33 39 echo '<p class="negrita">Total votes:' . $total_votes . '</p>';40 }41 else // the user has no voted, print the form42 { 34 echo $html->para('negrita', __('Total votes', true).':' . $total_votes); 35 36 else: // the user has no voted, print the form 37 43 38 echo $ajax->form(); 44 39 45 40 $array = array(); 46 41 47 echo "<p><b>" . $Element["Poll"]['Poll']['question'] ."</b></p>";42 echo $html->para('negrita', $Element['Poll']['Poll']['question']); 48 43 49 echo $form->hidden('Pollrow.poll_id', array( "value"=>$Element["Poll"]['Poll']['id'])); // Poll_id44 echo $form->hidden('Pollrow.poll_id', array('value'=>$Element['Poll']['Poll']['id'])); // Poll_id 50 45 51 foreach ($Element["Poll"]['Pollrow'] as $key=>$val) 52 { 53 $array[$val['id']] = $val['answer']; // construct id->value array 54 } 46 foreach ($Element['Poll']['Pollrow'] as $val): 47 $array[$val['id']] = $val['answer']; // construct id->value array 48 endforeach; 55 49 56 50 echo '<span style="font-size:7pt">'; … … 64 58 )); 65 59 echo '</span></form>'; 66 } 67 60 endif; 68 61 ?> 69 62 </div>
