.

WidgetVotingResult Class Reference

A widget to print a voting result. More...

Inheritance diagram for WidgetVotingResult:
IWidget IRenderer

List of all members.

Public Member Functions

  __construct ($instance, $params)
  render ($policy=self::NONE)

Static Public Member Functions

static  output ($instance, $params=array())
  Output voting result for given instance.

Public Attributes

  $instance
  $params

Detailed Description

A widget to print a voting result.

Definition at line 5 of file votingresult.widget.php.


Constructor & Destructor Documentation

WidgetVotingResult::__construct ( instance,
params  
)

Definition at line 22 of file votingresult.widget.php.

00022                                                         {
00023                 $this->instance = $instance;
00024                 $this->params = $params;
00025         }

Member Function Documentation

static WidgetVotingResult::output ( instance,
params = array()  
) [static]

Output voting result for given instance.

$params get set on view

Parameters:
IDataObject  $instance
array  $params

Definition at line 17 of file votingresult.widget.php.

00017                                                                     {
00018                 $w = new WidgetVotingResult($instance, $params);
00019                 return $w->render();
00020         }
WidgetVotingResult::render ( policy = self::NONE  ) 

Implements IRenderer.

Definition at line 27 of file votingresult.widget.php.

00027                                                    {
00028                 Load::models('votesaggregates');
00029                 $inst = $this->instance;
00030                 $dao_avg = ($inst instanceof DAOVotesaggregates) ? $inst : VotesAggregates::get_for_instance($inst);
00031                 $avg = ($dao_avg) ? $dao_avg->get_average() : 0;
00032                 $count = ($dao_avg) ? $dao_avg->numtotal : 0;
00033                         
00034                 $view = ViewFactory::create_view(IViewFactory::MESSAGE, 'widgets/votingresult');
00035                 $view->assign('average', $avg);
00036                 $view->assign('count', $count);
00037                 $view->assign('instance', $inst);
00038                 foreach(Arr::force($this->params, false) as $var => $value) {
00039                         $view->assign($var, $value);
00040                 }
00041                 return $view->render();
00042         }

Member Data Documentation

WidgetVotingResult::$instance

Definition at line 6 of file votingresult.widget.php.

WidgetVotingResult::$params

Definition at line 7 of file votingresult.widget.php.


The documentation for this class was generated from the following file: