Perforce Chronicle 2012.2/486814
API Documentation

Widget_View_Helper_Widget Class Reference

View helper that renders a widget using a specified template. More...

List of all members.

Public Member Functions

 widget ($widget, $template= 'widget.phtml')
 Render the given widget using the specified template.

Detailed Description

View helper that renders a widget using a specified template.

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

Widget_View_Helper_Widget::widget ( widget,
template = 'widget.phtml' 
)

Render the given widget using the specified template.

Parameters:
P4Cms_Widget$widgetthe widget to display.
string$templateoptional - the view script to render to.
    {
        $view         = $this->view;
        $view->widget = $widget;

        // get resource and privilege of the widget type if they have been set.
        try {
            $resource  = $widget->getType()->getValue('resource');
            $privilege = $widget->getType()->getValue('privilege');
        } catch (Exception $e) {
            $resource = null;
        }

        // don't render widget if user is not allowed to see it.
        if ($resource && P4Cms_User::hasActive()) {
            $user = P4Cms_User::fetchActive();
            if (!$user->isAllowed($resource, $privilege)) {
                return null;
            }
        }

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

        return $view->render($template);
    }

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