123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- <?php
- if (!defined('STATUSNET')) {
-
-
- exit(1);
- }
- class PollResultForm extends Form
- {
- protected $poll;
-
- public function __construct(Poll $poll, HTMLOutputter $out)
- {
- parent::__construct($out);
- $this->poll = $poll;
- }
-
- public function id()
- {
- return 'pollresult-form';
- }
-
- public function formClass()
- {
- return 'form_settings ajax';
- }
-
- public function action()
- {
- return common_local_url('respondpoll', array('id' => $this->poll->id));
- }
-
- public function formData()
- {
- $poll = $this->poll;
- $out = $this->out;
- $counts = $poll->countResponses();
- $width = 200;
- $max = max($counts);
- if ($max == 0) {
- $max = 1;
- }
- $out->element('p', 'poll-question', $poll->question);
- $out->elementStart('table', 'poll-results');
- foreach ($poll->getOptions() as $i => $opt) {
- $w = intval($counts[$i] * $width / $max) + 1;
- $out->elementStart('tr');
- $out->elementStart('td');
- $out->text($opt);
- $out->elementEnd('td');
- $out->elementStart('td');
- $out->element(
- 'span',
- array('class' => 'poll-block',
- 'style' => "width: {$w}px"),
- "\xc2\xa0"
- );
- $out->text($counts[$i]);
- $out->elementEnd('td');
- $out->elementEnd('tr');
- }
- $out->elementEnd('table');
- }
-
- public function formActions()
- {
- }
- }
|