OSDN Git Service

- followed ini file name changes.
[ethna/ethna.git] / class / View / Ethna_View_Json.php
1 <?php
2 // vim: foldmethod=marker
3 /**
4  *  Ethna_View_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$
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 class Ethna_View_Json extends Ethna_ViewClass
21 {
22     /**#@+
23      *  @access private
24      */
25
26     /**#@-*/
27
28     /**
29      *  Jsonを出力する
30      *
31      *  @access public
32      *  @param  array  $encode_param  出力するJSONにエンコードする値
33      */
34     function preforward($encode_param = array())
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         $this->header(array('Content-Type' => 'application/json; charset=UTF-8'));
43         echo $encoded_param;
44     }
45
46     function forward()
47     {
48         // do nothing.
49     }
50 }
51 // }}}