• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List

E:/E/GEAMP/www/openbiz/openbiz/others/Zend/View/Helper/Json.php

00001 <?php
00024 require_once 'Zend/Json.php';
00025 
00027 require_once 'Zend/Controller/Front.php';
00028 
00030 require_once 'Zend/View/Helper/Abstract.php';
00031 
00040 class Zend_View_Helper_Json extends Zend_View_Helper_Abstract
00041 {
00055     public function json($data, $keepLayouts = false)
00056     {
00057         $options = array();
00058         if (is_array($keepLayouts))
00059         {
00060             $options     = $keepLayouts;
00061             $keepLayouts = (array_key_exists('keepLayouts', $keepLayouts))
00062                             ? $keepLayouts['keepLayouts']
00063                             : false;
00064             unset($options['keepLayouts']);
00065         }
00066 
00067         $data = Zend_Json::encode($data, null, $options);
00068         if (!$keepLayouts) {
00069             require_once 'Zend/Layout.php';
00070             $layout = Zend_Layout::getMvcInstance();
00071             if ($layout instanceof Zend_Layout) {
00072                 $layout->disableLayout();
00073             }
00074         }
00075 
00076         $response = Zend_Controller_Front::getInstance()->getResponse();
00077         $response->setHeader('Content-Type', 'application/json');
00078         return $data;
00079     }
00080 }

Generated on Thu Apr 19 2012 17:01:17 for openbiz by  doxygen 1.7.2