Perforce Chronicle 2012.2/486814
API Documentation

Ui_View_Helper_Notifications Class Reference

View helper that renders the notification area. More...

List of all members.

Public Member Functions

 notifications ($severity=null)
 Render the notifications dijit.

Detailed Description

View helper that renders the notification area.

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

Ui_View_Helper_Notifications::notifications ( severity = null)

Render the notifications dijit.

Parameters:
string$severityThe severity of notifications to render. null means render all available notifications.
    {
        $html = "<div id=\"p4cms-ui-notices\">\n";
        $notifications = array();
        if (P4Cms_Notifications::exist()) {
            // Cancel page caching as a notification will be present
            if (P4Cms_Cache::canCache('page')) {
                P4Cms_Cache::getCache('page')->cancel();
            }

            $notifications = P4Cms_Notifications::fetch(null);
        }
        $severityList = array();
        if (isset($severity) and array_key_exists($severity, $notifications)) {
            $severityList[] = $severity;
        } else {
            $keys = array_keys($notifications);
            sort($keys);
            $severityList = array_unique(
                array_merge(array('error', 'warn', 'info'), $keys)
            );
        }

        foreach ($severityList as $aSeverity) {
            if (!array_key_exists($aSeverity, $notifications)) {
                continue;
            }
            foreach ($notifications[$aSeverity] as $message) {
                $escapedMessage = htmlspecialchars($message);
                $span = ($aSeverity == 'error') ? '' : '<span class="close">&times;</span>';
                $html .= <<<EOM
<div class="severity-$aSeverity" dojoType="p4cms.ui.Notice"
    message="$escapedMessage" severity="$aSeverity"
>
    <span class="message">$span$escapedMessage</span>
</div>
EOM;
            }
        }
        $html .= "</div>\n";

        return $html;
    }

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