Perforce Chronicle 2012.2/486814
API Documentation

Menu_WidgetController Class Reference

Provides a menu widget for use in regions. More...

Inheritance diagram for Menu_WidgetController:
P4Cms_Widget_ControllerAbstract

List of all members.

Public Member Functions

 indexAction ()
 Display the menu.

Static Public Member Functions

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

Detailed Description

Provides a menu widget for use in regions.

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

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

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 from P4Cms_Widget_ControllerAbstract.

    {
        $form = new Menu_Form_Widget;

        $config    = $request->getParam('config');
        $menuId    = isset($config['menu']) ? $config['menu'] : $widget->getConfig('menu');
        
        // if the menu we are dealing with is a dynamic entry
        // allow the dynamic handler a chance to adjust the form.
        $handlerId = P4Cms_Menu::isDynamicHandlerId($menuId);
        if ($handlerId && P4Cms_Navigation_DynamicHandler::exists($handlerId)) {
            $handler = P4Cms_Navigation_DynamicHandler::fetch($handlerId);
            $form    = $handler->prepareForm($form);
        }
        
        return $form;
    }
Menu_WidgetController::indexAction ( )

Display the menu.

    {
        // make the options available to the view.
        $options = $this->getOptions()->toArray();
        $this->view->widgetOptions = $options;

        // try to fetch menu items for the view.
        try {
            $menu = P4Cms_Menu::fetchMenuOrHandlerAsMenu($this->getOption('menu'));

            // tag the page cache so it can be appropriately cleared later
            if (P4Cms_Cache::canCache('page')) {
                P4Cms_Cache::getCache('page')
                    ->addTag('p4cms_menu')
                    ->addTag('p4cms_menu_' . bin2hex($menu->getId()));
            }

            $this->view->menu      = $menu;
            $this->view->menuItems = $menu->getExpandedContainer($options);
        } catch (Exception $e) {
            // menu id appears invalid - no valid menu to display.
        }
    }

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