OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / widgets / ec_menu / include / container / admin_ec_menuOtherWidgetContainer.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_ec_menuOtherWidgetContainer.php 5458 2012-12-12 08:29:09Z fishbone $
14  * @link       http://www.magic3.org
15  */
16 require_once($gEnvManager->getCurrentWidgetContainerPath() .    '/admin_ec_menuBaseWidgetContainer.php');
17
18 class admin_ec_menuOtherWidgetContainer extends admin_ec_menuBaseWidgetContainer
19 {
20         const DEFAULT_CATEGORY_COUNT = 2;       // デフォルトの商品カテゴリー選択可能数
21         
22         /**
23          * コンストラクタ
24          */
25         function __construct()
26         {
27                 // 親クラスを呼び出す
28                 parent::__construct();
29         }
30         /**
31          * テンプレートファイルを設定
32          *
33          * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
34          * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
35          *
36          * @param RequestManager $request               HTTPリクエスト処理クラス
37          * @param object         $param                 任意使用パラメータ。そのまま_assign()に渡る
38          * @return string                                               テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
39          */
40         function _setTemplate($request, &$param)
41         {       
42                 return 'admin_other.tmpl.html';
43         }
44         /**
45          * テンプレートにデータ埋め込む
46          *
47          * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
48          *
49          * @param RequestManager $request               HTTPリクエスト処理クラス
50          * @param object         $param                 任意使用パラメータ。_setTemplate()と共有。
51          * @param                                                               なし
52          */
53         function _assign($request, &$param)
54         {
55                 $act = $request->trimValueOf('act');
56                 if ($act == 'update'){          // 設定更新のとき
57                         // 入力値を取得
58                         $useVerticalMenu = ($request->trimValueOf('item_vertical_menu') == 'on') ? 1 : 0;               // 縦型メニューデザインを使用するかどうか
59                         $linkProduct = ($request->trimValueOf('item_link_product') == 'on') ? 1 : 0;            // 商品詳細にカテゴリーを連動
60                         $categoryCount  = $request->valueOf('item_category_count');             // 商品カテゴリー選択可能数
61                         
62                         if ($this->getMsgCount() == 0){                 // エラーのないとき
63                                 $paramObj = new stdClass;
64                                 $paramObj->useVerticalMenu      = $useVerticalMenu;             // 縦型メニューデザインを使用するかどうか
65                                 $paramObj->linkProduct = $linkProduct;          // 商品詳細にカテゴリーを連動
66                                 $paramObj->categoryCount        = $categoryCount;               // 商品カテゴリー選択可能数
67                                 $ret = $this->updateWidgetParamObj($paramObj);
68                                 if ($ret){
69                                         $this->setMsg(self::MSG_GUIDANCE, 'データを更新しました');
70                                 } else {
71                                         $this->setMsg(self::MSG_APP_ERR, 'データ更新に失敗しました');
72                                 }
73                                 $this->gPage->updateParentWindow();// 親ウィンドウを更新
74                         }
75                 } else {                // 初期表示の場合
76                         // デフォルト値設定
77                         $useVerticalMenu = 1;   // 縦型メニューデザインを使用するかどうか
78                         $linkProduct = 1;               // 商品詳細にカテゴリーを連動
79                         $categoryCount = self::DEFAULT_CATEGORY_COUNT;
80                         $paramObj = $this->getWidgetParamObj();
81                         if (!empty($paramObj)){
82                                 $useVerticalMenu        = $paramObj->useVerticalMenu;
83                                 $linkProduct            = $paramObj->linkProduct;               // 商品詳細にカテゴリーを連動
84                                 $categoryCount          = $paramObj->categoryCount;             // 商品カテゴリー選択可能数
85                         }
86                 }
87                 
88                 // 画面にデータを埋め込む
89                 $checked = '';
90                 if ($useVerticalMenu) $checked = 'checked';
91                 $this->tmpl->addVar("_widget", "vertical_menu", $checked);              // 縦型メニューデザインを使用するかどうか
92                 $checked = '';
93                 if ($linkProduct) $checked = 'checked';
94                 $this->tmpl->addVar("_widget", "link_product", $checked);               // 商品詳細にカテゴリーを連動
95                 $this->tmpl->addVar("_widget", "category_count", $categoryCount);               // 商品カテゴリー選択可能数
96         }
97 }
98 ?>