Perforce Chronicle 2012.2/486814
API Documentation

Widget_TextWidgetController Class Reference

A widget that displays arbitrary text in a region. More...

Inheritance diagram for Widget_TextWidgetController:
P4Cms_Widget_ControllerAbstract

List of all members.

Public Member Functions

 indexAction ()
 Display the text stored in the widget.

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 arbitrary text in a region.

The text can be edited.

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_TextWidgetController::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|null the sub-form to integrate into the default widget config form or null for no sub-form.
    {
        // if we are configured to solidify macros expand macros the first
        // time the widget is configured and clear the solidify flag.
        if ($widget->getConfig('solidifyMacros')) {
            $filter = new P4Cms_Filter_Macro(array('widget' => $widget));
            $text   = $filter->filter($widget->getConfig('text'));
            $widget->getConfig()->text = $text;
            $widget->getConfig()->solidifyMacros = false;
        }

        // de-branchify urls so that they do not get edited
        // or stored with a branch specific base url.
        $filter = new P4Cms_Filter_DebranchifyUrls;
        $text   = $filter->filter($widget->getConfig('text'));
        $widget->getConfig()->text = $text;

        return new Widget_Form_TextWidget;
    }
Widget_TextWidgetController::indexAction ( )

Display the text stored in the widget.

    {
        // disable autorendering for this action.
        $this->_helper->viewRenderer->setNoRender();

        // apply macro expansion so users can embed macros
        // branchify urls so they point to the active branch
        $text      = $this->getOption('text');
        $macro     = new P4Cms_Filter_Macro(array('widget' => $this->_getWidget()));
        $branchify = new P4Cms_Filter_BranchifyUrls;

        print $branchify->filter($macro->filter($text));
    }

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