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