OSDN Git Service

89c249cd53e4cdd38d657ac3a79c3e327561c055
[magic3/magic3.git] / widgets / m / contactus / include / container / admin_m_contactusWidgetContainer.php
1 <?php
2 /**
3  * コンテナクラス
4  *
5  * PHP versions 5
6  *
7  * LICENSE: This source file is licensed under the terms of the GNU General Public License.
8  *
9  * @package    Magic3 Framework
10  * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
11  * @copyright  Copyright 2006-2008 Magic3 Project.
12  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
13  * @version    SVN: $Id: admin_m_contactusWidgetContainer.php 867 2008-07-28 09:04:54Z fishbone $
14  * @link       http://www.magic3.org
15  */
16 require_once($gEnvManager->getContainerPath() .                 '/baseWidgetContainer.php');
17 require_once($gEnvManager->getCurrentWidgetDbPath() .   '/contactus_mainDb.php');
18
19 class admin_m_contactusWidgetContainer extends BaseWidgetContainer
20 {
21         private $db;    // DB接続オブジェクト
22         const DEFAULT_SEND_MESSAGE = 1;         // メール送信機能を使用するかどうか(デフォルト使用)
23                                         
24         /**
25          * コンストラクタ
26          */
27         function __construct()
28         {
29                 // 親クラスを呼び出す
30                 parent::__construct();
31                 
32                 // DBオブジェクト作成
33                 $this->db = new contactus_mainDb();
34         }
35         /**
36          * テンプレートファイルを設定
37          *
38          * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
39          * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
40          *
41          * @param RequestManager $request               HTTPリクエスト処理クラス
42          * @param object         $param                 任意使用パラメータ。そのまま_assign()に渡る
43          * @return string                                               テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
44          */
45         function _setTemplate($request, &$param)
46         {
47                 return 'admin.tmpl.html';
48         }
49         /**
50          * テンプレートにデータ埋め込む
51          *
52          * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
53          *
54          * @param RequestManager $request               HTTPリクエスト処理クラス
55          * @param object         $param                 任意使用パラメータ。_setTemplate()と共有。
56          * @param                                                               なし
57          */
58         function _assign($request, &$param)
59         {
60                 global $gEnvManager;
61                 global $gPageManager;
62                 
63                 $defaultLang    = $gEnvManager->getDefaultLanguage();
64                 $act = $request->trimValueOf('act');
65                 if ($act == 'update'){          // 設定更新のとき
66                         $sendMessage = ($request->trimValueOf('send_message') == 'on') ? 1 : 0;         // メール送信機能を使用するかどうか
67                         //$emailReceiver = $request->trimValueOf('email_receiver');                     // メール受信者
68                         $emailReceiver = trim($request->valueOf('email_receiver'));                     // メール受信者(aaaa<xxx@xxx.xxx>形式が可能)
69                         $companyVisible = ($request->trimValueOf('company_visible') == 'on') ? 1 : 0;           // 会社名入力フィールドの表示
70                         $addressVisible = ($request->trimValueOf('address_visible') == 'on') ? 1 : 0;           // 住所入力フィールドの表示
71                         $telVisible = ($request->trimValueOf('tel_visible') == 'on') ? 1 : 0;           // 電話番号入力フィールドの表示
72                         // 入力値のエラーチェック
73                         if ($this->getMsgCount() == 0){                 // エラーのないとき
74                                 $paramObj->sendMessage = $sendMessage;                  // メール送信機能を使用するかどうか
75                                 $paramObj->emailReceiver = $emailReceiver;              // メール受信者
76                                 $paramObj->companyVisible = $companyVisible;    // 会社名入力フィールドの表示
77                                 $paramObj->addressVisible = $addressVisible;    // 住所入力フィールドの表示
78                                 $paramObj->telVisible = $telVisible;    // 電話番号入力フィールドの表示
79                                 $ret = $this->updateWidgetParamObj($paramObj);
80                                 if ($ret){
81                                         $this->setMsg(self::MSG_GUIDANCE, 'データを更新しました');
82                                 } else {
83                                         $this->setMsg(self::MSG_APP_ERR, 'データ更新に失敗しました');
84                                 }
85                                 $gPageManager->updateParentWindow();// 親ウィンドウを更新
86                         }
87                 } else {                // 初期表示の場合
88                         // デフォルト値の設定
89                         $sendMessage = self::DEFAULT_SEND_MESSAGE;                      // メール送信機能を使用するかどうか
90                         $emailReceiver = '';            // メール受信者
91                         $companyVisible = 0;    // 会社名入力フィールドの表示
92                         $addressVisible = 0;    // 住所入力フィールドの表示
93                         $telVisible = 0;                // 電話番号入力フィールドの表示
94                         $paramObj = $this->getWidgetParamObj();
95                         if (!empty($paramObj)){
96                                 $sendMessage = $paramObj->sendMessage;                  // メール送信機能を使用するかどうか
97                                 $emailReceiver = $paramObj->emailReceiver;              // メール受信者
98                                 $companyVisible = $paramObj->companyVisible;    // 会社名入力フィールドの表示
99                                 $addressVisible = $paramObj->addressVisible;    // 住所入力フィールドの表示
100                                 $telVisible = $paramObj->telVisible;            // 電話番号入力フィールドの表示
101                         }
102                 }
103                 // 画面に書き戻す
104                 $checked = '';
105                 if ($sendMessage) $checked = 'checked';
106                 $this->tmpl->addVar("_widget", "send_message", $checked);
107                 $this->tmpl->addVar("_widget", "email_receiver", $emailReceiver);               // メール受信者
108                 $checked = '';
109                 if ($companyVisible) $checked = 'checked';
110                 $this->tmpl->addVar("_widget", "company_visible", $checked);// 会社名入力フィールドの表示
111                 $checked = '';
112                 if ($addressVisible) $checked = 'checked';
113                 $this->tmpl->addVar("_widget", "address_visible", $checked);// 住所入力フィールドの表示
114                 $checked = '';
115                 if ($telVisible) $checked = 'checked';
116                 $this->tmpl->addVar("_widget", "tel_visible", $checked);// 電話番号入力フィールドの表示
117         }
118 }
119 ?>