TextWidgetController.php #1

  • //
  • guest/
  • perforce_software/
  • chronicle/
  • main/
  • application/
  • widget/
  • controllers/
  • TextWidgetController.php
  • View
  • Commits
  • Open Download .zip Download (2 KB)
<?php
/**
 * A widget that displays arbitrary text in a region.
 * The text can be edited.
 *
 * @copyright   2011 Perforce Software. All rights reserved.
 * @license     Please see LICENSE.txt in top-level folder of this distribution.
 * @version     <release>/<patch>
 */
class Widget_TextWidgetController extends P4Cms_Widget_ControllerAbstract
{
    /**
     * Display the text stored in the widget.
     */
    public function indexAction()
    {
        // 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));
    }

    /**
     * Get config sub-form to present additional options when
     * configuring a widget of this type.
     *
     * @param   P4Cms_Widget            $widget     the widget instance being configured.
     * @return  Zend_Form_SubForm|null  the sub-form to integrate into the default
     *                                  widget config form or null for no sub-form.
     */
    public static function getConfigSubForm($widget)
    {
        // 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;
    }
}
# Change User Description Committed
#1 16170 perforce_software Move Chronicle files to follow new path scheme for branching.
//guest/perforce_software/chronicle/application/widget/controllers/TextWidgetController.php
#1 8972 Matt Attaway Initial add of the Chronicle source code