Perforce Chronicle 2012.2/486814
API Documentation

P4Cms_Widget_ControllerAbstract Class Reference

Enhances Zend_Controller_Action to provide additional functionality that is specific to widget controllers. More...

Inheritance diagram for P4Cms_Widget_ControllerAbstract:
Category_AssociatedCategoriesWidgetController Content_ListWidgetController Flickr_StreamController Menu_WidgetController Search_WidgetController Widget_IframeWidgetController Widget_ImageWidgetController Widget_TextWidgetController Youtube_VideoController

List of all members.

Public Member Functions

 getOption ($option, $default=null)
 Get a saved option for this widget instance.
 getOptions ()
 Get all saved options for this widget instance.
 init ()
 Prepare the widget view with context data.

Static Public Member Functions

static getConfigSubForm ($widget, $request)
 Get config sub-form to present additional options when configuring a widget of this type.
static saveConfigForm ($form, $widget)
 Updates the widget model with the passed configuration form values and writes out the new settings to storage.

Protected Member Functions

 _getWidget ()
 Get the widget model associated with this widget controller instance.

Detailed Description

Enhances Zend_Controller_Action to provide additional functionality that is specific to widget controllers.

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

P4Cms_Widget_ControllerAbstract::_getWidget ( ) [protected]

Get the widget model associated with this widget controller instance.

Returns:
P4Cms_Widget the associated widget model.
    {
        // the associated widget model is passed in via
        // the request parameters - it could be a widget
        // model instance, or string id in the latter case
        $request = $this->getRequest();
        $widget  = $request->getParam('widget');
        if (!$widget instanceof P4Cms_Widget) {
            $widget = P4Cms_Widget::fetch($widget);
        }

        return $widget;
    }
static P4Cms_Widget_ControllerAbstract::getConfigSubForm ( widget,
request 
) [static]

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

The config form will then be integrated into the default widget config form to present additional options to the user when configuring the widget. The saved form values be passed as additional request parameters to actions on the widget controller.

Parameters:
P4Cms_Widget$widgetthe widget instance being configured.
Zend_Controller_Request_Abstract$requestthe request values.
Returns:
Zend_Form_SubForm|null the sub-form to integrate into the default widget config form or null for no sub-form.

Reimplemented in Menu_WidgetController.

    {
        return null;
    }
P4Cms_Widget_ControllerAbstract::getOption ( option,
default = null 
)

Get a saved option for this widget instance.

Parameters:
string$optionthe name of the option to get.
mixed$defaultoptional - a default value to return if no value is set.
Returns:
mixed the value of the named option.
    {
        return $this->_getWidget()->getConfig($option, $default);
    }
P4Cms_Widget_ControllerAbstract::getOptions ( )

Get all saved options for this widget instance.

Returns:
array all of the saved options.
    {
        return $this->_getWidget()->getConfig();
    }
P4Cms_Widget_ControllerAbstract::init ( )

Prepare the widget view with context data.

    {
        parent::init();

        // handle any provided widgetContext
        $this->widgetContext->setEncodedValues(
            $this->getRequest()->getParam('widgetContext')
        );

        // make the widget context available to the view
        $this->view->widgetContext = $this->widgetContext->getEncodedValues();
    }
static P4Cms_Widget_ControllerAbstract::saveConfigForm ( form,
widget 
) [static]

Updates the widget model with the passed configuration form values and writes out the new settings to storage.

Parameters:
Zend_Form$formform with new config values
P4Cms_Widget$widgetwidget to save
    {
        $widget->setValues($form->getValues())->save();

        // clear any cached entries related to this widget
        P4Cms_Cache::clean(
            Zend_Cache::CLEANING_MODE_MATCHING_TAG,
            'p4cms_widget_' . bin2hex($widget->getId())
        );
    }

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