Perforce Chronicle 2012.2/486814
API Documentation

P4Cms_View_Helper_DojoIoResponse Class Reference

View helper that returns an instance of the named enabled module model. More...

List of all members.

Public Member Functions

 dojoIoResponse ($data, $handleAs= 'json')
 Create response text for dojo.io.iframe request.

Detailed Description

View helper that returns an instance of the named enabled module model.

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

P4Cms_View_Helper_DojoIoResponse::dojoIoResponse ( data,
handleAs = 'json' 
)

Create response text for dojo.io.iframe request.

Parameters:
mixed$datadata to send to dojo.io.iframe
string$handleAsEncoding method one of: text, html, xml, json, javascript NOTE: Presently xml is not supported.
Returns:
string|void
    {
        $formats = array('json', 'html', 'text', 'javascript');
        if (!in_array($handleAs, $formats)) {
            throw new InvalidArgumentException(
                'Invalid handleAs format. Expected one of: ' . implode(', ', $formats)
            );
        }

        // automatically encode as json.
        if ($handleAs == 'json') {
            $data = Zend_Json::encode($data);
        }

        return '<html><head>'
             . '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'
             . '</head><body><textarea>'
             . $this->view->escape($data)
             . '</textarea></body></html>';
    }

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