|
Perforce Chronicle 2012.2/486814
API Documentation
|
A widget that displays a youtube video. More...
Public Member Functions | |
| indexAction () | |
| Provides information needed for initial render of the widget. | |
Static Public Member Functions | |
| static | getConfigSubForm ($widget) |
| Get a widget config sub-form to present additional options to the user when configuring a widget instance. | |
A widget that displays a youtube video.
| static Youtube_VideoController::getConfigSubForm | ( | $ | widget | ) | [static] |
Get a widget config sub-form to present additional options to the user when configuring a widget instance.
| P4Cms_Widget | $widget | the widget model instance being configured. |
{
return new Youtube_Form_VideoWidget;
}
| Youtube_VideoController::indexAction | ( | ) |
Provides information needed for initial render of the widget.
Parses configuration options and passes them to the view.
{
$view = $this->view;
try {
$query = Zend_Uri::factory($this->getOption('videoUrl'))->getQueryAsArray();
$view->videoId = $query['v'];
}
catch (Zend_Uri_Exception $e) {
// empty or invalid uri, handled by view script
}
$view->autoplay = $this->getOption('autoplay');
$view->showRelated = $this->getOption('showRelated');
$view->loop = $this->getOption('loop');
$view->playHd = $this->getOption('playHd');
// valid options are 1 and 3 per youtube player embed code documentation
// http://code.google.com/apis/youtube/player_parameters.html#iv_load_policy
$view->showAnnotations = ($this->getOption('showAnnotations')) ? 1 : 3;
// autohide and full screen have a dependency on control visibility - if
// no controls are shown at all, there's no point to hiding them or showing/hiding
// the fullscreen control
$controls = $this->getOption('controls');
if ($controls == Youtube_Form_VideoWidget::CONTROLS_NEVER_SHOW) {
$view->controls = 0;
} else {
$view->allowFullscreen = $this->getOption('allowFullscreen');
$view->autohide = $controls;
$view->controls = 1;
}
// if not set, the inherent default values are used by the player
// if a custom size is set, use it, otherwise use the specified size
$size = $this->getOption('videoSize');
$view->size = $size;
if ($size == Youtube_Form_VideoWidget::DIMENSION_CUSTOM) {
$view->videoHeight = $this->getOption('videoHeight');
$view->videoWidth = $this->getOption('videoWidth');
} else if (Youtube_Form_VideoWidget::hasDimension($size)) {
$view->videoHeight = Youtube_Form_VideoWidget::getHeight($size);
$view->videoWidth = Youtube_Form_VideoWidget::getWidth($size);
}
}