|
Perforce Chronicle 2012.2/486814
API Documentation
|
View helper that renders a widget using a specified template. More...
Public Member Functions | |
| widget ($widget, $template= 'widget.phtml') | |
| Render the given widget using the specified template. | |
View helper that renders a widget using a specified template.
| Widget_View_Helper_Widget::widget | ( | $ | widget, |
| $ | template = 'widget.phtml' |
||
| ) |
Render the given widget using the specified template.
| P4Cms_Widget | $widget | the widget to display. |
| string | $template | optional - 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);
}