HTML and CSS Reference
In-Depth Information
if (!$this->is_active) {
$view->questions_class = 'closed';
}
$view->controls = $this->output_presenter_controls();
$view->questions = $this->output_questions();
$view->render();
}
}
In addition to the standard constructor stuff—calling the parent constructor, setting the model, and ensuring
that valid options were supplied—the Room constructor also sets some room-specific properties.
The $room property will hold basic information about the room, which is returned from the get_room_data()
method as an object. The model will be set up to retrieve this data later in this chapter.
To handle the differences in the room markup for presenters versus attendees, $is_presenter holds a Boolean
value that is determined by the is_presenter() method, which will be written shortly.
Finally, the $is_active property acts as a shortcut to the active state of the room. Because it is stored in the
database as a 1 or 0 , it is cast as a Boolean to allow for strict Boolean comparisons within the controller's methods.
The get_title() method uses the room's and presenter's names to generate a meaningful title for the room.
In output_view() , the room view is loaded, and a handful of variables are set, which will be gone over a bit later
in this chapter.
Determining Whether the User Is the Presenter
Because different markup is shown to the presenter than to the attendees, the app needs a method to determine
whether the user is the presenter for the current room. This will be stored as a cookie.
Add the following bold code to the Room controller:
$view->controls = $this->output_presenter_controls();
$view->questions = $this->output_questions();
$view->render();
}
/**
* Determines whether or not the current user is the presenter
*
* @return boolean TRUE if it's the presenter, otherwise FALSE
*/
protected function is_presenter( )
{
$cookie = 'presenter_room_' . $this->room->room_id;
return (isset($_COOKIE[$cookie]) && $_COOKIE[$cookie]==1);
}
}
This method figures out the cookie name using the current room's ID and then returns TRUE if the cookie is both
set and equal to 1 .
 
Search WWH ::




Custom Search