Perforce Chronicle 2012.2/486814
API Documentation

Youtube_VideoController Class Reference

A widget that displays a youtube video. More...

Inheritance diagram for Youtube_VideoController:
P4Cms_Widget_ControllerAbstract

List of all members.

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.

Detailed Description

A widget that displays a youtube video.

Copyright:
2011-2012 Perforce Software. All rights reserved
License:
Please see LICENSE.txt in top-level folder of this distribution.
Version:
2012.2/486814

Member Function Documentation

static Youtube_VideoController::getConfigSubForm ( widget) [static]

Get a widget config sub-form to present additional options to the user when configuring a widget instance.

Parameters:
P4Cms_Widget$widgetthe widget model instance being configured.
Returns:
Widget_Form_SubConfig the sub-form to integrate into the default widget config form.
    {
        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);
        }
    }

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