Source for file Json.php

Documentation is available at Json.php

  1. <?php
  2. // vim: foldmethod=marker
  3. /**
  4.  *  Json.php
  5.  *
  6.  *  @author     Yoshinari Takaoka <takaoka@beatcraft.com>
  7.  *  @license    http://www.opensource.org/licenses/bsd-license.php The BSD License
  8.  *  @package    Ethna
  9.  *  @version    $Id: 6270c08c38dfe406dd028fcd5b38979f9f3d4509 $
  10.  */
  11.  
  12. // {{{ Ethna_View_Json
  13. /**
  14.  *  JSON を出力するビューの実装
  15.  *
  16.  *  @author     Yoshinari Takaoka <takaoka@beatcraft.com>
  17.  *  @access     public
  18.  *  @package    Ethna
  19.  */
  20. {
  21.     /**#@+
  22.      *  @access private
  23.      */
  24.     public $has_default_header = false;
  25.  
  26.     /**#@-*/
  27.  
  28.     /**
  29.      *  Jsonを出力する
  30.      *
  31.      *  @access public
  32.      *  @param  array  $encode_param  出力するJSONにエンコードする値
  33.      */
  34.     public function preforward($encode_param array()$header false)
  35.     {
  36.         $client_enc $this->ctl->getClientEncoding();
  37.         if (mb_enabled(&& strcasecmp('UTF-8'$client_enc!= 0{
  38.             mb_convert_variables('UTF-8'$client_enc$encode_param);
  39.         }
  40.         $encoded_param json_encode($encode_param);
  41.  
  42.         if (!$header{
  43.             $this->header(array('Content-Type' => 'application/json; charset=UTF-8'));
  44.         else {
  45.             $this->header($header);
  46.         }
  47.         echo $encoded_param;
  48.     }
  49.  
  50.     public function forward()
  51.     {
  52.         // do nothing.
  53.     }
  54. }
  55. // }}}

Documentation generated on Fri, 11 Nov 2011 03:58:27 +0900 by phpDocumentor 1.4.3