1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved. |
---|
6 | * |
---|
7 | * http://www.lockon.co.jp/ |
---|
8 | * |
---|
9 | * This program is free software; you can redistribute it and/or |
---|
10 | * modify it under the terms of the GNU General Public License |
---|
11 | * as published by the Free Software Foundation; either version 2 |
---|
12 | * of the License, or (at your option) any later version. |
---|
13 | * |
---|
14 | * This program is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this program; if not, write to the Free Software |
---|
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
22 | */ |
---|
23 | |
---|
24 | /** |
---|
25 | * セッションの初期化処理を抽象化するファクトリークラス. |
---|
26 | * |
---|
27 | * このクラスはセッションの維持方法を管理するクラスです. |
---|
28 | * 他のセッション管理クラスとは若干異なります. |
---|
29 | * |
---|
30 | * EC-CUBE2.1.1ベータ版から、 |
---|
31 | * 管理画面>基本情報>パラメーター管理で、セッションの維持方法を |
---|
32 | * ・Cookieを使用する場合 |
---|
33 | * ・リクエストパラメーターを使用する場合 |
---|
34 | * の2種類が選択できますが、どちらの設定であっても下記のように呼び出すことで |
---|
35 | * 適切にセッションを開始することができます. |
---|
36 | * |
---|
37 | * $sessionFactory = SC_SessionFactory::getInstance() |
---|
38 | * $sessionFactory->initSession(); |
---|
39 | * |
---|
40 | * @package SC_Session |
---|
41 | * @author LOCKON CO.,LTD. |
---|
42 | * @version $Id$ |
---|
43 | */ |
---|
44 | class SC_SessionFactory |
---|
45 | { |
---|
46 | |
---|
47 | // }}} |
---|
48 | // {{{ functions |
---|
49 | |
---|
50 | /** |
---|
51 | * パラメーター管理で設定したセッション維持設定に従って適切なオブジェクトを返す. |
---|
52 | * |
---|
53 | * @return SC_SessionFactory |
---|
54 | */ |
---|
55 | function getInstance() |
---|
56 | { |
---|
57 | |
---|
58 | $type = defined('SESSION_KEEP_METHOD') |
---|
59 | ? SESSION_KEEP_METHOD |
---|
60 | : ''; |
---|
61 | |
---|
62 | switch ($type) { |
---|
63 | // セッションの維持にリクエストパラメーターを使用する |
---|
64 | case 'useRequest': |
---|
65 | $session = new SC_SessionFactory_UseRequest_Ex; |
---|
66 | SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE |
---|
67 | ? $session->setState('mobile') |
---|
68 | : $session->setState('pc'); |
---|
69 | break; |
---|
70 | |
---|
71 | // クッキーを使用する |
---|
72 | case 'useCookie': |
---|
73 | default: |
---|
74 | // モバイルの場合はSC_SessionFactory_UseRequestを使用する |
---|
75 | if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) { |
---|
76 | $session = new SC_SessionFactory_UseRequest_Ex; |
---|
77 | $session->setState('mobile'); |
---|
78 | } else { |
---|
79 | $session = new SC_SessionFactory_UseCookie_Ex; |
---|
80 | } |
---|
81 | break; |
---|
82 | } |
---|
83 | |
---|
84 | return $session; |
---|
85 | } |
---|
86 | |
---|
87 | /** |
---|
88 | * セッションの初期化を行う. |
---|
89 | * |
---|
90 | */ |
---|
91 | function initSession() |
---|
92 | {} |
---|
93 | |
---|
94 | /** |
---|
95 | * Cookieを使用するかどうかを返す. |
---|
96 | * |
---|
97 | * @return boolean |
---|
98 | */ |
---|
99 | function useCookie() |
---|
100 | {} |
---|
101 | |
---|
102 | } |
---|
103 | /* |
---|
104 | * Local variables: |
---|
105 | * coding: utf-8 |
---|
106 | * End: |
---|
107 | */ |
---|