|
Perforce Chronicle 2012.2/486814
API Documentation
|
A widget that displays an arbitrary image in a region. More...
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. | |
A widget that displays an arbitrary image in a region.
The image can be updated (replaced).
| static Widget_ImageWidgetController::getConfigSubForm | ( | $ | widget | ) | [static] |
Get config sub-form to present additional options when configuring a widget of this type.
| P4Cms_Widget | $widget | the widget instance being configured. |
{
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;
}