OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / widgets / ec_main / include / iwidgets / productrate / include / container / admin_productrateWidgetContainer.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-2012 Magic3 Project.
12  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
13  * @version    SVN: $Id: admin_productrateWidgetContainer.php 5436 2012-12-07 09:55:12Z fishbone $
14  * @link       http://www.magic3.org
15  */
16 require_once($gEnvManager->getContainerPath() . '/baseIWidgetContainer.php');
17
18 class admin_productrateWidgetContainer extends BaseIWidgetContainer
19 {
20         /**
21          * コンストラクタ
22          */
23         function __construct()
24         {
25                 // 親クラスを呼び出す
26                 parent::__construct();
27         }
28         /**
29          * テンプレートファイルを設定
30          *
31          * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
32          * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
33          *
34          * @param RequestManager $request               HTTPリクエスト処理クラス
35          * @param string         $act                   実行処理
36          * @param object         $configObj             定義情報オブジェクト
37          * @param object         $optionObj             可変パラメータオブジェクト
38          * @return string                                               テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
39          */
40         function _setTemplate($request, $act, $configObj, $optionObj)
41         {       
42                 return 'admin.tmpl.html';
43         }
44         /**
45          * テンプレートにデータ埋め込む
46          *
47          * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
48          *
49          * @param RequestManager $request               HTTPリクエスト処理クラス
50          * @param string         $act                   実行処理
51          * @param object         $configObj             定義情報オブジェクト
52          * @param object         $optionObj             可変パラメータオブジェクト
53          * @param                                                               なし
54          */
55         function _assign($request, $act, $configObj, $optionObj)
56         {
57                 // 基本情報を取得
58                 $id             = $optionObj->id;               // ユニークなID(配送方法ID)
59                 $init   = $optionObj->init;             // データ初期化を行うかどうか
60                 
61                 // 入力値を取得
62                 $minPrice = $request->trimValueOf('iw_min_price');      // 最小購入額
63                 $useMin = ($request->trimValueOf('iw_use_min') == 'on') ? 1 : 0;                // 無料となる購入額を使用するかどうか
64                 $inputDate = ($request->trimValueOf('iw_input_date') == 'on') ? 1 : 0;                  // 配達希望日時の入力を許可するかどうか
65                 
66                 if ($act == 'update'){          // 設定更新のとき
67                         // 入力エラーチェック
68                         $this->checkNumeric($minPrice, '最小購入額');
69                         
70                         if ($this->getMsgCount() == 0){                 // エラーのないとき
71                                 $configObj->minPrice    = $minPrice;    // 最小購入額
72                                 $configObj->inputDate = $inputDate;             // 希望日時の入力許可
73                                 $configObj->useMin      = $useMin;              // 無料となる購入額を使用するかどうか
74                                 $ret = $this->updateConfigObj($configObj);
75                                 if (!$ret) $this->setMsg(self::MSG_APP_ERR, 'インナーウィジェットデータの更新に失敗しました');
76                                 // ***** 正常に終了した場合はメッセージを残さない *****
77                         }
78                 } else if ($act == 'content'){          // 画面表示のとき
79                         if (!empty($init)){                     // 初期表示のとき
80                                 if (empty($configObj)){         // 定義値がないとき(管理画面なので最初は定義値が存在しない)
81                                         $minPrice = 5000;       // 最小購入額
82                                         $inputDate      = 0;            // 希望日時の入力許可
83                                         $useMin = 0;            // 無料となる購入額を使用するかどうか
84                                 } else {
85                                         $minPrice = $configObj->minPrice;       // 最小購入額
86                                         $inputDate      = $configObj->inputDate;                // 希望日時の入力許可
87                                         $useMin = $configObj->useMin;           // 無料となる購入額を使用するかどうか
88                                 }
89                         }
90                         // 画面にデータを埋め込む
91                         $this->tmpl->addVar("_widget", "min_price",     $minPrice);
92                         if ($inputDate) $this->tmpl->addVar('_widget', 'input_date', 'checked');                // 配達希望日時が入力可能かどうか
93                         if ($useMin == 1) $this->tmpl->addVar("_widget", "use_min",     "checked");
94                 }
95         }
96 }
97 ?>