source: branches/camp/camp-2_5-E/data/class/SC_Display.php @ 19040

Revision 19040, 1.9 KB checked in by miningbrownie, 16 years ago (diff)
Line 
1<?php
2class SC_Display{
3
4    var $response;
5
6    var $device;
7
8    var $autoSet;
9   
10    /**
11     *
12     */
13    var $view;
14
15    // TODO php4を捨てたときに ここのコメントアウトを外してね。
16    /*
17    * const('MOBILE',1);
18    * const('SMARTPHONE',2);
19    * const('PC',4);
20    */
21
22    function SC_Display($autoGenerateHttpHeaders = true){
23        require_once(CLASS_EX_PATH."/SC_Response_Ex.php");
24        $this->response = new SC_Response_Ex();
25        $this->autoSet = $autoGenerateHttpHeaders;
26    }
27
28
29    // TODO このメソッドは、レスポンスを返すためのメソッドです。名前を絶対に変えましょう。
30    /**
31    *
32    * @param $page LC_Page
33    */
34    function hoge(LC_Page $page){
35        $this->assign($page);
36
37    }
38
39    /**
40     * デバイス毎の出力方法を自動で変更する、ファサード
41     * Enter description here ...
42     */
43    function setDevice(int $device = 4){
44        switch ($device){
45            case 1:
46                $this->response->setContentType("text/html");
47               
48                break;
49            case 2:
50
51                break;
52            case 4:
53               
54                break;
55        }
56    }
57
58    /**
59     * 機種を判別する。
60     * SC_Display::MOBILE = ガラケー = 1
61     * SC_Display::SMARTPHONE = スマホ = 2
62     * SC_Display::PC = PC = 4
63     * ※PHP4の為にconstは使っていません。 1がガラケーで、2がスマホで4がPCです。
64     * @return
65     */
66    function detectDevice(){
67        $nu = new Net_UserAgent_Mobile();
68        $retDevice = 0;
69        if($nu->isMobile()){
70            $retDevice = 1;
71        }elseif ($nu->isSmartphone()){
72            $retDevice = 2;
73        }else{
74            $retDevice = 4;
75        }
76
77        if($this->autoSet){
78            $this->setDevice($retDevice);
79        }
80        return $retDevice;
81    }
82
83    function assign(LC_Page $page){
84     
85    }
86
87
88}
Note: See TracBrowser for help on using the repository browser.