Perforce Chronicle 2012.2/486814
API Documentation

Widget_ImageWidgetController Class Reference

A widget that displays an arbitrary image in a region. More...

Inheritance diagram for Widget_ImageWidgetController:
P4Cms_Widget_ControllerAbstract

List of all members.

Public Member Functions

 indexAction ()
 Output the widgets html; uses an img tag to call imageAction if configured.

Static Public Member Functions

static getConfigSubForm ($widget)
 Get config sub-form to present additional options when configuring a widget of this type.

Detailed Description

A widget that displays an arbitrary image in a region.

The image can be updated (replaced).

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 Widget_ImageWidgetController::getConfigSubForm ( widget) [static]

Get config sub-form to present additional options when configuring a widget of this type.

Parameters:
P4Cms_Widget$widgetthe widget instance being configured.
Returns:
Zend_Form_SubForm the sub-form to integrate into the default widget config form or null for no sub-form.
    {
        return new Widget_Form_ImageWidget;
    }
Widget_ImageWidgetController::indexAction ( )

Output the widgets html; uses an img tag to call imageAction if configured.

    {
        $widget = $this->_getWidget();

        // if we have an image setting, and it is valid, determine the src.
        $url         = $this->getOption('imageUrl');
        $contentId   = $this->getOption('contentId');
        $imageSource = $this->getOption('imageSource');
        $isLocal     = $imageSource === 'content';
        $isRemote    = $imageSource === 'remote';

        if ($isLocal && $contentId) {
            $imageSrc = $this->getHelper('url')->url(
                array(
                    'module'        => 'content',
                    'controller'    => 'index',
                    'action'        => 'image',
                    'id'            => $contentId,
                    'width'         => $this->getOption('imageWidth'),
                    'height'        => $this->getOption('imageHeight')
                )
            );
        } else if ($isRemote && $url) {
            $filter   = new P4Cms_Filter_Macro(array('widget' => $widget));
            $imageSrc = $filter->filter($url);
        }

        // setup the view.
        $this->view->widget   = $widget;
        $this->view->imageSrc = isset($imageSrc) ? $imageSrc : null;
    }

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